Add a shadow to the app badge
Test: manual - post a bubble, observe a slight shadow on the app badge
Bug: 129158983
Change-Id: Ia87c5b2ccc2e556ef88c6605c4f782f14c0fd4ed
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleIconFactory.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleIconFactory.java
index dc38d59..ac5fd60 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleIconFactory.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleIconFactory.java
@@ -28,4 +28,9 @@
protected BubbleIconFactory(Context context, int iconBitmapSize) {
super(context, context.getResources().getConfiguration().densityDpi, iconBitmapSize);
}
+
+ public int getBadgeSize() {
+ return mContext.getResources().getDimensionPixelSize(
+ com.android.launcher3.icons.R.dimen.profile_badge_size);
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleView.java
index 4176738..be4d20b 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleView.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleView.java
@@ -20,10 +20,12 @@
import android.app.Notification;
import android.content.Context;
import android.graphics.Bitmap;
+import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Path;
import android.graphics.drawable.AdaptiveIconDrawable;
+import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Icon;
@@ -33,6 +35,7 @@
import android.widget.FrameLayout;
import com.android.internal.graphics.ColorUtils;
+import com.android.launcher3.icons.ShadowGenerator;
import com.android.systemui.Interpolators;
import com.android.systemui.R;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
@@ -235,7 +238,17 @@
Bitmap bubbleIcon = mBubbleIconFactory.createBadgedIconBitmap(iconDrawable,
null /* user */,
true /* shrinkNonAdaptiveIcons */).icon;
- mBubbleIconFactory.badgeWithDrawable(bubbleIcon, mUserBadgedAppIcon);
+
+ // Give it a shadow
+ Bitmap userBadgedBitmap = mBubbleIconFactory.createIconBitmap(mUserBadgedAppIcon,
+ 1f, mBubbleIconFactory.getBadgeSize());
+ Canvas c = new Canvas();
+ ShadowGenerator shadowGenerator = new ShadowGenerator(mBubbleIconFactory.getBadgeSize());
+ c.setBitmap(userBadgedBitmap);
+ shadowGenerator.recreateIcon(Bitmap.createBitmap(userBadgedBitmap), c);
+
+ mBubbleIconFactory.badgeWithDrawable(bubbleIcon,
+ new BitmapDrawable(mContext.getResources(), userBadgedBitmap));
mBadgedImageView.setImageBitmap(bubbleIcon);
// Update badge.