summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorrepo sync <cywang@google.com>2011-07-14 10:09:24 +0800
committerrepo sync <cywang@google.com>2011-07-16 01:51:30 +0800
commit2b1f214ecbd9c0e40edf827620b59ba00777c948 (patch)
tree81aea239a33b34506111f3562a5ccdcb57895347 /src
parent5281216188a75f5a2edd87ef5f7358a956f17e28 (diff)
downloadLegacyCamera-2b1f214ecbd9c0e40edf827620b59ba00777c948.zip
LegacyCamera-2b1f214ecbd9c0e40edf827620b59ba00777c948.tar.gz
LegacyCamera-2b1f214ecbd9c0e40edf827620b59ba00777c948.tar.bz2
Merge the different implementations on CameraSwitch.
+enable the camera/video icon rotation for tablet version. +render disabled effect for tablet only. Change-Id: I2827cb57ac7d8d60efdb6f3172c89db32ac443d4
Diffstat (limited to 'src')
-rw-r--r--src/com/android/camera/Switcher.java11
-rw-r--r--src/com/android/camera/SwitcherSet.java56
2 files changed, 26 insertions, 41 deletions
diff --git a/src/com/android/camera/Switcher.java b/src/com/android/camera/Switcher.java
index 7c93d20..dee5f3e 100644
--- a/src/com/android/camera/Switcher.java
+++ b/src/com/android/camera/Switcher.java
@@ -202,15 +202,4 @@ public class Switcher extends ImageView implements View.OnTouchListener {
event.offsetLocation(getLeft(), getTop());
return true;
}
-
- @Override
- public void setEnabled(boolean enabled) {
- super.setEnabled(enabled);
- Drawable drawable = getDrawable();
- if (enabled) {
- drawable.clearColorFilter();
- } else {
- drawable.setColorFilter(DISABLED_COLOR, PorterDuff.Mode.SRC_ATOP);
- }
- }
}
diff --git a/src/com/android/camera/SwitcherSet.java b/src/com/android/camera/SwitcherSet.java
index 587b735..0371b43 100644
--- a/src/com/android/camera/SwitcherSet.java
+++ b/src/com/android/camera/SwitcherSet.java
@@ -20,32 +20,28 @@ import android.content.Context;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
-import android.widget.CompoundButton;
-import android.widget.RadioGroup;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
/**
- * A widget that includes two {@code RadioButton}'s and a {@link Switcher}.
+ * A widget that includes two {@code RotateImageView}'s and a {@link Switcher}.
*/
-public class SwitcherSet extends RadioGroup implements Switcher.OnSwitchListener,
- RadioGroup.OnCheckedChangeListener {
+public class SwitcherSet extends LinearLayout implements Switcher.OnSwitchListener {
private final int DISABLED_COLOR;
private Switcher.OnSwitchListener mListener;
- private CompoundButton mOnView;
- private CompoundButton mOffView;
+ private View mOnView;
+ private View mOffView;
private Switcher mSwitcher;
+ private Context mContext;
public SwitcherSet(Context context, AttributeSet attrs) {
super(context, attrs);
+ mContext = context;
DISABLED_COLOR = context.getResources().getColor(R.color.icon_disabled_color);
}
- @Override
- public void onCheckedChanged(RadioGroup group, int checkedId) {
- boolean onOff = checkedId == mOnView.getId();
- tryToSetSwitch(onOff);
- }
-
protected void onFinishInflate() {
super.onFinishInflate();
mSwitcher = (Switcher) findViewById(R.id.switcher);
@@ -54,19 +50,14 @@ public class SwitcherSet extends RadioGroup implements Switcher.OnSwitchListener
}
mSwitcher.setOnSwitchListener(this);
mSwitcher.addTouchView(this);
- setOnCheckedChangeListener(this);
- mOnView = (CompoundButton) findViewById(R.id.switch_on_button);
- mOffView = (CompoundButton) findViewById(R.id.switch_off_button);
+ mOnView = findViewById(R.id.camera_switch_icon);
+ mOffView = findViewById(R.id.video_switch_icon);
}
public void setSwitch(boolean onOff) {
- if ((mOnView == null) && (mOffView == null)) {
- tryToSetSwitch(onOff);
- } else {
- // will trigger onCheckedChanged() and callback in tryToSetSwitch()
- CompoundButton button = onOff ? mOnView : mOffView;
- if (button != null) button.setChecked(true);
- }
+ mOnView.setSelected(onOff);
+ mOffView.setSelected(!onOff);
+ mSwitcher.setSwitch(onOff);
}
public void setOnSwitchListener(Switcher.OnSwitchListener listener) {
@@ -75,7 +66,6 @@ public class SwitcherSet extends RadioGroup implements Switcher.OnSwitchListener
// 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);
@@ -86,20 +76,26 @@ public class SwitcherSet extends RadioGroup implements Switcher.OnSwitchListener
@Override
public boolean onSwitchChanged(Switcher source, boolean onOff) {
setSwitch(onOff);
+ tryToSetSwitch(onOff);
return true;
}
@Override
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
- mSwitcher.setEnabled(enabled);
- if (mOnView != null) setEnabled(mOnView, enabled);
- if (mOffView != null) setEnabled(mOffView, enabled);
+
+ setEnabled(mSwitcher, enabled);
+ setEnabled(mOnView, enabled);
+ setEnabled(mOffView, enabled);
}
- private void setEnabled(CompoundButton button, boolean enabled) {
- button.setEnabled(enabled);
- Drawable drawable = button.getBackground();
+ public void setEnabled(View view, boolean enabled) {
+ view.setEnabled(enabled);
+
+ // render disabled effect for tablet only.
+ if (mContext.getResources().getConfiguration().screenWidthDp < 1024) return;
+
+ Drawable drawable = ((ImageView) view).getDrawable();
if (enabled) {
drawable.clearColorFilter();
} else {