summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/widget
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2017-12-19 16:49:24 -0800
committerSunny Goyal <sunnygoyal@google.com>2018-01-03 16:55:58 -0800
commit179249d804e103625cd95c4265db83ab9828ad5a (patch)
tree510fa44c2f9167523a52cd7c36755d0e383fad5d /src/com/android/launcher3/widget
parent8c3c9d26347b5b860f9cd57a8d0b885daaae3c60 (diff)
downloadandroid_packages_apps_Trebuchet-179249d804e103625cd95c4265db83ab9828ad5a.tar.gz
android_packages_apps_Trebuchet-179249d804e103625cd95c4265db83ab9828ad5a.tar.bz2
android_packages_apps_Trebuchet-179249d804e103625cd95c4265db83ab9828ad5a.zip
Dominant color is part of icon cache
> Calculating extracted color during icon generation and storing it in model and DB > Removing unused logic avoid various types of badge rendering > Icons are badged with extracted colors, while folder is badged with theme color Bug: 35428783 Change-Id: I93e30c52fbded7515c3ae1778422e84672eafb56
Diffstat (limited to 'src/com/android/launcher3/widget')
-rw-r--r--src/com/android/launcher3/widget/PendingAppWidgetHostView.java29
1 files changed, 9 insertions, 20 deletions
diff --git a/src/com/android/launcher3/widget/PendingAppWidgetHostView.java b/src/com/android/launcher3/widget/PendingAppWidgetHostView.java
index 24bcebb2e..697083336 100644
--- a/src/com/android/launcher3/widget/PendingAppWidgetHostView.java
+++ b/src/com/android/launcher3/widget/PendingAppWidgetHostView.java
@@ -58,8 +58,6 @@ public class PendingAppWidgetHostView extends LauncherAppWidgetHostView
private final int mStartState;
private final boolean mDisabledForSafeMode;
- private Bitmap mIcon;
-
private Drawable mCenterDrawable;
private Drawable mSettingIconDrawable;
@@ -129,53 +127,44 @@ public class PendingAppWidgetHostView extends LauncherAppWidgetHostView
@Override
public void reapplyItemInfo(ItemInfoWithIcon info) {
- Bitmap icon = info.iconBitmap;
- if (mIcon == icon) {
- return;
- }
- mIcon = icon;
if (mCenterDrawable != null) {
mCenterDrawable.setCallback(null);
mCenterDrawable = null;
}
- if (mIcon != null) {
+ if (info.iconBitmap != null) {
// The view displays three modes,
// 1) App icon in the center
// 2) Preload icon in the center
// 3) Setup icon in the center and app icon in the top right corner.
DrawableFactory drawableFactory = DrawableFactory.get(getContext());
if (mDisabledForSafeMode) {
- FastBitmapDrawable disabledIcon = drawableFactory.newIcon(mIcon, mInfo);
+ FastBitmapDrawable disabledIcon = drawableFactory.newIcon(info);
disabledIcon.setIsDisabled(true);
mCenterDrawable = disabledIcon;
mSettingIconDrawable = null;
} else if (isReadyForClickSetup()) {
- mCenterDrawable = drawableFactory.newIcon(mIcon, mInfo);
+ mCenterDrawable = drawableFactory.newIcon(info);
mSettingIconDrawable = getResources().getDrawable(R.drawable.ic_setting).mutate();
-
- updateSettingColor();
+ updateSettingColor(info.iconColor);
} else {
mCenterDrawable = DrawableFactory.get(getContext())
- .newPendingIcon(mIcon, getContext());
- mCenterDrawable.setCallback(this);
+ .newPendingIcon(info, getContext());
mSettingIconDrawable = null;
applyState();
}
+ mCenterDrawable.setCallback(this);
mDrawableSizeChanged = true;
}
invalidate();
}
- private void updateSettingColor() {
- int color = Utilities.findDominantColorByHue(mIcon, 20);
+ private void updateSettingColor(int dominantColor) {
// Make the dominant color bright.
float[] hsv = new float[3];
- Color.colorToHSV(color, hsv);
+ Color.colorToHSV(dominantColor, hsv);
hsv[1] = Math.min(hsv[1], MIN_SATUNATION);
hsv[2] = 1;
- color = Color.HSVToColor(hsv);
-
- mSettingIconDrawable.setColorFilter(color, PorterDuff.Mode.SRC_IN);
+ mSettingIconDrawable.setColorFilter(Color.HSVToColor(hsv), PorterDuff.Mode.SRC_IN);
}
@Override