Fix issue with z order layering
- Move first frame remote animation logic into the same method to ensure we consistently update the layers and state for every animation Bug: 78249267 Change-Id: Id0378cfe3e1be56128c2a1cd607929225927e3b4
This commit is contained in:
@@ -190,7 +190,7 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
|
||||
}
|
||||
});
|
||||
}
|
||||
anim.play(getWindowAnimators(v, targetCompats));
|
||||
anim.play(getOpeningWindowAnimators(v, targetCompats));
|
||||
}
|
||||
|
||||
if (launcherClosing) {
|
||||
@@ -454,7 +454,7 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
|
||||
/**
|
||||
* @return Animator that controls the window of the opening targets.
|
||||
*/
|
||||
private ValueAnimator getWindowAnimators(View v, RemoteAnimationTargetCompat[] targets) {
|
||||
private ValueAnimator getOpeningWindowAnimators(View v, RemoteAnimationTargetCompat[] targets) {
|
||||
Rect bounds = new Rect();
|
||||
if (v.getParent() instanceof DeepShortcutView) {
|
||||
// Deep shortcut views have their icon drawn in a separate view.
|
||||
@@ -475,7 +475,6 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
|
||||
appAnimator.addUpdateListener(new MultiValueUpdateListener() {
|
||||
// Fade alpha for the app window.
|
||||
FloatProp mAlpha = new FloatProp(0f, 1f, 0, 60, LINEAR);
|
||||
|
||||
boolean isFirstFrame = true;
|
||||
|
||||
@Override
|
||||
@@ -522,6 +521,10 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
|
||||
crop.bottom = (int) (crop.top + cropHeight);
|
||||
|
||||
TransactionCompat t = new TransactionCompat();
|
||||
if (isFirstFrame) {
|
||||
RemoteAnimationProvider.prepareTargetsForFirstFrame(targets, t, MODE_OPENING);
|
||||
isFirstFrame = false;
|
||||
}
|
||||
for (RemoteAnimationTargetCompat target : targets) {
|
||||
if (target.mode == MODE_OPENING) {
|
||||
t.setAlpha(target.leash, mAlpha.value);
|
||||
@@ -533,15 +536,10 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
|
||||
t.setWindowCrop(target.leash, crop);
|
||||
t.deferTransactionUntil(target.leash, surface, getNextFrameNumber(surface));
|
||||
}
|
||||
if (isFirstFrame) {
|
||||
t.show(target.leash);
|
||||
}
|
||||
}
|
||||
t.setEarlyWakeup();
|
||||
t.apply();
|
||||
|
||||
matrix.reset();
|
||||
isFirstFrame = false;
|
||||
}
|
||||
});
|
||||
return appAnimator;
|
||||
@@ -638,6 +636,10 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
|
||||
@Override
|
||||
public void onUpdate(float percent) {
|
||||
TransactionCompat t = new TransactionCompat();
|
||||
if (isFirstFrame) {
|
||||
RemoteAnimationProvider.prepareTargetsForFirstFrame(targets, t, MODE_CLOSING);
|
||||
isFirstFrame = false;
|
||||
}
|
||||
for (RemoteAnimationTargetCompat app : targets) {
|
||||
if (app.mode == RemoteAnimationTargetCompat.MODE_CLOSING) {
|
||||
t.setAlpha(app.leash, mAlpha.value);
|
||||
@@ -648,19 +650,10 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
|
||||
matrix.postTranslate(app.position.x, app.position.y);
|
||||
t.setMatrix(app.leash, matrix);
|
||||
}
|
||||
if (isFirstFrame) {
|
||||
int layer = app.mode == RemoteAnimationTargetCompat.MODE_CLOSING
|
||||
? Integer.MAX_VALUE
|
||||
: app.prefixOrderIndex;
|
||||
t.setLayer(app.leash, layer);
|
||||
t.show(app.leash);
|
||||
}
|
||||
}
|
||||
t.setEarlyWakeup();
|
||||
t.apply();
|
||||
|
||||
matrix.reset();
|
||||
isFirstFrame = false;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -42,7 +42,6 @@ import android.os.SystemClock;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewConfiguration;
|
||||
|
||||
import com.android.launcher3.AbstractFloatingView;
|
||||
import com.android.launcher3.BaseDraggingActivity;
|
||||
import com.android.launcher3.MainThreadExecutor;
|
||||
@@ -52,7 +51,6 @@ import com.android.quickstep.ActivityControlHelper.AnimationFactory;
|
||||
import com.android.quickstep.ActivityControlHelper.FallbackActivityControllerHelper;
|
||||
import com.android.quickstep.ActivityControlHelper.LauncherActivityControllerHelper;
|
||||
import com.android.quickstep.util.ClipAnimationHelper;
|
||||
import com.android.quickstep.util.RemoteAnimationProvider;
|
||||
import com.android.quickstep.util.RemoteAnimationTargetSet;
|
||||
import com.android.quickstep.util.SysuiEventLogger;
|
||||
import com.android.quickstep.views.RecentsView;
|
||||
@@ -60,7 +58,6 @@ import com.android.systemui.shared.system.ActivityManagerWrapper;
|
||||
import com.android.systemui.shared.system.PackageManagerWrapper;
|
||||
import com.android.systemui.shared.system.RemoteAnimationTargetCompat;
|
||||
import com.android.systemui.shared.system.TransactionCompat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
@@ -278,7 +275,6 @@ public class OverviewCommandHelper {
|
||||
if (mListener != null) {
|
||||
mListener.unregister();
|
||||
}
|
||||
RemoteAnimationProvider.showOpeningTarget(targetCompats);
|
||||
AnimatorSet anim = new AnimatorSet();
|
||||
anim.addListener(new AnimationSuccessListener() {
|
||||
@Override
|
||||
@@ -321,12 +317,13 @@ public class OverviewCommandHelper {
|
||||
mHelper.getSwipeUpDestinationAndLength(
|
||||
mActivity.getDeviceProfile(), mActivity, targetRect);
|
||||
clipHelper.updateTargetRect(targetRect);
|
||||
clipHelper.prepareAnimation(false /* isOpening */);
|
||||
|
||||
ValueAnimator valueAnimator = ValueAnimator.ofFloat(0, 1);
|
||||
valueAnimator.setDuration(RECENTS_LAUNCH_DURATION);
|
||||
valueAnimator.setInterpolator(TOUCH_RESPONSE_INTERPOLATOR);
|
||||
valueAnimator.addUpdateListener((v) ->
|
||||
clipHelper.applyTransform(targetSet, (float) v.getAnimatedValue()));
|
||||
clipHelper.applyTransform(targetSet, (float) v.getAnimatedValue()));
|
||||
|
||||
if (targetSet.isAnimatingHome()) {
|
||||
// If we are animating home, fade in the opening targets
|
||||
@@ -337,9 +334,7 @@ public class OverviewCommandHelper {
|
||||
valueAnimator.addUpdateListener((v) -> {
|
||||
for (RemoteAnimationTargetCompat app : openingSet.apps) {
|
||||
transaction.setAlpha(app.leash, (float) v.getAnimatedValue());
|
||||
transaction.show(app.leash);
|
||||
}
|
||||
transaction.setEarlyWakeup();
|
||||
transaction.apply();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ import com.android.launcher3.compat.UserManagerCompat;
|
||||
import com.android.launcher3.util.ComponentKey;
|
||||
import com.android.quickstep.RecentsAnimationInterpolator.TaskWindowBounds;
|
||||
import com.android.quickstep.util.MultiValueUpdateListener;
|
||||
import com.android.quickstep.util.RemoteAnimationProvider;
|
||||
import com.android.quickstep.views.RecentsView;
|
||||
import com.android.quickstep.views.TaskView;
|
||||
import com.android.systemui.shared.recents.model.Task;
|
||||
@@ -159,7 +160,6 @@ public class TaskUtils {
|
||||
|
||||
@Override
|
||||
public void onUpdate(float percent) {
|
||||
|
||||
final Surface surface = getSurface(v);
|
||||
final long frameNumber = surface != null ? getNextFrameNumber(surface) : -1;
|
||||
if (frameNumber == -1) {
|
||||
@@ -182,6 +182,10 @@ public class TaskUtils {
|
||||
crop.set(tw.winCrop);
|
||||
|
||||
TransactionCompat t = new TransactionCompat();
|
||||
if (isFirstFrame) {
|
||||
RemoteAnimationProvider.prepareTargetsForFirstFrame(targets, t, MODE_OPENING);
|
||||
isFirstFrame = false;
|
||||
}
|
||||
for (RemoteAnimationTargetCompat target : targets) {
|
||||
if (target.mode == RemoteAnimationTargetCompat.MODE_OPENING) {
|
||||
t.setAlpha(target.leash, mTaskAlpha.value);
|
||||
@@ -196,15 +200,10 @@ public class TaskUtils {
|
||||
t.deferTransactionUntil(target.leash, surface, frameNumber);
|
||||
}
|
||||
}
|
||||
if (isFirstFrame) {
|
||||
t.show(target.leash);
|
||||
}
|
||||
}
|
||||
t.setEarlyWakeup();
|
||||
t.apply();
|
||||
|
||||
matrix.reset();
|
||||
isFirstFrame = false;
|
||||
}
|
||||
});
|
||||
return appAnimator;
|
||||
|
||||
@@ -64,6 +64,7 @@ import com.android.quickstep.ActivityControlHelper.AnimationFactory;
|
||||
import com.android.quickstep.ActivityControlHelper.LayoutListener;
|
||||
import com.android.quickstep.TouchConsumer.InteractionType;
|
||||
import com.android.quickstep.util.ClipAnimationHelper;
|
||||
import com.android.quickstep.util.RemoteAnimationProvider;
|
||||
import com.android.quickstep.util.RemoteAnimationTargetSet;
|
||||
import com.android.quickstep.util.SysuiEventLogger;
|
||||
import com.android.quickstep.views.RecentsView;
|
||||
@@ -545,9 +546,9 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> {
|
||||
if (runningTaskTarget != null) {
|
||||
mClipAnimationHelper.updateSource(overviewStackBounds, runningTaskTarget);
|
||||
}
|
||||
mClipAnimationHelper.prepareAnimation(false /* isOpening */);
|
||||
initTransitionEndpoints(dp);
|
||||
|
||||
|
||||
mRecentsAnimationWrapper.setController(controller, targets);
|
||||
setStateOnUiThread(STATE_APP_CONTROLLER_RECEIVED);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@ package com.android.quickstep.util;
|
||||
|
||||
import static com.android.launcher3.anim.Interpolators.LINEAR;
|
||||
import static com.android.launcher3.anim.Interpolators.SCROLL;
|
||||
import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_CLOSING;
|
||||
import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_OPENING;
|
||||
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Matrix;
|
||||
@@ -68,6 +70,11 @@ public class ClipAnimationHelper {
|
||||
|
||||
private float mTargetScale = 1f;
|
||||
|
||||
// Whether to boost the opening animation target layers, or the closing
|
||||
private int mBoostModeTargetLayers = -1;
|
||||
// Wether or not applyTransform has been called yet since prepareAnimation()
|
||||
private boolean mIsFirstFrame = true;
|
||||
|
||||
public void updateSource(Rect homeStackBounds, RemoteAnimationTargetCompat target) {
|
||||
mHomeStackBounds.set(homeStackBounds);
|
||||
mSourceInsets.set(target.contentInsets);
|
||||
@@ -101,6 +108,11 @@ public class ClipAnimationHelper {
|
||||
mSourceRect.set(scaledTargetRect);
|
||||
}
|
||||
|
||||
public void prepareAnimation(boolean isOpening) {
|
||||
mIsFirstFrame = true;
|
||||
mBoostModeTargetLayers = isOpening ? MODE_OPENING : MODE_CLOSING;
|
||||
}
|
||||
|
||||
public void applyTransform(RemoteAnimationTargetSet targetSet, float progress) {
|
||||
RectF currentRect;
|
||||
mTmpRectF.set(mTargetRect);
|
||||
@@ -121,6 +133,11 @@ public class ClipAnimationHelper {
|
||||
(mSourceStackBounds.height() - (mSourceWindowClipInsets.bottom * progress));
|
||||
|
||||
TransactionCompat transaction = new TransactionCompat();
|
||||
if (mIsFirstFrame) {
|
||||
RemoteAnimationProvider.prepareTargetsForFirstFrame(targetSet.unfilteredApps,
|
||||
transaction, mBoostModeTargetLayers);
|
||||
mIsFirstFrame = false;
|
||||
}
|
||||
for (RemoteAnimationTargetCompat app : targetSet.apps) {
|
||||
if (app.activityType != RemoteAnimationTargetCompat.ACTIVITY_TYPE_HOME) {
|
||||
mTmpMatrix.setRectToRect(mSourceRect, currentRect, ScaleToFit.FILL);
|
||||
@@ -133,9 +150,7 @@ public class ClipAnimationHelper {
|
||||
|| app.activityType == RemoteAnimationTargetCompat.ACTIVITY_TYPE_HOME) {
|
||||
transaction.setAlpha(app.leash, 1 - progress);
|
||||
}
|
||||
transaction.show(app.leash);
|
||||
}
|
||||
transaction.setEarlyWakeup();
|
||||
transaction.apply();
|
||||
}
|
||||
|
||||
|
||||
@@ -44,15 +44,22 @@ public interface RemoteAnimationProvider {
|
||||
new RemoteAnimationAdapterCompat(runner, duration, 0));
|
||||
}
|
||||
|
||||
static void showOpeningTarget(RemoteAnimationTargetCompat[] targetCompats) {
|
||||
TransactionCompat t = new TransactionCompat();
|
||||
for (RemoteAnimationTargetCompat target : targetCompats) {
|
||||
int layer = target.mode == RemoteAnimationTargetCompat.MODE_CLOSING
|
||||
/**
|
||||
* Prepares the given {@param targets} for a remote animation, and should be called with the
|
||||
* transaction from the first frame of animation.
|
||||
*
|
||||
* @param boostModeTargets The mode indicating which targets to boost in z-order above other
|
||||
* targets.
|
||||
*/
|
||||
static void prepareTargetsForFirstFrame(RemoteAnimationTargetCompat[] targets,
|
||||
TransactionCompat t, int boostModeTargets) {
|
||||
for (RemoteAnimationTargetCompat target : targets) {
|
||||
int layer = target.mode == boostModeTargets
|
||||
? Integer.MAX_VALUE
|
||||
: target.prefixOrderIndex;
|
||||
t.setLayer(target.leash, layer);
|
||||
t.show(target.leash);
|
||||
}
|
||||
t.apply();
|
||||
t.setEarlyWakeup();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.util.ArrayList;
|
||||
*/
|
||||
public class RemoteAnimationTargetSet {
|
||||
|
||||
public final RemoteAnimationTargetCompat[] unfilteredApps;
|
||||
public final RemoteAnimationTargetCompat[] apps;
|
||||
|
||||
public RemoteAnimationTargetSet(RemoteAnimationTargetCompat[] apps, int targetMode) {
|
||||
@@ -36,6 +37,7 @@ public class RemoteAnimationTargetSet {
|
||||
}
|
||||
}
|
||||
|
||||
this.unfilteredApps = apps;
|
||||
this.apps = filteredApps.toArray(new RemoteAnimationTargetCompat[filteredApps.size()]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user