summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
authorWu-cheng Li <wuchengli@google.com>2011-04-27 17:23:10 +0800
committerWu-cheng Li <wuchengli@google.com>2011-04-28 13:24:26 +0800
commit97d089d718dc92c0e9ccc3c923066cf4f0101c35 (patch)
tree190bbf95855939174b4cb8f7cdf8990f2e6ed8a9 /src/com/android
parentfeaf2ccff42c44b74be814b66296f9ddedcc9aa9 (diff)
downloadLegacyCamera-97d089d718dc92c0e9ccc3c923066cf4f0101c35.zip
LegacyCamera-97d089d718dc92c0e9ccc3c923066cf4f0101c35.tar.gz
LegacyCamera-97d089d718dc92c0e9ccc3c923066cf4f0101c35.tar.bz2
Do not trigger touch focus when popup window is dismissed.
Also use getLocationInWindow instead of getLocationOnScreen. bug:3475893 Change-Id: I6e5917cf7340a7968fd07c13bf91e3c555d0cf87
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/camera/Camera.java35
-rw-r--r--src/com/android/camera/Util.java8
-rw-r--r--src/com/android/camera/VideoCamera.java26
3 files changed, 33 insertions, 36 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java
index 909d218..1ec55f4 100644
--- a/src/com/android/camera/Camera.java
+++ b/src/com/android/camera/Camera.java
@@ -542,27 +542,21 @@ public class Camera extends ActivityBase implements View.OnClickListener,
return result;
}
- private int mLocation[] = new int[2];
- private class PopupGestureListener extends
- GestureDetector.SimpleOnGestureListener {
+ private class PopupGestureListener
+ extends GestureDetector.SimpleOnGestureListener {
public boolean onDown(MotionEvent e) {
// Check if the popup window is visible.
- View v = mIndicatorWheel.getActivePopupWindow();
- if (v == null) return false;
-
- int x = Math.round(e.getX());
- int y = Math.round(e.getY());
-
- // Dismiss the popup window if users touch on the outside.
- v.getLocationOnScreen(mLocation);
- if (x < mLocation[0] || (x > mLocation[0] + v.getWidth())
- || y < mLocation[1] || (y > mLocation[1] + v.getHeight())) {
- // Let indicator wheel handle its own event.
- mIndicatorWheel.getLocationOnScreen(mLocation);
- if (x < mLocation[0] || (x > mLocation[0] + mIndicatorWheel.getWidth())
- || y < mLocation[1] || (y > mLocation[1] + mIndicatorWheel.getHeight())) {
- mIndicatorWheel.dismissSettingPopup();
- }
+ View popup = mIndicatorWheel.getActivePopupWindow();
+ if (popup == null) return false;
+
+
+ // Let popup window, indicator wheel or preview frame handle the
+ // event by themselves. Dismiss the popup window if users touch on
+ // other areas.
+ if (!Util.pointInView(e.getX(), e.getY(), popup)
+ && !Util.pointInView(e.getX(), e.getY(), mIndicatorWheel)
+ && !Util.pointInView(e.getX(), e.getY(), mPreviewFrame)) {
+ mIndicatorWheel.dismissSettingPopup();
// Let event fall through.
}
return false;
@@ -1601,6 +1595,9 @@ public class Camera extends ActivityBase implements View.OnClickListener,
// Preview area is touched. Handle touch focus.
@Override
public boolean onTouch(View v, MotionEvent e) {
+ // Do not trigger touch focus when popup window is dismissed.
+ if (collapseCameraControls()) return false;
+
if (mPausing || !mFirstTimeInitialized || !canTakePicture()) {
return false;
}
diff --git a/src/com/android/camera/Util.java b/src/com/android/camera/Util.java
index 5cafe7a..de176c4 100644
--- a/src/com/android/camera/Util.java
+++ b/src/com/android/camera/Util.java
@@ -443,4 +443,12 @@ public class Util {
return (intentCameraId == android.hardware.Camera.CameraInfo.CAMERA_FACING_BACK);
}
+ private static int mLocation[] = new int[2];
+
+ // This method is not thread-safe.
+ public static boolean pointInView(float x, float y, View v) {
+ v.getLocationInWindow(mLocation);
+ return x >= mLocation[0] && x < (mLocation[0] + v.getWidth())
+ && y >= mLocation[1] && y < (mLocation[1] + v.getHeight());
+ }
}
diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java
index 2a5fbc3..03944a1 100644
--- a/src/com/android/camera/VideoCamera.java
+++ b/src/com/android/camera/VideoCamera.java
@@ -1941,28 +1941,20 @@ public class VideoCamera extends ActivityBase
return super.dispatchTouchEvent(m);
}
- private int mLocation[] = new int[2];
private class PopupGestureListener extends
GestureDetector.SimpleOnGestureListener {
@Override
public boolean onDown(MotionEvent e) {
// Check if the popup window is visible.
- View v = mIndicatorWheel.getActivePopupWindow();
- if (v == null) return false;
-
- int x = Math.round(e.getX());
- int y = Math.round(e.getY());
-
- // Dismiss the popup window if users touch on the outside.
- v.getLocationOnScreen(mLocation);
- if (x < mLocation[0] || (x > mLocation[0] + v.getWidth())
- || y < mLocation[1] || (y > mLocation[1] + v.getHeight())) {
- // Let indicator wheel handle its own event.
- mIndicatorWheel.getLocationOnScreen(mLocation);
- if (x < mLocation[0] || (x > mLocation[0] + mIndicatorWheel.getWidth())
- || y < mLocation[1] || (y > mLocation[1] + mIndicatorWheel.getHeight())) {
- mIndicatorWheel.dismissSettingPopup();
- }
+ View popup = mIndicatorWheel.getActivePopupWindow();
+ if (popup == null) return false;
+
+ // Let popup window or indicator wheel handle the event by
+ // themselves. Dismiss the popup window if users touch on other
+ // areas.
+ if (!Util.pointInView(e.getX(), e.getY(), popup)
+ && !Util.pointInView(e.getX(), e.getY(), mIndicatorWheel)) {
+ mIndicatorWheel.dismissSettingPopup();
// Let event fall through.
}
return false;