aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandros Frantzis <alexandros.frantzis@linaro.org>2012-07-18 12:46:21 +0300
committerAlexandros Frantzis <alexandros.frantzis@linaro.org>2012-07-18 12:46:21 +0300
commit4df18a01115ef7b64284133c6c49909da2759fb5 (patch)
treeb6fe1f88c056ad4ea70e9f8f0b574ff520b8fa38
parent0fed88b4ba5da7f127fdb8d089c708ebebefa95d (diff)
downloadglmark2-4df18a01115ef7b64284133c6c49909da2759fb5.tar.gz
Android: Display a list of acceptable values instead of a text entry for options that have such a list.
-rw-r--r--android/src/org/linaro/glmark2/EditorActivity.java37
1 files changed, 31 insertions, 6 deletions
diff --git a/android/src/org/linaro/glmark2/EditorActivity.java b/android/src/org/linaro/glmark2/EditorActivity.java
index ead67e3..3c29428 100644
--- a/android/src/org/linaro/glmark2/EditorActivity.java
+++ b/android/src/org/linaro/glmark2/EditorActivity.java
@@ -56,7 +56,8 @@ import android.widget.TextView.OnEditorActionListener;
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 @@ public class EditorActivity extends Activity {
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 @@ public class EditorActivity extends Activity {
}
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 @@ public class EditorActivity extends Activity {
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 @@ public class EditorActivity extends Activity {
}
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;