Loading api/current.txt +10 −0 Original line number Diff line number Diff line Loading @@ -4515,6 +4515,7 @@ package android.app { ctor public Notification.Action(int, java.lang.CharSequence, android.app.PendingIntent); method public android.app.Notification.Action clone(); method public int describeContents(); method public android.os.Bundle getExtras(); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator CREATOR; field public android.app.PendingIntent actionIntent; Loading @@ -4522,6 +4523,14 @@ package android.app { field public java.lang.CharSequence title; } public static class Notification.Action.Builder { ctor public Notification.Action.Builder(int, java.lang.CharSequence, android.app.PendingIntent); ctor public Notification.Action.Builder(android.app.Notification.Action); method public android.app.Notification.Action.Builder addExtras(android.os.Bundle); method public android.app.Notification.Action build(); method public android.os.Bundle getExtras(); } public static class Notification.BigPictureStyle extends android.app.Notification.Style { ctor public Notification.BigPictureStyle(); ctor public Notification.BigPictureStyle(android.app.Notification.Builder); Loading @@ -4542,6 +4551,7 @@ package android.app { public static class Notification.Builder { ctor public Notification.Builder(android.content.Context); method public android.app.Notification.Builder addAction(int, java.lang.CharSequence, android.app.PendingIntent); method public android.app.Notification.Builder addAction(android.app.Notification.Action); 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(); core/java/android/app/Notification.java +126 −20 Original line number Diff line number Diff line Loading @@ -16,9 +16,6 @@ package android.app; import com.android.internal.R; import com.android.internal.util.NotificationColorUtil; import android.annotation.IntDef; import android.content.Context; import android.content.Intent; Loading @@ -41,6 +38,9 @@ import android.view.View; import android.widget.ProgressBar; import android.widget.RemoteViews; import com.android.internal.R; import com.android.internal.util.NotificationColorUtil; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.text.NumberFormat; Loading Loading @@ -134,7 +134,7 @@ public class Notification implements Parcelable * leave it at its default value of 0. * * @see android.widget.ImageView#setImageLevel * @see android.graphics.drawable#setLevel * @see android.graphics.drawable.Drawable#setLevel */ public int iconLevel; Loading Loading @@ -700,10 +700,13 @@ public class Notification implements Parcelable * It must include an icon, a label, and a {@link PendingIntent} to be fired when the action is * selected by the user. * <p> * Apps should use {@link Builder#addAction(int, CharSequence, PendingIntent)} to create and * attach actions. * Apps should use {@link Notification.Builder#addAction(int, CharSequence, PendingIntent)} * or {@link Notification.Builder#addAction(Notification.Action)} * to attach actions. */ public static class Action implements Parcelable { private final Bundle mExtras; /** * Small icon representing the action. */ Loading @@ -718,21 +721,101 @@ public class Notification implements Parcelable */ public PendingIntent actionIntent; private Action() { } private Action(Parcel in) { icon = in.readInt(); title = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in); if (in.readInt() == 1) { actionIntent = PendingIntent.CREATOR.createFromParcel(in); } mExtras = in.readBundle(); } /** * Use {@link Builder#addAction(int, CharSequence, PendingIntent)}. * Use {@link Notification.Builder#addAction(int, CharSequence, PendingIntent)}. */ public Action(int icon, CharSequence title, PendingIntent intent) { this(icon, title, intent, new Bundle()); } private Action(int icon, CharSequence title, PendingIntent intent, Bundle extras) { this.icon = icon; this.title = title; this.actionIntent = intent; this.mExtras = extras != null ? extras : new Bundle(); } /** * Get additional metadata carried around with this Action. */ public Bundle getExtras() { return mExtras; } /** * Builder class for {@link Action} objects. */ public static class Builder { private final int mIcon; private final CharSequence mTitle; private final PendingIntent mIntent; private final Bundle mExtras; /** * Construct a new builder for {@link Action} object. * @param icon icon to show for this action * @param title the title of the action * @param intent the {@link PendingIntent} to fire when users trigger this action */ public Builder(int icon, CharSequence title, PendingIntent intent) { this(icon, title, intent, new Bundle()); } /** * Construct a new builder for {@link Action} object using the fields from an * {@link Action}. * @param action the action to read fields from. */ public Builder(Action action) { this(action.icon, action.title, action.actionIntent, new Bundle(action.mExtras)); } private Builder(int icon, CharSequence title, PendingIntent intent, Bundle extras) { mIcon = icon; mTitle = title; mIntent = intent; mExtras = extras; } /** * Merge additional metadata into this builder. * * <p>Values within the Bundle will replace existing extras values in this Builder. * * @see Notification.Action#extras */ public Builder addExtras(Bundle extras) { if (extras != null) { mExtras.putAll(extras); } return this; } /** * Get the metadata Bundle used by this Builder. * * <p>The returned Bundle is shared with this Builder. */ public Bundle getExtras() { return mExtras; } /** * Combine all of the options that have been set and return a new {@link Action} * object. * @return the built action */ public Action build() { return new Action(mIcon, mTitle, mIntent, mExtras); } } @Override Loading @@ -740,8 +823,8 @@ public class Notification implements Parcelable return new Action( this.icon, this.title, this.actionIntent // safe to alias ); this.actionIntent, // safe to alias new Bundle(this.mExtras)); } @Override public int describeContents() { Loading @@ -757,9 +840,10 @@ public class Notification implements Parcelable } else { out.writeInt(0); } out.writeBundle(mExtras); } public static final Parcelable.Creator<Action> CREATOR = new Parcelable.Creator<Action>() { public static final Parcelable.Creator<Action> CREATOR = new Parcelable.Creator<Action>() { public Action createFromParcel(Parcel in) { return new Action(in); } Loading Loading @@ -1761,11 +1845,13 @@ public class Notification implements Parcelable * * @see Notification#extras */ public Builder addExtras(Bundle bag) { public Builder addExtras(Bundle extras) { if (extras != null) { if (mExtras == null) { mExtras = new Bundle(bag); mExtras = new Bundle(extras); } else { mExtras.putAll(bag); mExtras.putAll(extras); } } return this; } Loading @@ -1782,8 +1868,8 @@ public class Notification implements Parcelable * * @see Notification#extras */ public Builder setExtras(Bundle bag) { mExtras = bag; public Builder setExtras(Bundle extras) { mExtras = extras; return this; } Loading Loading @@ -1826,6 +1912,26 @@ public class Notification implements Parcelable return this; } /** * Add an action to this notification. Actions are typically displayed by * the system as a button adjacent to the notification content. * <p> * Every action must have an icon (32dp square and matching the * <a href="{@docRoot}design/style/iconography.html#action-bar">Holo * Dark action bar</a> visual style), a textual label, and a {@link PendingIntent}. * <p> * A notification in its expanded form can display up to 3 actions, from left to right in * the order they were added. Actions will not be displayed when the notification is * collapsed, however, so be sure that any essential functions may be accessed by the user * in some other way (for example, in the Activity pointed to by {@link #contentIntent}). * * @param action The action to add. */ public Builder addAction(Action action) { mActions.add(action); return this; } /** * Add a rich notification style to be applied at build time. * Loading Loading
api/current.txt +10 −0 Original line number Diff line number Diff line Loading @@ -4515,6 +4515,7 @@ package android.app { ctor public Notification.Action(int, java.lang.CharSequence, android.app.PendingIntent); method public android.app.Notification.Action clone(); method public int describeContents(); method public android.os.Bundle getExtras(); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator CREATOR; field public android.app.PendingIntent actionIntent; Loading @@ -4522,6 +4523,14 @@ package android.app { field public java.lang.CharSequence title; } public static class Notification.Action.Builder { ctor public Notification.Action.Builder(int, java.lang.CharSequence, android.app.PendingIntent); ctor public Notification.Action.Builder(android.app.Notification.Action); method public android.app.Notification.Action.Builder addExtras(android.os.Bundle); method public android.app.Notification.Action build(); method public android.os.Bundle getExtras(); } public static class Notification.BigPictureStyle extends android.app.Notification.Style { ctor public Notification.BigPictureStyle(); ctor public Notification.BigPictureStyle(android.app.Notification.Builder); Loading @@ -4542,6 +4551,7 @@ package android.app { public static class Notification.Builder { ctor public Notification.Builder(android.content.Context); method public android.app.Notification.Builder addAction(int, java.lang.CharSequence, android.app.PendingIntent); method public android.app.Notification.Builder addAction(android.app.Notification.Action); 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();
core/java/android/app/Notification.java +126 −20 Original line number Diff line number Diff line Loading @@ -16,9 +16,6 @@ package android.app; import com.android.internal.R; import com.android.internal.util.NotificationColorUtil; import android.annotation.IntDef; import android.content.Context; import android.content.Intent; Loading @@ -41,6 +38,9 @@ import android.view.View; import android.widget.ProgressBar; import android.widget.RemoteViews; import com.android.internal.R; import com.android.internal.util.NotificationColorUtil; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.text.NumberFormat; Loading Loading @@ -134,7 +134,7 @@ public class Notification implements Parcelable * leave it at its default value of 0. * * @see android.widget.ImageView#setImageLevel * @see android.graphics.drawable#setLevel * @see android.graphics.drawable.Drawable#setLevel */ public int iconLevel; Loading Loading @@ -700,10 +700,13 @@ public class Notification implements Parcelable * It must include an icon, a label, and a {@link PendingIntent} to be fired when the action is * selected by the user. * <p> * Apps should use {@link Builder#addAction(int, CharSequence, PendingIntent)} to create and * attach actions. * Apps should use {@link Notification.Builder#addAction(int, CharSequence, PendingIntent)} * or {@link Notification.Builder#addAction(Notification.Action)} * to attach actions. */ public static class Action implements Parcelable { private final Bundle mExtras; /** * Small icon representing the action. */ Loading @@ -718,21 +721,101 @@ public class Notification implements Parcelable */ public PendingIntent actionIntent; private Action() { } private Action(Parcel in) { icon = in.readInt(); title = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in); if (in.readInt() == 1) { actionIntent = PendingIntent.CREATOR.createFromParcel(in); } mExtras = in.readBundle(); } /** * Use {@link Builder#addAction(int, CharSequence, PendingIntent)}. * Use {@link Notification.Builder#addAction(int, CharSequence, PendingIntent)}. */ public Action(int icon, CharSequence title, PendingIntent intent) { this(icon, title, intent, new Bundle()); } private Action(int icon, CharSequence title, PendingIntent intent, Bundle extras) { this.icon = icon; this.title = title; this.actionIntent = intent; this.mExtras = extras != null ? extras : new Bundle(); } /** * Get additional metadata carried around with this Action. */ public Bundle getExtras() { return mExtras; } /** * Builder class for {@link Action} objects. */ public static class Builder { private final int mIcon; private final CharSequence mTitle; private final PendingIntent mIntent; private final Bundle mExtras; /** * Construct a new builder for {@link Action} object. * @param icon icon to show for this action * @param title the title of the action * @param intent the {@link PendingIntent} to fire when users trigger this action */ public Builder(int icon, CharSequence title, PendingIntent intent) { this(icon, title, intent, new Bundle()); } /** * Construct a new builder for {@link Action} object using the fields from an * {@link Action}. * @param action the action to read fields from. */ public Builder(Action action) { this(action.icon, action.title, action.actionIntent, new Bundle(action.mExtras)); } private Builder(int icon, CharSequence title, PendingIntent intent, Bundle extras) { mIcon = icon; mTitle = title; mIntent = intent; mExtras = extras; } /** * Merge additional metadata into this builder. * * <p>Values within the Bundle will replace existing extras values in this Builder. * * @see Notification.Action#extras */ public Builder addExtras(Bundle extras) { if (extras != null) { mExtras.putAll(extras); } return this; } /** * Get the metadata Bundle used by this Builder. * * <p>The returned Bundle is shared with this Builder. */ public Bundle getExtras() { return mExtras; } /** * Combine all of the options that have been set and return a new {@link Action} * object. * @return the built action */ public Action build() { return new Action(mIcon, mTitle, mIntent, mExtras); } } @Override Loading @@ -740,8 +823,8 @@ public class Notification implements Parcelable return new Action( this.icon, this.title, this.actionIntent // safe to alias ); this.actionIntent, // safe to alias new Bundle(this.mExtras)); } @Override public int describeContents() { Loading @@ -757,9 +840,10 @@ public class Notification implements Parcelable } else { out.writeInt(0); } out.writeBundle(mExtras); } public static final Parcelable.Creator<Action> CREATOR = new Parcelable.Creator<Action>() { public static final Parcelable.Creator<Action> CREATOR = new Parcelable.Creator<Action>() { public Action createFromParcel(Parcel in) { return new Action(in); } Loading Loading @@ -1761,11 +1845,13 @@ public class Notification implements Parcelable * * @see Notification#extras */ public Builder addExtras(Bundle bag) { public Builder addExtras(Bundle extras) { if (extras != null) { if (mExtras == null) { mExtras = new Bundle(bag); mExtras = new Bundle(extras); } else { mExtras.putAll(bag); mExtras.putAll(extras); } } return this; } Loading @@ -1782,8 +1868,8 @@ public class Notification implements Parcelable * * @see Notification#extras */ public Builder setExtras(Bundle bag) { mExtras = bag; public Builder setExtras(Bundle extras) { mExtras = extras; return this; } Loading Loading @@ -1826,6 +1912,26 @@ public class Notification implements Parcelable return this; } /** * Add an action to this notification. Actions are typically displayed by * the system as a button adjacent to the notification content. * <p> * Every action must have an icon (32dp square and matching the * <a href="{@docRoot}design/style/iconography.html#action-bar">Holo * Dark action bar</a> visual style), a textual label, and a {@link PendingIntent}. * <p> * A notification in its expanded form can display up to 3 actions, from left to right in * the order they were added. Actions will not be displayed when the notification is * collapsed, however, so be sure that any essential functions may be accessed by the user * in some other way (for example, in the Activity pointed to by {@link #contentIntent}). * * @param action The action to add. */ public Builder addAction(Action action) { mActions.add(action); return this; } /** * Add a rich notification style to be applied at build time. * Loading