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

Commit 14a7d63c authored by Android Build Prod User's avatar Android Build Prod User Committed by Android (Google) Code Review
Browse files

Merge changes I54e39cc5,Iec62abae into sc-v2-dev

* changes:
  Set thumbnails for GroupedTaskView based on split layout bounds
  Implement swipe gesture for staged split in landscape
parents 9b2ec7d2 c35507dc
Loading
Loading
Loading
Loading
+0 −28
Original line number Original line 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.BaseState;
import com.android.launcher3.statemanager.StatefulActivity;
import com.android.launcher3.statemanager.StatefulActivity;
import com.android.launcher3.touch.PagedOrientationHandler;
import com.android.launcher3.touch.PagedOrientationHandler;
import com.android.launcher3.util.SplitConfigurationOptions;
import com.android.launcher3.util.WindowBounds;
import com.android.launcher3.util.WindowBounds;
import com.android.launcher3.views.ScrimView;
import com.android.launcher3.views.ScrimView;
import com.android.quickstep.SysUINavigationMode.Mode;
import com.android.quickstep.SysUINavigationMode.Mode;
@@ -202,33 +201,6 @@ public abstract class BaseActivityInterface<STATE_TYPE extends BaseState<STATE_T
        recentsView.switchToScreenshot(thumbnailData, runnable);
        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.
     * Calculates the taskView size for the provided device configuration.
     */
     */
+6 −9
Original line number Original line 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
            // 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
            // fullscreen scale and pivot remains the same since the task fits into the existing
            // sized task space bounds
            // sized task space bounds
            mSizeStrategy.calculateStagedSplitTaskSize(mContext, mDp, mTaskRect, mStagedSplitBounds,
            mSizeStrategy.calculateTaskSize(mContext, mDp, mTaskRect);
                    mStagePosition);
            mOrientationState.getOrientationHandler()
                    .setSplitTaskSwipeRect(mDp, mTaskRect, mStagedSplitBounds, mStagePosition);
        } else {
        } else {
            mTaskRect.set(fullTaskSize);
            mTaskRect.set(fullTaskSize);
        }
        }
