mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-19 18:58:19 +00:00
Merge "Crossfading splashscreen if icon is themed" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
55060ca7ea
@@ -583,7 +583,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
|
||||
|
||||
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 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
|
||||
|
||||
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 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
|
||||
: 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());
|
||||
|
||||
@@ -119,7 +119,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
|
||||
};
|
||||
|
||||
private final ActivityContext mActivity;
|
||||
private Drawable mIcon;
|
||||
private FastBitmapDrawable mIcon;
|
||||
private boolean mCenterVertically;
|
||||
|
||||
protected final int mDisplay;
|
||||
@@ -335,16 +335,6 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
@@ -369,7 +359,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
|
||||
}
|
||||
|
||||
/** Returns the icon for this view. */
|
||||
public Drawable getIcon() {
|
||||
public FastBitmapDrawable getIcon() {
|
||||
return mIcon;
|
||||
}
|
||||
|
||||
@@ -704,7 +694,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ import com.android.launcher3.dragndrop.DragLayer;
|
||||
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 @@ public class FloatingIconView extends FrameLayout implements
|
||||
@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();
|
||||
@@ -367,6 +353,13 @@ public class FloatingIconView extends FrameLayout implements
|
||||
invalidate();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 @@ public class FloatingIconView extends FrameLayout implements
|
||||
*/
|
||||
@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 @@ public class FloatingIconView extends FrameLayout implements
|
||||
|
||||
private static class IconLoadResult {
|
||||
final ItemInfo itemInfo;
|
||||
final boolean isThemed;
|
||||
Drawable btvDrawable;
|
||||
Drawable drawable;
|
||||
Drawable badge;
|
||||
@@ -633,8 +643,9 @@ public class FloatingIconView extends FrameLayout implements
|
||||
Runnable onIconLoaded;
|
||||
boolean isIconLoaded;
|
||||
|
||||
IconLoadResult(ItemInfo itemInfo) {
|
||||
IconLoadResult(ItemInfo itemInfo, boolean isThemed) {
|
||||
this.itemInfo = itemInfo;
|
||||
this.isThemed = isThemed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user