Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 34488242 authored by Winson Chung's avatar Winson Chung
Browse files

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
parent 2d5c0d89
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -103,6 +103,7 @@ public class PipManager implements BasePipManager {
            // Re-enable touches after the animation completes
            mTouchHandler.setTouchEnabled(true);
            mTouchHandler.onPinnedStackAnimationEnded();
            mMenuController.onPinnedStackAnimationEnded();
        }

        @Override
+13 −0
Original line number Diff line number Diff line
@@ -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<RemoteAction> 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) {
+13 −0
Original line number Diff line number Diff line
@@ -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.
     */