summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/ui/BasicIndicator.java
diff options
context:
space:
mode:
authorOwen Lin <owenlin@google.com>2010-01-28 16:10:19 -0800
committerOwen Lin <owenlin@google.com>2010-02-26 20:26:48 +0800
commit4de149ceb47f2c251f646419907424bfb67d2b64 (patch)
tree6f48682fe065902039bad89d1f3ca90720eca819 /src/com/android/camera/ui/BasicIndicator.java
parent02627adfa3d240d817e34af69be8d07e9c66c136 (diff)
downloadLegacyCamera-4de149ceb47f2c251f646419907424bfb67d2b64.zip
LegacyCamera-4de149ceb47f2c251f646419907424bfb67d2b64.tar.gz
LegacyCamera-4de149ceb47f2c251f646419907424bfb67d2b64.tar.bz2
The first runnable version of the new UI.
Implement the new UI with OpenGL (GLSurfaceView). Known issues: * Texture are never freed from GL * Do not consider the density of screen. Currently, the dimensions in mdpi devices are wrong. * It won't work on Sapphire, bug fired: Bug: 2473605 * The action UP event may pass a wrong target. (It should pass to the same target who recive the DOWN action. * Animation is not smooth enough. * Should not allocate objects into heap during rendering path. * The scrollbar in GLListView doesn't match the design * We should calculate our own orientation instead of using the system one. * Regression: "restore to default settings" is removed Change-Id: I93fa45831aa87787dd5ee9e43e270a9d786c5a2a
Diffstat (limited to 'src/com/android/camera/ui/BasicIndicator.java')
-rw-r--r--src/com/android/camera/ui/BasicIndicator.java82
1 files changed, 82 insertions, 0 deletions
diff --git a/src/com/android/camera/ui/BasicIndicator.java b/src/com/android/camera/ui/BasicIndicator.java
new file mode 100644
index 0000000..0d97ee7
--- /dev/null
+++ b/src/com/android/camera/ui/BasicIndicator.java
@@ -0,0 +1,82 @@
+package com.android.camera.ui;
+
+import android.content.Context;
+
+import com.android.camera.IconListPreference;
+import com.android.camera.R;
+import com.android.camera.ui.GLListView.OnItemSelectedListener;
+
+public class BasicIndicator extends AbstractIndicator {
+
+ private final ResourceTexture mIcon[];
+ private final IconListPreference mPreference;
+ protected int mIndex;
+ private GLListView mPopupContent;
+ private PreferenceAdapter mModel;
+ private String mOverride;
+
+ public BasicIndicator(IconListPreference preference) {
+ mPreference = preference;
+ mIcon = new ResourceTexture[preference.getIconIds().length];
+ mIndex = preference.findIndexOfValue(preference.getValue());
+ }
+
+ @Override
+ public void overrideSettings(String key, String settings) {
+ IconListPreference pref = mPreference;
+
+ if (!pref.getKey().equals(key)) return;
+ mOverride = settings;
+ mIndex = pref.findIndexOfValue(
+ settings == null ? pref.getValue() : settings);
+ invalidate();
+ }
+
+ @Override
+ public GLView getPopupContent() {
+ if (mPopupContent == null) {
+ Context context = getGLRootView().getContext();
+ mPopupContent = new GLListView();
+ mPopupContent.setHighLight(new NinePatchTexture(
+ context, R.drawable.optionitem_highlight));
+ mPopupContent.setScroller(new NinePatchTexture(
+ context, R.drawable.scrollbar_handle_vertical));
+ mModel = new PreferenceAdapter(context, mPreference);
+ mPopupContent.setOnItemSelectedListener(new MyListener(mModel));
+ mPopupContent.setDataModel(mModel);
+ }
+ mModel.overrideSettings(mOverride);
+ return mPopupContent;
+ }
+
+ protected void onPreferenceChanged(int newIndex) {
+ mIndex = newIndex;
+ invalidate();
+ }
+
+ private class MyListener implements OnItemSelectedListener {
+
+ private final PreferenceAdapter mAdapter;
+
+ public MyListener(PreferenceAdapter adapter) {
+ mAdapter = adapter;
+ }
+
+ public void onItemSelected(GLView view, int position) {
+ mAdapter.onItemSelected(view, position);
+ onPreferenceChanged(position - 1);
+ }
+ }
+
+ @Override
+ protected ResourceTexture getIcon() {
+ int index = mIndex;
+ if (mIcon[index] == null) {
+ IconListPreference pref = mPreference;
+ Context context = getGLRootView().getContext();
+ mIcon[index] = new ResourceTexture(
+ context, mPreference.getLargeIconIds()[index]);
+ }
+ return mIcon[index];
+ }
+}