OSDN Git Service

Ensuring that we remove the input consumer after moving expanded PiP
authorWinson Chung <winsonc@google.com>
Thu, 16 Mar 2017 02:43:00 +0000 (19:43 -0700)
committerWinson Chung <winsonc@google.com>
Thu, 16 Mar 2017 02:44:08 +0000 (02:44 +0000)
- We re-enable the input consumer once the user starts dragging the
  expanded PiP to allow the touch handler to take over, but once we
  reset the timer (after showing the menu again), we need to disable
  the input consumer so that the menu can get touches again.

Bug: 36266913
Test: Expand PiP, move, click action
Change-Id: I30ebccd165fd764a9a8de8313659c24ecd12aec0

packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivity.java
packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivityController.java
packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java

index 2f9c3fc..36360e7 100644 (file)
@@ -268,7 +268,10 @@ public class PipMenuActivity extends Activity {
             mMenuContainerAnimator.addUpdateListener(mMenuBgUpdateListener);
             mMenuContainerAnimator.start();
         } else {
+            // If we are already visible, then just start the delayed dismiss and unregister any
+            // existing input consumers from the previous drag
             repostDelayedFinish(POST_INTERACTION_DISMISS_DELAY);
+            notifyUnregisterInputConsumer();
         }
     }
 
@@ -416,6 +419,12 @@ public class PipMenuActivity extends Activity {
         sendMessage(m, "Could not notify controller to register input consumer");
     }
 
+    private void notifyUnregisterInputConsumer() {
+        Message m = Message.obtain();
+        m.what = PipMenuActivityController.MESSAGE_UNREGISTER_INPUT_CONSUMER;
+        sendMessage(m, "Could not notify controller to unregister input consumer");
+    }
+
     private void notifyMenuVisibility(boolean visible) {
         mMenuVisible = visible;
         Message m = Message.obtain();
index 7dc455b..724f453 100644 (file)
@@ -63,6 +63,7 @@ public class PipMenuActivityController {
     public static final int MESSAGE_DISMISS_PIP = 103;
     public static final int MESSAGE_UPDATE_ACTIVITY_CALLBACK = 104;
     public static final int MESSAGE_REGISTER_INPUT_CONSUMER = 105;
+    public static final int MESSAGE_UNREGISTER_INPUT_CONSUMER = 106;
 
     /**
      * A listener interface to receive notification on changes in PIP.
@@ -135,6 +136,10 @@ public class PipMenuActivityController {
                     mInputConsumerController.registerInputConsumer();
                     break;
                 }
+                case MESSAGE_UNREGISTER_INPUT_CONSUMER: {
+                    mInputConsumerController.unregisterInputConsumer();
+                    break;
+                }
                 case MESSAGE_UPDATE_ACTIVITY_CALLBACK: {
                     mToActivityMessenger = msg.replyTo;
                     mStartActivityRequested = false;
index c52fc3e..f70d5b4 100644 (file)
@@ -504,8 +504,8 @@ public class PipTouchHandler {
                 return false;
             }
 
-            try {
-                if (ENABLE_DISMISS_DRAG_TO_TARGET) {
+            if (ENABLE_DISMISS_DRAG_TO_TARGET) {
+                try {
                     mHandler.removeCallbacks(mShowDismissAffordance);
                     PointF vel = mTouchState.getVelocity();
                     final float velocity = PointF.length(vel.x, vel.y);
@@ -520,9 +520,9 @@ public class PipTouchHandler {
                             return true;
                         }
                     }
+                } finally {
+                    mDismissViewController.destroyDismissTarget();
                 }
-            } finally {
-                mDismissViewController.destroyDismissTarget();
             }
 
             if (touchState.isDragging()) {