diff options
| -rw-r--r-- | core/java/android/app/Notification.java | 36 | ||||
| -rw-r--r-- | packages/SystemUI/res/values/dimens.xml | 3 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java | 22 |
3 files changed, 59 insertions, 2 deletions
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 79265959c7d7..b067cd004770 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -204,6 +204,15 @@ public class Notification implements Parcelable */ public RemoteViews bigContentView; + + /** + * @hide + * A medium-format version of {@link #contentView}, giving the Notification an + * opportunity to add action buttons to contentView. The system UI may + * choose to show this as a popup notification at its discretion. + */ + public RemoteViews headsUpContentView; + /** * The bitmap that may escape the bounds of the panel and bar. */ @@ -809,6 +818,10 @@ public class Notification implements Parcelable bigContentView = RemoteViews.CREATOR.createFromParcel(parcel); } + if (parcel.readInt() != 0) { + headsUpContentView = RemoteViews.CREATOR.createFromParcel(parcel); + } + visibility = parcel.readInt(); if (parcel.readInt() != 0) { @@ -899,6 +912,10 @@ public class Notification implements Parcelable that.bigContentView = this.bigContentView.clone(); } + if (heavy && this.headsUpContentView != null) { + that.headsUpContentView = this.headsUpContentView.clone(); + } + that.visibility = this.visibility; if (this.publicVersion != null) { @@ -920,6 +937,7 @@ public class Notification implements Parcelable tickerView = null; contentView = null; bigContentView = null; + headsUpContentView = null; largeIcon = null; if (extras != null) { extras.remove(Notification.EXTRA_LARGE_ICON); @@ -1032,6 +1050,13 @@ public class Notification implements Parcelable parcel.writeInt(0); } + if (headsUpContentView != null) { + parcel.writeInt(1); + headsUpContentView.writeToParcel(parcel, 0); + } else { + parcel.writeInt(0); + } + parcel.writeInt(visibility); if (publicVersion != null) { @@ -1182,6 +1207,9 @@ public class Notification implements Parcelable if (bigContentView != null) { bigContentView.setUser(user); } + if (headsUpContentView != null) { + headsUpContentView.setUser(user); + } } /** @@ -1881,6 +1909,13 @@ public class Notification implements Parcelable return applyStandardTemplateWithActions(R.layout.notification_template_big_base); } + private RemoteViews makeHEadsUpContentView() { + if (mActions.size() == 0) return null; + + return applyStandardTemplateWithActions(R.layout.notification_template_big_base); + } + + private RemoteViews generateActionButton(Action action) { final boolean tombstone = (action.actionIntent == null); RemoteViews button = new RemoteViews(mContext.getPackageName(), @@ -1921,6 +1956,7 @@ public class Notification implements Parcelable n.defaults = mDefaults; n.flags = mFlags; n.bigContentView = makeBigContentView(); + n.headsUpContentView = makeHEadsUpContentView(); if (mLedOnMs != 0 || mLedOffMs != 0) { n.flags |= FLAG_SHOW_LIGHTS; } diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index e6b2b8b9b6c0..65cd23197e9e 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -79,6 +79,9 @@ <!-- Height of a large notification in the status bar --> <dimen name="notification_max_height">256dp</dimen> + <!-- Height of a medium notification in the status bar --> + <dimen name="notification_mid_height">128dp</dimen> + <!-- Height of a small notification in the status bar plus glow, padding, etc --> <dimen name="notification_row_min_height">70dp</dimen> diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java index 74e9704b0bb8..0c50cda0f449 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java @@ -685,6 +685,13 @@ public abstract class BaseStatusBar extends SystemUI implements StatusBarNotification sbn = entry.notification; RemoteViews contentView = sbn.getNotification().contentView; RemoteViews bigContentView = sbn.getNotification().bigContentView; + + if (isHeadsUp) { + maxHeight = + mContext.getResources().getDimensionPixelSize(R.dimen.notification_mid_height); + bigContentView = sbn.getNotification().headsUpContentView; + } + if (contentView == null) { return false; } @@ -1040,6 +1047,8 @@ public abstract class BaseStatusBar extends SystemUI implements final RemoteViews contentView = notification.getNotification().contentView; final RemoteViews oldBigContentView = oldNotification.getNotification().bigContentView; final RemoteViews bigContentView = notification.getNotification().bigContentView; + final RemoteViews oldHeadsUpContentView = oldNotification.getNotification().headsUpContentView; + final RemoteViews headsUpContentView = notification.getNotification().headsUpContentView; final Notification oldPublicNotification = oldNotification.getNotification().publicVersion; final RemoteViews oldPublicContentView = oldPublicNotification != null ? oldPublicNotification.contentView : null; @@ -1079,6 +1088,13 @@ public abstract class BaseStatusBar extends SystemUI implements && oldBigContentView.getPackage() != null && oldBigContentView.getPackage().equals(bigContentView.getPackage()) && oldBigContentView.getLayoutId() == bigContentView.getLayoutId()); + boolean headsUpContentsUnchanged = + (oldHeadsUpContentView == null && headsUpContentView == null) + || ((oldHeadsUpContentView != null && headsUpContentView != null) + && headsUpContentView.getPackage() != null + && oldHeadsUpContentView.getPackage() != null + && oldHeadsUpContentView.getPackage().equals(headsUpContentView.getPackage()) + && oldHeadsUpContentView.getLayoutId() == headsUpContentView.getLayoutId()); boolean publicUnchanged = (oldPublicContentView == null && publicContentView == null) || ((oldPublicContentView != null && publicContentView != null) @@ -1097,7 +1113,7 @@ public abstract class BaseStatusBar extends SystemUI implements && !TextUtils.equals(notification.getNotification().tickerText, oldEntry.notification.getNotification().tickerText); boolean isTopAnyway = isTopNotification(rowParent, oldEntry); - if (contentsUnchanged && bigContentsUnchanged && publicUnchanged + if (contentsUnchanged && bigContentsUnchanged && headsUpContentsUnchanged && publicUnchanged && (orderUnchanged || isTopAnyway)) { if (DEBUG) Log.d(TAG, "reusing notification for key: " + key); oldEntry.notification = notification; @@ -1181,7 +1197,9 @@ public abstract class BaseStatusBar extends SystemUI implements private void updateNotificationViews(NotificationData.Entry entry, StatusBarNotification notification, boolean isHeadsUp) { final RemoteViews contentView = notification.getNotification().contentView; - final RemoteViews bigContentView = notification.getNotification().bigContentView; + final RemoteViews bigContentView = isHeadsUp + ? notification.getNotification().headsUpContentView + : notification.getNotification().bigContentView; final Notification publicVersion = notification.getNotification().publicVersion; final RemoteViews publicContentView = publicVersion != null ? publicVersion.contentView : null; |