Improve widget-activity transition animation for translucent activities
Activities may be translucent. In that case, the widget should not
visually be a part of the activity launch or return animations.
Bug: 169042867
Test: manual
Change-Id: Ifb690672f71854e491fa240a6c7f0d882910a47c
diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
index 1b54211..de9b361 100644
--- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
+++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
@@ -783,7 +783,7 @@
final FloatingWidgetView floatingView = FloatingWidgetView.getFloatingWidgetView(mLauncher,
v, widgetBackgroundBounds,
new Size(windowTargetBounds.width(), windowTargetBounds.height()),
- finalWindowRadius);
+ finalWindowRadius, appTargetsAreTranslucent);
final float initialWindowRadius = supportsRoundedCornersOnWindows(mLauncher.getResources())
? floatingView.getInitialCornerRadius() : 0;
diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
index 25be30f..bdb9fb0 100644
--- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
+++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
@@ -1056,7 +1056,7 @@
}
protected abstract HomeAnimationFactory createHomeAnimationFactory(
- ArrayList<IBinder> launchCookies, long duration);
+ ArrayList<IBinder> launchCookies, long duration, boolean isTargetTranslucent);
private final TaskStackChangeListener mActivityRestartListener = new TaskStackChangeListener() {
@Override
@@ -1100,7 +1100,9 @@
final ArrayList<IBinder> cookies = runningTaskTarget != null
? runningTaskTarget.taskInfo.launchCookies
: new ArrayList<>();
- HomeAnimationFactory homeAnimFactory = createHomeAnimationFactory(cookies, duration);
+ boolean isTranslucent = runningTaskTarget != null && runningTaskTarget.isTranslucent;
+ HomeAnimationFactory homeAnimFactory =
+ createHomeAnimationFactory(cookies, duration, isTranslucent);
mIsSwipingPipToHome = homeAnimFactory.supportSwipePipToHome()
&& runningTaskTarget != null
&& runningTaskTarget.taskInfo.pictureInPictureParams != null
diff --git a/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java b/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java
index 9846ee7..2d81429 100644
--- a/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java
+++ b/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java
@@ -129,7 +129,7 @@
@Override
protected HomeAnimationFactory createHomeAnimationFactory(ArrayList<IBinder> launchCookies,
- long duration) {
+ long duration, boolean isTargetTranslucent) {
mActiveAnimationFactory = new FallbackHomeAnimationFactory(duration);
ActivityOptions options = ActivityOptions.makeCustomAnimation(mContext, 0, 0);
Intent intent = new Intent(mGestureState.getHomeIntent());
diff --git a/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java b/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java
index 46cd8a2..267227d 100644
--- a/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java
+++ b/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java
@@ -80,7 +80,7 @@
@Override
protected HomeAnimationFactory createHomeAnimationFactory(ArrayList<IBinder> launchCookies,
- long duration) {
+ long duration, boolean isTargetTranslucent) {
if (mActivity == null) {
mStateCallback.addChangeListener(STATE_LAUNCHER_PRESENT | STATE_HANDLER_INVALIDATED,
isPresent -> mRecentsView.startHome());
@@ -103,7 +103,8 @@
return new LauncherHomeAnimationFactory();
}
if (workspaceView instanceof LauncherAppWidgetHostView) {
- return createWidgetHomeAnimationFactory((LauncherAppWidgetHostView) workspaceView);
+ return createWidgetHomeAnimationFactory((LauncherAppWidgetHostView) workspaceView,
+ isTargetTranslucent);
}
return createIconHomeAnimationFactory(workspaceView);
}
@@ -235,7 +236,7 @@
}
private HomeAnimationFactory createWidgetHomeAnimationFactory(
- LauncherAppWidgetHostView hostView) {
+ LauncherAppWidgetHostView hostView, boolean isTargetTranslucent) {
RectF backgroundLocation = new RectF();
Rect crop = new Rect();
@@ -243,7 +244,7 @@
Size windowSize = new Size(crop.width(), crop.height());
FloatingWidgetView floatingWidgetView = FloatingWidgetView.getFloatingWidgetView(mActivity,
hostView, backgroundLocation, windowSize,
- mTaskViewSimulator.getCurrentCornerRadius());
+ mTaskViewSimulator.getCurrentCornerRadius(), isTargetTranslucent);
return new LauncherHomeAnimationFactory() {
diff --git a/quickstep/src/com/android/quickstep/views/FloatingWidgetView.java b/quickstep/src/com/android/quickstep/views/FloatingWidgetView.java
index ed54f10..121e094 100644
--- a/quickstep/src/com/android/quickstep/views/FloatingWidgetView.java
+++ b/quickstep/src/com/android/quickstep/views/FloatingWidgetView.java
@@ -57,6 +57,7 @@
private Runnable mEndRunnable;
private Runnable mFastFinishRunnable;
private Runnable mOnTargetChangeRunnable;
+ private boolean mAppTargetIsTranslucent;
public FloatingWidgetView(Context context) {
this(context, null);
@@ -142,10 +143,12 @@
}
private void init(DragLayer dragLayer, LauncherAppWidgetHostView originalView,
- RectF widgetBackgroundPosition, Size windowSize, float windowCornerRadius) {
+ RectF widgetBackgroundPosition, Size windowSize, float windowCornerRadius,
+ boolean appTargetIsTranslucent) {
mAppWidgetView = originalView;
mAppWidgetView.beginDeferringUpdates();
mBackgroundPosition = widgetBackgroundPosition;
+ mAppTargetIsTranslucent = appTargetIsTranslucent;
mEndRunnable = () -> finish(dragLayer);
mAppWidgetBackgroundView = RoundedCornerEnforcement.findBackground(mAppWidgetView);
@@ -155,11 +158,13 @@
getRelativePosition(mAppWidgetBackgroundView, dragLayer, mBackgroundPosition);
getRelativePosition(mAppWidgetBackgroundView, mAppWidgetView, mBackgroundOffset);
- mBackgroundView.init(mAppWidgetView, mAppWidgetBackgroundView, windowCornerRadius);
- // Layout call before GhostView creation so that the overlaid view isn't clipped
- layout(0, 0, windowSize.getWidth(), windowSize.getHeight());
- mForegroundOverlayView = GhostView.addGhost(mAppWidgetView, this);
- positionViews();
+ if (!mAppTargetIsTranslucent) {
+ mBackgroundView.init(mAppWidgetView, mAppWidgetBackgroundView, windowCornerRadius);
+ // Layout call before GhostView creation so that the overlaid view isn't clipped
+ layout(0, 0, windowSize.getWidth(), windowSize.getHeight());
+ mForegroundOverlayView = GhostView.addGhost(mAppWidgetView, this);
+ positionViews();
+ }
mListenerView.setListener(this::fastFinish);
dragLayer.addView(mListenerView);
@@ -179,7 +184,7 @@
*/
public void update(RectF backgroundPosition, float floatingWidgetAlpha, float foregroundAlpha,
float fallbackBackgroundAlpha, float cornerRadiusProgress) {
- if (isUninitialized()) return;
+ if (isUninitialized() || mAppTargetIsTranslucent) return;
setAlpha(floatingWidgetAlpha);
mBackgroundView.update(cornerRadiusProgress, fallbackBackgroundAlpha);
mAppWidgetView.setAlpha(foregroundAlpha);
@@ -203,13 +208,16 @@
backgroundParams.height = (int) mBackgroundPosition.height();
mBackgroundView.setLayoutParams(backgroundParams);
- sTmpMatrix.reset();
- float foregroundScale = mBackgroundPosition.width() / mAppWidgetBackgroundView.getWidth();
- sTmpMatrix.setTranslate(-mBackgroundOffset.left - mAppWidgetView.getLeft(),
- -mBackgroundOffset.top - mAppWidgetView.getTop());
- sTmpMatrix.postScale(foregroundScale, foregroundScale);
- sTmpMatrix.postTranslate(mBackgroundPosition.left, mBackgroundPosition.top);
- mForegroundOverlayView.setMatrix(sTmpMatrix);
+ if (mForegroundOverlayView != null) {
+ sTmpMatrix.reset();
+ float foregroundScale =
+ mBackgroundPosition.width() / mAppWidgetBackgroundView.getWidth();
+ sTmpMatrix.setTranslate(-mBackgroundOffset.left - mAppWidgetView.getLeft(),
+ -mBackgroundOffset.top - mAppWidgetView.getTop());
+ sTmpMatrix.postScale(foregroundScale, foregroundScale);
+ sTmpMatrix.postTranslate(mBackgroundPosition.left, mBackgroundPosition.top);
+ mForegroundOverlayView.setMatrix(sTmpMatrix);
+ }
}
private void finish(DragLayer dragLayer) {
@@ -254,7 +262,7 @@
*/
public static FloatingWidgetView getFloatingWidgetView(Launcher launcher,
LauncherAppWidgetHostView originalView, RectF widgetBackgroundPosition,
- Size windowSize, float windowCornerRadius) {
+ Size windowSize, float windowCornerRadius, boolean appTargetsAreTranslucent) {
final DragLayer dragLayer = launcher.getDragLayer();
ViewGroup parent = (ViewGroup) dragLayer.getParent();
FloatingWidgetView floatingView =
@@ -262,7 +270,7 @@
floatingView.recycle();
floatingView.init(dragLayer, originalView, widgetBackgroundPosition, windowSize,
- windowCornerRadius);
+ windowCornerRadius, appTargetsAreTranslucent);
parent.addView(floatingView);
return floatingView;
}