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

Commit 17af0292 authored by Ben Lin's avatar Ben Lin Committed by Android (Google) Code Review
Browse files

Merge "PiP: Add stash a11y support." into sc-dev

parents 395e8c99 58b79104
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@
-->
<resources>
    <item type="id" name="action_pip_resize" />
    <item type="id" name="action_pip_stash" />
    <item type="id" name="action_pip_unstash" />

    <!-- Accessibility actions for the docked stack divider -->
    <item type="id" name="action_move_tl_full" />
+6 −0
Original line number Diff line number Diff line
@@ -48,6 +48,12 @@
    <!-- Accessibility action for resizing PIP [CHAR LIMIT=NONE] -->
    <string name="accessibility_action_pip_resize">Resize</string>

    <!-- Accessibility action for stashing PIP [CHAR LIMIT=NONE] -->
    <string name="accessibility_action_pip_stash">Stash</string>

    <!-- Accessibility action for unstashing PIP [CHAR LIMIT=NONE] -->
    <string name="accessibility_action_pip_unstash">Unstash</string>

    <!-- TODO Deprecated. Label for PIP action to Minimize the PIP. DO NOT TRANSLATE [CHAR LIMIT=25] -->
    <string name="pip_phone_minimize">Minimize</string>

+1 −1
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ public final class PipBoundsState {
            STASH_TYPE_RIGHT
    })
    @Retention(RetentionPolicy.SOURCE)
    @interface StashType {}
    public @interface StashType {}

    private static final String TAG = PipBoundsState.class.getSimpleName();

+16 −1
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@
 */
package com.android.wm.shell.pip.phone;

import static com.android.wm.shell.pip.PipBoundsState.STASH_TYPE_NONE;

import android.annotation.NonNull;
import android.content.Context;
import android.graphics.Rect;
@@ -59,6 +61,7 @@ public class PipAccessibilityInteractionConnection {
    private final PipTaskOrganizer mTaskOrganizer;
    private final PipSnapAlgorithm mSnapAlgorithm;
    private final Runnable mUpdateMovementBoundCallback;
    private final Runnable mUnstashCallback;
    private final AccessibilityCallbacks mCallbacks;
    private final IAccessibilityInteractionConnection mConnectionImpl;

@@ -72,7 +75,7 @@ public class PipAccessibilityInteractionConnection {
            @NonNull PipBoundsState pipBoundsState, PipMotionHelper motionHelper,
            PipTaskOrganizer taskOrganizer, PipSnapAlgorithm snapAlgorithm,
            AccessibilityCallbacks callbacks, Runnable updateMovementBoundCallback,
            ShellExecutor mainExcutor) {
            Runnable unstashCallback, ShellExecutor mainExcutor) {
        mContext = context;
        mMainExcutor = mainExcutor;
        mPipBoundsState = pipBoundsState;
@@ -80,6 +83,7 @@ public class PipAccessibilityInteractionConnection {
        mTaskOrganizer = taskOrganizer;
        mSnapAlgorithm = snapAlgorithm;
        mUpdateMovementBoundCallback = updateMovementBoundCallback;
        mUnstashCallback = unstashCallback;
        mCallbacks = callbacks;
        mConnectionImpl = new PipAccessibilityInteractionConnectionImpl();
    }
@@ -118,6 +122,13 @@ public class PipAccessibilityInteractionConnection {
                    setToNormalBounds();
                }
                result = true;
            } else if (action == R.id.action_pip_stash) {
                mMotionHelper.animateToStashedClosestEdge();
                result = true;
            } else if (action == R.id.action_pip_unstash) {
                mUnstashCallback.run();
                mPipBoundsState.setStashed(STASH_TYPE_NONE);
                result = true;
            } else {
                switch (action) {
                    case AccessibilityNodeInfo.ACTION_CLICK:
@@ -246,6 +257,10 @@ public class PipAccessibilityInteractionConnection {
        info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_EXPAND);
        info.addAction(new AccessibilityNodeInfo.AccessibilityAction(R.id.action_pip_resize,
                context.getString(R.string.accessibility_action_pip_resize)));
        info.addAction(new AccessibilityNodeInfo.AccessibilityAction(R.id.action_pip_stash,
                context.getString(R.string.accessibility_action_pip_stash)));
        info.addAction(new AccessibilityNodeInfo.AccessibilityAction(R.id.action_pip_unstash,
                context.getString(R.string.accessibility_action_pip_unstash)));
        info.setImportantForAccessibility(true);
        info.setClickable(true);
        info.setVisibleToUser(true);
+24 −0
Original line number Diff line number Diff line
@@ -21,7 +21,9 @@ import static androidx.dynamicanimation.animation.SpringForce.STIFFNESS_LOW;
import static androidx.dynamicanimation.animation.SpringForce.STIFFNESS_MEDIUM;

import static com.android.wm.shell.pip.PipAnimationController.TRANSITION_DIRECTION_EXPAND_OR_UNEXPAND;
import static com.android.wm.shell.pip.PipBoundsState.STASH_TYPE_LEFT;
import static com.android.wm.shell.pip.PipBoundsState.STASH_TYPE_NONE;
import static com.android.wm.shell.pip.PipBoundsState.STASH_TYPE_RIGHT;
import static com.android.wm.shell.pip.phone.PipMenuView.ANIM_TYPE_DISMISS;
import static com.android.wm.shell.pip.phone.PipMenuView.ANIM_TYPE_NONE;

@@ -498,6 +500,28 @@ public class PipMotionHelper implements PipAppOpsListener.Callback,
        }
    }

    /**
     * Animates the PiP to the stashed state, choosing the closest edge.
     */
    void animateToStashedClosestEdge() {
        Rect tmpBounds = new Rect();
        final Rect insetBounds = mPipBoundsState.getDisplayLayout().stableInsets();
        final int stashType =
                mPipBoundsState.getBounds().left == mPipBoundsState.getMovementBounds().left
                ? STASH_TYPE_LEFT : STASH_TYPE_RIGHT;
        final float leftEdge = stashType == STASH_TYPE_LEFT
                ? mPipBoundsState.getStashOffset()
                - mPipBoundsState.getBounds().width() + insetBounds.left
                : mPipBoundsState.getDisplayBounds().right
                        - mPipBoundsState.getStashOffset() - insetBounds.right;
        tmpBounds.set((int) leftEdge,
                mPipBoundsState.getBounds().top,
                (int) (leftEdge + mPipBoundsState.getBounds().width()),
                mPipBoundsState.getBounds().bottom);
        resizeAndAnimatePipUnchecked(tmpBounds, UNSTASH_DURATION);
        mPipBoundsState.setStashed(stashType);
    }

    /**
     * Animates the PiP from stashed state into un-stashed, popping it out from the edge.
     */
Loading