summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrei Warkentin <andreiw@motorola.com>2010-11-12 18:40:42 -0600
committerWu-cheng Li <wuchengli@google.com>2010-11-13 14:36:57 +0800
commitfec1720cda1be572610c601ef6a6d929fb37be65 (patch)
treeaa3ba87f6e8e347e3f478ed4e91e4ab19eba8c17 /src
parent6eabb9b770a7c60cb92aa2e22f360754f32f39f8 (diff)
downloadpackages_apps_LegacyCamera-fec1720cda1be572610c601ef6a6d929fb37be65.zip
packages_apps_LegacyCamera-fec1720cda1be572610c601ef6a6d929fb37be65.tar.gz
packages_apps_LegacyCamera-fec1720cda1be572610c601ef6a6d929fb37be65.tar.bz2
Camera App: Properly re-init ControlPanel on sensor switch.
Handle cases where there are less/more settings after switch, for example caused by switching from a sensor without flash to a sensor with flash. Change-Id: I56a556f03679ab37c12f5918b09f6ac252c2ae3b Signed-off-by: Andrei Warkentin <andreiw@motorola.com> bug:3166542
Diffstat (limited to 'src')
-rw-r--r--src/com/android/camera/ui/ControlPanel.java37
-rw-r--r--src/com/android/camera/ui/IndicatorWheel.java8
2 files changed, 29 insertions, 16 deletions
diff --git a/src/com/android/camera/ui/ControlPanel.java b/src/com/android/camera/ui/ControlPanel.java
index 9718074..6ac7a98 100644
--- a/src/com/android/camera/ui/ControlPanel.java
+++ b/src/com/android/camera/ui/ControlPanel.java
@@ -37,6 +37,8 @@ import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
+import java.util.ArrayList;
+
public class ControlPanel extends RelativeLayout
implements BasicSettingPopup.Listener, IndicatorWheel.Listener,
OtherSettingsPopup.Listener, PopupWindow.OnDismissListener {
@@ -44,14 +46,13 @@ public class ControlPanel extends RelativeLayout
private Context mContext;
private ComboPreferences mSharedPrefs;
private PreferenceGroup mPreferenceGroup;
- private String[] mPreferenceKeys;
+ private ArrayList<String> mPreferenceKeys;
private Listener mListener;
private IndicatorWheel mIndicatorWheel;
private BasicSettingPopup[] mBasicSettingPopups;
private OtherSettingsPopup mOtherSettingsPopup;
private int mActiveIndicator = -1;
private boolean mEnabled = true;
- private ListView mThumbnailList;
static public interface Listener {
public void onSharedPreferenceChanged();
@@ -66,12 +67,13 @@ public class ControlPanel extends RelativeLayout
mContext = context;
}
- protected void addIndicator(
+ protected boolean addIndicator(
Context context, PreferenceGroup group, String key) {
IconListPreference pref = (IconListPreference) group.findPreference(key);
- if (pref == null) return;
+ if (pref == null) return false;
IndicatorButton b = new IndicatorButton(context, pref);
mIndicatorWheel.addView(b);
+ return true;
}
private void addOtherSettingIndicator(Context context) {
@@ -81,32 +83,35 @@ public class ControlPanel extends RelativeLayout
mIndicatorWheel.addView(b);
}
+ @Override
+ protected void onFinishInflate() {
+ mIndicatorWheel = (IndicatorWheel) findViewById(R.id.indicator_wheel);
+ mIndicatorWheel.setListener(this);
+ }
+
public void initialize(Context context, PreferenceGroup group,
String[] keys, boolean enableOtherSettings) {
// Reset the variables and states.
dismissSettingPopup();
- if (mIndicatorWheel != null) {
- // The first view is the shutter button.
- mIndicatorWheel.removeViews(1, mIndicatorWheel.getChildCount() - 1);
- }
+ mIndicatorWheel.removeIndicators();
mOtherSettingsPopup = null;
mActiveIndicator = -1;
+ mPreferenceKeys = new ArrayList<String>();
// Initialize all variables and icons.
mPreferenceGroup = group;
- mPreferenceKeys = keys;
- mBasicSettingPopups = new BasicSettingPopup[mPreferenceKeys.length];
- mIndicatorWheel = (IndicatorWheel) findViewById(R.id.indicator_wheel);
- mThumbnailList = (ListView) findViewById(R.id.thumbnail_list);
mSharedPrefs = ComboPreferences.get(context);
- for (int i = 0; i < mPreferenceKeys.length; i++) {
- addIndicator(context, group, mPreferenceKeys[i]);
+ for (int i = 0; i < keys.length; i++) {
+ if (addIndicator(context, group, keys[i])) {
+ mPreferenceKeys.add(keys[i]);
+ }
}
+ mBasicSettingPopups = new BasicSettingPopup[mPreferenceKeys.size()];
+
if (enableOtherSettings) {
addOtherSettingIndicator(context);
}
requestLayout();
- mIndicatorWheel.setListener(this);
}
public void onOtherSettingChanged() {
@@ -136,7 +141,7 @@ public class ControlPanel extends RelativeLayout
private void initializeSettingPopup(int index) {
IconListPreference pref = (IconListPreference)
- mPreferenceGroup.findPreference(mPreferenceKeys[index]);
+ mPreferenceGroup.findPreference(mPreferenceKeys.get(index));
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
diff --git a/src/com/android/camera/ui/IndicatorWheel.java b/src/com/android/camera/ui/IndicatorWheel.java
index aab41fc..e967017 100644
--- a/src/com/android/camera/ui/IndicatorWheel.java
+++ b/src/com/android/camera/ui/IndicatorWheel.java
@@ -84,6 +84,14 @@ public class IndicatorWheel extends ViewGroup {
super(context, attrs);
}
+ public void removeIndicators() {
+ // Remove everything but the shutter button.
+ int count = getChildCount();
+ if (count > 1) {
+ removeViews(1, count - 1);
+ }
+ }
+
@Override
protected void onMeasure(int widthSpec, int heightSpec) {
// Measure all children.