From 05e860bef32d9b52e3735b9180181e08f6b78639 Mon Sep 17 00:00:00 2001 From: Mady Mellor Date: Wed, 30 Oct 2019 22:48:15 -0700 Subject: [PATCH] Bubble icon improvements * The tinting logic isn't good for developers, this change removes that logic and respsects whatever icon they provide, HOWEVER, if it is not adaptive it gets put on an adapative shape, consistent with launcher * Updates the dot colour to be based on colour sample from the app icon bitmap rather than the notification colour, consistent with launcher * Updates Notification documentation to reflect changes Test: manual with Bubbles test app (options for all the icon types) Bug: 138943209 Change-Id: I8abfcef9ac1dcdd9f74643e84ef40a97385b744b --- core/java/android/app/Notification.java | 17 +-- packages/SystemUI/res/values/dimens.xml | 2 - .../com/android/systemui/bubbles/Bubble.java | 5 +- .../systemui/bubbles/BubbleStackView.java | 2 +- .../android/systemui/bubbles/BubbleView.java | 131 +++++++----------- 5 files changed, 61 insertions(+), 96 deletions(-) diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index efb9f6bb88f11..47118a81632e9 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -17,7 +17,6 @@ package android.app; import static android.annotation.Dimension.DP; -import static android.graphics.drawable.Icon.TYPE_BITMAP; import static com.android.internal.util.ContrastColorUtil.satisfiesTextContrast; @@ -8741,26 +8740,20 @@ public class Notification implements Parcelable * If your app produces multiple bubbles, the image should be unique for each of them. *

* - *

The shape of a bubble icon is adaptive and can match the device theme. + *

The shape of a bubble icon is adaptive and will match the device theme. * - * If your icon is bitmap-based, you should create it using - * {@link Icon#createWithAdaptiveBitmap(Bitmap)}, otherwise this method will throw. - * - * If your icon is not bitmap-based, you should expect that the icon will be tinted. + * Ideally your icon should be constructed via + * {@link Icon#createWithAdaptiveBitmap(Bitmap)}, otherwise, the icon will be shrunk + * and placed on an adaptive shape. *

* - * @throws IllegalArgumentException if icon is null or a non-adaptive bitmap + * @throws IllegalArgumentException if icon is null. */ @NonNull public BubbleMetadata.Builder setIcon(@NonNull Icon icon) { if (icon == null) { throw new IllegalArgumentException("Bubbles require non-null icon"); } - if (icon.getType() == TYPE_BITMAP) { - throw new IllegalArgumentException("When using bitmap based icons, Bubbles " - + "require TYPE_ADAPTIVE_BITMAP, please use" - + " Icon#createWithAdaptiveBitmap instead"); - } mIcon = icon; return this; } diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index 14371fe4b41bf..64b2892efc9a7 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -1120,8 +1120,6 @@ 12dp 52dp - - 16dp 4dp