Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eb049d0b authored by Mady Mellor's avatar Mady Mellor
Browse files

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
parent d21c45fc
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -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;