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

Commit 7aa49372 authored by Mateusz Cicheński's avatar Mateusz Cicheński
Browse files

Add system property to enable/disable fling to dismiss for PiP and Bubbles.

This will prevent the users from accidentally dismissing the pip when flinging
quickly towards the dismiss target. The dismiss action will now require an
intentional drag over the dismiss target.

Default value for both properties maintains the original dismiss behavior.

Bug: 214264312
Test: manually, set the property to false, open pip, move it up, fast fling
towards dismiss target -> pip remains on screen, similar for bubbles

Change-Id: I95cbbcbd3f15e5ab5ab708ecfa91f86c26fa3024
parent d6f9be64
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -111,6 +111,9 @@ public class BubbleStackView extends FrameLayout
    public static final boolean HOME_GESTURE_ENABLED =
            SystemProperties.getBoolean("persist.wm.debug.bubbles_home_gesture", true);

    public static final boolean ENABLE_FLING_TO_DISMISS_BUBBLE =
            SystemProperties.getBoolean("persist.wm.debug.fling_to_dismiss_bubble", true);

    private static final String TAG = TAG_WITH_CLASS_NAME ? "BubbleStackView" : TAG_BUBBLES;

    /** How far the flyout needs to be dragged before it's dismissed regardless of velocity. */
+2 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.wm.shell.bubbles.animation;
import static android.view.View.LAYOUT_DIRECTION_RTL;

import static com.android.wm.shell.bubbles.BubblePositioner.NUM_VISIBLE_WHEN_RESTING;
import static com.android.wm.shell.bubbles.BubbleStackView.ENABLE_FLING_TO_DISMISS_BUBBLE;
import static com.android.wm.shell.bubbles.BubbleStackView.HOME_GESTURE_ENABLED;

import android.content.res.Resources;
@@ -366,6 +367,7 @@ public class ExpandedAnimationController
        mMagnetizedBubbleDraggingOut.setMagnetListener(listener);
        mMagnetizedBubbleDraggingOut.setHapticsEnabled(true);
        mMagnetizedBubbleDraggingOut.setFlingToTargetMinVelocity(FLING_TO_DISMISS_MIN_VELOCITY);
        mMagnetizedBubbleDraggingOut.setFlingToTargetEnabled(ENABLE_FLING_TO_DISMISS_BUBBLE);
    }

    private void springBubbleTo(View bubble, float x, float y) {
+2 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.wm.shell.bubbles.animation;

import static com.android.wm.shell.bubbles.BubblePositioner.NUM_VISIBLE_WHEN_RESTING;
import static com.android.wm.shell.bubbles.BubbleStackView.ENABLE_FLING_TO_DISMISS_BUBBLE;

import android.content.ContentResolver;
import android.content.res.Resources;
@@ -1028,6 +1029,7 @@ public class StackAnimationController extends
            };
            mMagnetizedStack.setHapticsEnabled(true);
            mMagnetizedStack.setFlingToTargetMinVelocity(FLING_TO_DISMISS_MIN_VELOCITY);
            mMagnetizedStack.setFlingToTargetEnabled(ENABLE_FLING_TO_DISMISS_BUBBLE);
        }

        final ContentResolver contentResolver = mLayout.getContext().getContentResolver();
+4 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import android.content.Context;
import android.graphics.PointF;
import android.graphics.Rect;
import android.os.Debug;
import android.os.SystemProperties;

import com.android.internal.protolog.common.ProtoLog;
import com.android.wm.shell.R;
@@ -58,6 +59,8 @@ import kotlin.jvm.functions.Function0;
public class PipMotionHelper implements PipAppOpsListener.Callback,
        FloatingContentCoordinator.FloatingContent {

    public static final boolean ENABLE_FLING_TO_DISMISS_PIP =
            SystemProperties.getBoolean("persist.wm.debug.fling_to_dismiss_pip", true);
    private static final String TAG = "PipMotionHelper";
    private static final boolean DEBUG = false;

@@ -704,6 +707,7 @@ public class PipMotionHelper implements PipAppOpsListener.Callback,
                    loc[1] = animatedPipBounds.top;
                }
            };
            mMagnetizedPip.setFlingToTargetEnabled(ENABLE_FLING_TO_DISMISS_PIP);
        }

        return mMagnetizedPip;