Heads-up notifications of increased height behave better
In the shade, the heads-up version when their height is increased now behave better and the notification shows more then a single message as well. Test: add heads-up for messaging style notification while shade is expanded Bug: 34469375 Change-Id: Ia3475eec5b4474aae950ef0eb84afb28689245ae
This commit is contained in:
@@ -4082,16 +4082,23 @@ public class Notification implements Parcelable
|
||||
|
||||
/**
|
||||
* Construct a RemoteViews for the final heads-up notification layout.
|
||||
*
|
||||
* @param increasedHeight true if this layout be created with an increased height. Some
|
||||
* styles may support showing more then just that basic 1U size
|
||||
* and the system may decide to render important notifications
|
||||
* slightly bigger even when collapsed.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public RemoteViews createHeadsUpContentView() {
|
||||
public RemoteViews createHeadsUpContentView(boolean increasedHeight) {
|
||||
if (mN.headsUpContentView != null
|
||||
&& (mStyle == null || !mStyle.displayCustomViewInline())) {
|
||||
return mN.headsUpContentView;
|
||||
} else if (mStyle != null) {
|
||||
final RemoteViews styleView = mStyle.makeHeadsUpContentView();
|
||||
if (styleView != null) {
|
||||
return styleView;
|
||||
}
|
||||
final RemoteViews styleView = mStyle.makeHeadsUpContentView(increasedHeight);
|
||||
if (styleView != null) {
|
||||
return styleView;
|
||||
}
|
||||
} else if (mActions.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
@@ -4099,6 +4106,13 @@ public class Notification implements Parcelable
|
||||
return applyStandardTemplateWithActions(getBigBaseLayoutResource());
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a RemoteViews for the final heads-up notification layout.
|
||||
*/
|
||||
public RemoteViews createHeadsUpContentView() {
|
||||
return createHeadsUpContentView(false /* useIncreasedHeight */);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a RemoteViews for the display in public contexts like on the lockscreen.
|
||||
*
|
||||
@@ -4823,9 +4837,11 @@ public class Notification implements Parcelable
|
||||
|
||||
/**
|
||||
* Construct a Style-specific RemoteViews for the final HUN layout.
|
||||
*
|
||||
* @param increasedHeight true if this layout be created with an increased height.
|
||||
* @hide
|
||||
*/
|
||||
public RemoteViews makeHeadsUpContentView() {
|
||||
public RemoteViews makeHeadsUpContentView(boolean increasedHeight) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -5168,6 +5184,17 @@ public class Notification implements Parcelable
|
||||
return super.makeContentView(increasedHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
@Override
|
||||
public RemoteViews makeHeadsUpContentView(boolean increasedHeight) {
|
||||
if (increasedHeight && mBuilder.mActions.size() > 0) {
|
||||
return makeBigContentView();
|
||||
}
|
||||
return super.makeHeadsUpContentView(increasedHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
@@ -5578,7 +5605,10 @@ public class Notification implements Parcelable
|
||||
* @hide
|
||||
*/
|
||||
@Override
|
||||
public RemoteViews makeHeadsUpContentView() {
|
||||
public RemoteViews makeHeadsUpContentView(boolean increasedHeight) {
|
||||
if (increasedHeight) {
|
||||
return makeBigContentView();
|
||||
}
|
||||
Message m = findLatestIncomingMessage();
|
||||
CharSequence title = mConversationTitle != null
|
||||
? mConversationTitle
|
||||
@@ -6028,7 +6058,7 @@ public class Notification implements Parcelable
|
||||
* @hide
|
||||
*/
|
||||
@Override
|
||||
public RemoteViews makeHeadsUpContentView() {
|
||||
public RemoteViews makeHeadsUpContentView(boolean increasedHeight) {
|
||||
RemoteViews expanded = makeMediaBigContentView();
|
||||
return expanded != null ? expanded : makeMediaContentView();
|
||||
}
|
||||
@@ -6208,7 +6238,7 @@ public class Notification implements Parcelable
|
||||
* @hide
|
||||
*/
|
||||
@Override
|
||||
public RemoteViews makeHeadsUpContentView() {
|
||||
public RemoteViews makeHeadsUpContentView(boolean increasedHeight) {
|
||||
return makeDecoratedHeadsUpContentView();
|
||||
}
|
||||
|
||||
@@ -6344,7 +6374,7 @@ public class Notification implements Parcelable
|
||||
* @hide
|
||||
*/
|
||||
@Override
|
||||
public RemoteViews makeHeadsUpContentView() {
|
||||
public RemoteViews makeHeadsUpContentView(boolean increasedHeight) {
|
||||
RemoteViews customRemoteView = mBuilder.mN.headsUpContentView != null
|
||||
? mBuilder.mN.headsUpContentView
|
||||
: mBuilder.mN.contentView;
|
||||
|
||||
@@ -69,8 +69,8 @@
|
||||
<!-- Height of a small notification in the status bar-->
|
||||
<dimen name="notification_min_height">92dp</dimen>
|
||||
|
||||
<!-- Height of a small notification in the status bar if it is a large (like messaging)-->
|
||||
<dimen name="notification_min_height_large">132dp</dimen>
|
||||
<!-- Increased height of a small notification in the status bar -->
|
||||
<dimen name="notification_min_height_increased">132dp</dimen>
|
||||
|
||||
<!-- Height of a small notification in the status bar which was used before android N -->
|
||||
<dimen name="notification_min_height_legacy">64dp</dimen>
|
||||
@@ -87,6 +87,9 @@
|
||||
<!-- Height of a heads up notification in the status bar -->
|
||||
<dimen name="notification_max_heads_up_height">148dp</dimen>
|
||||
|
||||
<!-- Height of a heads up notification in the status bar -->
|
||||
<dimen name="notification_max_heads_up_height_increased">188dp</dimen>
|
||||
|
||||
<!-- a threshold in dp per second that is considered fast scrolling -->
|
||||
<dimen name="scroll_fast_threshold">1500dp</dimen>
|
||||
|
||||
|
||||
@@ -76,6 +76,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
|
||||
private int mNotificationMinHeightLegacy;
|
||||
private int mMaxHeadsUpHeightLegacy;
|
||||
private int mMaxHeadsUpHeight;
|
||||
private int mMaxHeadsUpHeightIncreased;
|
||||
private int mNotificationMinHeight;
|
||||
private int mNotificationMinHeightLarge;
|
||||
private int mNotificationMaxHeight;
|
||||
@@ -209,6 +210,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
|
||||
private boolean mIsLowPriority;
|
||||
private boolean mIsColorized;
|
||||
private boolean mUseIncreasedCollapsedHeight;
|
||||
private boolean mUseIncreasedHeadsUpHeight;
|
||||
|
||||
@Override
|
||||
public boolean isGroupExpansionChanging() {
|
||||
@@ -354,8 +356,14 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
|
||||
boolean headsUpCustom = layout.getHeadsUpChild() != null &&
|
||||
layout.getHeadsUpChild().getId()
|
||||
!= com.android.internal.R.id.status_bar_latest_event_content;
|
||||
int headsUpheight = headsUpCustom && beforeN ? mMaxHeadsUpHeightLegacy
|
||||
: mMaxHeadsUpHeight;
|
||||
int headsUpheight;
|
||||
if (headsUpCustom && beforeN) {
|
||||
headsUpheight = mMaxHeadsUpHeightLegacy;
|
||||
} else if (mUseIncreasedHeadsUpHeight && layout == mPrivateLayout) {
|
||||
headsUpheight = mMaxHeadsUpHeightIncreased;
|
||||
} else {
|
||||
headsUpheight = mMaxHeadsUpHeight;
|
||||
}
|
||||
layout.setHeights(minHeight, headsUpheight, mNotificationMaxHeight,
|
||||
mNotificationAmbientHeight);
|
||||
}
|
||||
@@ -991,6 +999,10 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
|
||||
mUseIncreasedCollapsedHeight = use;
|
||||
}
|
||||
|
||||
public void setUseIncreasedHeadsUpHeight(boolean use) {
|
||||
mUseIncreasedHeadsUpHeight = use;
|
||||
}
|
||||
|
||||
public interface ExpansionLogger {
|
||||
public void logNotificationExpansion(String key, boolean userAction, boolean expanded);
|
||||
}
|
||||
@@ -1005,12 +1017,14 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
|
||||
mNotificationMinHeightLegacy = getFontScaledHeight(R.dimen.notification_min_height_legacy);
|
||||
mNotificationMinHeight = getFontScaledHeight(R.dimen.notification_min_height);
|
||||
mNotificationMinHeightLarge = getFontScaledHeight(
|
||||
R.dimen.notification_min_height_large);
|
||||
R.dimen.notification_min_height_increased);
|
||||
mNotificationMaxHeight = getFontScaledHeight(R.dimen.notification_max_height);
|
||||
mNotificationAmbientHeight = getFontScaledHeight(R.dimen.notification_ambient_height);
|
||||
mMaxHeadsUpHeightLegacy = getFontScaledHeight(
|
||||
R.dimen.notification_max_heads_up_height_legacy);
|
||||
mMaxHeadsUpHeight = getFontScaledHeight(R.dimen.notification_max_heads_up_height);
|
||||
mMaxHeadsUpHeightIncreased = getFontScaledHeight(
|
||||
R.dimen.notification_max_heads_up_height_increased);
|
||||
mIncreasedPaddingBetweenElements = getResources()
|
||||
.getDimensionPixelSize(R.dimen.notification_divider_height_increased);
|
||||
mIconTransformContentShiftNoIcon = getResources().getDimensionPixelSize(
|
||||
|
||||
@@ -126,7 +126,8 @@ public class NotificationData {
|
||||
}
|
||||
|
||||
public boolean cacheContentViews(Context ctx, Notification updatedNotification,
|
||||
boolean isLowPriority, boolean useIncreasedCollapsedView) {
|
||||
boolean isLowPriority, boolean useIncreasedCollapsedView,
|
||||
boolean useIncreasedHeadsUp) {
|
||||
boolean applyInPlace = false;
|
||||
if (updatedNotification != null) {
|
||||
final Notification.Builder updatedNotificationBuilder
|
||||
@@ -136,7 +137,7 @@ public class NotificationData {
|
||||
final RemoteViews newBigContentView = createBigContentView(
|
||||
updatedNotificationBuilder, isLowPriority);
|
||||
final RemoteViews newHeadsUpContentView =
|
||||
updatedNotificationBuilder.createHeadsUpContentView();
|
||||
updatedNotificationBuilder.createHeadsUpContentView(useIncreasedHeadsUp);
|
||||
final RemoteViews newPublicNotification
|
||||
= updatedNotificationBuilder.makePublicContentView();
|
||||
final RemoteViews newAmbientNotification
|
||||
@@ -165,7 +166,7 @@ public class NotificationData {
|
||||
cachedContentView = createContentView(builder, isLowPriority,
|
||||
useIncreasedCollapsedView);
|
||||
cachedBigContentView = createBigContentView(builder, isLowPriority);
|
||||
cachedHeadsUpContentView = builder.createHeadsUpContentView();
|
||||
cachedHeadsUpContentView = builder.createHeadsUpContentView(useIncreasedHeadsUp);
|
||||
cachedPublicContentView = builder.makePublicContentView();
|
||||
cachedAmbientContentView = builder.makeAmbientNotification();
|
||||
|
||||
|
||||
@@ -712,6 +712,7 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
private NetworkController mNetworkController;
|
||||
private KeyguardMonitorImpl mKeyguardMonitor;
|
||||
private BatteryController mBatteryController;
|
||||
private boolean mPanelExpanded;
|
||||
private LogMaker mStatusBarStateLog;
|
||||
private LockscreenGestureLogger mLockscreenGestureLogger = new LockscreenGestureLogger();
|
||||
private NotificationIconAreaController mNotificationIconAreaController;
|
||||
@@ -2679,6 +2680,7 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
}
|
||||
|
||||
public void setPanelExpanded(boolean isExpanded) {
|
||||
mPanelExpanded = isExpanded;
|
||||
mStatusBarWindowManager.setPanelExpanded(isExpanded);
|
||||
mVisualStabilityManager.setPanelExpanded(isExpanded);
|
||||
if (isExpanded && getBarState() != StatusBarState.KEYGUARD) {
|
||||
@@ -6090,8 +6092,10 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
boolean isLowPriority = mNotificationData.isAmbient(sbn.getKey());
|
||||
boolean useIncreasedCollapsedHeight = mMessagingUtil.isImportantMessaging(sbn,
|
||||
mNotificationData.getImportance(sbn.getKey()));
|
||||
boolean useIncreasedHeadsUp = useIncreasedCollapsedHeight && mPanelExpanded;
|
||||
try {
|
||||
entry.cacheContentViews(mContext, null, isLowPriority, useIncreasedCollapsedHeight);
|
||||
entry.cacheContentViews(mContext, null, isLowPriority, useIncreasedCollapsedHeight,
|
||||
useIncreasedHeadsUp);
|
||||
} catch (RuntimeException e) {
|
||||
Log.e(TAG, "Unable to get notification remote views", e);
|
||||
return false;
|
||||
@@ -6262,6 +6266,7 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
}
|
||||
row.setUserLocked(userLocked);
|
||||
row.setUseIncreasedCollapsedHeight(useIncreasedCollapsedHeight);
|
||||
row.setUseIncreasedHeadsUpHeight(useIncreasedHeadsUp);
|
||||
row.onNotificationUpdated(entry);
|
||||
return true;
|
||||
}
|
||||
@@ -6756,10 +6761,13 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
boolean useIncreasedCollapsedHeight = mMessagingUtil.isImportantMessaging(notification,
|
||||
mNotificationData.getImportance(notification.getKey()));
|
||||
entry.row.setUseIncreasedCollapsedHeight(useIncreasedCollapsedHeight);
|
||||
boolean useIncreasedHeadsUp = useIncreasedCollapsedHeight && mPanelExpanded;
|
||||
entry.row.setUseIncreasedHeadsUpHeight(useIncreasedHeadsUp);
|
||||
boolean applyInPlace;
|
||||
try {
|
||||
applyInPlace = entry.cacheContentViews(mContext, notification.getNotification(),
|
||||
mNotificationData.isAmbient(key), useIncreasedCollapsedHeight);
|
||||
mNotificationData.isAmbient(key), useIncreasedCollapsedHeight,
|
||||
useIncreasedHeadsUp);
|
||||
} catch (RuntimeException e) {
|
||||
Log.e(TAG, "Unable to get notification remote views", e);
|
||||
applyInPlace = false;
|
||||
|
||||
Reference in New Issue
Block a user