Crossfading splashscreen if icon is themed
Bug: 188840653
Test: Manual
Change-Id: Ibd00bb1a94576a7512872eba39a936c174f9871d
diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
index ec77b9b..3aa758f 100644
--- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
+++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
@@ -583,7 +583,7 @@
AnimOpenProperties prop = new AnimOpenProperties(mLauncher.getResources(), mDeviceProfile,
windowTargetBounds, launcherIconBounds, v, dragLayerBounds[0], dragLayerBounds[1],
- hasSplashScreen);
+ hasSplashScreen, floatingView.isDifferentFromAppIcon());
int left = (int) (prop.cropCenterXStart - prop.cropWidthStart / 2);
int top = (int) (prop.cropCenterYStart - prop.cropHeightStart / 2);
int right = (int) (left + prop.cropWidthStart);
@@ -1327,7 +1327,7 @@
AnimOpenProperties(Resources r, DeviceProfile dp, Rect windowTargetBounds,
RectF launcherIconBounds, View view, int dragLayerLeft, int dragLayerTop,
- boolean hasSplashScreen) {
+ boolean hasSplashScreen, boolean hasDifferentAppIcon) {
// Scale the app icon to take up the entire screen. This simplifies the math when
// animating the app window position / scale.
float smallestSize = Math.min(windowTargetBounds.height(), windowTargetBounds.width());
@@ -1359,8 +1359,7 @@
: APP_LAUNCH_DOWN_CURVED_DURATION;
alphaDuration = useUpwardAnimation ? APP_LAUNCH_ALPHA_DURATION
: APP_LAUNCH_ALPHA_DOWN_DURATION;
-
- iconAlphaStart = hasSplashScreen ? 0 : 1f;
+ iconAlphaStart = hasSplashScreen && !hasDifferentAppIcon ? 0 : 1f;
// TOOD: Share value from shell when available.
final float windowIconSize = Utilities.pxFromSp(108, r.getDisplayMetrics());
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index 7866786..4f0ef12 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -119,7 +119,7 @@
};
private final ActivityContext mActivity;
- private Drawable mIcon;
+ private FastBitmapDrawable mIcon;
private boolean mCenterVertically;
protected final int mDisplay;
@@ -336,16 +336,6 @@
}
/**
- * Directly set the icon and label.
- */
- @UiThread
- public void applyIconAndLabel(Drawable icon, CharSequence label) {
- setIcon(icon);
- setText(label);
- setContentDescription(label);
- }
-
- /**
* Overrides the default long press timeout.
*/
public void setLongPressTimeoutFactor(float longPressTimeoutFactor) {
@@ -369,7 +359,7 @@
}
/** Returns the icon for this view. */
- public Drawable getIcon() {
+ public FastBitmapDrawable getIcon() {
return mIcon;
}
@@ -704,7 +694,7 @@
/**
* Sets the icon for this view based on the layout direction.
*/
- protected void setIcon(Drawable icon) {
+ protected void setIcon(FastBitmapDrawable icon) {
if (mIsIconVisible) {
applyCompoundDrawables(icon);
}
diff --git a/src/com/android/launcher3/views/FloatingIconView.java b/src/com/android/launcher3/views/FloatingIconView.java
index f973c2b..25cce69 100644
--- a/src/com/android/launcher3/views/FloatingIconView.java
+++ b/src/com/android/launcher3/views/FloatingIconView.java
@@ -52,6 +52,7 @@
import com.android.launcher3.dragndrop.FolderAdaptiveIcon;
import com.android.launcher3.folder.FolderIcon;
import com.android.launcher3.graphics.PreloadIconDrawable;
+import com.android.launcher3.icons.FastBitmapDrawable;
import com.android.launcher3.icons.LauncherIcons;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.ItemInfoWithIcon;
@@ -250,27 +251,12 @@
@WorkerThread
@SuppressWarnings("WrongThread")
private static void getIconResult(Launcher l, View originalView, ItemInfo info, RectF pos,
- IconLoadResult iconLoadResult) {
+ Drawable btvIcon, IconLoadResult iconLoadResult) {
Drawable drawable;
- Drawable btvIcon;
- Drawable badge = null;
boolean supportsAdaptiveIcons = ADAPTIVE_ICON_WINDOW_ANIM.get()
&& !info.isDisabled(); // Use original icon for disabled icons.
- if (originalView instanceof BubbleTextView) {
- BubbleTextView btv = (BubbleTextView) originalView;
-
- if (info instanceof ItemInfoWithIcon
- && (((ItemInfoWithIcon) info).runtimeStatusFlags
- & ItemInfoWithIcon.FLAG_SHOW_DOWNLOAD_PROGRESS_MASK) != 0) {
- btvIcon = btv.makePreloadIcon();
- } else {
- btvIcon = btv.getIcon();
- }
- } else {
- btvIcon = null;
- }
-
+ Drawable badge = null;
if (info instanceof SystemShortcut) {
if (originalView instanceof ImageView) {
drawable = ((ImageView) originalView).getDrawable();
@@ -368,6 +354,13 @@
}
/**
+ * Returns true if the icon is different from main app icon
+ */
+ public boolean isDifferentFromAppIcon() {
+ return mIconLoadResult == null ? false : mIconLoadResult.isThemed;
+ }
+
+ /**
* Checks if the icon result is loaded. If true, we set the icon immediately. Else, we add a
* callback to set the icon once the icon result is loaded.
*/
@@ -505,12 +498,28 @@
*/
@UiThread
public static IconLoadResult fetchIcon(Launcher l, View v, ItemInfo info, boolean isOpening) {
- IconLoadResult result = new IconLoadResult(info);
- MODEL_EXECUTOR.getHandler().postAtFrontOfQueue(() -> {
- RectF position = new RectF();
- getLocationBoundsForView(l, v, isOpening, position);
- getIconResult(l, v, info, position, result);
- });
+ RectF position = new RectF();
+ getLocationBoundsForView(l, v, isOpening, position);
+
+ final FastBitmapDrawable btvIcon;
+ if (v instanceof BubbleTextView) {
+ BubbleTextView btv = (BubbleTextView) v;
+ if (info instanceof ItemInfoWithIcon
+ && (((ItemInfoWithIcon) info).runtimeStatusFlags
+ & ItemInfoWithIcon.FLAG_SHOW_DOWNLOAD_PROGRESS_MASK) != 0) {
+ btvIcon = btv.makePreloadIcon();
+ } else {
+ btvIcon = btv.getIcon();
+ }
+ } else {
+ btvIcon = null;
+ }
+
+ IconLoadResult result = new IconLoadResult(info,
+ btvIcon == null ? false : btvIcon.isThemed());
+
+ MODEL_EXECUTOR.getHandler().postAtFrontOfQueue(() ->
+ getIconResult(l, v, info, position, btvIcon, result));
sIconLoadResult = result;
return result;
@@ -626,6 +635,7 @@
private static class IconLoadResult {
final ItemInfo itemInfo;
+ final boolean isThemed;
Drawable btvDrawable;
Drawable drawable;
Drawable badge;
@@ -633,8 +643,9 @@
Runnable onIconLoaded;
boolean isIconLoaded;
- IconLoadResult(ItemInfo itemInfo) {
+ IconLoadResult(ItemInfo itemInfo, boolean isThemed) {
this.itemInfo = itemInfo;
+ this.isThemed = isThemed;
}
}
}