summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHung-ying Tyan <tyanh@google.com>2010-11-18 17:59:58 +0800
committerHung-ying Tyan <tyanh@google.com>2010-11-24 17:37:14 +0800
commiteb1f0c8299d96bad9bb449ff9e13eff4b43272cc (patch)
treea8f78fb4623b5c89eb3af56fb2b695e2f574f6cf /src
parent677c81c916b4105131b395399b0a91d5eeb82935 (diff)
downloadLegacyCamera-eb1f0c8299d96bad9bb449ff9e13eff4b43272cc.zip
LegacyCamera-eb1f0c8299d96bad9bb449ff9e13eff4b43272cc.tar.gz
LegacyCamera-eb1f0c8299d96bad9bb449ff9e13eff4b43272cc.tar.bz2
Highlight camera/video icon when mode is changed.
+ Make camera/video icons on switcher radio buttons instead of RotateImageView for x-large devices. + Add icons for camera and video on different states (normal and checked) for x-large devices. + Add SwitcherSet.java that consists of the radio buttons and the Switcher and replace the camera_switch_set linear layout with it. + Replace Switcher with SwitcherSet in Camera and VideoCamera. Bug: 3156677 Change-Id: I1ea7b4d4149d0a8dc548086150a9ae1a616cd8de
Diffstat (limited to 'src')
-rw-r--r--src/com/android/camera/Camera.java19
-rw-r--r--src/com/android/camera/Switcher.java2
-rw-r--r--src/com/android/camera/SwitcherSet.java84
-rw-r--r--src/com/android/camera/VideoCamera.java19
4 files changed, 103 insertions, 21 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java
index b2c5be1..0396a07 100644
--- a/src/com/android/camera/Camera.java
+++ b/src/com/android/camera/Camera.java
@@ -159,7 +159,7 @@ public class Camera extends NoSearchActivity implements View.OnClickListener,
private ToneGenerator mFocusToneGenerator;
private GestureDetector mPopupGestureDetector;
private GestureDetector mZoomGestureDetector;
- private Switcher mSwitcher;
+ private SwitcherSet mSwitcher;
private boolean mStartPreviewFail = false;
private GLRootView mGLRootView;
@@ -1036,9 +1036,8 @@ public class Camera extends NoSearchActivity implements View.OnClickListener,
controlBar.findViewById(R.id.btn_retake).setOnClickListener(this);
controlBar.findViewById(R.id.btn_done).setOnClickListener(this);
} else {
- mSwitcher = ((Switcher) findViewById(R.id.camera_switch));
+ mSwitcher = (SwitcherSet) findViewById(R.id.camera_switch);
mSwitcher.setOnSwitchListener(this);
- mSwitcher.addTouchView(findViewById(R.id.camera_switch_set));
}
// Show zoom picker.
@@ -1201,14 +1200,14 @@ public class Camera extends NoSearchActivity implements View.OnClickListener,
}
private void setOrientationIndicator(int degree) {
- RotateImageView thumbnail = (RotateImageView) findViewById(
+ RotateImageView icon = (RotateImageView) findViewById(
R.id.review_thumbnail);
- if (thumbnail != null) thumbnail.setDegree(degree);
+ if (icon != null) icon.setDegree(degree);
- ((RotateImageView) findViewById(
- R.id.camera_switch_icon)).setDegree(degree);
- ((RotateImageView) findViewById(
- R.id.video_switch_icon)).setDegree(degree);
+ icon = (RotateImageView) findViewById(R.id.camera_switch_icon);
+ if (icon != null) icon.setDegree(degree);
+ icon = (RotateImageView) findViewById(R.id.video_switch_icon);
+ if (icon != null) icon.setDegree(degree);
}
@Override
@@ -2234,7 +2233,7 @@ public class Camera extends NoSearchActivity implements View.OnClickListener,
private boolean switchToVideoMode() {
if (isFinishing() || !isCameraIdle()) return false;
- MenuHelper.gotoVideoMode(this);
+ MenuHelper.gotoVideoMode(Camera.this);
mHandler.removeMessages(FIRST_TIME_INIT);
finish();
return true;
diff --git a/src/com/android/camera/Switcher.java b/src/com/android/camera/Switcher.java
index e003875..5b43f8e 100644
--- a/src/com/android/camera/Switcher.java
+++ b/src/com/android/camera/Switcher.java
@@ -27,7 +27,7 @@ import android.view.animation.AnimationUtils;
import android.widget.ImageView;
/**
- * A widget which switchs between the {@code Camera} and the {@code VideoCamera}
+ * A widget which switches between the {@code Camera} and the {@code VideoCamera}
* activities.
*/
public class Switcher extends ImageView implements View.OnTouchListener {
diff --git a/src/com/android/camera/SwitcherSet.java b/src/com/android/camera/SwitcherSet.java
new file mode 100644
index 0000000..1346f0f
--- /dev/null
+++ b/src/com/android/camera/SwitcherSet.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.camera;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.widget.CompoundButton;
+import android.widget.RadioGroup;
+
+/**
+ * A widget that includes two {@code RadioButton}'s and a {@link Switcher}.
+ */
+public class SwitcherSet extends RadioGroup implements Switcher.OnSwitchListener {
+ private Switcher.OnSwitchListener mListener;
+ private CompoundButton mOnView;
+ private CompoundButton mOffView;
+ private Switcher mSwitcher;
+
+ public SwitcherSet(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ protected void onFinishInflate() {
+ super.onFinishInflate();
+ mSwitcher = (Switcher) findViewById(R.id.switcher);
+ if (mSwitcher == null) {
+ throw new NullPointerException("cannot find switcher in layout file");
+ }
+ mSwitcher.setOnSwitchListener(this);
+ mSwitcher.addTouchView(this);
+ mOnView = (CompoundButton) findViewById(R.id.switch_on_button);
+ mOffView = (CompoundButton) findViewById(R.id.switch_off_button);
+ CompoundButton.OnCheckedChangeListener listener =
+ new CompoundButton.OnCheckedChangeListener() {
+ public void onCheckedChanged(CompoundButton v, boolean isChecked) {
+ if (!isChecked) return;
+ boolean onOff = (v == mOnView) ^ !isChecked;
+ tryToSetSwitch(onOff);
+ }
+ };
+ if (mOnView != null) mOnView.setOnCheckedChangeListener(listener);
+ if (mOffView != null) mOffView.setOnCheckedChangeListener(listener);
+ }
+
+ public void setSwitch(boolean onOff) {
+ // will trigger onCheckedChanged() and callback in tryToSetSwitch()
+ CompoundButton button = onOff ? mOnView : mOffView;
+ if (button != null) button.setChecked(true);
+ }
+
+ public void setOnSwitchListener(Switcher.OnSwitchListener listener) {
+ mListener = listener;
+ }
+
+ // Try to change the switch position. (The client can veto it.)
+ private void tryToSetSwitch(boolean onOff) {
+ mSwitcher.setSwitch(onOff);
+ if (mListener != null) {
+ if (!mListener.onSwitchChanged(mSwitcher, onOff)) {
+ setSwitch(!onOff);
+ }
+ }
+ }
+
+ @Override
+ public boolean onSwitchChanged(Switcher source, boolean onOff) {
+ setSwitch(onOff);
+ return true;
+ }
+}
diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java
index c4ab942..7ff6bec 100644
--- a/src/com/android/camera/VideoCamera.java
+++ b/src/com/android/camera/VideoCamera.java
@@ -187,7 +187,7 @@ public class VideoCamera extends NoSearchActivity
private ShutterButton mShutterButton;
private TextView mRecordingTimeView, mTimeLapseRecordingTimeView;
- private Switcher mSwitcher;
+ private SwitcherSet mSwitcher;
private boolean mRecordingTimeCountsDown = false;
private final ArrayList<MenuItem> mGalleryItems = new ArrayList<MenuItem>();
@@ -353,9 +353,8 @@ public class VideoCamera extends NoSearchActivity
setContentView(R.layout.video_camera);
initThumbnailButton();
- mSwitcher = ((Switcher) findViewById(R.id.camera_switch));
+ mSwitcher = (SwitcherSet) findViewById(R.id.camera_switch);
mSwitcher.setOnSwitchListener(this);
- mSwitcher.addTouchView(findViewById(R.id.camera_switch_set));
}
mPreviewFrameLayout = (PreviewFrameLayout)
@@ -517,14 +516,14 @@ public class VideoCamera extends NoSearchActivity
}
private void setOrientationIndicator(int degree) {
- RotateImageView thumbnail = (RotateImageView) findViewById(
+ RotateImageView icon = (RotateImageView) findViewById(
R.id.review_thumbnail);
- if (thumbnail != null) thumbnail.setDegree(degree);
+ if (icon != null) icon.setDegree(degree);
- ((RotateImageView) findViewById(
- R.id.camera_switch_icon)).setDegree(degree);
- ((RotateImageView) findViewById(
- R.id.video_switch_icon)).setDegree(degree);
+ icon = (RotateImageView) findViewById(R.id.camera_switch_icon);
+ if (icon != null) icon.setDegree(degree);
+ icon = (RotateImageView) findViewById(R.id.video_switch_icon);
+ if (icon != null) icon.setDegree(degree);
}
@Override
@@ -1730,7 +1729,7 @@ public class VideoCamera extends NoSearchActivity
private boolean switchToCameraMode() {
if (isFinishing() || mMediaRecorderRecording) return false;
- MenuHelper.gotoCameraMode(this);
+ MenuHelper.gotoCameraMode(VideoCamera.this);
finish();
return true;
}