Merge "Resize mRemoteTargetHandles when RecentsAnimationStarts" into udc-dev am: 52ac882e9b
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/23267214 Change-Id: I8db6ea9281b0bfadb77c7a4b21f22c3583195c3f Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -147,6 +147,7 @@ import com.android.wm.shell.startingsurface.SplashScreenExitAnimationUtils;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
@@ -662,6 +663,14 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
|
|||||||
} else {
|
} else {
|
||||||
runningTasks = mGestureState.getRunningTask().getPlaceholderTasks();
|
runningTasks = mGestureState.getRunningTask().getPlaceholderTasks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Safeguard against any null tasks being sent to recents view, happens when quickswitching
|
||||||
|
// very quickly w/ split tasks because TopTaskTracker provides stale information compared to
|
||||||
|
// actual running tasks in the recents animation.
|
||||||
|
// TODO(b/236226779), Proper fix (ag/22237143)
|
||||||
|
if (Arrays.stream(runningTasks).anyMatch(Objects::isNull)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
mRecentsView.onGestureAnimationStart(runningTasks, mDeviceState.getRotationTouchHelper());
|
mRecentsView.onGestureAnimationStart(runningTasks, mDeviceState.getRotationTouchHelper());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -915,7 +924,12 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
|
|||||||
if (DesktopTaskView.DESKTOP_MODE_SUPPORTED && targets.hasDesktopTasks()) {
|
if (DesktopTaskView.DESKTOP_MODE_SUPPORTED && targets.hasDesktopTasks()) {
|
||||||
mRemoteTargetHandles = mTargetGluer.assignTargetsForDesktop(targets);
|
mRemoteTargetHandles = mTargetGluer.assignTargetsForDesktop(targets);
|
||||||
} else {
|
} else {
|
||||||
|
int untrimmedAppCount = mRemoteTargetHandles.length;
|
||||||
mRemoteTargetHandles = mTargetGluer.assignTargetsForSplitScreen(targets);
|
mRemoteTargetHandles = mTargetGluer.assignTargetsForSplitScreen(targets);
|
||||||
|
if (mRemoteTargetHandles.length < untrimmedAppCount && mIsSwipeForSplit) {
|
||||||
|
updateIsGestureForSplit(mRemoteTargetHandles.length);
|
||||||
|
setupRecentsViewUi();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mRecentsAnimationController = controller;
|
mRecentsAnimationController = controller;
|
||||||
mRecentsAnimationTargets = targets;
|
mRecentsAnimationTargets = targets;
|
||||||
|
|||||||
@@ -29,12 +29,15 @@ import com.android.quickstep.util.TransformParams;
|
|||||||
import com.android.quickstep.views.DesktopTaskView;
|
import com.android.quickstep.views.DesktopTaskView;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Glues together the necessary components to animate a remote target using a
|
* Glues together the necessary components to animate a remote target using a
|
||||||
* {@link TaskViewSimulator}
|
* {@link TaskViewSimulator}
|
||||||
*/
|
*/
|
||||||
public class RemoteTargetGluer {
|
public class RemoteTargetGluer {
|
||||||
|
private static final int DEFAULT_NUM_HANDLES = 2;
|
||||||
|
|
||||||
private RemoteTargetHandle[] mRemoteTargetHandles;
|
private RemoteTargetHandle[] mRemoteTargetHandles;
|
||||||
private SplitBounds mSplitBounds;
|
private SplitBounds mSplitBounds;
|
||||||
|
|
||||||
@@ -62,8 +65,9 @@ public class RemoteTargetGluer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int[] splitIds = TopTaskTracker.INSTANCE.get(context).getRunningSplitTaskIds();
|
// Assume 2 handles needed for split, scale down as needed later on when we actually
|
||||||
init(context, sizingStrategy, splitIds.length == 2 ? 2 : 1, false /* forDesktop */);
|
// get remote targets
|
||||||
|
init(context, sizingStrategy, DEFAULT_NUM_HANDLES, false /* forDesktop */);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init(Context context, BaseActivityInterface sizingStrategy, int numHandles,
|
private void init(Context context, BaseActivityInterface sizingStrategy, int numHandles,
|
||||||
@@ -108,6 +112,17 @@ public class RemoteTargetGluer {
|
|||||||
* the left/top task, index 1 right/bottom.
|
* the left/top task, index 1 right/bottom.
|
||||||
*/
|
*/
|
||||||
public RemoteTargetHandle[] assignTargetsForSplitScreen(RemoteAnimationTargets targets) {
|
public RemoteTargetHandle[] assignTargetsForSplitScreen(RemoteAnimationTargets targets) {
|
||||||
|
// Resize the mRemoteTargetHandles array since we started assuming split screen, but
|
||||||
|
// targets.apps is the ultimate source of truth here
|
||||||
|
long appCount = Arrays.stream(targets.apps)
|
||||||
|
.filter(app -> app.mode == targets.targetMode)
|
||||||
|
.count();
|
||||||
|
if (appCount < mRemoteTargetHandles.length) {
|
||||||
|
RemoteTargetHandle[] newHandles = new RemoteTargetHandle[(int) appCount];
|
||||||
|
System.arraycopy(mRemoteTargetHandles, 0/*src*/, newHandles, 0/*dst*/, (int) appCount);
|
||||||
|
mRemoteTargetHandles = newHandles;
|
||||||
|
}
|
||||||
|
|
||||||
if (mRemoteTargetHandles.length == 1) {
|
if (mRemoteTargetHandles.length == 1) {
|
||||||
// If we're not in split screen, the splitIds count doesn't really matter since we
|
// If we're not in split screen, the splitIds count doesn't really matter since we
|
||||||
// should always hit this case.
|
// should always hit this case.
|
||||||
@@ -233,6 +248,14 @@ public class RemoteTargetGluer {
|
|||||||
targets.targetMode);
|
targets.targetMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The object returned by this is may be modified in
|
||||||
|
* {@link #assignTargetsForSplitScreen(RemoteAnimationTargets)}, specifically the length of the
|
||||||
|
* array may be shortened based on the number of RemoteAnimationTargets present.
|
||||||
|
* <p>
|
||||||
|
* This can be accessed at any time, however the count will be more accurate if accessed after
|
||||||
|
* calling one of the respective assignTargets*() methods
|
||||||
|
*/
|
||||||
public RemoteTargetHandle[] getRemoteTargetHandles() {
|
public RemoteTargetHandle[] getRemoteTargetHandles() {
|
||||||
return mRemoteTargetHandles;
|
return mRemoteTargetHandles;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,7 +82,8 @@ public abstract class SwipeUpAnimationLogic implements
|
|||||||
mContext = context;
|
mContext = context;
|
||||||
mDeviceState = deviceState;
|
mDeviceState = deviceState;
|
||||||
mGestureState = gestureState;
|
mGestureState = gestureState;
|
||||||
mIsSwipeForSplit = TopTaskTracker.INSTANCE.get(context).getRunningSplitTaskIds().length > 1;
|
updateIsGestureForSplit(TopTaskTracker.INSTANCE.get(context)
|
||||||
|
.getRunningSplitTaskIds().length);
|
||||||
|
|
||||||
mTargetGluer = new RemoteTargetGluer(mContext, mGestureState.getActivityInterface());
|
mTargetGluer = new RemoteTargetGluer(mContext, mGestureState.getActivityInterface());
|
||||||
mRemoteTargetHandles = mTargetGluer.getRemoteTargetHandles();
|
mRemoteTargetHandles = mTargetGluer.getRemoteTargetHandles();
|
||||||
@@ -280,6 +281,10 @@ public abstract class SwipeUpAnimationLogic implements
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void updateIsGestureForSplit(int targetCount) {
|
||||||
|
mIsSwipeForSplit = targetCount > 1;
|
||||||
|
}
|
||||||
|
|
||||||
private RectFSpringAnim getWindowAnimationToHomeInternal(
|
private RectFSpringAnim getWindowAnimationToHomeInternal(
|
||||||
HomeAnimationFactory homeAnimationFactory, RectF targetRect,
|
HomeAnimationFactory homeAnimationFactory, RectF targetRect,
|
||||||
TransformParams transformParams, TaskViewSimulator taskViewSimulator,
|
TransformParams transformParams, TaskViewSimulator taskViewSimulator,
|
||||||
|
|||||||
Reference in New Issue
Block a user