summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/graphics
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2018-03-12 11:35:00 -0700
committerSunny Goyal <sunnygoyal@google.com>2018-03-13 09:35:54 -0700
commit038e454df650bada8bc90cced6dd278830fd26b4 (patch)
tree21ccd63ed8c8a6c98302fd371b47d79b1b482804 /src/com/android/launcher3/graphics
parent7eee62b313f2dfb5577e6d0e718e652646fe61f1 (diff)
downloadandroid_packages_apps_Trebuchet-038e454df650bada8bc90cced6dd278830fd26b4.tar.gz
android_packages_apps_Trebuchet-038e454df650bada8bc90cced6dd278830fd26b4.tar.bz2
android_packages_apps_Trebuchet-038e454df650bada8bc90cced6dd278830fd26b4.zip
Using the task primary color as the background for the wrapped icon
Bug: 74445840 Change-Id: I6c6248c8c71cc9b27cbf301e36400a983127da18
Diffstat (limited to 'src/com/android/launcher3/graphics')
-rw-r--r--src/com/android/launcher3/graphics/LauncherIcons.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/com/android/launcher3/graphics/LauncherIcons.java b/src/com/android/launcher3/graphics/LauncherIcons.java
index 2e9ff239f..3b5585bcf 100644
--- a/src/com/android/launcher3/graphics/LauncherIcons.java
+++ b/src/com/android/launcher3/graphics/LauncherIcons.java
@@ -29,11 +29,13 @@ import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
+import android.graphics.Color;
import android.graphics.PaintFlagsDrawFilter;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.AdaptiveIconDrawable;
import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.PaintDrawable;
import android.os.Build;
@@ -60,6 +62,8 @@ import com.android.launcher3.util.Themes;
*/
public class LauncherIcons implements AutoCloseable {
+ private static final int DEFAULT_WRAPPER_BACKGROUND = Color.WHITE;
+
public static final Object sPoolSync = new Object();
private static LauncherIcons sPool;
@@ -84,6 +88,9 @@ public class LauncherIcons implements AutoCloseable {
*/
public void recycle() {
synchronized (sPoolSync) {
+ // Clear any temporary state variables
+ mWrapperBackgroundColor = DEFAULT_WRAPPER_BACKGROUND;
+
next = sPool;
sPool = this;
}
@@ -104,7 +111,9 @@ public class LauncherIcons implements AutoCloseable {
private IconNormalizer mNormalizer;
private ShadowGenerator mShadowGenerator;
+
private Drawable mWrapperIcon;
+ private int mWrapperBackgroundColor = DEFAULT_WRAPPER_BACKGROUND;
// sometimes we store linked lists of these things
private LauncherIcons next;
@@ -222,6 +231,13 @@ public class LauncherIcons implements AutoCloseable {
Math.min(scale[0], ShadowGenerator.getScaleForBounds(iconBounds)));
}
+ /**
+ * Sets the background color used for wrapped adaptive icon
+ */
+ public void setWrapperBackgroundColor(int color) {
+ mWrapperBackgroundColor = (Color.alpha(color) < 255) ? DEFAULT_WRAPPER_BACKGROUND : color;
+ }
+
private Drawable normalizeAndWrapToAdaptiveIcon(Drawable icon, int iconAppTargetSdk,
RectF outIconBounds, float[] outScale) {
float scale = 1f;
@@ -240,6 +256,8 @@ public class LauncherIcons implements AutoCloseable {
fsd.setScale(scale);
icon = dr;
scale = getNormalizer().getScale(icon, outIconBounds, null, null);
+
+ ((ColorDrawable) dr.getBackground()).setColor(mWrapperBackgroundColor);
}
} else {
scale = getNormalizer().getScale(icon, outIconBounds, null, null);