Merge "Add themed work badge for themed icons in dragview or floatingiconview" into udc-qpr-dev am: d2d1942b27
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/23786528 Change-Id: I6fa18fc1ecf2b8c269ff7db517118c7bef360096 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -569,12 +569,13 @@ public final class Utilities {
|
||||
*/
|
||||
@TargetApi(Build.VERSION_CODES.TIRAMISU)
|
||||
public static Drawable getFullDrawable(Context context, ItemInfo info, int width, int height,
|
||||
boolean shouldThemeIcon, Object[] outObj) {
|
||||
boolean shouldThemeIcon, Object[] outObj, boolean[] outIsIconThemed) {
|
||||
Drawable icon = loadFullDrawableWithoutTheme(context, info, width, height, outObj);
|
||||
if (ATLEAST_T && icon instanceof AdaptiveIconDrawable && shouldThemeIcon) {
|
||||
AdaptiveIconDrawable aid = (AdaptiveIconDrawable) icon.mutate();
|
||||
Drawable mono = aid.getMonochrome();
|
||||
if (mono != null && Themes.isThemedIconEnabled(context)) {
|
||||
outIsIconThemed[0] = true;
|
||||
int[] colors = ThemedIconDrawable.getColors(context);
|
||||
mono = mono.mutate();
|
||||
mono.setTint(colors[1]);
|
||||
@@ -635,7 +636,8 @@ public final class Utilities {
|
||||
* badge. When dragged from workspace or folder, it may contain app AND/OR work profile badge
|
||||
**/
|
||||
@TargetApi(Build.VERSION_CODES.O)
|
||||
public static Drawable getBadge(Context context, ItemInfo info, Object obj) {
|
||||
public static Drawable getBadge(Context context, ItemInfo info, Object obj,
|
||||
boolean isIconThemed) {
|
||||
LauncherAppState appState = LauncherAppState.getInstance(context);
|
||||
if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) {
|
||||
boolean iconBadged = (info instanceof ItemInfoWithIcon)
|
||||
@@ -653,7 +655,8 @@ public final class Utilities {
|
||||
} else {
|
||||
return Process.myUserHandle().equals(info.user)
|
||||
? new ColorDrawable(Color.TRANSPARENT)
|
||||
: context.getDrawable(R.drawable.ic_work_app_badge);
|
||||
: context.getDrawable(isIconThemed
|
||||
? R.drawable.ic_work_app_badge_themed : R.drawable.ic_work_app_badge);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -224,11 +224,11 @@ public abstract class DragView<T extends Context & ActivityContext> extends Fram
|
||||
// Load the adaptive icon on a background thread and add the view in ui thread.
|
||||
MODEL_EXECUTOR.getHandler().postAtFrontOfQueue(() -> {
|
||||
Object[] outObj = new Object[1];
|
||||
boolean[] outIsIconThemed = new boolean[1];
|
||||
int w = mWidth;
|
||||
int h = mHeight;
|
||||
Drawable dr = Utilities.getFullDrawable(mActivity, info, w, h,
|
||||
true /* shouldThemeIcon */, outObj);
|
||||
|
||||
true /* shouldThemeIcon */, outObj, outIsIconThemed);
|
||||
if (dr instanceof AdaptiveIconDrawable) {
|
||||
int blurMargin = (int) mActivity.getResources()
|
||||
.getDimension(R.dimen.blur_size_medium_outline) / 2;
|
||||
@@ -237,7 +237,7 @@ public abstract class DragView<T extends Context & ActivityContext> extends Fram
|
||||
bounds.inset(blurMargin, blurMargin);
|
||||
// Badge is applied after icon normalization so the bounds for badge should not
|
||||
// be scaled down due to icon normalization.
|
||||
mBadge = getBadge(mActivity, info, outObj[0]);
|
||||
mBadge = getBadge(mActivity, info, outObj[0], outIsIconThemed[0]);
|
||||
FastBitmapDrawable.setBadgeBounds(mBadge, bounds);
|
||||
|
||||
// Do not draw the background in case of folder as its translucent
|
||||
|
||||
@@ -289,12 +289,14 @@ public class FloatingIconView extends FrameLayout implements
|
||||
int width = (int) pos.width();
|
||||
int height = (int) pos.height();
|
||||
Object[] tmpObjArray = new Object[1];
|
||||
boolean[] outIsIconThemed = new boolean[1];
|
||||
if (supportsAdaptiveIcons) {
|
||||
boolean shouldThemeIcon = btvIcon instanceof FastBitmapDrawable
|
||||
&& ((FastBitmapDrawable) btvIcon).isThemed();
|
||||
drawable = getFullDrawable(l, info, width, height, shouldThemeIcon, tmpObjArray);
|
||||
drawable = getFullDrawable(
|
||||
l, info, width, height, shouldThemeIcon, tmpObjArray, outIsIconThemed);
|
||||
if (drawable instanceof AdaptiveIconDrawable) {
|
||||
badge = getBadge(l, info, tmpObjArray[0]);
|
||||
badge = getBadge(l, info, tmpObjArray[0], outIsIconThemed[0]);
|
||||
} else {
|
||||
// The drawable we get back is not an adaptive icon, so we need to use the
|
||||
// BubbleTextView icon that is already legacy treated.
|
||||
@@ -306,7 +308,7 @@ public class FloatingIconView extends FrameLayout implements
|
||||
drawable = btvIcon;
|
||||
} else {
|
||||
drawable = getFullDrawable(l, info, width, height, true /* shouldThemeIcon */,
|
||||
tmpObjArray);
|
||||
tmpObjArray, outIsIconThemed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user