diff options
-rw-r--r-- | api/current.txt | 2 | ||||
-rw-r--r-- | core/java/android/app/Notification.java | 43 | ||||
-rw-r--r-- | core/res/res/layout/notification_intruder_content.xml | 21 |
3 files changed, 55 insertions, 11 deletions
diff --git a/api/current.txt b/api/current.txt index c3c5b24..4cdd30b 100644 --- a/api/current.txt +++ b/api/current.txt @@ -3712,6 +3712,7 @@ package android.app { method public android.app.Notification.Builder setDefaults(int); method public android.app.Notification.Builder setDeleteIntent(android.app.PendingIntent); method public android.app.Notification.Builder setFullScreenIntent(android.app.PendingIntent, boolean); + method public android.app.Notification.Builder setIntruderActionsShowText(boolean); method public android.app.Notification.Builder setLargeIcon(android.graphics.Bitmap); method public android.app.Notification.Builder setLights(int, int, int); method public android.app.Notification.Builder setNumber(int); @@ -3725,6 +3726,7 @@ package android.app { method public android.app.Notification.Builder setSound(android.net.Uri, int); method public android.app.Notification.Builder setTicker(java.lang.CharSequence); method public android.app.Notification.Builder setTicker(java.lang.CharSequence, android.widget.RemoteViews); + method public android.app.Notification.Builder setUsesIntruderAlert(boolean); method public android.app.Notification.Builder setVibrate(long[]); method public android.app.Notification.Builder setWhen(long); } 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; } diff --git a/core/res/res/layout/notification_intruder_content.xml b/core/res/res/layout/notification_intruder_content.xml index 61be5f5..7f37032 100644 --- a/core/res/res/layout/notification_intruder_content.xml +++ b/core/res/res/layout/notification_intruder_content.xml @@ -2,7 +2,6 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" - android:background="#FF333333" android:padding="4dp" > <ImageView android:id="@+id/icon" @@ -39,29 +38,35 @@ <LinearLayout android:id="@+id/actions" android:layout_width="match_parent" - android:layout_height="40dp" + android:layout_height="wrap_content" android:layout_marginTop="48dp" android:orientation="horizontal" android:visibility="gone" > - <ImageView + <Button + style="?android:attr/buttonBarButtonStyle" + android:textAppearance="@style/TextAppearance.StatusBar.EventContent.Title" android:id="@+id/action0" android:layout_width="0dp" - android:layout_height="match_parent" + android:layout_height="wrap_content" android:layout_weight="1" android:visibility="gone" /> - <ImageView + <Button + style="?android:attr/buttonBarButtonStyle" + android:textAppearance="@style/TextAppearance.StatusBar.EventContent.Title" android:id="@+id/action1" android:layout_width="0dp" - android:layout_height="match_parent" + android:layout_height="wrap_content" android:layout_weight="1" android:visibility="gone" /> - <ImageView + <Button + style="?android:attr/buttonBarButtonStyle" + android:textAppearance="@style/TextAppearance.StatusBar.EventContent.Title" android:id="@+id/action2" android:layout_width="0dp" - android:layout_height="match_parent" + android:layout_height="wrap_content" android:layout_weight="1" android:visibility="gone" /> |