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

Commit 2388f0c8 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Disable PIP minimize and put it behind a tuner item"

parents 117e0c9b 2e138788
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -1878,6 +1878,15 @@
    <!-- PiP BTW notification description. [CHAR LIMIT=NONE] -->
    <string name="pip_notification_message">If you don’t want <xliff:g id="name" example="Google Maps">%s</xliff:g> to use this feature, tap to open settings and turn it off.</string>

    <!-- PiP section of the tuner. [CHAR LIMIT=NONE] -->
    <string name="picture_in_picture" translatable="false">Picture-in-Picture</string>

    <!-- PiP minimize title. [CHAR LIMIT=NONE]-->
    <string name="pip_minimize_title" translatable="false">Minimize</string>

    <!-- PiP minimize description. [CHAR LIMIT=NONE] -->
    <string name="pip_minimize_description" translatable="false">Drag or fling the PIP to the edges of the screen to minimize it.</string>

    <!-- Tuner string -->
    <string name="change_theme_reboot" translatable="false">Changing the theme requires a restart.</string>
    <!-- Tuner string -->
+12 −0
Original line number Diff line number Diff line
@@ -121,6 +121,18 @@

    </PreferenceScreen>

    <PreferenceScreen
      android:key="picture_in_picture"
      android:title="@string/picture_in_picture">

      <com.android.systemui.tuner.TunerSwitch
        android:key="pip_minimize"
        android:title="@string/pip_minimize_title"
        android:summary="@string/pip_minimize_description"
        sysui:defValue="false" />

    </PreferenceScreen>

    <PreferenceScreen
      android:key="doze"
      android:title="@string/tuner_doze">
+35 −3
Original line number Diff line number Diff line
@@ -37,8 +37,10 @@ import android.view.accessibility.AccessibilityNodeInfo;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.policy.PipSnapAlgorithm;
import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.statusbar.FlingAnimationUtils;
import com.android.systemui.tuner.TunerService;

import java.io.PrintWriter;

@@ -46,9 +48,11 @@ import java.io.PrintWriter;
 * Manages all the touch handling for PIP on the Phone, including moving, dismissing and expanding
 * the PIP.
 */
public class PipTouchHandler {
public class PipTouchHandler implements TunerService.Tunable {
    private static final String TAG = "PipTouchHandler";

    private static final String TUNER_KEY_MINIMIZE = "pip_minimize";

    // These values are used for metrics and should never change
    private static final int METRIC_VALUE_DISMISSED_BY_TAP = 0;
    private static final int METRIC_VALUE_DISMISSED_BY_DRAG = 1;
@@ -97,6 +101,9 @@ public class PipTouchHandler {
                }
            };

    // Allow the PIP to be dragged to the edge of the screen to be minimized.
    private boolean mEnableMinimize = false;

    // Behaviour states
    private boolean mIsMenuVisible;
    private boolean mIsMinimized;
@@ -169,6 +176,9 @@ public class PipTouchHandler {
        mExpandedShortestEdgeSize = context.getResources().getDimensionPixelSize(
                R.dimen.pip_expanded_shortest_edge_size);

        // Register any tuner settings changes
        Dependency.get(TunerService.class).addTunable(this, TUNER_KEY_MINIMIZE);

        // Register the listener for input consumer touch events
        inputConsumerController.setTouchListener(this::handleTouchEvent);
        inputConsumerController.setRegistrationListener(this::onRegistrationChanged);
@@ -189,6 +199,20 @@ public class PipTouchHandler {
        }
    }

    @Override
    public void onTuningChanged(String key, String newValue) {
        if (newValue == null) {
            // Reset back to default
            mEnableMinimize = false;
            return;
        }
        switch (key) {
            case TUNER_KEY_MINIMIZE:
                mEnableMinimize = Integer.parseInt(newValue) != 0;
                break;
        }
    }

    public void onConfigurationChanged() {
        mMotionHelper.onConfigurationChanged();
        mMotionHelper.synchronizePinnedStackBounds();
@@ -368,6 +392,9 @@ public class PipTouchHandler {
     * Sets the minimized state.
     */
    void setMinimizedStateInternal(boolean isMinimized) {
        if (!mEnableMinimize) {
            return;
        }
        setMinimizedState(isMinimized, false /* fromController */);
    }

@@ -375,6 +402,9 @@ public class PipTouchHandler {
     * Sets the minimized state.
     */
    void setMinimizedState(boolean isMinimized, boolean fromController) {
        if (!mEnableMinimize) {
            return;
        }
        if (mIsMinimized != isMinimized) {
            MetricsLogger.action(mContext, MetricsEvent.ACTION_PICTURE_IN_PICTURE_MINIMIZED,
                    isMinimized);
@@ -483,7 +513,7 @@ public class PipTouchHandler {
                final PointF lastDelta = touchState.getLastTouchDelta();
                float left = mTmpBounds.left + lastDelta.x;
                float top = mTmpBounds.top + lastDelta.y;
                if (!touchState.allowDraggingOffscreen()) {
                if (!touchState.allowDraggingOffscreen() || !mEnableMinimize) {
                    left = Math.max(mMovementBounds.left, Math.min(mMovementBounds.right, left));
                }
                if (ENABLE_DISMISS_DRAG_TO_EDGE) {
@@ -563,7 +593,8 @@ public class PipTouchHandler {
                            MetricsEvent.ACTION_PICTURE_IN_PICTURE_DISMISSED,
                            METRIC_VALUE_DISMISSED_BY_DRAG);
                    return true;
                } else if (!mIsMinimized && (mMotionHelper.shouldMinimizePip() || isFlingToEdge)) {
                } else if (mEnableMinimize &&
                        !mIsMinimized && (mMotionHelper.shouldMinimizePip() || isFlingToEdge)) {
                    // Pip should be minimized
                    setMinimizedStateInternal(true);
                    if (mMenuController.isMenuVisible()) {
@@ -631,6 +662,7 @@ public class PipTouchHandler {
        pw.println(innerPrefix + "mImeHeight=" + mImeHeight);
        pw.println(innerPrefix + "mSavedSnapFraction=" + mSavedSnapFraction);
        pw.println(innerPrefix + "mEnableDragToDismiss=" + ENABLE_DISMISS_DRAG_TO_TARGET);
        pw.println(innerPrefix + "mEnableMinimize=" + mEnableMinimize);
        mSnapAlgorithm.dump(pw, innerPrefix);
        mTouchState.dump(pw, innerPrefix);
        mMotionHelper.dump(pw, innerPrefix);