summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/drawable-hdpi/btn_ic_mode_switch_camera.pngbin1014 -> 0 bytes
-rw-r--r--res/drawable-hdpi/btn_ic_mode_switch_camera_checked.pngbin0 -> 747 bytes
-rw-r--r--res/drawable-hdpi/btn_ic_mode_switch_camera_normal.png (renamed from res/drawable-mdpi/btn_ic_mode_switch_camera.png)bin694 -> 694 bytes
-rw-r--r--res/drawable-hdpi/btn_ic_mode_switch_video.pngbin752 -> 0 bytes
-rw-r--r--res/drawable-hdpi/btn_ic_mode_switch_video_checked.pngbin0 -> 482 bytes
-rw-r--r--res/drawable-hdpi/btn_ic_mode_switch_video_normal.png (renamed from res/drawable-mdpi/btn_ic_mode_switch_video.png)bin544 -> 544 bytes
-rw-r--r--res/drawable-mdpi/btn_ic_mode_switch_camera_checked.pngbin0 -> 747 bytes
-rw-r--r--res/drawable-mdpi/btn_ic_mode_switch_camera_normal.pngbin0 -> 817 bytes
-rw-r--r--res/drawable-mdpi/btn_ic_mode_switch_video_checked.pngbin0 -> 482 bytes
-rw-r--r--res/drawable-mdpi/btn_ic_mode_switch_video_normal.pngbin0 -> 525 bytes
-rw-r--r--res/drawable/btn_ic_mode_switch_camera.xml20
-rw-r--r--res/drawable/btn_ic_mode_switch_video.xml20
-rw-r--r--res/layout-xlarge/camera_control.xml18
-rw-r--r--res/layout/camera_control.xml6
-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
18 files changed, 156 insertions, 32 deletions
diff --git a/res/drawable-hdpi/btn_ic_mode_switch_camera.png b/res/drawable-hdpi/btn_ic_mode_switch_camera.png
deleted file mode 100644
index ca53bb7..0000000
--- a/res/drawable-hdpi/btn_ic_mode_switch_camera.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/btn_ic_mode_switch_camera_checked.png b/res/drawable-hdpi/btn_ic_mode_switch_camera_checked.png
new file mode 100644
index 0000000..d64d636
--- /dev/null
+++ b/res/drawable-hdpi/btn_ic_mode_switch_camera_checked.png
Binary files differ
diff --git a/res/drawable-mdpi/btn_ic_mode_switch_camera.png b/res/drawable-hdpi/btn_ic_mode_switch_camera_normal.png
index b8b0df7..b8b0df7 100644
--- a/res/drawable-mdpi/btn_ic_mode_switch_camera.png
+++ b/res/drawable-hdpi/btn_ic_mode_switch_camera_normal.png
Binary files differ
diff --git a/res/drawable-hdpi/btn_ic_mode_switch_video.png b/res/drawable-hdpi/btn_ic_mode_switch_video.png
deleted file mode 100644
index 09a2036..0000000
--- a/res/drawable-hdpi/btn_ic_mode_switch_video.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/btn_ic_mode_switch_video_checked.png b/res/drawable-hdpi/btn_ic_mode_switch_video_checked.png
new file mode 100644
index 0000000..9411f4c
--- /dev/null
+++ b/res/drawable-hdpi/btn_ic_mode_switch_video_checked.png
Binary files differ
diff --git a/res/drawable-mdpi/btn_ic_mode_switch_video.png b/res/drawable-hdpi/btn_ic_mode_switch_video_normal.png
index f31e9ff..f31e9ff 100644
--- a/res/drawable-mdpi/btn_ic_mode_switch_video.png
+++ b/res/drawable-hdpi/btn_ic_mode_switch_video_normal.png
Binary files differ
diff --git a/res/drawable-mdpi/btn_ic_mode_switch_camera_checked.png b/res/drawable-mdpi/btn_ic_mode_switch_camera_checked.png
new file mode 100644
index 0000000..d64d636
--- /dev/null
+++ b/res/drawable-mdpi/btn_ic_mode_switch_camera_checked.png
Binary files differ
diff --git a/res/drawable-mdpi/btn_ic_mode_switch_camera_normal.png b/res/drawable-mdpi/btn_ic_mode_switch_camera_normal.png
new file mode 100644
index 0000000..a695238
--- /dev/null
+++ b/res/drawable-mdpi/btn_ic_mode_switch_camera_normal.png
Binary files differ
diff --git a/res/drawable-mdpi/btn_ic_mode_switch_video_checked.png b/res/drawable-mdpi/btn_ic_mode_switch_video_checked.png
new file mode 100644
index 0000000..9411f4c
--- /dev/null
+++ b/res/drawable-mdpi/btn_ic_mode_switch_video_checked.png
Binary files differ
diff --git a/res/drawable-mdpi/btn_ic_mode_switch_video_normal.png b/res/drawable-mdpi/btn_ic_mode_switch_video_normal.png
new file mode 100644
index 0000000..9758931
--- /dev/null
+++ b/res/drawable-mdpi/btn_ic_mode_switch_video_normal.png
Binary files differ
diff --git a/res/drawable/btn_ic_mode_switch_camera.xml b/res/drawable/btn_ic_mode_switch_camera.xml
new file mode 100644
index 0000000..adbd879
--- /dev/null
+++ b/res/drawable/btn_ic_mode_switch_camera.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:state_checked="true" android:drawable="@drawable/btn_ic_mode_switch_camera_checked" />
+ <item android:drawable="@drawable/btn_ic_mode_switch_camera_normal" />
+</selector>
diff --git a/res/drawable/btn_ic_mode_switch_video.xml b/res/drawable/btn_ic_mode_switch_video.xml
new file mode 100644
index 0000000..00f989d
--- /dev/null
+++ b/res/drawable/btn_ic_mode_switch_video.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:state_checked="true" android:drawable="@drawable/btn_ic_mode_switch_video_checked" />
+ <item android:drawable="@drawable/btn_ic_mode_switch_video_normal" />
+</selector>
diff --git a/res/layout-xlarge/camera_control.xml b/res/layout-xlarge/camera_control.xml
index 38c6200..961ae27 100644
--- a/res/layout-xlarge/camera_control.xml
+++ b/res/layout-xlarge/camera_control.xml
@@ -67,7 +67,7 @@
android:background="@drawable/btn_shutter" />
</com.android.camera.ui.IndicatorWheel>
- <LinearLayout android:id="@+id/camera_switch_set"
+ <com.android.camera.SwitcherSet android:id="@+id/camera_switch"
android:orientation="vertical"
android:gravity="center"
android:layout_height="150dp"
@@ -76,21 +76,23 @@
android:layout_alignParentLeft="true"
android:layout_marginLeft="21dp"
android:background="@drawable/mode_switch_bg_v2">
- <com.android.camera.RotateImageView android:id="@+id/video_switch_icon"
+ <RadioButton android:id="@+id/switch_off_button"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
- android:src="@drawable/btn_ic_mode_switch_video"/>
- <com.android.camera.Switcher android:id="@+id/camera_switch"
+ android:button="@android:color/transparent"
+ android:background="@drawable/btn_ic_mode_switch_video"/>
+ <com.android.camera.Switcher android:id="@+id/switcher"
android:layout_width="wrap_content"
- android:layout_height="60dp"
+ android:layout_height="50dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:src="@drawable/btn_mode_switch_knob_v2"
android:background="@drawable/btn_mode_switch_bg_v2" />
- <com.android.camera.RotateImageView android:id="@+id/camera_switch_icon"
+ <RadioButton android:id="@+id/switch_on_button"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
- android:src="@drawable/btn_ic_mode_switch_camera"/>
- </LinearLayout>
+ android:button="@android:color/transparent"
+ android:background="@drawable/btn_ic_mode_switch_camera"/>
+ </com.android.camera.SwitcherSet>
</com.android.camera.ui.ControlPanel>
diff --git a/res/layout/camera_control.xml b/res/layout/camera_control.xml
index c89418e..f4117a2 100644
--- a/res/layout/camera_control.xml
+++ b/res/layout/camera_control.xml
@@ -24,7 +24,7 @@
<include layout="@layout/review_thumbnail"/>
- <LinearLayout android:id="@+id/camera_switch_set"
+ <com.android.camera.SwitcherSet android:id="@+id/camera_switch"
android:orientation="vertical"
android:gravity="center"
android:layout_centerInParent="true"
@@ -34,7 +34,7 @@
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="@drawable/btn_ic_mode_switch_video"/>
- <com.android.camera.Switcher android:id="@+id/camera_switch"
+ <com.android.camera.Switcher android:id="@+id/switcher"
android:layout_width="wrap_content"
android:layout_height="70dp"
android:src="@drawable/btn_mode_switch_knob"
@@ -45,7 +45,7 @@
android:layout_width="wrap_content"
android:layout_marginBottom="3dp"
android:src="@drawable/btn_ic_mode_switch_camera"/>
- </LinearLayout>
+ </com.android.camera.SwitcherSet>
<com.android.camera.ShutterButton android:id="@+id/shutter_button"
android:layout_alignParentBottom="true"
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;
}