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

Commit a380af6d authored by Vinit Nayak's avatar Vinit Nayak
Browse files

Update crop for offscreen flex split apps

* Update thumbnail hint to only crop 10% of
app that is visible to the user

Test: Swipe up gesture keeps visible crop
Flag: com.android.wm.shell.enable_flexible_two_app_split
Bug: 395547133
Change-Id: I555ebb109771048dee9ed12a6c34d04d9bda3ffa
parent 1cce78ff
Loading
Loading
Loading
Loading
+33 −0
Original line number Diff line number Diff line
@@ -5,11 +5,17 @@ import static android.view.Surface.ROTATION_180;
import static android.view.Surface.ROTATION_270;
import static android.view.Surface.ROTATION_90;

import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_2_10_90;
import static com.android.wm.shell.shared.split.SplitScreenConstants.SPLIT_POSITION_UNDEFINED;

import android.graphics.Matrix;
import android.graphics.Rect;
import android.graphics.RectF;

import androidx.annotation.Nullable;

import com.android.systemui.shared.recents.model.ThumbnailData;
import com.android.wm.shell.shared.split.SplitBounds;

/**
 * Utility class to position the thumbnail in the TaskView
@@ -34,6 +40,18 @@ public class PreviewPositionHelper {

    private final Matrix mMatrix = new Matrix();
    private boolean mIsOrientationChanged;
    /**
     * Only used when this helper is being used for an app in split screen. Refers to the position
     * of the app in the pair.
     * See {@link com.android.wm.shell.shared.split.SplitScreenConstants#@SplitPosition}
     */
    private int mStagePosition = SPLIT_POSITION_UNDEFINED;
    /**
     * Guarded by enableFlexibleTwoAppSplit() flag, but this class doesn't have access so the
     * caller is responsible for checking. If the flag is disabled this will be null
     */
    @Nullable
    private SplitBounds mSplitBounds;

    public Matrix getMatrix() {
        return mMatrix;
@@ -160,6 +178,16 @@ public class PreviewPositionHelper {
            }

            thumbnailScale = targetW / (croppedWidth * scale);

            if (mSplitBounds != null
                    && mSplitBounds.snapPosition == SNAP_TO_2_10_90
                    && mStagePosition == STAGE_POSITION_TOP_OR_LEFT) {
                if (mSplitBounds.appsStackedVertically) {
                    thumbnailClipHint.top += availableHeight - croppedHeight;
                } else {
                    thumbnailClipHint.left += availableWidth - croppedWidth;
                }
            }
        }

        if (!isRotated) {
@@ -209,6 +237,11 @@ public class PreviewPositionHelper {
        mMatrix.postTranslate(translateX, translateY);
    }

    public void setSplitBounds(SplitBounds splitBounds, int stagePosition) {
        mSplitBounds = splitBounds;
        mStagePosition = stagePosition;
    }

    /**
     * A factory that returns a new instance of the {@link PreviewPositionHelper}.
     * <p>{@link PreviewPositionHelper} is a stateful helper, and hence when using it in distinct