diff --git a/quickstep/src/com/android/launcher3/uioverrides/BaseRecentsViewStateController.java b/quickstep/src/com/android/launcher3/uioverrides/BaseRecentsViewStateController.java index d74b6c5f1d..c85b2566a7 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/BaseRecentsViewStateController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/BaseRecentsViewStateController.java @@ -34,6 +34,7 @@ import static com.android.quickstep.views.RecentsView.TASK_SECONDARY_SPLIT_TRANS import static com.android.quickstep.views.RecentsView.TASK_SECONDARY_TRANSLATION; import android.util.FloatProperty; +import android.util.Pair; import androidx.annotation.NonNull; @@ -101,11 +102,13 @@ public abstract class BaseRecentsViewStateController config.getInterpolator(ANIM_OVERVIEW_TRANSLATE_Y, LINEAR)); PagedOrientationHandler orientationHandler = ((RecentsView) mLauncher.getOverviewPanel()).getPagedOrientationHandler(); - FloatProperty taskViewsFloat = orientationHandler.getSplitSelectTaskOffset( - TASK_PRIMARY_SPLIT_TRANSLATION, TASK_SECONDARY_SPLIT_TRANSLATION, - mLauncher.getDeviceProfile()); - setter.setFloat(mRecentsView, taskViewsFloat, + Pair taskViewsFloat = + orientationHandler.getSplitSelectTaskOffset( + TASK_PRIMARY_SPLIT_TRANSLATION, TASK_SECONDARY_SPLIT_TRANSLATION, + mLauncher.getDeviceProfile()); + setter.setFloat(mRecentsView, taskViewsFloat.first, toState.getSplitSelectTranslation(mLauncher), LINEAR); + setter.setFloat(mRecentsView, taskViewsFloat.second, 0, LINEAR); setter.setFloat(mRecentsView, getContentAlphaProperty(), toState.overviewUi ? 1 : 0, config.getInterpolator(ANIM_OVERVIEW_FADE, AGGRESSIVE_EASE_IN_OUT)); diff --git a/quickstep/src/com/android/quickstep/SystemUiProxy.java b/quickstep/src/com/android/quickstep/SystemUiProxy.java index c8abd14d22..2543e6c594 100644 --- a/quickstep/src/com/android/quickstep/SystemUiProxy.java +++ b/quickstep/src/com/android/quickstep/SystemUiProxy.java @@ -565,12 +565,12 @@ public class SystemUiProxy implements ISystemUiProxy, /** Start multiple tasks in split-screen simultaneously. */ public void startTasks(int mainTaskId, Bundle mainOptions, int sideTaskId, Bundle sideOptions, - @SplitConfigurationOptions.StagePosition int sidePosition, + @SplitConfigurationOptions.StagePosition int sidePosition, float splitRatio, RemoteTransitionCompat remoteTransition) { if (mSystemUiProxy != null) { try { mSplitScreen.startTasks(mainTaskId, mainOptions, sideTaskId, sideOptions, - sidePosition, remoteTransition.getTransition()); + sidePosition, splitRatio, remoteTransition.getTransition()); } catch (RemoteException e) { Log.w(TAG, "Failed call startTask"); } @@ -582,11 +582,11 @@ public class SystemUiProxy implements ISystemUiProxy, */ public void startTasksWithLegacyTransition(int mainTaskId, Bundle mainOptions, int sideTaskId, Bundle sideOptions, @SplitConfigurationOptions.StagePosition int sidePosition, - RemoteAnimationAdapter adapter) { + float splitRatio, RemoteAnimationAdapter adapter) { if (mSystemUiProxy != null) { try { mSplitScreen.startTasksWithLegacyTransition(mainTaskId, mainOptions, sideTaskId, - sideOptions, sidePosition, adapter); + sideOptions, sidePosition, splitRatio, adapter); } catch (RemoteException e) { Log.w(TAG, "Failed call startTasksWithLegacyTransition"); } diff --git a/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java b/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java index c784d82d30..d3108936e7 100644 --- a/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java +++ b/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java @@ -18,6 +18,7 @@ package com.android.quickstep.util; import static com.android.launcher3.Utilities.postAsyncCallback; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; +import static com.android.launcher3.util.SplitConfigurationOptions.DEFAULT_SPLIT_RATIO; import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_BOTTOM_OR_RIGHT; import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT; @@ -30,7 +31,6 @@ import android.view.RemoteAnimationAdapter; import android.view.SurfaceControl; import android.window.TransitionInfo; - import androidx.annotation.Nullable; import com.android.launcher3.statehandlers.DepthController; @@ -95,7 +95,7 @@ public class SplitSelectStateController { public void setSecondTaskId(Task task, Consumer callback) { mSecondTask = task; launchTasks(mInitialTask, mSecondTask, mStagePosition, callback, - false /* freezeTaskList */); + false /* freezeTaskList */, DEFAULT_SPLIT_RATIO); } /** @@ -107,14 +107,15 @@ public class SplitSelectStateController { TaskView.TaskIdAttributeContainer[] taskIdAttributeContainers = groupedTaskView.getTaskIdAttributeContainers(); launchTasks(taskIdAttributeContainers[0].getTask(), taskIdAttributeContainers[1].getTask(), - taskIdAttributeContainers[0].getStagePosition(), callback, freezeTaskList); + taskIdAttributeContainers[0].getStagePosition(), callback, freezeTaskList, + groupedTaskView.getSplitRatio()); } /** * @param stagePosition representing location of task1 */ public void launchTasks(Task task1, Task task2, @StagePosition int stagePosition, - Consumer callback, boolean freezeTaskList) { + Consumer callback, boolean freezeTaskList, float splitRatio) { // Assume initial task is for top/left part of screen final int[] taskIds = stagePosition == STAGE_POSITION_TOP_OR_LEFT ? new int[]{task1.key.id, task2.key.id} @@ -123,7 +124,7 @@ public class SplitSelectStateController { RemoteSplitLaunchTransitionRunner animationRunner = new RemoteSplitLaunchTransitionRunner(task1, task2); mSystemUiProxy.startTasks(taskIds[0], null /* mainOptions */, taskIds[1], - null /* sideOptions */, STAGE_POSITION_BOTTOM_OR_RIGHT, + null /* sideOptions */, STAGE_POSITION_BOTTOM_OR_RIGHT, splitRatio, new RemoteTransitionCompat(animationRunner, MAIN_EXECUTOR, ActivityThread.currentActivityThread().getApplicationThread())); } else { @@ -140,7 +141,7 @@ public class SplitSelectStateController { } mSystemUiProxy.startTasksWithLegacyTransition(taskIds[0], mainOpts.toBundle(), taskIds[1], null /* sideOptions */, STAGE_POSITION_BOTTOM_OR_RIGHT, - adapter); + splitRatio, adapter); } } diff --git a/quickstep/src/com/android/quickstep/views/GroupedTaskView.java b/quickstep/src/com/android/quickstep/views/GroupedTaskView.java index 4771d1ea82..00f541d4c6 100644 --- a/quickstep/src/com/android/quickstep/views/GroupedTaskView.java +++ b/quickstep/src/com/android/quickstep/views/GroupedTaskView.java @@ -1,5 +1,6 @@ package com.android.quickstep.views; +import static com.android.launcher3.util.SplitConfigurationOptions.DEFAULT_SPLIT_RATIO; import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_BOTTOM_OR_RIGHT; import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT; @@ -122,6 +123,14 @@ public class GroupedTaskView extends TaskView { invalidate(); } + public float getSplitRatio() { + if (mSplitBoundsConfig != null) { + return mSplitBoundsConfig.appsStackedVertically + ? mSplitBoundsConfig.topTaskPercent : mSplitBoundsConfig.leftTaskPercent; + } + return DEFAULT_SPLIT_RATIO; + } + @Override public boolean offerTouchToChildren(MotionEvent event) { computeAndSetIconTouchDelegate(mIconView2, mIcon2CenterCoords, mIcon2TouchDelegate); @@ -157,7 +166,8 @@ public class GroupedTaskView extends TaskView { @Override public void launchTask(@NonNull Consumer callback, boolean freezeTaskList) { getRecentsView().getSplitPlaceholder().launchTasks(mTask, mSecondaryTask, - STAGE_POSITION_TOP_OR_LEFT, callback, freezeTaskList); + STAGE_POSITION_TOP_OR_LEFT, callback, freezeTaskList, + getSplitRatio()); } @Override diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java index d844b877a7..2ebedf71de 100644 --- a/src/com/android/launcher3/InvariantDeviceProfile.java +++ b/src/com/android/launcher3/InvariantDeviceProfile.java @@ -286,7 +286,11 @@ public class InvariantDeviceProfile { mExtraAttrs = closestProfile.extraAttrs; iconSize = displayOption.iconSizes; - iconBitmapSize = ResourceUtils.pxFromDp(iconSize[INDEX_DEFAULT], metrics); + float maxIconSize = iconSize[0]; + for (int i = 1; i < iconSize.length; i++) { + maxIconSize = Math.max(maxIconSize, iconSize[i]); + } + iconBitmapSize = ResourceUtils.pxFromDp(maxIconSize, metrics); fillResIconDpi = getLauncherIconDensity(iconBitmapSize); iconTextSize = displayOption.textSizes; @@ -555,13 +559,10 @@ public class InvariantDeviceProfile { } out.multiply(1.0f / weights); - // Since the bitmaps are persisted, ensure that the default bitmap size is same as + // Since the bitmaps are persisted, ensure that all bitmap sizes are not larger than // predefined size to avoid cache invalidation - out.iconSizes[INDEX_DEFAULT] = - closestPoint.iconSizes[INDEX_DEFAULT]; - for (int i = INDEX_DEFAULT + 1; i < COUNT_SIZES; i++) { - out.iconSizes[i] = Math.min(out.iconSizes[i], - out.iconSizes[INDEX_DEFAULT]); + for (int i = INDEX_DEFAULT; i < COUNT_SIZES; i++) { + out.iconSizes[i] = Math.min(out.iconSizes[i], closestPoint.iconSizes[i]); } return out; diff --git a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java index e127074f54..c2552250df 100644 --- a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java +++ b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java @@ -36,6 +36,7 @@ import android.graphics.Rect; import android.graphics.RectF; import android.graphics.drawable.ShapeDrawable; import android.util.FloatProperty; +import android.util.Pair; import android.view.MotionEvent; import android.view.Surface; import android.view.VelocityTracker; @@ -462,8 +463,8 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler { } @Override - public FloatProperty getSplitSelectTaskOffset(FloatProperty primary, FloatProperty secondary, - DeviceProfile deviceProfile) { - return primary; + public Pair getSplitSelectTaskOffset(FloatProperty primary, + FloatProperty secondary, DeviceProfile deviceProfile) { + return new Pair<>(primary, secondary); } } diff --git a/src/com/android/launcher3/touch/PagedOrientationHandler.java b/src/com/android/launcher3/touch/PagedOrientationHandler.java index d954552000..54b30fbec8 100644 --- a/src/com/android/launcher3/touch/PagedOrientationHandler.java +++ b/src/com/android/launcher3/touch/PagedOrientationHandler.java @@ -24,6 +24,7 @@ import android.graphics.Rect; import android.graphics.RectF; import android.graphics.drawable.ShapeDrawable; import android.util.FloatProperty; +import android.util.Pair; import android.view.MotionEvent; import android.view.VelocityTracker; import android.view.View; @@ -113,8 +114,8 @@ public interface PagedOrientationHandler { float getSecondaryValue(float x, float y); boolean isLayoutNaturalToLauncher(); - FloatProperty getSplitSelectTaskOffset(FloatProperty primary, FloatProperty secondary, - DeviceProfile deviceProfile); + Pair getSplitSelectTaskOffset(FloatProperty primary, + FloatProperty secondary, DeviceProfile deviceProfile); int getDistanceToBottomOfRect(DeviceProfile dp, Rect rect); List getSplitPositionOptions(DeviceProfile dp); /** diff --git a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java index fbc335c56e..e69944abef 100644 --- a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java +++ b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java @@ -35,6 +35,7 @@ import android.graphics.Rect; import android.graphics.RectF; import android.graphics.drawable.ShapeDrawable; import android.util.FloatProperty; +import android.util.Pair; import android.view.MotionEvent; import android.view.Surface; import android.view.VelocityTracker; @@ -571,12 +572,12 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler { } @Override - public FloatProperty getSplitSelectTaskOffset(FloatProperty primary, FloatProperty secondary, - DeviceProfile dp) { - if (dp.isLandscape) { // or seascape - return primary; + public Pair getSplitSelectTaskOffset(FloatProperty primary, + FloatProperty secondary, DeviceProfile deviceProfile) { + if (deviceProfile.isLandscape) { // or seascape + return new Pair<>(primary, secondary); } else { - return secondary; + return new Pair<>(secondary, primary); } } } diff --git a/src/com/android/launcher3/util/SplitConfigurationOptions.java b/src/com/android/launcher3/util/SplitConfigurationOptions.java index 53b1c3ea8e..cb714b2a8f 100644 --- a/src/com/android/launcher3/util/SplitConfigurationOptions.java +++ b/src/com/android/launcher3/util/SplitConfigurationOptions.java @@ -68,6 +68,11 @@ public final class SplitConfigurationOptions { public @interface StageType {} /////////////////////////////////// + /** + * Default split ratio for launching app pair from overview. + */ + public static final float DEFAULT_SPLIT_RATIO = 0.5f; + public static class SplitPositionOption { public final int iconResId; public final int textResId;