summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorChung-yih Wang <cywang@google.com>2011-09-29 01:19:59 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-09-29 01:19:59 -0700
commit10bc9cb3578d877c8e3eb944e0c4282b1ba1b0c6 (patch)
tree4507bb6743b49458e875376ae2ef7fd9fb878d21 /src/com
parentffe0a712b5a9bd1d46351b02e1bd738bc61578c2 (diff)
parent46f4430b50ba8ca8b04b698d45d9ca2d4513121d (diff)
downloadLegacyCamera-10bc9cb3578d877c8e3eb944e0c4282b1ba1b0c6.zip
LegacyCamera-10bc9cb3578d877c8e3eb944e0c4282b1ba1b0c6.tar.gz
LegacyCamera-10bc9cb3578d877c8e3eb944e0c4282b1ba1b0c6.tar.bz2
Merge "Fix ModePicker selection UI."
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/camera/Camera.java2
-rw-r--r--src/com/android/camera/ModePicker.java53
-rw-r--r--src/com/android/camera/VideoCamera.java2
3 files changed, 28 insertions, 29 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java
index dc4d45d..bd3c7b8 100644
--- a/src/com/android/camera/Camera.java
+++ b/src/com/android/camera/Camera.java
@@ -1849,7 +1849,7 @@ public class Camera extends ActivityBase implements FocusManager.Listener,
}
private boolean switchToOtherMode(int mode) {
- if (isFinishing() || !isCameraIdle()) return false;
+ if (isFinishing()) return false;
MenuHelper.gotoMode(mode, Camera.this);
mHandler.removeMessages(FIRST_TIME_INIT);
finish();
diff --git a/src/com/android/camera/ModePicker.java b/src/com/android/camera/ModePicker.java
index 468882a..62ee51e 100644
--- a/src/com/android/camera/ModePicker.java
+++ b/src/com/android/camera/ModePicker.java
@@ -22,6 +22,7 @@ import android.content.Context;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
+import android.util.Log;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
@@ -38,6 +39,7 @@ public class ModePicker extends RelativeLayout implements View.OnClickListener {
public static final int MODE_VIDEO = 1;
public static final int MODE_PANORAMA = 2;
+ private static final String TAG = "ModePicker";
// Total mode number
private static final int MODE_NUM = 3;
@@ -56,7 +58,6 @@ public class ModePicker extends RelativeLayout implements View.OnClickListener {
private View mCurrentModeFrame;
private RotateImageView mCurrentModeIcon[];
private View mCurrentModeBar;
- private View mSelectedView;
private int mCurrentMode = 0;
private Animation mFadeIn, mFadeOut;
@@ -87,7 +88,6 @@ public class ModePicker extends RelativeLayout implements View.OnClickListener {
// The current mode frame is for Phone UI only.
mCurrentModeFrame = findViewById(R.id.current_mode);
if (mCurrentModeFrame != null) {
- mCurrentModeFrame.setOnClickListener(this);
mCurrentModeIcon = new RotateImageView[MODE_NUM];
mCurrentModeIcon[0] = (RotateImageView) findViewById(R.id.mode_0);
mCurrentModeIcon[1] = (RotateImageView) findViewById(R.id.mode_1);
@@ -97,6 +97,16 @@ public class ModePicker extends RelativeLayout implements View.OnClickListener {
mCurrentModeBar = findViewById(R.id.current_mode_bar);
enableModeSelection(true);
}
+ registerOnClickListener();
+ }
+
+ private void registerOnClickListener() {
+ if (mCurrentModeFrame != null) {
+ mCurrentModeFrame.setOnClickListener(this);
+ }
+ for (int i = 0; i < MODE_NUM; ++i) {
+ mModeSelectionIcon[i].setOnClickListener(this);
+ }
}
private AnimationListener mAnimationListener = new AnimationListener() {
@@ -121,19 +131,14 @@ public class ModePicker extends RelativeLayout implements View.OnClickListener {
mModeSelectionFrame.setVisibility(View.VISIBLE);
mCurrentModeFrame.setVisibility(View.GONE);
}
- mCurrentModeFrame.setOnClickListener(enabled ? null : this);
- }
- for (int i = 0; i < MODE_NUM; ++i) {
- mModeSelectionIcon[i].setOnClickListener(enabled ? this : null);
}
updateModeState();
}
private void changeToSelectedMode() {
- for (int i = 0; i < MODE_NUM; ++i) {
- if (mSelectedView == mModeSelectionIcon[i]) {
- setCurrentMode(i);
- return;
+ if (mListener != null) {
+ if (mListener.onModeChanged(mCurrentMode)) {
+ Log.e(TAG, "failed:onModeChanged:" + mCurrentMode);
}
}
}
@@ -142,8 +147,13 @@ public class ModePicker extends RelativeLayout implements View.OnClickListener {
if (view == mCurrentModeFrame) {
enableModeSelection(true);
} else {
- // The view in selection menu is clicked.
- mSelectedView = view;
+ // Set the selected mode as the current one and switch to it.
+ for (int i = 0; i < MODE_NUM; ++i) {
+ if (view == mModeSelectionIcon[i] && (mCurrentMode != i)) {
+ setCurrentMode(i);
+ break;
+ }
+ }
if (mCurrentModeBar == null) {
enableModeSelection(false);
} else {
@@ -157,17 +167,8 @@ public class ModePicker extends RelativeLayout implements View.OnClickListener {
}
public void setCurrentMode(int mode) {
- tryToSetMode(mode);
- updateModeState();
- }
-
- private void tryToSetMode(int mode) {
- if (mListener != null) {
- if (!mListener.onModeChanged(mode)) {
- return;
- }
- }
mCurrentMode = mode;
+ updateModeState();
}
public boolean onModeChanged(int mode) {
@@ -200,14 +201,12 @@ public class ModePicker extends RelativeLayout implements View.OnClickListener {
if (enabled) updateModeState();
}
- private void highlightView(View view, boolean enabled) {
- Drawable drawable = ((ImageView) view).getDrawable();
+ private void highlightView(ImageView view, boolean enabled) {
if (enabled) {
- drawable.clearColorFilter();
+ view.clearColorFilter();
} else {
- drawable.setColorFilter(DISABLED_COLOR, PorterDuff.Mode.SRC_ATOP);
+ view.setColorFilter(DISABLED_COLOR, PorterDuff.Mode.SRC_ATOP);
}
- requestLayout();
}
private void updateModeState() {
diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java
index 537db23..29e1fac 100644
--- a/src/com/android/camera/VideoCamera.java
+++ b/src/com/android/camera/VideoCamera.java
@@ -1826,7 +1826,7 @@ public class VideoCamera extends ActivityBase
}
private boolean switchToOtherMode(int mode) {
- if (isFinishing() || mMediaRecorderRecording) return false;
+ if (isFinishing()) return false;
MenuHelper.gotoMode(mode, VideoCamera.this);
finish();
return true;