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

Commit 5c9cd687 authored by Mady Mellor's avatar Mady Mellor Committed by Android (Google) Code Review
Browse files

Merge "Add API so apps can know when a user dismisses a bubble"

parents d197bbf4 1ab4aa8b
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -5473,6 +5473,7 @@ package android.app {
  public static final class Notification.BubbleMetadata implements android.os.Parcelable {
    method public int describeContents();
    method public boolean getAutoExpandBubble();
    method public android.app.PendingIntent getDeleteIntent();
    method public int getDesiredHeight();
    method public android.graphics.drawable.Icon getIcon();
    method public android.app.PendingIntent getIntent();
@@ -5486,6 +5487,7 @@ package android.app {
    ctor public Notification.BubbleMetadata.Builder();
    method public android.app.Notification.BubbleMetadata build();
    method public android.app.Notification.BubbleMetadata.Builder setAutoExpandBubble(boolean);
    method public android.app.Notification.BubbleMetadata.Builder setDeleteIntent(android.app.PendingIntent);
    method public android.app.Notification.BubbleMetadata.Builder setDesiredHeight(int);
    method public android.app.Notification.BubbleMetadata.Builder setIcon(android.graphics.drawable.Icon);
    method public android.app.Notification.BubbleMetadata.Builder setIntent(android.app.PendingIntent);
+30 −4
Original line number Diff line number Diff line
@@ -8408,6 +8408,7 @@ public class Notification implements Parcelable
    public static final class BubbleMetadata implements Parcelable {

        private PendingIntent mPendingIntent;
        private PendingIntent mDeleteIntent;
        private CharSequence mTitle;
        private Icon mIcon;
        private int mDesiredHeight;
@@ -8436,11 +8437,13 @@ public class Notification implements Parcelable
         */
        private static final int FLAG_SUPPRESS_INITIAL_NOTIFICATION = 0x00000002;

        private BubbleMetadata(PendingIntent intent, CharSequence title, Icon icon, int height) {
            mPendingIntent = intent;
        private BubbleMetadata(PendingIntent expandIntent, PendingIntent deleteIntent,
                CharSequence title, Icon icon, int height) {
            mPendingIntent = expandIntent;
            mTitle = title;
            mIcon = icon;
            mDesiredHeight = height;
            mDeleteIntent = deleteIntent;
        }

        private BubbleMetadata(Parcel in) {
@@ -8449,6 +8452,9 @@ public class Notification implements Parcelable
            mIcon = Icon.CREATOR.createFromParcel(in);
            mDesiredHeight = in.readInt();
            mFlags = in.readInt();
            if (in.readInt() != 0) {
                mDeleteIntent = PendingIntent.CREATOR.createFromParcel(in);
            }
        }

        /**
@@ -8458,6 +8464,13 @@ public class Notification implements Parcelable
            return mPendingIntent;
        }

        /**
         * @return the pending intent to send when the bubble is dismissed by a user, if one exists.
         */
        public PendingIntent getDeleteIntent() {
            return mDeleteIntent;
        }

        /**
         * @return the title that will appear along with the app content defined by
         * {@link #getIntent()} for this bubble.
@@ -8525,6 +8538,10 @@ public class Notification implements Parcelable
            mIcon.writeToParcel(out, 0);
            out.writeInt(mDesiredHeight);
            out.writeInt(mFlags);
            out.writeInt(mDeleteIntent != null ? 1 : 0);
            if (mDeleteIntent != null) {
                mDeleteIntent.writeToParcel(out, 0);
            }
        }

        private void setFlags(int flags) {
@@ -8541,6 +8558,7 @@ public class Notification implements Parcelable
            private Icon mIcon;
            private int mDesiredHeight;
            private int mFlags;
            private PendingIntent mDeleteIntent;

            /**
             * Constructs a new builder object.
@@ -8632,6 +8650,14 @@ public class Notification implements Parcelable
                return this;
            }

            /**
             * Sets an optional intent to send when this bubble is explicitly removed by the user.
             */
            public BubbleMetadata.Builder setDeleteIntent(PendingIntent deleteIntent) {
                mDeleteIntent = deleteIntent;
                return this;
            }

            /**
             * Creates the {@link BubbleMetadata} defined by this builder.
             * <p>Will throw {@link IllegalStateException} if required fields have not been set
@@ -8647,8 +8673,8 @@ public class Notification implements Parcelable
                if (mIcon == null) {
                    throw new IllegalStateException("Must supply an icon for the bubble");
                }
                BubbleMetadata data = new BubbleMetadata(mPendingIntent, mTitle, mIcon,
                        mDesiredHeight);
                BubbleMetadata data = new BubbleMetadata(mPendingIntent, mDeleteIntent, mTitle,
                        mIcon, mDesiredHeight);
                data.setFlags(mFlags);
                return data;
            }