diff options
| author | Mady Mellor <madym@google.com> | 2020-01-23 12:01:01 -0800 |
|---|---|---|
| committer | Mady Mellor <madym@google.com> | 2020-01-27 13:20:00 -0800 |
| commit | eb049d0b47d9ef81500c957b431042e2fb26f291 (patch) | |
| tree | b75e6ac02ec11666f31788dc2f91d7513277f942 /core/java/android/app/Notification.java | |
| parent | d21c45fc95c64e3139016954bb099e057299037b (diff) | |
Bubble API: add support for URI based icons
I would ultimately like to restrict icons to be TYPE_URI_ADAPTIVE_BITMAP,
however, that would break existing app behaviour. Let's log a warning
and hope that we can change it to be one of the URI based icons in the
future.
Test: atest NotificationManagerTest
Bug: 138943209
Bug: 144352570
Change-Id: I044f035571fcaa817b19d8ff330fb22b4addf970
Diffstat (limited to 'core/java/android/app/Notification.java')
| -rw-r--r-- | core/java/android/app/Notification.java | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 1af275fedd74..b346e8f20feb 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -17,6 +17,8 @@ package android.app; import static android.annotation.Dimension.DP; +import static android.graphics.drawable.Icon.TYPE_URI; +import static android.graphics.drawable.Icon.TYPE_URI_ADAPTIVE_BITMAP; import static com.android.internal.util.ContrastColorUtil.satisfiesTextContrast; @@ -2504,6 +2506,14 @@ public class Notification implements Parcelable } } } + + if (mBubbleMetadata != null && mBubbleMetadata.getBubbleIcon() != null) { + final Icon icon = mBubbleMetadata.getBubbleIcon(); + final int iconType = icon.getType(); + if (iconType == TYPE_URI_ADAPTIVE_BITMAP || iconType == TYPE_URI) { + visitor.accept(icon.getUri()); + } + } } /** @@ -8900,6 +8910,12 @@ public class Notification implements Parcelable if (icon == null) { throw new IllegalArgumentException("Bubbles require non-null icon"); } + if (icon.getType() != TYPE_URI_ADAPTIVE_BITMAP + && icon.getType() != TYPE_URI) { + Log.w(TAG, "Bubbles work best with icons of TYPE_URI or " + + "TYPE_URI_ADAPTIVE_BITMAP. " + + "In the future, using an icon of this type will be required."); + } mShortcutId = null; mPendingIntent = intent; mIcon = icon; |
