Fix for popuping being hard to dismiss

Bug: 8688503
Change-Id: I86f1451867d7606060e5f81fdd3b8b0af1e0a6d3
diff --git a/src/com/android/camera/PhotoUI.java b/src/com/android/camera/PhotoUI.java
index fd148ba..ad04a4e 100644
--- a/src/com/android/camera/PhotoUI.java
+++ b/src/com/android/camera/PhotoUI.java
@@ -389,9 +389,7 @@
     }
 
     public boolean dispatchTouchEvent(MotionEvent m) {
-        if (mPopup != null) {
-            return mActivity.superDispatchTouchEvent(m);
-        } else if (mGestures != null && mRenderOverlay != null) {
+        if (mGestures != null && mRenderOverlay != null) {
             return mGestures.dispatchTouch(m);
         }
         return false;
@@ -462,6 +460,7 @@
                 LayoutParams.WRAP_CONTENT);
         lp.gravity = Gravity.CENTER;
         ((FrameLayout) mRootView).addView(mPopup, lp);
+        mGestures.addTouchReceiver(mPopup);
     }
 
     public void dismissPopup(boolean topPopupOnly) {
@@ -475,6 +474,7 @@
         }
         setShowMenu(fullScreen);
         if (mPopup != null) {
+            mGestures.removeTouchReceiver(mPopup);
             ((FrameLayout) mRootView).removeView(mPopup);
             mPopup = null;
         }
diff --git a/src/com/android/camera/PreviewGestures.java b/src/com/android/camera/PreviewGestures.java
index 90ab075..0b80ff6 100644
--- a/src/com/android/camera/PreviewGestures.java
+++ b/src/com/android/camera/PreviewGestures.java
@@ -128,6 +128,11 @@
         mReceivers.add(v);
     }
 
+    public void removeTouchReceiver(View v) {
+        if (mReceivers == null || v == null) return;
+        mReceivers.remove(v);
+    }
+
     public void addUnclickableArea(View v) {
         if (mUnclickableAreas == null) {
             mUnclickableAreas = new ArrayList<View>();
diff --git a/src/com/android/camera/VideoUI.java b/src/com/android/camera/VideoUI.java
index 79150e9..1da4c24 100644
--- a/src/com/android/camera/VideoUI.java
+++ b/src/com/android/camera/VideoUI.java
@@ -295,6 +295,7 @@
                 LayoutParams.WRAP_CONTENT);
         lp.gravity = Gravity.CENTER;
         ((FrameLayout) mRootView).addView(mPopup, lp);
+        mGestures.addTouchReceiver(mPopup);
     }
 
     public void dismissPopup(boolean topLevelOnly) {
@@ -308,6 +309,7 @@
         }
         setShowMenu(fullScreen);
         if (mPopup != null) {
+            mGestures.removeTouchReceiver(mPopup);
             ((FrameLayout) mRootView).removeView(mPopup);
             mPopup = null;
         }
@@ -486,10 +488,8 @@
     }
 
     public boolean dispatchTouchEvent(MotionEvent m) {
-        if (mPopup == null && mGestures != null && mRenderOverlay != null) {
+        if (mGestures != null && mRenderOverlay != null) {
             return mGestures.dispatchTouch(m);
-        } else if (mPopup != null) {
-            return mActivity.superDispatchTouchEvent(m);
         }
         return false;
     }