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

Commit 8b78c138 authored by Vinit Nayak's avatar Vinit Nayak
Browse files

Implement swipe gesture for staged split in landscape

* Maintain task split percentages when swiping up.
* Split percentages not maintained in GroupedTaskView, however.
That is a TODO.

Bug: 181704764, 181705607
Test: Swiped up in landscape with home rotation on/off.
Portrait still works.

Change-Id: Iec62abae34f6ccadf98e2afdc9409cf3160f8223
parent c8295216
Loading
Loading
Loading
Loading
+0 −28
Original line number Diff line number Diff line
@@ -53,7 +53,6 @@ import com.android.launcher3.statehandlers.DepthController;
import com.android.launcher3.statemanager.BaseState;
import com.android.launcher3.statemanager.StatefulActivity;
import com.android.launcher3.touch.PagedOrientationHandler;
import com.android.launcher3.util.SplitConfigurationOptions;
import com.android.launcher3.util.WindowBounds;
import com.android.launcher3.views.ScrimView;
import com.android.quickstep.SysUINavigationMode.Mode;
@@ -202,33 +201,6 @@ public abstract class BaseActivityInterface<STATE_TYPE extends BaseState<STATE_T
        recentsView.switchToScreenshot(thumbnailData, runnable);
    }

    /**
     * Sets the task size in {@param outRect} taking split screened windows into account.
     * We assume combined height of both tasks will be same as one normal task, then we'll modify
     * the task height/width based on the ratio of task screen space bounds from
     * {@param splitInfo}
     *
     * @param desiredStageBounds whether task size for top/left or bottom/right needs to be computed
     */
    public final void calculateStagedSplitTaskSize(Context context, DeviceProfile dp, Rect outRect,
            SplitConfigurationOptions.StagedSplitBounds splitInfo,
            @SplitConfigurationOptions.StagePosition int desiredStageBounds) {
        calculateTaskSize(context, dp, outRect);

        // TODO(b/181705607) Change for landscape vs portrait
        float totalHeight = splitInfo.mLeftTopBounds.height()
                + splitInfo.mRightBottomBounds.height()
                + splitInfo.mDividerBounds.height() / 2f;
        float topTaskPercent = splitInfo.mLeftTopBounds.height() / totalHeight;
        if (desiredStageBounds == SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT) {
            float diff = outRect.height() * (1f - topTaskPercent);
            outRect.bottom -= diff;
        } else {
            float diff = outRect.height() * topTaskPercent;
            outRect.top += diff;
        }
    }

    /**
     * Calculates the taskView size for the provided device configuration.
     */
+6 −9
Original line number Diff line number Diff line
@@ -145,8 +145,9 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy {
            // The task rect changes according to the staged split task sizes, but recents
            // fullscreen scale and pivot remains the same since the task fits into the existing
            // sized task space bounds
            mSizeStrategy.calculateStagedSplitTaskSize(mContext, mDp, mTaskRect, mStagedSplitBounds,
                    mStagePosition);
            mSizeStrategy.calculateTaskSize(mContext, mDp, mTaskRect);
            mOrientationState.getOrientationHandler()
                    .setSplitTaskSwipeRect(mDp, mTaskRect, mStagedSplitBounds, mStagePosition);
        } else {
            mTaskRect.set(fullTaskSize);
        }
