=== modified file 'android/src/org/linaro/glmark2/EditorActivity.java'
@@ -56,7 +56,8 @@
public class EditorActivity extends Activity {
public static final int DIALOG_SCENE_NAME_ID = 0;
- public static final int DIALOG_SCENE_OPTION_ID = 1;
+ public static final int DIALOG_SCENE_OPTION_TEXT_ID = 1;
+ public static final int DIALOG_SCENE_OPTION_LIST_ID = 2;
public static final int ITEM_POSITION_SCENE_NAME_HEADER = 0;
public static final int ITEM_POSITION_SCENE_NAME = 1;
@@ -117,10 +118,16 @@
Bundle bundle = new Bundle();
bundle.putInt("item-pos", position);
/* Show the right dialog, depending on the clicked list position */
- if (position == ITEM_POSITION_SCENE_NAME)
+ if (position == ITEM_POSITION_SCENE_NAME) {
showDialog(DIALOG_SCENE_NAME_ID, bundle);
- else if (position >= ITEM_POSITION_SCENE_OPTION)
- showDialog(DIALOG_SCENE_OPTION_ID, bundle);
+ }
+ else if (position >= ITEM_POSITION_SCENE_OPTION) {
+ String[] values = adapter.getItem(position).option.acceptableValues;
+ if (values.length == 0)
+ showDialog(DIALOG_SCENE_OPTION_TEXT_ID, bundle);
+ else
+ showDialog(DIALOG_SCENE_OPTION_LIST_ID, bundle);
+ }
}
});
@@ -161,7 +168,7 @@
}
break;
- case DIALOG_SCENE_OPTION_ID:
+ case DIALOG_SCENE_OPTION_TEXT_ID:
{
AlertDialog.Builder builder = new AlertDialog.Builder(this);
final EditorItem item = adapter.getItem(itemPos);
@@ -176,7 +183,7 @@
event.getAction() == KeyEvent.ACTION_UP))
{
item.value = v.getText().toString();
- dismissDialog(DIALOG_SCENE_OPTION_ID);
+ dismissDialog(DIALOG_SCENE_OPTION_TEXT_ID);
}
return true;
}
@@ -192,6 +199,24 @@
}
break;
+ case DIALOG_SCENE_OPTION_LIST_ID:
+ {
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ final EditorItem item = adapter.getItem(itemPos);
+ builder.setTitle(item.option.name + ": " + item.option.description);
+
+ builder.setItems(item.option.acceptableValues, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int index) {
+ item.value = item.option.acceptableValues[index];
+ adapter.notifyDataSetChanged();
+ dismissDialog(DIALOG_SCENE_OPTION_LIST_ID);
+ }
+ });
+
+ dialog = builder.create();
+ }
+ break;
+
default:
dialog = null;
break;
@@ -350,7 +375,7 @@
private ArrayList<SceneInfo> getSceneInfoList() {
ArrayList<SceneInfo> l = new ArrayList<SceneInfo>();
SceneInfo customSceneInfo = new SceneInfo("__custom__");
- customSceneInfo.addOption("__custom__", "Custom benchmark string", "");
+ customSceneInfo.addOption("__custom__", "Custom benchmark string", "", new String[0]);
for (Parcelable p: getIntent().getParcelableArrayExtra("scene-info"))
l.add((SceneInfo)p);
=== modified file 'android/src/org/linaro/glmark2/SceneInfo.java'
@@ -30,6 +30,7 @@
String name;
String description;
String defaultValue;
+ String[] acceptableValues;
}
public SceneInfo(String name) {
@@ -37,11 +38,14 @@
this.options = new ArrayList<Option>();
}
- public void addOption(String name, String description, String defaultValue) {
+ public void addOption(String name, String description, String defaultValue,
+ String[] acceptableValues)
+ {
Option opt = new Option();
opt.name = name;
opt.description = description;
opt.defaultValue = defaultValue;
+ opt.acceptableValues = acceptableValues;
this.options.add(opt);
}
@@ -71,6 +75,7 @@
out.writeString(opt.name);
out.writeString(opt.description);
out.writeString(opt.defaultValue);
+ out.writeStringArray(opt.acceptableValues);
}
}
@@ -84,6 +89,7 @@
opt.name = in.readString();
opt.description = in.readString();
opt.defaultValue = in.readString();
+ opt.acceptableValues = in.createStringArray();
options.add(opt);
}
}
=== modified file 'src/android.cpp'
@@ -179,7 +179,7 @@
{
jclass cls = env->FindClass("org/linaro/glmark2/SceneInfo");
jmethodID constructor = env->GetMethodID(cls, "<init>", "(Ljava/lang/String;)V");
- jmethodID add_option = env->GetMethodID(cls, "addOption", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
+ jmethodID add_option = env->GetMethodID(cls, "addOption", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)V");
/* Create the SceneInfo object */
jstring name = env->NewStringUTF(scene.name().c_str());
@@ -197,14 +197,27 @@
jstring opt_description = env->NewStringUTF(opt.description.c_str());
jstring opt_default_value = env->NewStringUTF(opt.default_value.c_str());
+ /* Create and populate the acceptable values array */
+ jclass string_cls = env->FindClass("java/lang/String");
+ jobjectArray opt_acceptable_values = env->NewObjectArray(opt.acceptable_values.size(),
+ string_cls, 0);
+
+ for (size_t i = 0; i < opt.acceptable_values.size(); i++) {
+ jstring opt_value = env->NewStringUTF(opt.acceptable_values[i].c_str());
+ env->SetObjectArrayElement(opt_acceptable_values, i, opt_value);
+ env->DeleteLocalRef(opt_value);
+ }
+
env->CallVoidMethod(scene_info, add_option,
opt_name,
opt_description,
- opt_default_value);
+ opt_default_value,
+ opt_acceptable_values);
env->DeleteLocalRef(opt_name);
env->DeleteLocalRef(opt_description);
env->DeleteLocalRef(opt_default_value);
+ env->DeleteLocalRef(opt_acceptable_values);
}
return scene_info;