summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/IconListPreference.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/camera/IconListPreference.java')
-rw-r--r--src/com/android/camera/IconListPreference.java38
1 files changed, 25 insertions, 13 deletions
diff --git a/src/com/android/camera/IconListPreference.java b/src/com/android/camera/IconListPreference.java
index fc23f6c..2a01e7e 100644
--- a/src/com/android/camera/IconListPreference.java
+++ b/src/com/android/camera/IconListPreference.java
@@ -30,36 +30,44 @@ public class IconListPreference extends ListPreference {
private int mIconIds[];
private int mLargeIconIds[];
+ private int mImageIds[];
public IconListPreference(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray a = context.obtainStyledAttributes(
attrs, R.styleable.IconListPreference, 0, 0);
Resources res = context.getResources();
- mIconIds = getIconIds(res, a.getResourceId(
+ mIconIds = getIds(res, a.getResourceId(
R.styleable.IconListPreference_icons, 0));
- mLargeIconIds = getIconIds(res, a.getResourceId(
+ mLargeIconIds = getIds(res, a.getResourceId(
R.styleable.IconListPreference_largeIcons, 0));
+ mImageIds = getIds(res, a.getResourceId(
+ R.styleable.IconListPreference_images, 0));
+ if (mImageIds == null) mImageIds = mLargeIconIds;
a.recycle();
}
- public int[] getLargeIconIds() {
- return mLargeIconIds;
- }
-
public int[] getIconIds() {
return mIconIds;
}
- public void setLargeIconIds(int[] largeIconIds) {
- mLargeIconIds = largeIconIds;
+ public int[] getLargeIconIds() {
+ return mLargeIconIds;
+ }
+
+ public int[] getImageIds() {
+ return mImageIds;
}
public void setIconIds(int[] iconIds) {
mIconIds = iconIds;
}
- private int[] getIconIds(Resources res, int iconsRes) {
+ public void setLargeIconIds(int[] largeIconIds) {
+ mLargeIconIds = largeIconIds;
+ }
+
+ private int[] getIds(Resources res, int iconsRes) {
if (iconsRes == 0) return null;
TypedArray array = res.obtainTypedArray(iconsRes);
int n = array.length();
@@ -76,16 +84,20 @@ public class IconListPreference extends ListPreference {
CharSequence entryValues[] = getEntryValues();
IntArray iconIds = new IntArray();
IntArray largeIconIds = new IntArray();
+ IntArray imageIds = new IntArray();
+ // We allow mIconsIds to be null, but not mLargeIconIds. The reason is that if large icons
+ // are unspecified, the on screen icons will be blank which is a bug.
for (int i = 0, len = entryValues.length; i < len; i++) {
if (supported.indexOf(entryValues[i].toString()) >= 0) {
- iconIds.add(mIconIds[i]);
+ if (mIconIds != null) iconIds.add(mIconIds[i]);
largeIconIds.add(mLargeIconIds[i]);
+ if (mImageIds != null) imageIds.add(mImageIds[i]);
}
}
- int size = iconIds.size();
- mIconIds = iconIds.toArray(new int[size]);
- mLargeIconIds = iconIds.toArray(new int[size]);
+ if (mIconIds != null) mIconIds = iconIds.toArray(new int[iconIds.size()]);
+ mLargeIconIds = largeIconIds.toArray(new int[largeIconIds.size()]);
+ if (mImageIds != null) mImageIds = imageIds.toArray(new int[imageIds.size()]);
super.filterUnsupported(supported);
}
}