summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/IconListPreference.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/IconListPreference.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/IconListPreference.java')
-rw-r--r--src/com/android/camera/IconListPreference.java38
1 files changed, 31 insertions, 7 deletions
diff --git a/src/com/android/camera/IconListPreference.java b/src/com/android/camera/IconListPreference.java
index 25c641c..54a101f 100644
--- a/src/com/android/camera/IconListPreference.java
+++ b/src/com/android/camera/IconListPreference.java
@@ -24,32 +24,56 @@ import android.util.AttributeSet;
/** A {@code ListPreference} where each entry has a corresponding icon. */
public class IconListPreference extends ListPreference {
+
+ private final int mIconIds[];
+ private final int mLargeIconIds[];
+
private Drawable mIcons[];
- private Resources mResources;
+ private final Resources mResources;
public IconListPreference(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray a = context.obtainStyledAttributes(
attrs, R.styleable.IconListPreference, 0, 0);
mResources = context.getResources();
- setIcons(a.getResourceId(R.styleable.IconListPreference_icons, 0));
+ mIconIds = getIconIds(a.getResourceId(
+ R.styleable.IconListPreference_icons, 0));
+ mLargeIconIds = getIconIds(a.getResourceId(
+ R.styleable.IconListPreference_largeIcons, 0));
a.recycle();
}
public Drawable[] getIcons() {
+ if (mIcons == null) {
+ int n = mIconIds.length;
+ Drawable[] drawable = new Drawable[n];
+ int[] id = mIconIds;
+ for (int i = 0; i < n; ++i) {
+ drawable[i] = id[i] == 0 ? null : mResources.getDrawable(id[i]);
+ }
+ mIcons = drawable;
+ }
return mIcons;
}
- private void setIcons(int iconsRes) {
+ public int[] getLargeIconIds() {
+ return mLargeIconIds;
+ }
+
+ public int[] getIconIds() {
+ return mIconIds;
+ }
+
+ private int[] getIconIds(int iconsRes) {
+ if (iconsRes == 0) return null;
TypedArray array = mResources.obtainTypedArray(iconsRes);
int n = array.length();
- Drawable drawable[] = new Drawable[n];
+ int ids[] = new int[n];
for (int i = 0; i < n; ++i) {
- int id = array.getResourceId(i, 0);
- drawable[i] = id == 0 ? null : mResources.getDrawable(id);
+ ids[i] = array.getResourceId(i, 0);
}
array.recycle();
- mIcons = drawable;
+ return ids;
}
public void setIcons(Drawable[] icons) {