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

Commit 7a63fb2d authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Fixing swipe-up form app in landspace, rotates the surface

PreviewPositionHelper was getting the Launcher rotation from context,
instead of RecentsOrientationState

Bug: 156042694
Change-Id: I645eccfcb519c59fe2f78ecb1a77d8a315bc36c9
parent 0e0bcc76
Loading
Loading
Loading
Loading
+6 −9
Original line number Original line Diff line number Diff line
@@ -19,7 +19,6 @@ import static android.view.Surface.ROTATION_0;


import static com.android.launcher3.states.RotationHelper.deltaRotation;
import static com.android.launcher3.states.RotationHelper.deltaRotation;
import static com.android.launcher3.touch.PagedOrientationHandler.MATRIX_POST_TRANSLATE;
import static com.android.launcher3.touch.PagedOrientationHandler.MATRIX_POST_TRANSLATE;
import static com.android.quickstep.util.RecentsOrientedState.isFixedRotationTransformEnabled;
import static com.android.quickstep.util.RecentsOrientedState.postDisplayRotation;
import static com.android.quickstep.util.RecentsOrientedState.postDisplayRotation;
import static com.android.systemui.shared.system.WindowManagerWrapper.WINDOWING_MODE_FULLSCREEN;
import static com.android.systemui.shared.system.WindowManagerWrapper.WINDOWING_MODE_FULLSCREEN;