@@ -277,13 +278,9 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy {
            getFullScreenScale();
            mThumbnailData.rotation = mOrientationState.getDisplayRotation();

            // TODO(b/195145340) handle non 50-50 split scenarios
            if (mStagedSplitBounds != null) {
                if (mStagePosition == STAGE_POSITION_BOTTOM_OR_RIGHT) {
                    // The preview set is for the bottom/right, inset by top/left task
                    mSplitOffset.y = mStagedSplitBounds.mLeftTopBounds.height() +
                        mStagedSplitBounds.mDividerBounds.height() / 2;
                }
                mOrientationState.getOrientationHandler().setLeashSplitOffset(mSplitOffset, mDp,
                        mStagedSplitBounds, mStagePosition);
            }

            // mIsRecentsRtl is the inverse of TaskView RTL.
@@ -331,7 +328,7 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy {
        applyWindowToHomeRotation(mMatrix);

        // Move lower/right split window into correct position
        mMatrix.postTranslate(0, mSplitOffset.y);
        mMatrix.postTranslate(mSplitOffset.x, mSplitOffset.y);

        // Crop rect is the inverse of thumbnail matrix
        mTempRectF.set(-insets.left, -insets.top,
+24 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITIO
import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_TYPE_MAIN;

import android.content.res.Resources;
import android.graphics.Point;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
@@ -41,6 +42,7 @@ import android.widget.LinearLayout;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.util.SplitConfigurationOptions;
import com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption;
import com.android.launcher3.views.BaseDragLayer;

@@ -381,6 +383,28 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler {
        out2.set(0, screenHeight / 2  + splitDividerSize, screenWidth, screenHeight);
    }

    @Override
    public void setSplitTaskSwipeRect(DeviceProfile dp, Rect outRect,
            SplitConfigurationOptions.StagedSplitBounds splitInfo, int desiredStagePosition) {
        float diff;
        if (desiredStagePosition == SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT) {
            diff = outRect.height() * (1f - splitInfo.mLeftTaskPercent);
            outRect.bottom -= diff;
        } else {
            diff = outRect.height() * splitInfo.mLeftTaskPercent;
            outRect.top += diff;
        }
    }

    @Override
    public void setLeashSplitOffset(Point splitOffset, DeviceProfile dp,
            SplitConfigurationOptions.StagedSplitBounds splitInfo, int desiredStagePosition) {
        if (desiredStagePosition == STAGE_POSITION_BOTTOM_OR_RIGHT) {
            // The preview set is for the bottom/right, inset by top/left task
            splitOffset.x = splitInfo.mLeftTopBounds.width() + splitInfo.mDividerBounds.width() / 2;
        }
    }

    @Override
    public FloatProperty getSplitSelectTaskOffset(FloatProperty primary, FloatProperty secondary,
            DeviceProfile deviceProfile) {
+27 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.launcher3.touch;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Point;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
@@ -31,6 +32,7 @@ import android.view.accessibility.AccessibilityEvent;
import android.widget.LinearLayout;

import com.android.launcher3.DeviceProfile;
import com.android.launcher3.util.SplitConfigurationOptions;
import com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption;
import com.android.launcher3.util.SplitConfigurationOptions.StagePosition;

@@ -133,6 +135,31 @@ public interface PagedOrientationHandler {
    void getFinalSplitPlaceholderBounds(int splitDividerSize, DeviceProfile dp,
            SplitPositionOption initialSplitOption, Rect out1, Rect out2);

    /**
     * @param outRect This is expected to be the rect that has the dimensions for a non-split,
     *                fullscreen task in overview. This will directly be modified.
     * @param desiredStagePosition Which stage position (topLeft/rightBottom) we want to resize
     *                           outRect for
     */
    void setSplitTaskSwipeRect(DeviceProfile dp, Rect outRect,
            SplitConfigurationOptions.StagedSplitBounds splitInfo,
            @SplitConfigurationOptions.StagePosition int desiredStagePosition);

    /**
     * It's important to note that {@link #setSplitTaskSwipeRect(DeviceProfile, Rect,
     * SplitConfigurationOptions.StagedSplitBounds, int)} above operates on the outRect based on
     * launcher's coordinate system, meaning it will treat the outRect as portrait if home rotation
     * is not allowed.
     *
     * However, here the splitOffset is from perspective of TaskViewSimulator, which is in display
     * orientation coordinates. So, for example, for the fake landscape scenario, even though
     * launcher is portrait, we inset the bottom/right task by an X coordinate instead of the
     * usual Y
     */
    void setLeashSplitOffset(Point splitOffset, DeviceProfile dp,
            SplitConfigurationOptions.StagedSplitBounds splitInfo,
            @SplitConfigurationOptions.StagePosition int desiredStagePosition);

    // Overview TaskMenuView methods
    float getTaskMenuX(float x, View thumbnailView, int overScroll);
    float getTaskMenuY(float y, View thumbnailView, int overScroll);
+40 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_TYPE_MA

import android.content.res.Resources;
import android.graphics.Matrix;
import android.graphics.Point;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
@@ -40,6 +41,7 @@ import android.widget.LinearLayout;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.util.SplitConfigurationOptions;
import com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption;
import com.android.launcher3.views.BaseDragLayer;

@@ -467,6 +469,44 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler {
        mTmpRectF.roundOut(out2);
    }

    @Override
    public void setSplitTaskSwipeRect(DeviceProfile dp, Rect outRect,
            SplitConfigurationOptions.StagedSplitBounds splitInfo, int desiredStagePosition) {
        boolean isLandscape = dp.isLandscape;
        float diff;
        if (desiredStagePosition == SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT) {
            if (isLandscape) {
                diff = outRect.width() * (1f - splitInfo.mLeftTaskPercent);
                outRect.right -= diff;
            } else {
                diff = outRect.height() * (1f - splitInfo.mTopTaskPercent);
                outRect.bottom -= diff;
            }
        } else {
            if (isLandscape) {
                diff = outRect.width() * splitInfo.mLeftTaskPercent;
                outRect.left += diff;
            } else {
                diff = outRect.height() * splitInfo.mTopTaskPercent;
                outRect.top += diff;
            }
        }
    }

    @Override
    public void setLeashSplitOffset(Point splitOffset, DeviceProfile dp,
            SplitConfigurationOptions.StagedSplitBounds splitInfo, int desiredStagePosition) {
        if (desiredStagePosition == STAGE_POSITION_BOTTOM_OR_RIGHT) {
            if (dp.isLandscape) {
                splitOffset.x = splitInfo.mLeftTopBounds.width() +
                        splitInfo.mDividerBounds.width() / 2;
            } else {
                splitOffset.y = splitInfo.mLeftTopBounds.height() +
                        splitInfo.mDividerBounds.height() / 2;
            }
        }
    }

    @Override
    public FloatProperty getSplitSelectTaskOffset(FloatProperty primary, FloatProperty secondary,
            DeviceProfile dp) {
Loading