diff options
Diffstat (limited to 'src/com/android/camera')
-rw-r--r-- | src/com/android/camera/Camera.java | 35 | ||||
-rw-r--r-- | src/com/android/camera/Util.java | 8 | ||||
-rw-r--r-- | src/com/android/camera/VideoCamera.java | 26 |
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; |