summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChih-yu Huang <akahuang@google.com>2011-08-22 18:12:07 +0800
committerChih-yu Huang <akahuang@google.com>2011-08-23 10:45:54 +0800
commit3ea573b7823efd6b8a19f4d6535ae61af0ae0b3c (patch)
tree6628f7ae644861fa203d5b40bbcc36e220388419
parent43b0b2ccd5949ee8fc377c37e7e2b82a26c88ca8 (diff)
downloadLegacyCamera-3ea573b7823efd6b8a19f4d6535ae61af0ae0b3c.zip
LegacyCamera-3ea573b7823efd6b8a19f4d6535ae61af0ae0b3c.tar.gz
LegacyCamera-3ea573b7823efd6b8a19f4d6535ae61af0ae0b3c.tar.bz2
Disable mode picker during video recording
bug:5152987 Change-Id: Icfa472494dad0c475fff5b71fe19f06e472873ff
-rw-r--r--res/layout/mode_picker.xml1
-rw-r--r--src/com/android/camera/ModePicker.java40
2 files changed, 23 insertions, 18 deletions
diff --git a/res/layout/mode_picker.xml b/res/layout/mode_picker.xml
index 2fa2c3d..9909307 100644
--- a/res/layout/mode_picker.xml
+++ b/res/layout/mode_picker.xml
@@ -25,7 +25,6 @@
android:layout_height="62dp"
android:layout_width="62dp"
android:scaleType="center"
- android:background="@drawable/btn_mode_background"
android:src="@drawable/btn_ic_camera" />
<LinearLayout android:id="@+id/mode_selection"
android:orientation="vertical"
diff --git a/src/com/android/camera/ModePicker.java b/src/com/android/camera/ModePicker.java
index 92a56c1..6dc19fc 100644
--- a/src/com/android/camera/ModePicker.java
+++ b/src/com/android/camera/ModePicker.java
@@ -19,6 +19,7 @@ package com.android.camera;
import com.android.camera.ui.RotateImageView;
import android.content.Context;
+import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
@@ -35,6 +36,9 @@ public class ModePicker extends RelativeLayout implements View.OnClickListener {
public static final int MODE_VIDEO = 1;
public static final int MODE_CAMERA = 2;
+ // Total mode number
+ private static final int MODE_NUM = 3;
+
/** A callback to be called when the user wants to switch activity. */
public interface OnModeChangeListener {
// Returns true if the listener agrees that the mode can be changed.
@@ -42,9 +46,10 @@ public class ModePicker extends RelativeLayout implements View.OnClickListener {
}
private final int DISABLED_COLOR;
+ private final int CURRENT_MODE_BACKGROUND;
private OnModeChangeListener mListener;
- private View mModeIcons[] = new View[3];
+ private View mModeIcons[] = new View[MODE_NUM];
private View mCurrentModeIcon;
private View mModeSelection;
private int mCurrentMode = MODE_CAMERA;
@@ -54,6 +59,7 @@ public class ModePicker extends RelativeLayout implements View.OnClickListener {
super(context, attrs);
mContext = context;
DISABLED_COLOR = context.getResources().getColor(R.color.icon_disabled_color);
+ CURRENT_MODE_BACKGROUND = R.drawable.btn_mode_background;
}
protected void onFinishInflate() {
@@ -63,6 +69,7 @@ public class ModePicker extends RelativeLayout implements View.OnClickListener {
mCurrentModeIcon = findViewById(R.id.current_mode);
mCurrentModeIcon.setOnClickListener(this);
+ mCurrentModeIcon.setBackgroundResource(CURRENT_MODE_BACKGROUND);
mModeIcons[MODE_PANORAMA] = findViewById(R.id.mode_panorama);
mModeIcons[MODE_VIDEO] = findViewById(R.id.mode_video);
@@ -73,14 +80,14 @@ public class ModePicker extends RelativeLayout implements View.OnClickListener {
mCurrentModeIcon.setVisibility(enabled ? View.GONE : View.VISIBLE);
mCurrentModeIcon.setOnClickListener(enabled ? null : this);
mModeSelection.setVisibility(enabled ? View.VISIBLE : View.GONE);
- for (int i = 0; i < 3; ++i) {
+ for (int i = 0; i < MODE_NUM; ++i) {
mModeIcons[i].setOnClickListener(enabled ? this : null);
- highlightCurrentMode(mModeIcons[i], (i == mCurrentMode));
+ highlightView(mModeIcons[i], (i == mCurrentMode));
}
}
public void onClick(View view) {
- for (int i = 0; i < 3; ++i) {
+ for (int i = 0; i < MODE_NUM; ++i) {
if (view == mModeIcons[i]) {
setCurrentMode(i);
enableModeSelection(false);
@@ -91,7 +98,7 @@ public class ModePicker extends RelativeLayout implements View.OnClickListener {
}
private void setMode(int mode) {
- for (int i = 0; i < 3; ++i) mModeIcons[i].setSelected(mode == i);
+ for (int i = 0; i < MODE_NUM; ++i) mModeIcons[i].setSelected(mode == i);
}
public void setOnModeChangeListener(OnModeChangeListener listener) {
@@ -121,7 +128,7 @@ public class ModePicker extends RelativeLayout implements View.OnClickListener {
}
public void setDegree(int degree) {
- for (int i = 0 ; i < 3 ; ++i) {
+ for (int i = 0; i < MODE_NUM; ++i) {
((RotateImageView) mModeIcons[i]).setDegree(degree);
}
((RotateImageView) mCurrentModeIcon).setDegree(degree);
@@ -130,23 +137,22 @@ public class ModePicker extends RelativeLayout implements View.OnClickListener {
@Override
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
- }
- private void highlightCurrentMode(View view, boolean enabled) {
- Drawable drawable = ((ImageView) view).getDrawable();
+ mCurrentModeIcon.setEnabled(enabled);
+ highlightView(mCurrentModeIcon, enabled);
if (enabled) {
- drawable.clearColorFilter();
+ mCurrentModeIcon.setBackgroundResource(CURRENT_MODE_BACKGROUND);
} else {
- drawable.setColorFilter(DISABLED_COLOR, PorterDuff.Mode.SRC_ATOP);
+ mCurrentModeIcon.setBackgroundColor(Color.BLACK);
}
- }
-
- public void setEnabled(View view, boolean enabled) {
- view.setEnabled(enabled);
- // render disabled effect for tablet only.
- if (!Util.isTabletUI()) return;
+ mModeSelection.setEnabled(enabled);
+ for (int i = 0; i < MODE_NUM; ++i) {
+ mModeIcons[i].setEnabled(enabled);
+ }
+ }
+ private void highlightView(View view, boolean enabled) {
Drawable drawable = ((ImageView) view).getDrawable();
if (enabled) {
drawable.clearColorFilter();