diff options
author | Likai Ding <likaid@codeaurora.org> | 2015-01-26 10:07:21 +0800 |
---|---|---|
committer | Likai Ding <likaid@codeaurora.org> | 2015-02-02 13:55:08 +0800 |
commit | e2fb5dc7798cf677f6a66b6a697c4a011b0a101f (patch) | |
tree | 9250c3a47e27b90e3c094c9d3ffa1365c3914178 /src/com/android/camera/PreviewGestures.java | |
parent | 07cf80cc97c68f12d5728919fcebba28e750761d (diff) | |
download | android_packages_apps_Snap-e2fb5dc7798cf677f6a66b6a697c4a011b0a101f.tar.gz android_packages_apps_Snap-e2fb5dc7798cf677f6a66b6a697c4a011b0a101f.tar.bz2 android_packages_apps_Snap-e2fb5dc7798cf677f6a66b6a697c4a011b0a101f.zip |
SnapdragonCamera: fix portrait orientation
Fix camera activity to portrait, so there is no delay when rotation
occurs. Main changes are:
1. RotateLayout now supports padding and dynamically added child.
2. Camera controls and gesture detetion are now orientation-aware.
3. Toasts are replaced with RotateTextToast.
4. Obselete layout files are removed.
Change-Id: I338849bd7fb84b847eb357f771a24a5cc09bf6fa
Diffstat (limited to 'src/com/android/camera/PreviewGestures.java')
-rw-r--r-- | src/com/android/camera/PreviewGestures.java | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/src/com/android/camera/PreviewGestures.java b/src/com/android/camera/PreviewGestures.java index ce461aadd..70a094c28 100644 --- a/src/com/android/camera/PreviewGestures.java +++ b/src/com/android/camera/PreviewGestures.java @@ -89,32 +89,36 @@ public class PreviewGestures if (mZoomOnly || mMode == MODE_ZOOM) return false; int deltaX = (int) (e1.getX() - e2.getX()); int deltaY = (int) (e1.getY() - e2.getY()); - if (deltaY > 2 * deltaX && deltaY > -2 * deltaX) { - // Open pie on swipe up - if (mPie != null && !mPie.showsItems()) { - openPie(); - return true; - } - } - if (deltaX < 0 && Math.abs(deltaX) > 2 * Math.abs(deltaY)) { - // Open menu on swipe left - waitUntilNextDown = true; - if (mPhotoMenu != null) { - if (!mPhotoMenu.isMenuBeingShown()) { - mPhotoMenu.openFirstLevel(); - } - } + int orientation = 0; + if (mPhotoMenu != null) + orientation = mPhotoMenu.getOrientation(); + else if (mVideoMenu != null) + orientation = mVideoMenu.getOrientation(); - if (mVideoMenu != null) { - if (!mVideoMenu.isMenuBeingShown()) { - mVideoMenu.openFirstLevel(); - } - } + if (isLeftSwipe(orientation, deltaX, deltaY)) { + waitUntilNextDown = true; + if (mPhotoMenu != null && !mPhotoMenu.isMenuBeingShown()) + mPhotoMenu.openFirstLevel(); + else if (mVideoMenu != null && !mVideoMenu.isMenuBeingShown()) + mVideoMenu.openFirstLevel(); return true; } return false; } + + private boolean isLeftSwipe(int orientation, int deltaX, int deltaY) { + switch (orientation) { + case 90: + return deltaY > 0 && Math.abs(deltaY) > 2 * Math.abs(deltaX); + case 180: + return deltaX > 0 && Math.abs(deltaX) > 2 * Math.abs(deltaY); + case 270: + return deltaY < 0 && Math.abs(deltaY) > 2 * Math.abs(deltaX); + default: + return deltaX < 0 && Math.abs(deltaX) > 2 * Math.abs(deltaY); + } + } }; public interface SingleTapListener { |