From 34488242f889d4d5889a38f796633b0d1c8b5541 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Wed, 26 Apr 2017 15:53:51 -0700 Subject: Fix issue with double tapping PiP - This is only an issue when double tapping while the menu is visible in the initial close state. The problem was that in a double tap, the first tap could trigger a move as the activity is actively resized, which triggers the input consumer to be re-registered. Then the subsequent tap will trigger an unexpected expand on touch up, which then can conflict when the menu gets resized down to the unexpanded state. For now, when expanding to/from the expanded state, disallow touches until after the animation ends, like we do in the input consumer touch handler. Bug: 37657050 Test: Double tap the PIP when it is unexpanded, ensure that it expands Change-Id: Ib68bcb80a54a801181f02ff73e7188678a26dd9b --- .../src/com/android/systemui/pip/phone/PipManager.java | 1 + .../src/com/android/systemui/pip/phone/PipMenuActivity.java | 13 +++++++++++++ .../systemui/pip/phone/PipMenuActivityController.java | 13 +++++++++++++ 3 files changed, 27 insertions(+) diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java index 28bd23ce9825..df03fdc46d06 100644 --- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java +++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java @@ -103,6 +103,7 @@ public class PipManager implements BasePipManager { // Re-enable touches after the animation completes mTouchHandler.setTouchEnabled(true); mTouchHandler.onPinnedStackAnimationEnded(); + mMenuController.onPinnedStackAnimationEnded(); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivity.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivity.java index 79ac8160c095..80305a5adc02 100644 --- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivity.java +++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivity.java @@ -80,6 +80,7 @@ public class PipMenuActivity extends Activity { public static final int MESSAGE_HIDE_MENU = 3; public static final int MESSAGE_UPDATE_ACTIONS = 4; public static final int MESSAGE_UPDATE_DISMISS_FRACTION = 5; + public static final int MESSAGE_ANIMATION_ENDED = 6; private static final long INITIAL_DISMISS_DELAY = 3500; private static final long POST_INTERACTION_DISMISS_DELAY = 2000; @@ -92,6 +93,7 @@ public class PipMenuActivity extends Activity { private int mMenuState; private boolean mAllowMenuTimeout = true; + private boolean mAllowTouches = true; private final List mActions = new ArrayList<>(); @@ -149,6 +151,10 @@ public class PipMenuActivity extends Activity { updateDismissFraction(data.getFloat(EXTRA_DISMISS_FRACTION)); break; } + case MESSAGE_ANIMATION_ENDED: { + mAllowTouches = true; + break; + } } } }); @@ -245,6 +251,10 @@ public class PipMenuActivity extends Activity { @Override public boolean dispatchTouchEvent(MotionEvent ev) { + if (!mAllowTouches) { + return super.dispatchTouchEvent(ev); + } + // On the first action outside the window, hide the menu switch (ev.getAction()) { case MotionEvent.ACTION_OUTSIDE: @@ -284,6 +294,9 @@ public class PipMenuActivity extends Activity { boolean allowMenuTimeout) { mAllowMenuTimeout = allowMenuTimeout; if (mMenuState != menuState) { + boolean deferTouchesUntilAnimationEnds = (mMenuState == MENU_STATE_FULL) || + (menuState == MENU_STATE_FULL); + mAllowTouches = !deferTouchesUntilAnimationEnds; cancelDelayedFinish(); updateActionViews(stackBounds); if (mMenuContainerAnimator != null) { diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivityController.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivityController.java index c41f898ef4fe..d5cf1dd0387d 100644 --- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivityController.java +++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivityController.java @@ -197,6 +197,19 @@ public class PipMenuActivityController { } } + public void onPinnedStackAnimationEnded() { + // Note: Only active menu activities care about this event + if (mToActivityMessenger != null) { + Message m = Message.obtain(); + m.what = PipMenuActivity.MESSAGE_ANIMATION_ENDED; + try { + mToActivityMessenger.send(m); + } catch (RemoteException e) { + Log.e(TAG, "Could not notify menu pinned animation ended", e); + } + } + } + /** * Adds a new menu activity listener. */ -- cgit v1.2.3-59-g8ed1b