Loading packages/SystemUI/shared/src/com/android/systemui/shared/recents/utilities/PreviewPositionHelper.java +33 −0 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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; Loading Loading @@ -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) { Loading Loading @@ -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 Loading Loading
packages/SystemUI/shared/src/com/android/systemui/shared/recents/utilities/PreviewPositionHelper.java +33 −0 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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; Loading Loading @@ -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) { Loading Loading @@ -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 Loading