@@ -277,13 +278,9 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy {
            getFullScreenScale();
            getFullScreenScale();
            mThumbnailData.rotation = mOrientationState.getDisplayRotation();
            mThumbnailData.rotation = mOrientationState.getDisplayRotation();


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


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


        // Move lower/right split window into correct position
        // 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
        // Crop rect is the inverse of thumbnail matrix
        mTempRectF.set(-insets.left, -insets.top,
        mTempRectF.set(-insets.left, -insets.top,
+11 −28
Original line number Original line Diff line number Diff line
package com.android.quickstep.views;
package com.android.quickstep.views;


import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;

import android.content.Context;
import android.content.Context;
import android.util.AttributeSet;
import android.util.AttributeSet;
import android.view.ViewGroup;


import com.android.launcher3.DeviceProfile;
import com.android.launcher3.R;
import com.android.launcher3.R;
import com.android.launcher3.util.SplitConfigurationOptions;
import com.android.quickstep.RecentsModel;
import com.android.quickstep.RecentsModel;
import com.android.quickstep.TaskThumbnailCache;
import com.android.quickstep.TaskThumbnailCache;
import com.android.quickstep.util.CancellableTask;
import com.android.quickstep.util.CancellableTask;
@@ -48,13 +45,14 @@ public class GroupedTaskView extends TaskView {
        mSnapshotView2 = findViewById(R.id.bottomright_snapshot);
        mSnapshotView2 = findViewById(R.id.bottomright_snapshot);
    }
    }


    public void bind(Task primary, Task secondary, RecentsOrientedState orientedState) {
    public void bind(Task primary, Task secondary, RecentsOrientedState orientedState,
            SplitConfigurationOptions.StagedSplitBounds splitBoundsConfig) {
        super.bind(primary, orientedState);
        super.bind(primary, orientedState);
        mSecondaryTask = secondary;
        mSecondaryTask = secondary;
        mTaskIdContainer[1] = secondary.key.id;
        mTaskIdContainer[1] = secondary.key.id;
        mTaskIdAttributeContainer[1] = new TaskIdAttributeContainer(secondary, mSnapshotView2);
        mTaskIdAttributeContainer[1] = new TaskIdAttributeContainer(secondary, mSnapshotView2);
        mSnapshotView2.bind(secondary);
        mSnapshotView2.bind(secondary);
        adjustThumbnailBoundsForSplit();
        adjustThumbnailBoundsForSplit(splitBoundsConfig, orientedState);
    }
    }


    @Override
    @Override
@@ -108,30 +106,15 @@ public class GroupedTaskView extends TaskView {
        mSnapshotView2.setOverlayEnabled(overlayEnabled);
        mSnapshotView2.setOverlayEnabled(overlayEnabled);
    }
    }


    private void adjustThumbnailBoundsForSplit() {
    private void adjustThumbnailBoundsForSplit(
        DeviceProfile deviceProfile = mActivity.getDeviceProfile();
            SplitConfigurationOptions.StagedSplitBounds splitBoundsConfig,
        ViewGroup.LayoutParams primaryLp = mSnapshotView.getLayoutParams();
            RecentsOrientedState orientedState) {
        primaryLp.width = mSecondaryTask == null ?
        if (splitBoundsConfig == null) {
                MATCH_PARENT :
                getWidth();
        int spaceAboveSnapshot = deviceProfile.overviewTaskThumbnailTopMarginPx;
        // TODO get divider height
        int dividerBar = 20;
        primaryLp.height = mSecondaryTask == null ?
                MATCH_PARENT :
                (getHeight() - spaceAboveSnapshot - dividerBar) / 2;
        mSnapshotView.setLayoutParams(primaryLp);

        if (mSecondaryTask == null) {
            mSnapshotView2.setVisibility(GONE);
            return;
            return;
        }
        }


        mSnapshotView2.setVisibility(VISIBLE);
        orientedState.getOrientationHandler().setGroupedTaskViewThumbnailBounds(
        ViewGroup.LayoutParams secondaryLp = mSnapshotView2.getLayoutParams();
                mSnapshotView, mSnapshotView2, this, splitBoundsConfig,
        secondaryLp.width = getWidth();
                mActivity.getDeviceProfile());
        secondaryLp.height = primaryLp.height;
        mSnapshotView2.setLayoutParams(secondaryLp);
        mSnapshotView2.setTranslationY(primaryLp.height + spaceAboveSnapshot + dividerBar);
    }
    }
}
}
+12 −6
Original line number Original line Diff line number Diff line
@@ -575,6 +575,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
     */
     */
    private TaskView mSplitHiddenTaskView;
    private TaskView mSplitHiddenTaskView;
    private TaskView mSecondSplitHiddenTaskView;
    private TaskView mSecondSplitHiddenTaskView;
    private SplitConfigurationOptions.StagedSplitBounds mSplitBoundsConfig;


    /**
    /**
     * Keeps track of the index of the TaskView that split screen was initialized with so we know
     * Keeps track of the index of the TaskView that split screen was initialized with so we know
@@ -1314,7 +1315,8 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
                    taskDataIndex--;
                    taskDataIndex--;
                    leftTop = tasks.get(taskDataIndex);
                    leftTop = tasks.get(taskDataIndex);
                }
                }
                ((GroupedTaskView) taskView).bind(leftTop, rightBottom, mOrientationState);
                ((GroupedTaskView) taskView).bind(leftTop, rightBottom, mOrientationState,
                        mSplitBoundsConfig);
            } else {
            } else {
                taskView.bind(task, mOrientationState);
                taskView.bind(task, mOrientationState);
            }
            }
@@ -2087,8 +2089,11 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
                        Task.from(new TaskKey(secondaryTaskInfo), secondaryTaskInfo, false)
                        Task.from(new TaskKey(secondaryTaskInfo), secondaryTaskInfo, false)
                };
                };
                addView(taskView, mTaskViewStartIndex);
                addView(taskView, mTaskViewStartIndex);
                // When we create a placeholder task view mSplitBoundsConfig will be null, but with
                // the actual app running we won't need to show the thumbnail until all the tasks
                // load later anyways
                ((GroupedTaskView)taskView).bind(mTmpRunningTasks[0], mTmpRunningTasks[1],
                ((GroupedTaskView)taskView).bind(mTmpRunningTasks[0], mTmpRunningTasks[1],
                        mOrientationState);
                        mOrientationState, mSplitBoundsConfig);
            } else {
            } else {
                taskView = getTaskViewFromPool(false);
                taskView = getTaskViewFromPool(false);
                addView(taskView, mTaskViewStartIndex);
                addView(taskView, mTaskViewStartIndex);
@@ -4038,12 +4043,13 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
            mRemoteTargetHandles[1] = new RemoteTargetHandle(secondaryTvs, new TransformParams());
            mRemoteTargetHandles[1] = new RemoteTargetHandle(secondaryTvs, new TransformParams());
            RemoteAnimationTargetCompat primaryTaskTarget = recentsAnimationTargets.apps[0];
            RemoteAnimationTargetCompat primaryTaskTarget = recentsAnimationTargets.apps[0];
            RemoteAnimationTargetCompat secondaryTaskTarget = recentsAnimationTargets.apps[1];
            RemoteAnimationTargetCompat secondaryTaskTarget = recentsAnimationTargets.apps[1];
            SplitConfigurationOptions.StagedSplitBounds
            mSplitBoundsConfig = new SplitConfigurationOptions.StagedSplitBounds(
                    info = new SplitConfigurationOptions.StagedSplitBounds(
                    primaryTaskTarget.screenSpaceBounds,
                    primaryTaskTarget.screenSpaceBounds,
                    secondaryTaskTarget.screenSpaceBounds, dividerTarget.screenSpaceBounds);
                    secondaryTaskTarget.screenSpaceBounds, dividerTarget.screenSpaceBounds);
            mRemoteTargetHandles[0].mTaskViewSimulator.setPreview(primaryTaskTarget, info);
            mRemoteTargetHandles[0].mTaskViewSimulator.setPreview(primaryTaskTarget,
            mRemoteTargetHandles[1].mTaskViewSimulator.setPreview(secondaryTaskTarget, info);
                    mSplitBoundsConfig);
            mRemoteTargetHandles[1].mTaskViewSimulator.setPreview(secondaryTaskTarget,
                    mSplitBoundsConfig);
            RemoteAnimationTargets rats = new RemoteAnimationTargets(
            RemoteAnimationTargets rats = new RemoteAnimationTargets(
                    new RemoteAnimationTargetCompat[]{primaryTaskTarget},
                    new RemoteAnimationTargetCompat[]{primaryTaskTarget},
                    recentsAnimationTargets.wallpapers, recentsAnimationTargets.nonApps,
                    recentsAnimationTargets.wallpapers, recentsAnimationTargets.nonApps,
+44 −0
Original line number Original line 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 static com.android.launcher3.util.SplitConfigurationOptions.STAGE_TYPE_MAIN;


import android.content.res.Resources;
import android.content.res.Resources;
import android.graphics.Point;
import android.graphics.PointF;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.RectF;
@@ -35,12 +36,14 @@ import android.view.MotionEvent;
import android.view.Surface;
import android.view.Surface;
import android.view.VelocityTracker;
import android.view.VelocityTracker;
import android.view.View;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityEvent;
import android.widget.LinearLayout;
import android.widget.LinearLayout;


import com.android.launcher3.DeviceProfile;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.R;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.Utilities;
import com.android.launcher3.util.SplitConfigurationOptions;
import com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption;
import com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption;
import com.android.launcher3.views.BaseDragLayer;
import com.android.launcher3.views.BaseDragLayer;


@@ -381,6 +384,47 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler {
        out2.set(0, screenHeight / 2  + splitDividerSize, screenWidth, screenHeight);
        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 void setGroupedTaskViewThumbnailBounds(View mSnapshotView, View mSnapshotView2,
            View taskParent, SplitConfigurationOptions.StagedSplitBounds splitBoundsConfig,
            DeviceProfile dp) {
        int spaceAboveSnapshot = dp.overviewTaskThumbnailTopMarginPx;
        int totalThumbnailHeight = taskParent.getHeight() - spaceAboveSnapshot;
        int totalThumbnailWidth = taskParent.getWidth();
        int dividerBar = splitBoundsConfig.mDividerBounds.width() / 2;
        ViewGroup.LayoutParams primaryLp = mSnapshotView.getLayoutParams();
        ViewGroup.LayoutParams secondaryLp = mSnapshotView2.getLayoutParams();

        primaryLp.width = totalThumbnailWidth;
        primaryLp.height = (int)(totalThumbnailHeight * splitBoundsConfig.mLeftTaskPercent);

        secondaryLp.width = totalThumbnailWidth;
        secondaryLp.height = totalThumbnailHeight - primaryLp.height - dividerBar;
        mSnapshotView2.setTranslationY(primaryLp.height + spaceAboveSnapshot + dividerBar);
    }

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