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

Commit 4b64c4a7 authored by Aran Ink's avatar Aran Ink Committed by Android (Google) Code Review
Browse files

Merge "Fix touch slop issues on bubble long-press menu."

parents b3fa0c77 141a8158
Loading
Loading
Loading
Loading
+26 −29
Original line number Diff line number Diff line
@@ -1119,12 +1119,6 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
    }

    private void sendScreenshotToBubble(Bubble bubble) {
        // delay allows the bubble menu to disappear before the screenshot
        // done here because we already have a Handler to delay with.
        // TODO: Hide bubble + menu UI from screenshots entirely instead of just delaying.
        mHandler.postDelayed(new Runnable() {
            @Override
            public void run() {
        mScreenshotHelper.takeScreenshot(
                android.view.WindowManager.TAKE_SCREENSHOT_FULLSCREEN,
                true /* hasStatus */,
@@ -1137,6 +1131,7 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
                            NotificationEntry entry = bubble.getEntry();
                            Pair<RemoteInput, Notification.Action> pair = entry.getSbn()
                                    .getNotification().findRemoteInputActionPair(false);
                            if (pair != null) {
                                RemoteInput remoteInput = pair.first;
                                Notification.Action action = pair.second;
                                Intent dataIntent = prepareRemoteInputFromData("image/png", uri,
@@ -1144,11 +1139,13 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
                                sendRemoteInput(dataIntent, entry, action.actionIntent);
                                mBubbleData.setSelectedBubble(bubble);
                                mBubbleData.setExpanded(true);
                            } else {
                                Log.w(TAG, "No RemoteInput found for notification: "
                                        + entry.getSbn().getKey());
                            }
                        }
                        });
                    }
        }, 200);
                });
    }

    private final BubbleScreenshotListener mBubbleScreenshotListener =
+3 −0
Original line number Diff line number Diff line
@@ -31,6 +31,9 @@ public class BubbleMenuView extends FrameLayout {
    private FrameLayout mMenu;
    private boolean mShowing = false;

    /** Delay before taking a screenshot once the button is tapped to allow the menu time to hide.*/
    public static final long SCREENSHOT_DELAY = 200;

    public BubbleMenuView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
+18 −11
Original line number Diff line number Diff line
@@ -1731,17 +1731,18 @@ public class BubbleStackView extends FrameLayout {
     */
    public void showBubbleMenu() {
        PointF currentPos = mStackAnimationController.getStackPosition();
        mBubbleMenuView.setVisibility(View.INVISIBLE);
        post(() -> {
            float yPos = currentPos.y;
            float xPos = currentPos.x;
            if (mStackAnimationController.isStackOnLeftSide()) {
                xPos += mBubbleSize;
            } else {
            //TODO: Use the width of the menu instead of this fixed offset. Offset used for now
            // because menu width isn't correct the first time the menu is shown.
            xPos -= mBubbleMenuOffset;
                xPos -= mBubbleMenuView.getMenuView().getWidth();
            }

            mBubbleMenuView.show(xPos, yPos);
        });
    }

    /**
@@ -1762,6 +1763,12 @@ public class BubbleStackView extends FrameLayout {
     * Take a screenshot and send it to the specified bubble.
     */
    public void sendScreenshotToBubble(Bubble bubble) {
        hideBubbleMenu();
        // delay allows the bubble menu to disappear before the screenshot
        // done here because we already have a Handler to delay with.
        // TODO: Hide bubble + menu UI from screenshots entirely instead of just delaying.
        postDelayed(() -> {
            mBubbleScreenshotListener.onBubbleScreenshot(bubble);
        }, BubbleMenuView.SCREENSHOT_DELAY);
    }
}
+9 −7
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@ class BubbleTouchHandler implements View.OnTouchListener {
    private boolean mMovedEnough;
    private int mTouchSlopSquared;
    private VelocityTracker mVelocityTracker;
    private Runnable mShowBubbleMenuRunnable;

    /** View that was initially touched, when we received the first ACTION_DOWN event. */
    private View mTouchedView;
@@ -133,6 +134,11 @@ class BubbleTouchHandler implements View.OnTouchListener {
                if (isStack) {
                    mViewPositionOnTouchDown.set(mStack.getStackPosition());
                    mStack.onDragStart();
                    if (!mStack.isShowingBubbleMenu() && !mStack.isExpanded()) {
                        mShowBubbleMenuRunnable = mStack::showBubbleMenu;
                        mStack.postDelayed(mShowBubbleMenuRunnable,
                                ViewConfiguration.getLongPressTimeout());
                    }
                } else if (isFlyout) {
                    mStack.onFlyoutDragStart();
                } else {
@@ -156,6 +162,7 @@ class BubbleTouchHandler implements View.OnTouchListener {
                }

                if (mMovedEnough) {
                    mStack.removeCallbacks(mShowBubbleMenuRunnable);
                    if (isStack) {
                        mStack.onDragged(viewX, viewY);
                    } else if (isFlyout) {
@@ -163,13 +170,6 @@ class BubbleTouchHandler implements View.OnTouchListener {
                    } else {
                        mStack.onBubbleDragged(mTouchedView, viewX, viewY);
                    }
                } else {
                    float touchTime = event.getEventTime() - event.getDownTime();
                    if (touchTime > ViewConfiguration.getLongPressTimeout() && !mStack.isExpanded()
                            && BubbleExperimentConfig.allowBubbleScreenshotMenu(mContext)) {
                        mStack.showBubbleMenu();
                        return true;
                    }
                }

                final boolean currentlyInDismissTarget = mStack.isInDismissTarget(event);
@@ -196,6 +196,8 @@ class BubbleTouchHandler implements View.OnTouchListener {
                if (mStack.isShowingBubbleMenu()) {
                    resetForNextGesture();
                    return true;
                } else {
                    mStack.removeCallbacks(mShowBubbleMenuRunnable);
                }
                trackMovement(event);
                mVelocityTracker.computeCurrentVelocity(/* maxVelocity */ 1000);