OSDN Git Service

Allow swiping to filmstrip from blocker bar
authorDoris Liu <tianliu@google.com>
Tue, 16 Apr 2013 16:50:56 +0000 (09:50 -0700)
committerDoris Liu <tianliu@google.com>
Thu, 18 Apr 2013 20:59:42 +0000 (13:59 -0700)
Bug: 8607910
Change-Id: I69bfcf8d95d6071be7d65fbf433916740cbb655c

res/layout-land/camera_controls.xml
res/layout-port/camera_controls.xml
src/com/android/camera/CameraActivity.java
src/com/android/camera/PhotoModule.java
src/com/android/camera/PhotoUI.java
src/com/android/camera/PreviewGestures.java
src/com/android/camera/VideoUI.java

index 59a83e0..683f0e5 100644 (file)
@@ -23,7 +23,6 @@
             android:id="@+id/blocker"
             android:layout_height="match_parent"
             android:layout_width="@dimen/switcher_size"
-            android:clickable="true"
             android:layout_gravity="right" />
 
         <include layout="@layout/menu_indicators"
index e3fdce8..76e23be 100644 (file)
@@ -23,8 +23,7 @@
             android:id="@+id/blocker"
             android:layout_width="match_parent"
             android:layout_height="@dimen/switcher_size"
-            android:layout_gravity="bottom"
-            android:clickable="true" />
+            android:layout_gravity="bottom" />
 
         <include layout="@layout/menu_indicators"
             android:layout_width="80dip"
index 1215cec..5e55846 100644 (file)
@@ -423,9 +423,10 @@ public class CameraActivity extends ActivityBase
     }
 
     // Preview area is touched. Handle touch focus.
+    // Touch to focus is handled by PreviewGestures, this function call
+    // is no longer needed. TODO: Clean it up in the next refactor
     @Override
     protected void onSingleTapUp(View view, int x, int y) {
-        mCurrentModule.onSingleTapUp(view, x, y);
     }
 
     @Override
index 1270364..3e71aa6 100644 (file)
@@ -1199,10 +1199,6 @@ public class PhotoModule
         if (pressed && !canTakePicture()) return;
 
         if (pressed) {
-            if (mSceneMode == Util.SCENE_MODE_HDR) {
-                mActivity.hideSwitcher();
-                mActivity.setSwipingEnabled(false);
-            }
             mFocusManager.onShutterDown();
         } else {
             // for countdown mode, we need to postpone the shutter release
@@ -1227,6 +1223,10 @@ public class PhotoModule
         }
         Log.v(TAG, "onShutterButtonClick: mCameraState=" + mCameraState);
 
+        if (mSceneMode == Util.SCENE_MODE_HDR) {
+            mActivity.hideSwitcher();
+            mActivity.setSwipingEnabled(false);
+        }
         // If the user wants to do a snapshot while the previous one is still
         // in progress, remember the fact and do it after we finish the previous
         // one and re-start the preview. Snapshot in progress also includes the
index 53fdc96..fd148ba 100644 (file)
@@ -180,10 +180,10 @@ public class PhotoUI implements PieListener,
             mGestures = new PreviewGestures(mActivity, this, mZoomRenderer, mPieRenderer,
                     this);
         }
-        mGestures.clearTouchReceivers();
+        mGestures.reset();
         mGestures.setRenderOverlay(mRenderOverlay);
         mGestures.addTouchReceiver(mMenuButton);
-        mGestures.addTouchReceiver(mBlocker);
+        mGestures.addUnclickableArea(mBlocker);
         // make sure to add touch targets for image capture
         if (mController.isImageCaptureIntent()) {
             if (mReviewCancelButton != null) {
index 351da0a..b968a02 100644 (file)
@@ -59,6 +59,7 @@ public class PreviewGestures
     private MotionEvent mCurrent;
     private ScaleGestureDetector mScale;
     private List<View> mReceivers;
+    private List<View> mUnclickableAreas;
     private int mMode;
     private int mSlop;
     private int mTapTimeout;
@@ -127,12 +128,41 @@ public class PreviewGestures
         mReceivers.add(v);
     }
 
+    public void addUnclickableArea(View v) {
+        if (mUnclickableAreas == null) {
+            mUnclickableAreas = new ArrayList<View>();
+        }
+        mUnclickableAreas.add(v);
+    }
+
     public void clearTouchReceivers() {
         if (mReceivers != null) {
             mReceivers.clear();
         }
     }
 
+    public void clearUnclickableAreas() {
+        if (mUnclickableAreas != null) {
+            mUnclickableAreas.clear();
+        }
+    }
+
+    private boolean checkClickable(MotionEvent m) {
+        if (mUnclickableAreas != null) {
+            for (View v : mUnclickableAreas) {
+                if (isInside(m, v)) {
+                    return false;
+                }
+            }
+        }
+        return true;
+    }
+
+    public void reset() {
+        clearTouchReceivers();
+        clearUnclickableAreas();
+    }
+
     public boolean dispatchTouch(MotionEvent m) {
         if (!mEnabled) {
             return mActivity.superDispatchTouchEvent(m);
@@ -149,7 +179,7 @@ public class PreviewGestures
                     mMode = MODE_PIE;
                     return sendToPie(m);
                 }
-                if (mPie != null && !mZoomOnly) {
+                if (mPie != null && !mZoomOnly && checkClickable(m)) {
                     mHandler.sendEmptyMessageDelayed(MSG_PIE, TIMEOUT_PIE);
                 }
                 if (mZoom != null) {
@@ -216,9 +246,10 @@ public class PreviewGestures
             }
             if (MotionEvent.ACTION_UP == m.getActionMasked()) {
                 cancelPie();
-                cancelActivityTouchHandling(m);
                 // must have been tap
-                if (m.getEventTime() - mDown.getEventTime() < mTapTimeout) {
+                if (m.getEventTime() - mDown.getEventTime() < mTapTimeout
+                        && checkClickable(m)) {
+                    cancelActivityTouchHandling(m);
                     mTapListener.onSingleTapUp(null,
                             (int) mDown.getX() - mOverlay.getWindowPositionX(),
                             (int) mDown.getY() - mOverlay.getWindowPositionY());
index 43822e7..79150e9 100644 (file)
@@ -213,9 +213,9 @@ public class VideoUI implements SurfaceHolder.Callback, PieRenderer.PieListener,
             mGestures = new PreviewGestures(mActivity, this, mZoomRenderer, mPieRenderer, this);
         }
         mGestures.setRenderOverlay(mRenderOverlay);
-        mGestures.clearTouchReceivers();
+        mGestures.reset();
         mGestures.addTouchReceiver(mMenu);
-        mGestures.addTouchReceiver(mBlocker);
+        mGestures.addUnclickableArea(mBlocker);
         if (mController.isVideoCaptureIntent()) {
             if (mReviewCancelButton != null) {
                 mGestures.addTouchReceiver(mReviewCancelButton);