summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChih-Chung Chang <chihchung@google.com>2009-08-10 13:45:21 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2009-08-10 13:45:21 -0700
commit6db7f8e12af8def5ddaa49aed55d006d868f81ef (patch)
tree4d0826e7950285b3975f1afece26e3863f5fc3e3 /src
parent60f640e3864e6d2dd52b3993f838c2461eb13e1f (diff)
parent781f55b23ec3c3f97189efaba9d214183109f769 (diff)
downloadpackages_apps_LegacyCamera-6db7f8e12af8def5ddaa49aed55d006d868f81ef.zip
packages_apps_LegacyCamera-6db7f8e12af8def5ddaa49aed55d006d868f81ef.tar.gz
packages_apps_LegacyCamera-6db7f8e12af8def5ddaa49aed55d006d868f81ef.tar.bz2
am 781f55b2: Make the responsive region larger for the Picture/Video mode switch.
Merge commit '781f55b23ec3c3f97189efaba9d214183109f769' * commit '781f55b23ec3c3f97189efaba9d214183109f769': Make the responsive region larger for the Picture/Video mode switch.
Diffstat (limited to 'src')
-rw-r--r--src/com/android/camera/Camera.java1
-rw-r--r--src/com/android/camera/Switcher.java25
-rw-r--r--src/com/android/camera/VideoCamera.java1
3 files changed, 24 insertions, 3 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java
index 727b7d3..ff0471c 100644
--- a/src/com/android/camera/Camera.java
+++ b/src/com/android/camera/Camera.java
@@ -747,6 +747,7 @@ public class Camera extends Activity implements View.OnClickListener,
inflater.inflate(R.layout.camera_control, rootView);
mSwitcher = ((Switcher) findViewById(R.id.camera_switch));
mSwitcher.setOnSwitchListener(this);
+ mSwitcher.addTouchView(findViewById(R.id.camera_switch_set));
}
// Make sure preview is started.
diff --git a/src/com/android/camera/Switcher.java b/src/com/android/camera/Switcher.java
index 06e0af5..3c7fc44 100644
--- a/src/com/android/camera/Switcher.java
+++ b/src/com/android/camera/Switcher.java
@@ -22,10 +22,11 @@ import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
+import android.view.View;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
-public class Switcher extends ImageView {
+public class Switcher extends ImageView implements View.OnTouchListener {
private static final String TAG = "Switcher";
public interface OnSwitchListener {
@@ -46,6 +47,13 @@ public class Switcher extends ImageView {
}
public void setSwitch(boolean onOff) {
+ if (mSwitch == onOff) return;
+ mSwitch = onOff;
+ invalidate();
+ }
+
+ // Try to change the switch position. (The client can veto it.)
+ private void tryToSetSwitch(boolean onOff) {
try {
if (mSwitch == onOff) return;
@@ -85,12 +93,12 @@ public class Switcher extends ImageView {
case MotionEvent.ACTION_UP:
trackTouchEvent(event);
- setSwitch(mPosition >= available / 2);
+ tryToSetSwitch(mPosition >= available / 2);
setPressed(false);
break;
case MotionEvent.ACTION_CANCEL:
- setSwitch(mSwitch);
+ tryToSetSwitch(mSwitch);
setPressed(false);
break;
}
@@ -160,4 +168,15 @@ public class Switcher extends ImageView {
canvas.restoreToCount(saveCount);
}
+ // Consume the touch events for the specified view.
+ public void addTouchView(View v) {
+ v.setOnTouchListener(this);
+ }
+
+ // This implements View.OnTouchListener so we intercept the touch events
+ // and pass them to ourselves.
+ public boolean onTouch(View v, MotionEvent event) {
+ onTouchEvent(event);
+ return true;
+ }
}
diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java
index 0d10b09..ba6296d 100644
--- a/src/com/android/camera/VideoCamera.java
+++ b/src/com/android/camera/VideoCamera.java
@@ -259,6 +259,7 @@ public class VideoCamera extends Activity implements View.OnClickListener,
mThumbController.loadData(ImageManager.getLastVideoThumbPath());
mSwitcher = ((Switcher) findViewById(R.id.camera_switch));
mSwitcher.setOnSwitchListener(this);
+ mSwitcher.addTouchView(findViewById(R.id.camera_switch_set));
} else {
View controlBar = inflater.inflate(
R.layout.attach_camera_control, rootView);