summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera
diff options
context:
space:
mode:
authorWu-cheng Li <wuchengli@google.com>2011-05-10 04:00:14 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-05-10 04:00:14 -0700
commit43af5df853bdfa17715eb9abe61a7d3485aa05d7 (patch)
treedd9a9e759c739cd95dce87152ee3e7d1fc297bfb /src/com/android/camera
parent0d604e2af9eeed22685fd62e2281c2cd9728d58b (diff)
parentd50b09687918ae1c89e9c19175e217910b330c60 (diff)
downloadLegacyCamera-43af5df853bdfa17715eb9abe61a7d3485aa05d7.zip
LegacyCamera-43af5df853bdfa17715eb9abe61a7d3485aa05d7.tar.gz
LegacyCamera-43af5df853bdfa17715eb9abe61a7d3485aa05d7.tar.bz2
Merge "Refactor IndicatorWheel."
Diffstat (limited to 'src/com/android/camera')
-rw-r--r--src/com/android/camera/Camera.java18
-rw-r--r--src/com/android/camera/VideoCamera.java5
-rw-r--r--src/com/android/camera/ui/AbstractSettingPopup.java2
-rw-r--r--src/com/android/camera/ui/BasicSettingPopup.java1
-rw-r--r--src/com/android/camera/ui/IndicatorWheel.java117
-rw-r--r--src/com/android/camera/ui/OtherSettingsPopup.java33
6 files changed, 83 insertions, 93 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java
index 845bd36..1eb040d 100644
--- a/src/com/android/camera/Camera.java
+++ b/src/com/android/camera/Camera.java
@@ -1120,11 +1120,19 @@ public class Camera extends ActivityBase implements View.OnClickListener,
if (mIndicatorWheel == null) return;
loadCameraPreferences();
- String[] keys = new String[]{CameraSettings.KEY_FLASH_MODE,
- CameraSettings.KEY_WHITE_BALANCE,
- CameraSettings.KEY_COLOR_EFFECT,
- CameraSettings.KEY_SCENE_MODE};
- mIndicatorWheel.initialize(this, mPreferenceGroup, keys, true);
+ final String[] SETTING_KEYS = {
+ CameraSettings.KEY_FLASH_MODE,
+ CameraSettings.KEY_WHITE_BALANCE,
+ CameraSettings.KEY_COLOR_EFFECT,
+ CameraSettings.KEY_SCENE_MODE};
+ final String[] OTHER_SETTING_KEYS = {
+ CameraSettings.KEY_RECORD_LOCATION,
+ CameraSettings.KEY_FOCUS_MODE,
+ CameraSettings.KEY_EXPOSURE,
+ CameraSettings.KEY_PICTURE_SIZE,
+ CameraSettings.KEY_JPEG_QUALITY};
+ mIndicatorWheel.initialize(this, mPreferenceGroup, SETTING_KEYS,
+ OTHER_SETTING_KEYS);
mIndicatorWheel.setListener(new MyIndicatorWheelListener());
mPopupGestureDetector = new GestureDetector(this,
new PopupGestureListener());
diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java
index dd7088b..8ddf440 100644
--- a/src/com/android/camera/VideoCamera.java
+++ b/src/com/android/camera/VideoCamera.java
@@ -527,12 +527,13 @@ public class VideoCamera extends ActivityBase
if (mIndicatorWheel == null) return;
loadCameraPreferences();
- String[] keys = new String[]{CameraSettings.KEY_VIDEOCAMERA_FLASH_MODE,
+ final String[] SETTING_KEYS = {
+ CameraSettings.KEY_VIDEOCAMERA_FLASH_MODE,
CameraSettings.KEY_WHITE_BALANCE,
CameraSettings.KEY_COLOR_EFFECT,
CameraSettings.KEY_VIDEO_QUALITY,
CameraSettings.KEY_VIDEO_TIME_LAPSE_FRAME_INTERVAL};
- mIndicatorWheel.initialize(this, mPreferenceGroup, keys, false);
+ mIndicatorWheel.initialize(this, mPreferenceGroup, SETTING_KEYS, null);
mIndicatorWheel.setListener(new MyIndicatorWheelListener());
mPopupGestureDetector = new GestureDetector(this,
new PopupGestureListener());
diff --git a/src/com/android/camera/ui/AbstractSettingPopup.java b/src/com/android/camera/ui/AbstractSettingPopup.java
index 32fbe67..794152e 100644
--- a/src/com/android/camera/ui/AbstractSettingPopup.java
+++ b/src/com/android/camera/ui/AbstractSettingPopup.java
@@ -44,4 +44,6 @@ abstract public class AbstractSettingPopup extends LinearLayout {
mTitle = (TextView) findViewById(R.id.title);
mSettingList = (ViewGroup) findViewById(R.id.settingList);
}
+
+ abstract public void reloadPreference();
}
diff --git a/src/com/android/camera/ui/BasicSettingPopup.java b/src/com/android/camera/ui/BasicSettingPopup.java
index 2e33720..1496e9e 100644
--- a/src/com/android/camera/ui/BasicSettingPopup.java
+++ b/src/com/android/camera/ui/BasicSettingPopup.java
@@ -80,6 +80,7 @@ public class BasicSettingPopup extends AbstractSettingPopup implements
}
// The value of the preference may have changed. Update the UI.
+ @Override
public void reloadPreference() {
int index = mPreference.findIndexOfValue(mPreference.getValue());
if (index != -1) {
diff --git a/src/com/android/camera/ui/IndicatorWheel.java b/src/com/android/camera/ui/IndicatorWheel.java
index 8ddd7cd..3fcb844 100644
--- a/src/com/android/camera/ui/IndicatorWheel.java
+++ b/src/com/android/camera/ui/IndicatorWheel.java
@@ -83,9 +83,9 @@ public class IndicatorWheel extends ViewGroup implements
private Context mContext;
private PreferenceGroup mPreferenceGroup;
- private ArrayList<String> mPreferenceKeys;
- private BasicSettingPopup[] mBasicSettingPopups;
- private OtherSettingsPopup mOtherSettingsPopup;
+ private ArrayList<String> mPrefKeys;
+ private String[] mOtherSettingPrefKeys;
+ private AbstractSettingPopup[] mSettingPopups;
private Animation mFadeIn, mFadeOut;
// The previous view that has the animation. The animation may have stopped.
@@ -441,26 +441,28 @@ public class IndicatorWheel extends ViewGroup implements
}
public void initialize(Context context, PreferenceGroup group,
- String[] keys, boolean enableOtherSettings) {
+ String[] keys, String[] otherSettingKeys) {
// Reset the variables and states.
dismissSettingPopup();
removeIndicators();
- mOtherSettingsPopup = null;
mSelectedIndex = -1;
- mPreferenceKeys = new ArrayList<String>();
+ mPrefKeys = new ArrayList<String>();
// Initialize all variables and icons.
mPreferenceGroup = group;
for (int i = 0; i < keys.length; i++) {
if (addIndicator(context, group, keys[i])) {
- mPreferenceKeys.add(keys[i]);
+ mPrefKeys.add(keys[i]);
}
}
- mBasicSettingPopups = new BasicSettingPopup[mPreferenceKeys.size()];
-
- if (enableOtherSettings) {
+ int len = keys.length;
+ mOtherSettingPrefKeys = otherSettingKeys;
+ if (mOtherSettingPrefKeys != null) {
addOtherSettingIndicator(context);
+ len++;
}
+ mSettingPopups = new AbstractSettingPopup[len];
+
requestLayout();
}
@@ -486,52 +488,38 @@ public class IndicatorWheel extends ViewGroup implements
}
private void initializeSettingPopup(int index) {
- IconListPreference pref = (IconListPreference)
- mPreferenceGroup.findPreference(mPreferenceKeys.get(index));
-
- LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(
- Context.LAYOUT_INFLATER_SERVICE);
- ViewGroup root = (ViewGroup) getRootView().findViewById(R.id.app_root);
- BasicSettingPopup popup = (BasicSettingPopup) inflater.inflate(
- R.layout.basic_setting_popup, root, false);
- mBasicSettingPopups[index] = popup;
- popup.setSettingChangedListener(this);
- popup.initialize(pref);
- root.addView(popup);
- }
-
- private void initializeOtherSettingPopup() {
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
ViewGroup root = (ViewGroup) getRootView().findViewById(R.id.app_root);
- mOtherSettingsPopup = (OtherSettingsPopup) inflater.inflate(
- R.layout.other_setting_popup, root, false);
- mOtherSettingsPopup.setOtherSettingChangedListener(this);
- mOtherSettingsPopup.initialize(mPreferenceGroup);
- root.addView(mOtherSettingsPopup);
+ if (index < mPrefKeys.size()) {
+ IconListPreference pref = (IconListPreference)
+ mPreferenceGroup.findPreference(mPrefKeys.get(index));
+
+ BasicSettingPopup popup = (BasicSettingPopup) inflater.inflate(
+ R.layout.basic_setting_popup, root, false);
+ mSettingPopups[index] = popup;
+ popup.setSettingChangedListener(this);
+ popup.initialize(pref);
+ } else {
+ // Initialize other settings popup window.
+ OtherSettingsPopup popup = (OtherSettingsPopup) inflater.inflate(
+ R.layout.other_setting_popup, root, false);
+ mSettingPopups[index] = popup;
+ popup.setSettingChangedListener(this);
+ popup.initialize(mPreferenceGroup, mOtherSettingPrefKeys);
+ }
+ root.addView(mSettingPopups[index]);
}
private void showSettingPopup(int index) {
if (index == mSelectedIndex) return;
- if (index < mBasicSettingPopups.length) {
- if (mBasicSettingPopups[index] == null) {
- initializeSettingPopup(index);
- }
- } else if (mOtherSettingsPopup == null) {
- initializeOtherSettingPopup();
- }
+ if (mSettingPopups[index] == null) initializeSettingPopup(index);
- View popup;
if (mPrevAnimatingView != null) mPrevAnimatingView.clearAnimation();
- if (index == mBasicSettingPopups.length) {
- popup = mOtherSettingsPopup;
- } else {
- popup = mBasicSettingPopups[index];
- }
- popup.startAnimation(mFadeIn);
- popup.setVisibility(View.VISIBLE);
- mPrevAnimatingView = popup;
+ mSettingPopups[index].startAnimation(mFadeIn);
+ mSettingPopups[index].setVisibility(View.VISIBLE);
+ mPrevAnimatingView = mSettingPopups[index];
setHighlight(index, true);
mSelectedIndex = index;
invalidate();
@@ -539,16 +527,10 @@ public class IndicatorWheel extends ViewGroup implements
public boolean dismissSettingPopup() {
if (mSelectedIndex >= 0) {
- View popup;
if (mPrevAnimatingView != null) mPrevAnimatingView.clearAnimation();
- if (mSelectedIndex == mBasicSettingPopups.length) {
- popup = mOtherSettingsPopup;
- } else {
- popup = mBasicSettingPopups[mSelectedIndex];
- }
- popup.startAnimation(mFadeOut);
- popup.setVisibility(View.INVISIBLE);
- mPrevAnimatingView = popup;
+ mSettingPopups[mSelectedIndex].startAnimation(mFadeOut);
+ mSettingPopups[mSelectedIndex].setVisibility(View.INVISIBLE);
+ mPrevAnimatingView = mSettingPopups[mSelectedIndex];
setHighlight(mSelectedIndex, false);
mSelectedIndex = -1;
invalidate();
@@ -559,11 +541,7 @@ public class IndicatorWheel extends ViewGroup implements
public View getActivePopupWindow() {
if (mSelectedIndex >= 0) {
- if (mSelectedIndex == mBasicSettingPopups.length) {
- return mOtherSettingsPopup;
- } else {
- return mBasicSettingPopups[mSelectedIndex];
- }
+ return mSettingPopups[mSelectedIndex];
} else {
return null;
}
@@ -575,25 +553,26 @@ public class IndicatorWheel extends ViewGroup implements
throw new IllegalArgumentException();
}
- if (mOtherSettingsPopup == null) {
- initializeOtherSettingPopup();
- }
-
+ // Override the setting indicator.
for (int i = 0; i < keyvalues.length; i += 2) {
String key = keyvalues[i];
String value = keyvalues[i + 1];
overrideSettings(key, value);
- mOtherSettingsPopup.overrideSettings(key, value);
+ }
+
+ // Override other settings.
+ if (mOtherSettingPrefKeys != null) {
+ int index = mPrefKeys.size();
+ if (mSettingPopups[index] == null) initializeSettingPopup(index);
+ OtherSettingsPopup popup = (OtherSettingsPopup) mSettingPopups[index];
+ popup.overrideSettings(keyvalues);
}
}
public void reloadPreferences() {
mPreferenceGroup.reloadValue();
- for (BasicSettingPopup popup: mBasicSettingPopups) {
+ for (AbstractSettingPopup popup: mSettingPopups) {
if (popup != null) popup.reloadPreference();
}
- if (mOtherSettingsPopup != null) {
- mOtherSettingsPopup.reloadPreference();
- }
}
}
diff --git a/src/com/android/camera/ui/OtherSettingsPopup.java b/src/com/android/camera/ui/OtherSettingsPopup.java
index 018eb1c..920d270 100644
--- a/src/com/android/camera/ui/OtherSettingsPopup.java
+++ b/src/com/android/camera/ui/OtherSettingsPopup.java
@@ -41,12 +41,6 @@ public class OtherSettingsPopup extends AbstractSettingPopup
implements InLineSettingPicker.Listener,
AdapterView.OnItemClickListener {
private static final String TAG = "OtherSettingsPopup";
- private static final String[] OTHER_SETTING_KEYS = {
- CameraSettings.KEY_RECORD_LOCATION,
- CameraSettings.KEY_FOCUS_MODE,
- CameraSettings.KEY_EXPOSURE,
- CameraSettings.KEY_PICTURE_SIZE,
- CameraSettings.KEY_JPEG_QUALITY};
private static final String ITEM_KEY = "key";
private static final String ITEM_TITLE = "text";
private static final String ITEM_VALUE = "value";
@@ -100,7 +94,7 @@ public class OtherSettingsPopup extends AbstractSettingPopup
}
}
- public void setOtherSettingChangedListener(Listener listener) {
+ public void setSettingChangedListener(Listener listener) {
mListener = listener;
}
@@ -109,12 +103,12 @@ public class OtherSettingsPopup extends AbstractSettingPopup
mContext = context;
}
- public void initialize(PreferenceGroup group) {
+ public void initialize(PreferenceGroup group, String[] keys) {
mPreferenceGroup = group;
// Prepare the setting items.
- for (int i = 0; i < OTHER_SETTING_KEYS.length; ++i) {
+ for (int i = 0; i < keys.length; ++i) {
HashMap<String, Object> map = new HashMap<String, Object>();
- ListPreference pref = group.findPreference(OTHER_SETTING_KEYS[i]);
+ ListPreference pref = group.findPreference(keys[i]);
if (pref != null) {
map.put(ITEM_KEY, pref);
map.put(ITEM_TITLE, pref.getTitle());
@@ -145,14 +139,18 @@ public class OtherSettingsPopup extends AbstractSettingPopup
}
// Scene mode can override other camera settings (ex: flash mode).
- public void overrideSettings(String key, String value) {
+ public void overrideSettings(final String ... keyvalues) {
int count = mSettingList.getChildCount();
- for (int i = 0; i < count; i++) {
- ListPreference pref = (ListPreference) mListItem.get(i).get(ITEM_KEY);
- if (pref != null && key.equals(pref.getKey())) {
- InLineSettingPicker picker =
- (InLineSettingPicker) mSettingList.getChildAt(i);
- picker.overrideSettings(value);
+ for (int i = 0; i < keyvalues.length; i += 2) {
+ String key = keyvalues[i];
+ String value = keyvalues[i + 1];
+ for (int j = 0; j < count; j++) {
+ ListPreference pref = (ListPreference) mListItem.get(j).get(ITEM_KEY);
+ if (pref != null && key.equals(pref.getKey())) {
+ InLineSettingPicker picker =
+ (InLineSettingPicker) mSettingList.getChildAt(j);
+ picker.overrideSettings(value);
+ }
}
}
}
@@ -165,6 +163,7 @@ public class OtherSettingsPopup extends AbstractSettingPopup
}
}
+ @Override
public void reloadPreference() {
int count = mSettingList.getChildCount();
for (int i = 0; i < count; i++) {