mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-03 09:26:51 +00:00
Use the splash screen background color as the fallback background color
For the widget transition animation fallback background color, use either the splash screen background color if a task is starting or the task description-attached background color. With a background in place, allow the window to fully fade out before fading in the widget, by moving the window alpha math into an animation factory-specific implementation. Bug: 187706750 Test: Manual Change-Id: I2b5a7783b0585d447ad60534bc48d2e2176877ed
This commit is contained in:
@@ -214,8 +214,9 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
|
||||
}
|
||||
};
|
||||
|
||||
// Pairs of window starting type and starting window background color for starting tasks
|
||||
// Will never be larger than MAX_NUM_TASKS
|
||||
private LinkedHashMap<Integer, Integer> mTypeForTaskId;
|
||||
private LinkedHashMap<Integer, Pair<Integer, Integer>> mTaskStartParams;
|
||||
|
||||
public QuickstepTransitionManager(Context context) {
|
||||
mLauncher = Launcher.cast(Launcher.getLauncher(context));
|
||||
@@ -232,9 +233,9 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
|
||||
mLauncher.addOnDeviceProfileChangeListener(this);
|
||||
|
||||
if (supportsSSplashScreen()) {
|
||||
mTypeForTaskId = new LinkedHashMap<Integer, Integer>(MAX_NUM_TASKS) {
|
||||
mTaskStartParams = new LinkedHashMap<Integer, Pair<Integer, Integer>>(MAX_NUM_TASKS) {
|
||||
@Override
|
||||
protected boolean removeEldestEntry(Entry<Integer, Integer> entry) {
|
||||
protected boolean removeEldestEntry(Entry<Integer, Pair<Integer, Integer>> entry) {
|
||||
return size() > MAX_NUM_TASKS;
|
||||
}
|
||||
};
|
||||
@@ -420,15 +421,6 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
|
||||
return bounds;
|
||||
}
|
||||
|
||||
private int getOpeningTaskId(RemoteAnimationTargetCompat[] appTargets) {
|
||||
for (RemoteAnimationTargetCompat target : appTargets) {
|
||||
if (target.mode == MODE_OPENING) {
|
||||
return target.taskId;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void setRemoteAnimationProvider(final RemoteAnimationProvider animationProvider,
|
||||
CancellationSignal cancellationSignal) {
|
||||
mRemoteAnimationProvider = animationProvider;
|
||||
@@ -595,10 +587,12 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
|
||||
|
||||
final boolean hasSplashScreen;
|
||||
if (supportsSSplashScreen()) {
|
||||
int taskId = getOpeningTaskId(appTargets);
|
||||
int type = mTypeForTaskId.getOrDefault(taskId, STARTING_WINDOW_TYPE_NONE);
|
||||
mTypeForTaskId.remove(taskId);
|
||||
hasSplashScreen = type == STARTING_WINDOW_TYPE_SPLASH_SCREEN;
|
||||
int taskId = openingTargets.getFirstAppTargetTaskId();
|
||||
Pair<Integer, Integer> defaultParams = Pair.create(STARTING_WINDOW_TYPE_NONE, 0);
|
||||
Pair<Integer, Integer> taskParams =
|
||||
mTaskStartParams.getOrDefault(taskId, defaultParams);
|
||||
mTaskStartParams.remove(taskId);
|
||||
hasSplashScreen = taskParams.first == STARTING_WINDOW_TYPE_SPLASH_SCREEN;
|
||||
} else {
|
||||
hasSplashScreen = false;
|
||||
}
|
||||
@@ -799,18 +793,30 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
|
||||
final RectF widgetBackgroundBounds = new RectF();
|
||||
final Rect appWindowCrop = new Rect();
|
||||
final Matrix matrix = new Matrix();
|
||||
RemoteAnimationTargets openingTargets = new RemoteAnimationTargets(appTargets,
|
||||
wallpaperTargets, nonAppTargets, MODE_OPENING);
|
||||
|
||||
RemoteAnimationTargetCompat openingTarget = openingTargets.getFirstAppTarget();
|
||||
int fallbackBackgroundColor = 0;
|
||||
if (openingTarget != null && supportsSSplashScreen()) {
|
||||
fallbackBackgroundColor = mTaskStartParams.containsKey(openingTarget.taskId)
|
||||
? mTaskStartParams.get(openingTarget.taskId).second : 0;
|
||||
mTaskStartParams.remove(openingTarget.taskId);
|
||||
}
|
||||
if (fallbackBackgroundColor == 0) {
|
||||
fallbackBackgroundColor =
|
||||
FloatingWidgetView.getDefaultBackgroundColor(mLauncher, openingTarget);
|
||||
}
|
||||
|
||||
final float finalWindowRadius = mDeviceProfile.isMultiWindowMode
|
||||
? 0 : getWindowCornerRadius(mLauncher.getResources());
|
||||
final FloatingWidgetView floatingView = FloatingWidgetView.getFloatingWidgetView(mLauncher,
|
||||
v, widgetBackgroundBounds,
|
||||
new Size(windowTargetBounds.width(), windowTargetBounds.height()),
|
||||
finalWindowRadius, appTargetsAreTranslucent);
|
||||
finalWindowRadius, appTargetsAreTranslucent, fallbackBackgroundColor);
|
||||
final float initialWindowRadius = supportsRoundedCornersOnWindows(mLauncher.getResources())
|
||||
? floatingView.getInitialCornerRadius() : 0;
|
||||
|
||||
RemoteAnimationTargets openingTargets = new RemoteAnimationTargets(appTargets,
|
||||
wallpaperTargets, nonAppTargets, MODE_OPENING);
|
||||
SurfaceTransactionApplier surfaceApplier = new SurfaceTransactionApplier(floatingView);
|
||||
openingTargets.addReleaseCheck(surfaceApplier);
|
||||
|
||||
@@ -1434,8 +1440,8 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTaskLaunching(int taskId, int supportedType) {
|
||||
mTransitionManager.mTypeForTaskId.put(taskId, supportedType);
|
||||
public void onTaskLaunching(int taskId, int supportedType, int color) {
|
||||
mTransitionManager.mTaskStartParams.put(taskId, Pair.create(supportedType, color));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user