mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-01 16:26:47 +00:00
Merge "Improve widget-activity transition animation for translucent activities" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
6015c3fb03
@@ -783,7 +783,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
|
||||
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;
|
||||
|
||||
|
||||
@@ -1047,7 +1047,7 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
|
||||
}
|
||||
|
||||
protected abstract HomeAnimationFactory createHomeAnimationFactory(
|
||||
ArrayList<IBinder> launchCookies, long duration);
|
||||
ArrayList<IBinder> launchCookies, long duration, boolean isTargetTranslucent);
|
||||
|
||||
private final TaskStackChangeListener mActivityRestartListener = new TaskStackChangeListener() {
|
||||
@Override
|
||||
@@ -1091,7 +1091,9 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
|
||||
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
|
||||
|
||||
@@ -129,7 +129,7 @@ public class FallbackSwipeHandler extends
|
||||
|
||||
@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());
|
||||
|
||||
@@ -80,7 +80,7 @@ public class LauncherSwipeHandlerV2 extends
|
||||
|
||||
@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 @@ public class LauncherSwipeHandlerV2 extends
|
||||
return new LauncherHomeAnimationFactory();
|
||||
}
|
||||
if (workspaceView instanceof LauncherAppWidgetHostView) {
|
||||
return createWidgetHomeAnimationFactory((LauncherAppWidgetHostView) workspaceView);
|
||||
return createWidgetHomeAnimationFactory((LauncherAppWidgetHostView) workspaceView,
|
||||
isTargetTranslucent);
|
||||
}
|
||||
return createIconHomeAnimationFactory(workspaceView);
|
||||
}
|
||||
@@ -235,7 +236,7 @@ public class LauncherSwipeHandlerV2 extends
|
||||
}
|
||||
|
||||
private HomeAnimationFactory createWidgetHomeAnimationFactory(
|
||||
LauncherAppWidgetHostView hostView) {
|
||||
LauncherAppWidgetHostView hostView, boolean isTargetTranslucent) {
|
||||
|
||||
RectF backgroundLocation = new RectF();
|
||||
Rect crop = new Rect();
|
||||
@@ -243,7 +244,7 @@ public class LauncherSwipeHandlerV2 extends
|
||||
Size windowSize = new Size(crop.width(), crop.height());
|
||||
FloatingWidgetView floatingWidgetView = FloatingWidgetView.getFloatingWidgetView(mActivity,
|
||||
hostView, backgroundLocation, windowSize,
|
||||
mTaskViewSimulator.getCurrentCornerRadius());
|
||||
mTaskViewSimulator.getCurrentCornerRadius(), isTargetTranslucent);
|
||||
|
||||
return new LauncherHomeAnimationFactory() {
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@ public class FloatingWidgetView extends FrameLayout implements AnimatorListener,
|
||||
private Runnable mEndRunnable;
|
||||
private Runnable mFastFinishRunnable;
|
||||
private Runnable mOnTargetChangeRunnable;
|
||||
private boolean mAppTargetIsTranslucent;
|
||||
|
||||
public FloatingWidgetView(Context context) {
|
||||
this(context, null);
|
||||
@@ -142,10 +143,12 @@ public class FloatingWidgetView extends FrameLayout implements AnimatorListener,
|
||||
}
|
||||
|
||||
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 @@ public class FloatingWidgetView extends FrameLayout implements AnimatorListener,
|
||||
|
||||
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 class FloatingWidgetView extends FrameLayout implements AnimatorListener,
|
||||
*/
|
||||
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 @@ public class FloatingWidgetView extends FrameLayout implements AnimatorListener,
|
||||
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 class FloatingWidgetView extends FrameLayout implements AnimatorListener,
|
||||
*/
|
||||
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 @@ public class FloatingWidgetView extends FrameLayout implements AnimatorListener,
|
||||
floatingView.recycle();
|
||||
|
||||
floatingView.init(dragLayer, originalView, widgetBackgroundPosition, windowSize,
|
||||
windowCornerRadius);
|
||||
windowCornerRadius, appTargetsAreTranslucent);
|
||||
parent.addView(floatingView);
|
||||
return floatingView;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user