diff options
author | Owen Lin <owenlin@google.com> | 2010-03-03 21:12:40 +0800 |
---|---|---|
committer | Owen Lin <owenlin@google.com> | 2010-03-07 14:30:49 +0800 |
commit | 281be5337852cb4b5d24e0a0440c426cb96bbebd (patch) | |
tree | b4218ea13055f7e9302e432554baf1e12695cef1 /src/com/android/camera/ui/PreferenceAdapter.java | |
parent | be69d39c4ab8fa93a52ed13a72ba2ad582adf583 (diff) | |
download | LegacyCamera-281be5337852cb4b5d24e0a0440c426cb96bbebd.zip LegacyCamera-281be5337852cb4b5d24e0a0440c426cb96bbebd.tar.gz LegacyCamera-281be5337852cb4b5d24e0a0440c426cb96bbebd.tar.bz2 |
Add pixel density concept to the code. So, it draw about the same size on
mdpi and hdpi devices.
Update the UI assets for mdpi
Fix a issue that GLSurfaceView didn't call onPause and onResume in Camera.
Refactor. Improve the drawing and animation.
Also fix the RawTexture unsupported operation bugs and the NullPointerException
in GLRootView.
Change-Id: I7aeadcad72d64a665828a6bb4f0f73e685fde632
Diffstat (limited to 'src/com/android/camera/ui/PreferenceAdapter.java')
-rw-r--r-- | src/com/android/camera/ui/PreferenceAdapter.java | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/src/com/android/camera/ui/PreferenceAdapter.java b/src/com/android/camera/ui/PreferenceAdapter.java index 233f154..de3cda9 100644 --- a/src/com/android/camera/ui/PreferenceAdapter.java +++ b/src/com/android/camera/ui/PreferenceAdapter.java @@ -1,5 +1,6 @@ package com.android.camera.ui; +import static com.android.camera.ui.GLRootView.dpToPixel; import android.content.Context; import com.android.camera.IconListPreference; @@ -13,16 +14,26 @@ public class PreferenceAdapter implements GLListView.Model, GLListView.OnItemSelectedListener { private static final int ICON_NONE = 0; + private static final int HORIZONTAL_PADDINGS = 4; + private static final int VERTICAL_PADDINGS = 2; + + private static int sHorizontalPaddings = -1; + private static int sVerticalPaddings; - private final Context mContext; private final ArrayList<GLView> mContent = new ArrayList<GLView>(); private final ListPreference mPreference; private String mOverride; + private static void initializeStaticVariable(Context context) { + if (sHorizontalPaddings >= 0) return; + sHorizontalPaddings = dpToPixel(context, HORIZONTAL_PADDINGS); + sVerticalPaddings = dpToPixel(context, VERTICAL_PADDINGS); + } + public PreferenceAdapter(Context context, ListPreference preference) { - mContext = context; + initializeStaticVariable(context); mPreference = preference; - generateContent(preference); + generateContent(context, preference); } public void overrideSettings(String settings) { @@ -47,13 +58,12 @@ public class PreferenceAdapter } } - private void generateContent(ListPreference preference) { - Context context = mContext; - - GLOptionHeader header = new GLOptionHeader(preference); + private void generateContent(Context context, ListPreference preference) { + GLOptionHeader header = new GLOptionHeader(context, preference); header.setBackground(new NinePatchTexture( context, R.drawable.optionheader_background)); - header.setPaddings(5, 2, 5, 2); + header.setPaddings(sHorizontalPaddings, + sVerticalPaddings, sHorizontalPaddings, sVerticalPaddings); mContent.add(header); CharSequence[] entries = preference.getEntries(); CharSequence[] values = preference.getEntryValues(); @@ -67,7 +77,8 @@ public class PreferenceAdapter GLOptionItem item = new GLOptionItem( context, icons == null ? ICON_NONE : icons[i], entries[i].toString()); - item.setPaddings(5, 2, 5, 2); + item.setPaddings(sHorizontalPaddings, + sVerticalPaddings, sHorizontalPaddings, sVerticalPaddings); item.setChecked(values[i].equals(value)); mContent.add(item); } |