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

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

Adding experiment for minimized pinned stack.

- Also refactoring the PIP touch handling to be independent gestures

Test: Enable the setting in SystemUI tuner, then drag the PIP slightly
      offscreen. This is only experimental behaviour, and
      android.server.cts.ActivityManagerPinnedStackTests will be updated
      accordingly if we keep this behavior.

Change-Id: I5834971fcbbb127526339e764e7d76b5d22d4707
parent 7075d79c
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -31,6 +31,11 @@ interface IPinnedStackController {
     */
    oneway void setInInteractiveMode(boolean inInteractiveMode);

    /**
     * Notifies the controller that the PIP is currently minimized.
     */
    oneway void setIsMinimized(boolean isMinimized);

    /**
     * Notifies the controller that the desired snap mode is to the closest edge.
     */
+8 −4
Original line number Diff line number Diff line
@@ -208,15 +208,19 @@ public class PipSnapAlgorithm {
        final int fromTop = Math.abs(stackBounds.top - movementBounds.top);
        final int fromRight = Math.abs(movementBounds.right - stackBounds.left);
        final int fromBottom = Math.abs(movementBounds.bottom - stackBounds.top);
        final int boundedLeft = Math.max(movementBounds.left, Math.min(movementBounds.right,
                stackBounds.left));
        final int boundedTop = Math.max(movementBounds.top, Math.min(movementBounds.bottom,
                stackBounds.top));
        boundsOut.set(stackBounds);
        if (fromLeft <= fromTop && fromLeft <= fromRight && fromLeft <= fromBottom) {
            boundsOut.offsetTo(movementBounds.left, stackBounds.top);
            boundsOut.offsetTo(movementBounds.left, boundedTop);
        } else if (fromTop <= fromLeft && fromTop <= fromRight && fromTop <= fromBottom) {
            boundsOut.offsetTo(stackBounds.left, movementBounds.top);
            boundsOut.offsetTo(boundedLeft, movementBounds.top);
        } else if (fromRight < fromLeft && fromRight < fromTop && fromRight < fromBottom) {
            boundsOut.offsetTo(movementBounds.right, stackBounds.top);
            boundsOut.offsetTo(movementBounds.right, boundedTop);
        } else {
            boundsOut.offsetTo(stackBounds.left, movementBounds.bottom);
            boundsOut.offsetTo(boundedLeft, movementBounds.bottom);
        }
    }

+12 −4
Original line number Diff line number Diff line
@@ -1698,20 +1698,28 @@
        not appear on production builds ever. -->
    <string name="pip_drag_to_dismiss_summary" translatable="false">Drag to the dismiss target at the bottom of the screen to close the PIP</string>

    <!-- PIP tap once to break through to the activity. Non-translatable since it should
    <!-- PIP tap once to break through to the activity title. Non-translatable since it should
        not appear on production builds ever. -->
    <string name="pip_tap_through_title" translatable="false">Tap to interact</string>

    <!-- PIP tap once to break through to the activity. Non-translatable since it should
    <!-- PIP tap once to break through to the activity description. Non-translatable since it should
        not appear on production builds ever. -->
    <string name="pip_tap_through_summary" translatable="false">Tap once to interact with the activity</string>

    <!-- PIP snap to closest edge. Non-translatable since it should
    <!-- PIP snap to closest edge title. Non-translatable since it should
        not appear on production builds ever. -->
    <string name="pip_snap_mode_edge_title" translatable="false">Snap to closest edge</string>

    <!-- PIP snap to closest edge. Non-translatable since it should
    <!-- PIP snap to closest edge description. Non-translatable since it should
        not appear on production builds ever. -->
    <string name="pip_snap_mode_edge_summary" translatable="false">Snap to the closest edge</string>

    <!-- PIP allow minimize title. Non-translatable since it should
        not appear on production builds ever. -->
    <string name="pip_allow_minimize_title" translatable="false">Allow PIP to minimize</string>

    <!-- PIP allow minimize description. Non-translatable since it should
        not appear on production builds ever. -->
    <string name="pip_allow_minimize_summary" translatable="false">Allow PIP to minimize slightly offscreen</string>

</resources>
+6 −0
Original line number Diff line number Diff line
@@ -149,6 +149,12 @@
            android:summary="@string/pip_snap_mode_edge_summary"
            sysui:defValue="false" />

        <com.android.systemui.tuner.TunerSwitch
            android:key="pip_allow_minimize"
            android:title="@string/pip_allow_minimize_title"
            android:summary="@string/pip_allow_minimize_summary"
            sysui:defValue="false" />

    </PreferenceScreen>

    <PreferenceScreen
+42 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.pip.phone;

/**
 * A generic interface for a touch gesture.
 */
public abstract class PipTouchGesture {

    /**
     * Handle the touch down.
     */
    void onDown(PipTouchState touchState) {}

    /**
     * Handle the touch move, and return whether the event was consumed.
     */
    boolean onMove(PipTouchState touchState) {
        return false;
    }

    /**
     * Handle the touch up, and return whether the gesture was consumed.
     */
    boolean onUp(PipTouchState touchState) {
        return false;
    }
}
Loading