@@ -67,7 +66,7 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy {
    // Thumbnail view properties
    // Thumbnail view properties
    private final Rect mThumbnailPosition = new Rect();
    private final Rect mThumbnailPosition = new Rect();
    private final ThumbnailData mThumbnailData = new ThumbnailData();
    private final ThumbnailData mThumbnailData = new ThumbnailData();
    private final PreviewPositionHelper mPositionHelper;
    private final PreviewPositionHelper mPositionHelper = new PreviewPositionHelper();
    private final Matrix mInversePositionMatrix = new Matrix();
    private final Matrix mInversePositionMatrix = new Matrix();


    // TaskView properties
    // TaskView properties
@@ -87,7 +86,6 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy {
    public TaskViewSimulator(Context context, WindowSizeStrategy sizeStrategy) {
    public TaskViewSimulator(Context context, WindowSizeStrategy sizeStrategy) {
        mContext = context;
        mContext = context;
        mSizeStrategy = sizeStrategy;
        mSizeStrategy = sizeStrategy;
        mPositionHelper = new PreviewPositionHelper(context);


        mOrientationState = new RecentsOrientedState(context, sizeStrategy, i -> { });
        mOrientationState = new RecentsOrientedState(context, sizeStrategy, i -> { });
        // We do not need to attach listeners as the simulator is created just for the gesture
        // We do not need to attach listeners as the simulator is created just for the gesture
@@ -173,12 +171,12 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy {
            mLayoutValid = true;
            mLayoutValid = true;


            getFullScreenScale();
            getFullScreenScale();
            mThumbnailData.rotation = isFixedRotationTransformEnabled(mContext)
            mThumbnailData.rotation = mOrientationState.getDisplayRotation();
                    ? mOrientationState.getDisplayRotation() : mPositionHelper.getCurrentRotation();

            mPositionHelper.updateThumbnailMatrix(mThumbnailPosition, mThumbnailData,
                    mTaskRect.width(), mTaskRect.height(), mDp);


            mPositionHelper.updateThumbnailMatrix(
                    mThumbnailPosition, mThumbnailData,
                    mTaskRect.width(), mTaskRect.height(),
                    mDp, mOrientationState.getLauncherRotation());
            mPositionHelper.getMatrix().invert(mInversePositionMatrix);
            mPositionHelper.getMatrix().invert(mInversePositionMatrix);


            PagedOrientationHandler poh = mOrientationState.getOrientationHandler();
            PagedOrientationHandler poh = mOrientationState.getOrientationHandler();
@@ -188,7 +186,6 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy {
            mScrollValid = false;
            mScrollValid = false;
        }
        }



        if (!mScrollValid) {
        if (!mScrollValid) {
            mScrollValid = true;
            mScrollValid = true;
            int start = mOrientationState.getOrientationHandler()
            int start = mOrientationState.getOrientationHandler()
+6 −16
Original line number Original line Diff line number Diff line
@@ -90,7 +90,7 @@ public class TaskThumbnailView extends View implements PluginListener<OverviewSc


    // Contains the portion of the thumbnail that is clipped when fullscreen progress = 0.
    // Contains the portion of the thumbnail that is clipped when fullscreen progress = 0.
    private final Rect mPreviewRect = new Rect();
    private final Rect mPreviewRect = new Rect();
    private final PreviewPositionHelper mPreviewPositionHelper;
    private final PreviewPositionHelper mPreviewPositionHelper = new PreviewPositionHelper();
    // Initialize with dummy value. It is overridden later by TaskView
    // Initialize with dummy value. It is overridden later by TaskView
    private TaskView.FullscreenDrawParams mFullscreenParams = TEMP_PARAMS;
    private TaskView.FullscreenDrawParams mFullscreenParams = TEMP_PARAMS;


@@ -122,7 +122,6 @@ public class TaskThumbnailView extends View implements PluginListener<OverviewSc
        mDimmingPaintAfterClearing.setColor(Color.BLACK);
        mDimmingPaintAfterClearing.setColor(Color.BLACK);
        mActivity = BaseActivity.fromContext(context);
        mActivity = BaseActivity.fromContext(context);
        mIsDarkTextTheme = Themes.getAttrBoolean(mActivity, R.attr.isWorkspaceDarkText);
        mIsDarkTextTheme = Themes.getAttrBoolean(mActivity, R.attr.isWorkspaceDarkText);
        mPreviewPositionHelper = new PreviewPositionHelper(context);
    }
    }


    /**
    /**
@@ -349,8 +348,11 @@ public class TaskThumbnailView extends View implements PluginListener<OverviewSc
        if (mBitmapShader != null && mThumbnailData != null) {
        if (mBitmapShader != null && mThumbnailData != null) {
            mPreviewRect.set(0, 0, mThumbnailData.thumbnail.getWidth(),
            mPreviewRect.set(0, 0, mThumbnailData.thumbnail.getWidth(),
                    mThumbnailData.thumbnail.getHeight());
                    mThumbnailData.thumbnail.getHeight());
            int currentRotation = ConfigurationCompat.getWindowConfigurationRotation(
                    mActivity.getResources().getConfiguration());
            mPreviewPositionHelper.updateThumbnailMatrix(mPreviewRect, mThumbnailData,
            mPreviewPositionHelper.updateThumbnailMatrix(mPreviewRect, mThumbnailData,
                    getMeasuredWidth(), getMeasuredHeight(), mActivity.getDeviceProfile());
                    getMeasuredWidth(), getMeasuredHeight(), mActivity.getDeviceProfile(),
                    currentRotation);


            mBitmapShader.setLocalMatrix(mPreviewPositionHelper.mMatrix);
            mBitmapShader.setLocalMatrix(mPreviewPositionHelper.mMatrix);
            mPaint.setShader(mBitmapShader);
            mPaint.setShader(mBitmapShader);
@@ -417,17 +419,6 @@ public class TaskThumbnailView extends View implements PluginListener<OverviewSc
        private float mClipBottom = -1;
        private float mClipBottom = -1;
        private boolean mIsOrientationChanged;
        private boolean mIsOrientationChanged;


        private final Context mContext;

        public PreviewPositionHelper(Context context) {
            mContext = context;
        }

        public int getCurrentRotation() {
            return ConfigurationCompat.getWindowConfigurationRotation(
                    mContext.getResources().getConfiguration());
        }

        public Matrix getMatrix() {
        public Matrix getMatrix() {
            return mMatrix;
            return mMatrix;
        }
        }
@@ -436,7 +427,7 @@ public class TaskThumbnailView extends View implements PluginListener<OverviewSc
         * Updates the matrix based on the provided parameters
         * Updates the matrix based on the provided parameters
         */
         */
        public void updateThumbnailMatrix(Rect thumbnailPosition, ThumbnailData thumbnailData,
        public void updateThumbnailMatrix(Rect thumbnailPosition, ThumbnailData thumbnailData,
                int canvasWidth, int canvasHeight, DeviceProfile dp) {
                int canvasWidth, int canvasHeight, DeviceProfile dp, int currentRotation) {
            boolean isRotated = false;
            boolean isRotated = false;
            boolean isOrientationDifferent;
            boolean isOrientationDifferent;
            mClipBottom = -1;
            mClipBottom = -1;
@@ -451,7 +442,6 @@ public class TaskThumbnailView extends View implements PluginListener<OverviewSc


            final float thumbnailScale;
            final float thumbnailScale;
            int thumbnailRotation = thumbnailData.rotation;
            int thumbnailRotation = thumbnailData.rotation;
            int currentRotation = getCurrentRotation();
            int deltaRotate = getRotationDelta(currentRotation, thumbnailRotation);
            int deltaRotate = getRotationDelta(currentRotation, thumbnailRotation);


            Rect deviceInsets = dp.getInsets();
            Rect deviceInsets = dp.getInsets();