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

Commit 13d898c5 authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Additional badging APIs.

- shortcut id
- icon
- updated documentation for number

Test: cts
Change-Id: I0424b8879e79b3da70cc378c0ca96e14e328ea34
parent 4d600d15
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -5046,14 +5046,19 @@ package android.app {
    ctor public Notification(android.os.Parcel);
    method public android.app.Notification clone();
    method public int describeContents();
    method public int getBadgeIcon();
    method public java.lang.String getChannel();
    method public java.lang.String getGroup();
    method public android.graphics.drawable.Icon getLargeIcon();
    method public java.lang.String getShortcutId();
    method public android.graphics.drawable.Icon getSmallIcon();
    method public java.lang.String getSortKey();
    method public long getTimeout();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.media.AudioAttributes AUDIO_ATTRIBUTES_DEFAULT;
    field public static final int BADGE_ICON_LARGE = 2; // 0x2
    field public static final int BADGE_ICON_NONE = 0; // 0x0
    field public static final int BADGE_ICON_SMALL = 1; // 0x1
    field public static final java.lang.String CATEGORY_ALARM = "alarm";
    field public static final java.lang.String CATEGORY_CALL = "call";
    field public static final java.lang.String CATEGORY_EMAIL = "email";
@@ -5145,7 +5150,7 @@ package android.app {
    field public deprecated int ledARGB;
    field public deprecated int ledOffMS;
    field public deprecated int ledOnMS;
    field public deprecated int number;
    field public int number;
    field public deprecated int priority;
    field public android.app.Notification publicVersion;
    field public deprecated android.net.Uri sound;
@@ -5233,6 +5238,7 @@ package android.app {
    method public android.app.Notification.Builder addExtras(android.os.Bundle);
    method public android.app.Notification.Builder addPerson(java.lang.String);
    method public android.app.Notification build();
    method public android.app.Notification.Builder chooseBadgeIcon(int);
    method public android.widget.RemoteViews createBigContentView();
    method public android.widget.RemoteViews createContentView();
    method public android.widget.RemoteViews createHeadsUpContentView();
@@ -5265,13 +5271,14 @@ package android.app {
    method public android.app.Notification.Builder setLargeIcon(android.graphics.drawable.Icon);
    method public deprecated android.app.Notification.Builder setLights(int, int, int);
    method public android.app.Notification.Builder setLocalOnly(boolean);
    method public deprecated android.app.Notification.Builder setNumber(int);
    method public android.app.Notification.Builder setNumber(int);
    method public android.app.Notification.Builder setOngoing(boolean);
    method public android.app.Notification.Builder setOnlyAlertOnce(boolean);
    method public deprecated android.app.Notification.Builder setPriority(int);
    method public android.app.Notification.Builder setProgress(int, int, boolean);
    method public android.app.Notification.Builder setPublicVersion(android.app.Notification);
    method public android.app.Notification.Builder setRemoteInputHistory(java.lang.CharSequence[]);
    method public android.app.Notification.Builder setShortcutId(java.lang.String);
    method public android.app.Notification.Builder setShowWhen(boolean);
    method public android.app.Notification.Builder setSmallIcon(int);
    method public android.app.Notification.Builder setSmallIcon(int, int);
+9 −2
Original line number Diff line number Diff line
@@ -5206,15 +5206,20 @@ package android.app {
    ctor public Notification(android.os.Parcel);
    method public android.app.Notification clone();
    method public int describeContents();
    method public int getBadgeIcon();
    method public java.lang.String getChannel();
    method public java.lang.String getGroup();
    method public android.graphics.drawable.Icon getLargeIcon();
    method public static java.lang.Class<? extends android.app.Notification.Style> getNotificationStyleClass(java.lang.String);
    method public java.lang.String getShortcutId();
    method public android.graphics.drawable.Icon getSmallIcon();
    method public java.lang.String getSortKey();
    method public long getTimeout();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.media.AudioAttributes AUDIO_ATTRIBUTES_DEFAULT;
    field public static final int BADGE_ICON_LARGE = 2; // 0x2
    field public static final int BADGE_ICON_NONE = 0; // 0x0
    field public static final int BADGE_ICON_SMALL = 1; // 0x1
    field public static final java.lang.String CATEGORY_ALARM = "alarm";
    field public static final java.lang.String CATEGORY_CALL = "call";
    field public static final java.lang.String CATEGORY_EMAIL = "email";
@@ -5308,7 +5313,7 @@ package android.app {
    field public deprecated int ledARGB;
    field public deprecated int ledOffMS;
    field public deprecated int ledOnMS;
    field public deprecated int number;
    field public int number;
    field public deprecated int priority;
    field public android.app.Notification publicVersion;
    field public deprecated android.net.Uri sound;
@@ -5396,6 +5401,7 @@ package android.app {
    method public android.app.Notification.Builder addExtras(android.os.Bundle);
    method public android.app.Notification.Builder addPerson(java.lang.String);
    method public android.app.Notification build();
    method public android.app.Notification.Builder chooseBadgeIcon(int);
    method public android.widget.RemoteViews createBigContentView();
    method public android.widget.RemoteViews createContentView();
    method public android.widget.RemoteViews createHeadsUpContentView();
@@ -5428,13 +5434,14 @@ package android.app {
    method public android.app.Notification.Builder setLargeIcon(android.graphics.drawable.Icon);
    method public deprecated android.app.Notification.Builder setLights(int, int, int);
    method public android.app.Notification.Builder setLocalOnly(boolean);
    method public deprecated android.app.Notification.Builder setNumber(int);
    method public android.app.Notification.Builder setNumber(int);
    method public android.app.Notification.Builder setOngoing(boolean);
    method public android.app.Notification.Builder setOnlyAlertOnce(boolean);
    method public deprecated android.app.Notification.Builder setPriority(int);
    method public android.app.Notification.Builder setProgress(int, int, boolean);
    method public android.app.Notification.Builder setPublicVersion(android.app.Notification);
    method public android.app.Notification.Builder setRemoteInputHistory(java.lang.CharSequence[]);
    method public android.app.Notification.Builder setShortcutId(java.lang.String);
    method public android.app.Notification.Builder setShowWhen(boolean);
    method public android.app.Notification.Builder setSmallIcon(int);
    method public android.app.Notification.Builder setSmallIcon(int, int);
+9 −2
Original line number Diff line number Diff line
@@ -5056,14 +5056,19 @@ package android.app {
    ctor public Notification(android.os.Parcel);
    method public android.app.Notification clone();
    method public int describeContents();
    method public int getBadgeIcon();
    method public java.lang.String getChannel();
    method public java.lang.String getGroup();
    method public android.graphics.drawable.Icon getLargeIcon();
    method public java.lang.String getShortcutId();
    method public android.graphics.drawable.Icon getSmallIcon();
    method public java.lang.String getSortKey();
    method public long getTimeout();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.media.AudioAttributes AUDIO_ATTRIBUTES_DEFAULT;
    field public static final int BADGE_ICON_LARGE = 2; // 0x2
    field public static final int BADGE_ICON_NONE = 0; // 0x0
    field public static final int BADGE_ICON_SMALL = 1; // 0x1
    field public static final java.lang.String CATEGORY_ALARM = "alarm";
    field public static final java.lang.String CATEGORY_CALL = "call";
    field public static final java.lang.String CATEGORY_EMAIL = "email";
@@ -5155,7 +5160,7 @@ package android.app {
    field public deprecated int ledARGB;
    field public deprecated int ledOffMS;
    field public deprecated int ledOnMS;
    field public deprecated int number;
    field public int number;
    field public deprecated int priority;
    field public android.app.Notification publicVersion;
    field public deprecated android.net.Uri sound;
@@ -5243,6 +5248,7 @@ package android.app {
    method public android.app.Notification.Builder addExtras(android.os.Bundle);
    method public android.app.Notification.Builder addPerson(java.lang.String);
    method public android.app.Notification build();
    method public android.app.Notification.Builder chooseBadgeIcon(int);
    method public android.widget.RemoteViews createBigContentView();
    method public android.widget.RemoteViews createContentView();
    method public android.widget.RemoteViews createHeadsUpContentView();
@@ -5275,13 +5281,14 @@ package android.app {
    method public android.app.Notification.Builder setLargeIcon(android.graphics.drawable.Icon);
    method public deprecated android.app.Notification.Builder setLights(int, int, int);
    method public android.app.Notification.Builder setLocalOnly(boolean);
    method public deprecated android.app.Notification.Builder setNumber(int);
    method public android.app.Notification.Builder setNumber(int);
    method public android.app.Notification.Builder setOngoing(boolean);
    method public android.app.Notification.Builder setOnlyAlertOnce(boolean);
    method public deprecated android.app.Notification.Builder setPriority(int);
    method public android.app.Notification.Builder setProgress(int, int, boolean);
    method public android.app.Notification.Builder setPublicVersion(android.app.Notification);
    method public android.app.Notification.Builder setRemoteInputHistory(java.lang.CharSequence[]);
    method public android.app.Notification.Builder setShortcutId(java.lang.String);
    method public android.app.Notification.Builder setShowWhen(boolean);
    method public android.app.Notification.Builder setSmallIcon(int);
    method public android.app.Notification.Builder setSmallIcon(int, int);
+89 −13
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ShortcutInfo;
import android.content.res.ColorStateList;
import android.graphics.Bitmap;
import android.graphics.Canvas;
@@ -223,13 +224,11 @@ public class Notification implements Parcelable
     * superimposed over the icon in the status bar. Starting with
     * {@link android.os.Build.VERSION_CODES#HONEYCOMB}, the template used by
     * {@link Notification.Builder} has displayed the number in the expanded notification view.
     * Starting with {@link android.os.Build.VERSION_CODES#O}, the number may be displayed as a
     * badge icon in Launchers that support badging.
     *
     * If the number is 0 or negative, it is never shown.
     *
     * @deprecated this number is not shown anymore
     */
    @Deprecated
    public int number;
    public int number = 1;

    /**
     * The intent to execute when the expanded status entry is clicked.  If
@@ -1074,6 +1073,26 @@ public class Notification implements Parcelable
    private String mChannelId;
    private long mTimeout;

    private String mShortcutId;

    /**
     * If this notification is being shown as a badge, always show as a number.
     */
    public static final int BADGE_ICON_NONE = 0;

    /**
     * If this notification is being shown as a badge, use the {@link #getSmallIcon()} to
     * represent this notification.
     */
    public static final int BADGE_ICON_SMALL = 1;

    /**
     * If this notification is being shown as a badge, use the {@link #getLargeIcon()} to
     * represent this notification.
     */
    public static final int BADGE_ICON_LARGE = 2;
    private int mBadgeIcon = BADGE_ICON_LARGE;

    /**
     * Structure to encapsulate a named action that can be shown as part of this notification.
     * It must include an icon, a label, and a {@link PendingIntent} to be fired when the action is
@@ -1818,6 +1837,12 @@ public class Notification implements Parcelable
            mChannelId = parcel.readString();
        }
        mTimeout = parcel.readLong();

        if (parcel.readInt() != 0) {
            mShortcutId = parcel.readString();
        }

        mBadgeIcon = parcel.readInt();
    }

    @Override
@@ -2042,7 +2067,7 @@ public class Notification implements Parcelable
        }
        try {
            // IMPORTANT: Add marshaling code in writeToParcelImpl as we
            // want to intercept all pending events written to the pacel.
            // want to intercept all pending events written to the parcel.
            writeToParcelImpl(parcel, flags);
            // Must be written last!
            parcel.writeArraySet(allPendingIntents);
@@ -2185,6 +2210,15 @@ public class Notification implements Parcelable
            parcel.writeInt(0);
        }
        parcel.writeLong(mTimeout);

        if (mShortcutId != null) {
            parcel.writeInt(1);
            parcel.writeString(mShortcutId);
        } else {
            parcel.writeInt(0);
        }

        parcel.writeInt(mBadgeIcon);
    }

    /**
@@ -2382,12 +2416,29 @@ public class Notification implements Parcelable
    }

    /**
     * Returns the time at which this notification should be canceled, if it's not canceled already.
     * Returns the time at which this notification should be canceled by the system, if it's not
     * canceled already.
     */
    public long getTimeout() {
        return mTimeout;
    }

    /**
     * Returns what icon should be shown for this notification if it is being displayed in a
     * Launcher that supports badging. Will be one of {@link #BADGE_ICON_NONE},
     * {@link #BADGE_ICON_SMALL}, or {@link #BADGE_ICON_LARGE}.
     */
    public int getBadgeIcon() {
        return mBadgeIcon;
    }

    /**
     * Returns the {@link ShortcutInfo#getId() id} that this notification supersedes, if any.
     */
    public String getShortcutId() {
        return mShortcutId;
    }

    /**
     * The small icon representing this notification in the status bar and content view.
     *
@@ -2610,6 +2661,35 @@ public class Notification implements Parcelable
            return mColorUtil;
        }

        /**
         * If this notification is duplicative of a Launcher shortcut, sets the
         * {@link ShortcutInfo#getId() id} of the shortcut, in case the Launcher wants to hide
         * the shortcut.
         *
         * This field will be ignored by Launchers that don't support badging or
         * {@link android.content.pm.ShortcutManager shortcuts}.
         *
         * @param shortcutId the {@link ShortcutInfo#getId() id} of the shortcut this notification
         *                   supersedes
         */
        public Builder setShortcutId(String shortcutId) {
            mN.mShortcutId = shortcutId;
            return this;
        }

        /**
         * Sets which icon to display as a badge for this notification.
         *
         * Must be one of {@link #BADGE_ICON_NONE}, {@link #BADGE_ICON_SMALL},
         * {@link #BADGE_ICON_LARGE}.
         *
         * Note: This value might be ignored, for launchers that don't support badge icons.
         */
        public Builder chooseBadgeIcon(int icon) {
            mN.mBadgeIcon = icon;
            return this;
        }

        /**
         * Specifies the channel the notification should be delivered on.
         */
@@ -2805,13 +2885,9 @@ public class Notification implements Parcelable
        }

        /**
         * Set the large number at the right-hand side of the notification.  This is
         * equivalent to setContentInfo, although it might show the number in a different
         * font size for readability.
         *
         * @deprecated this number is not shown anywhere anymore
         * Sets the number of items this notification represents. May be displayed as a badge count
         * for Launchers that support badging.
         */
        @Deprecated
        public Builder setNumber(int number) {
            mN.number = number;
            return this;