diff options
author | Daniel Sandler <dsandler@android.com> | 2012-03-24 10:37:28 -0500 |
---|---|---|
committer | Daniel Sandler <dsandler@android.com> | 2012-03-26 16:25:21 -0400 |
commit | b2a1c23a553254b71f25f0ed0773d4d3126656f8 (patch) | |
tree | 839bf91c893ced21a60ecb092aa2f4c9786436e0 /core/java | |
parent | 7061b5ffb37ea15f235effa1faaf22bb1750c7f5 (diff) | |
download | frameworks_base-b2a1c23a553254b71f25f0ed0773d4d3126656f8.zip frameworks_base-b2a1c23a553254b71f25f0ed0773d4d3126656f8.tar.gz frameworks_base-b2a1c23a553254b71f25f0ed0773d4d3126656f8.tar.bz2 |
Add text labels to intruder actions.
Change-Id: I544bed7b37c043639ee0e6a11bf757c0a191c1fc
Diffstat (limited to 'core/java')
-rw-r--r-- | core/java/android/app/Notification.java | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 04ab407..bbb6a4e 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -918,6 +918,8 @@ public class Notification implements Parcelable private Bundle mExtras; private int mPriority; private ArrayList<Action> mActions = new ArrayList<Action>(3); + private boolean mCanHasIntruder; + private boolean mIntruderActionsShowText; /** * Constructs a new Builder with the defaults: @@ -1313,6 +1315,38 @@ public class Notification implements Parcelable return this; } + /** + * Specify whether this notification should pop up as an + * "intruder alert" (a small window that shares the screen with the + * current activity). This sort of notification is (as the name implies) + * very intrusive, so use it sparingly for notifications that require + * the user's attention. + * + * Notes: + * <ul> + * <li>Intruder alerts only show when the screen is on.</li> + * <li>Intruder alerts take precedence over fullScreenIntents.</li> + * </ul> + * + * @param intrude Whether to pop up an intruder alert (default false). + */ + public Builder setUsesIntruderAlert(boolean intrude) { + mCanHasIntruder = intrude; + return this; + } + + /** + * Control text on intruder alert action buttons. By default, action + * buttons in intruders do not show textual labels. + * + * @param showActionText Whether to show text labels beneath action + * icons (default false). + */ + public Builder setIntruderActionsShowText(boolean showActionText) { + mIntruderActionsShowText = showActionText; + return this; + } + private void setFlag(int mask, boolean value) { if (value) { mFlags |= mask; @@ -1394,7 +1428,7 @@ public class Notification implements Parcelable } } - private RemoteViews makeIntruderView() { + private RemoteViews makeIntruderView(boolean showLabels) { RemoteViews intruderView = new RemoteViews(mContext.getPackageName(), R.layout.notification_intruder_content); if (mLargeIcon != null) { @@ -1422,7 +1456,8 @@ public class Notification implements Parcelable final int buttonId = BUTTONS[i]; intruderView.setViewVisibility(buttonId, View.VISIBLE); - intruderView.setImageViewResource(buttonId, action.icon); + intruderView.setTextViewText(buttonId, showLabels ? action.title : null); + intruderView.setTextViewCompoundDrawables(buttonId, 0, action.icon, 0, 0); intruderView.setContentDescription(buttonId, action.title); intruderView.setOnClickPendingIntent(buttonId, action.actionIntent); } @@ -1457,7 +1492,9 @@ public class Notification implements Parcelable n.ledOffMS = mLedOffMs; n.defaults = mDefaults; n.flags = mFlags; - n.intruderView = makeIntruderView(); + if (mCanHasIntruder) { + n.intruderView = makeIntruderView(mIntruderActionsShowText); + } if (mLedOnMs != 0 && mLedOffMs != 0) { n.flags |= FLAG_SHOW_LIGHTS; } |