New pulsing notification layout
Test: wake up with power
Test: look at shelf on lock screen
Test: lock device w/ notifications from home screen
Test: receive notification on AOD
Test: atest KeyguardClockPositionAlgorithmTest
Test: atest NotificationRoundnessManagerTest
Test: atest ScrimControllerTest
Test: atest NotificationContentViewTest
Bug: 111405682
Change-Id: I9b4f2febd56a62256124567bffebc9f5f8255847
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 72819cb..b8d748d 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -384,9 +384,7 @@
STANDARD_LAYOUTS.add(R.layout.notification_template_material_messaging);
STANDARD_LAYOUTS.add(R.layout.notification_template_material_media);
STANDARD_LAYOUTS.add(R.layout.notification_template_material_big_media);
- STANDARD_LAYOUTS.add(R.layout.notification_template_ambient_header);
STANDARD_LAYOUTS.add(R.layout.notification_template_header);
- STANDARD_LAYOUTS.add(R.layout.notification_template_material_ambient);
}
/**
@@ -4570,9 +4568,7 @@
if (p.title != null) {
contentView.setViewVisibility(R.id.title, View.VISIBLE);
contentView.setTextViewText(R.id.title, processTextSpans(p.title));
- if (!p.ambient) {
- setTextViewColorPrimary(contentView, R.id.title, p);
- }
+ setTextViewColorPrimary(contentView, R.id.title, p);
contentView.setViewLayoutWidth(R.id.title, showProgress
? ViewGroup.LayoutParams.WRAP_CONTENT
: ViewGroup.LayoutParams.MATCH_PARENT);
@@ -4581,9 +4577,7 @@
int textId = showProgress ? com.android.internal.R.id.text_line_1
: com.android.internal.R.id.text;
contentView.setTextViewText(textId, processTextSpans(p.text));
- if (!p.ambient) {
- setTextViewColorSecondary(contentView, textId, p);
- }
+ setTextViewColorSecondary(contentView, textId, p);
contentView.setViewVisibility(textId, View.VISIBLE);
}
@@ -4842,7 +4836,7 @@
if (mN.mLargeIcon == null && mN.largeIcon != null) {
mN.mLargeIcon = Icon.createWithBitmap(mN.largeIcon);
}
- boolean showLargeIcon = mN.mLargeIcon != null && !p.hideLargeIcon && !p.ambient;
+ boolean showLargeIcon = mN.mLargeIcon != null && !p.hideLargeIcon;
if (showLargeIcon) {
contentView.setViewVisibility(R.id.right_icon, View.VISIBLE);
contentView.setImageViewIcon(R.id.right_icon, mN.mLargeIcon);
@@ -4856,7 +4850,7 @@
* @return if the reply icon is visible
*/
private boolean bindReplyIcon(RemoteViews contentView, StandardTemplateParams p) {
- boolean actionVisible = !p.hideReplyIcon && !p.ambient;
+ boolean actionVisible = !p.hideReplyIcon;
Action action = null;
if (actionVisible) {
action = findReplyAction();
@@ -4896,21 +4890,18 @@
private void bindNotificationHeader(RemoteViews contentView, StandardTemplateParams p) {
bindSmallIcon(contentView, p);
bindHeaderAppName(contentView, p);
- if (!p.ambient) {
- // Ambient view does not have these
- bindHeaderText(contentView, p);
- bindHeaderTextSecondary(contentView, p);
- bindHeaderChronometerAndTime(contentView, p);
- bindProfileBadge(contentView, p);
- bindAlertedIcon(contentView, p);
- }
+ bindHeaderText(contentView, p);
+ bindHeaderTextSecondary(contentView, p);
+ bindHeaderChronometerAndTime(contentView, p);
+ bindProfileBadge(contentView, p);
+ bindAlertedIcon(contentView, p);
bindActivePermissions(contentView, p);
bindExpandButton(contentView, p);
mN.mUsesStandardHeader = true;
}
private void bindActivePermissions(RemoteViews contentView, StandardTemplateParams p) {
- int color = p.ambient ? resolveAmbientColor(p) : getNeutralColor(p);
+ int color = getNeutralColor(p);
contentView.setDrawableTint(R.id.camera, false, color, PorterDuff.Mode.SRC_ATOP);
contentView.setDrawableTint(R.id.mic, false, color, PorterDuff.Mode.SRC_ATOP);
contentView.setDrawableTint(R.id.overlay, false, color, PorterDuff.Mode.SRC_ATOP);
@@ -5021,13 +5012,12 @@
if (isColorized(p)) {
setTextViewColorPrimary(contentView, R.id.app_name_text, p);
} else {
- contentView.setTextColor(R.id.app_name_text,
- p.ambient ? resolveAmbientColor(p) : getSecondaryTextColor(p));
+ contentView.setTextColor(R.id.app_name_text, getSecondaryTextColor(p));
}
}
private boolean isColorized(StandardTemplateParams p) {
- return p.allowColorization && !p.ambient && mN.isColorized();
+ return p.allowColorization && mN.isColorized();
}
private void bindSmallIcon(RemoteViews contentView, StandardTemplateParams p) {
@@ -5097,7 +5087,7 @@
List<Notification.Action> nonContextualActions = filterOutContextualActions(mActions);
int N = nonContextualActions.size();
- boolean emphazisedMode = mN.fullScreenIntent != null && !p.ambient;
+ boolean emphazisedMode = mN.fullScreenIntent != null;
big.setBoolean(R.id.actions, "setEmphasizedMode", emphazisedMode);
if (N > 0) {
big.setViewVisibility(R.id.actions_container, View.VISIBLE);
@@ -5122,7 +5112,7 @@
}
CharSequence[] replyText = mN.extras.getCharSequenceArray(EXTRA_REMOTE_INPUT_HISTORY);
- if (!p.ambient && validRemoteInput && replyText != null
+ if (validRemoteInput && replyText != null
&& replyText.length > 0 && !TextUtils.isEmpty(replyText[0])
&& p.maxRemoteInputHistory > 0) {
boolean showSpinner = mN.extras.getBoolean(EXTRA_SHOW_REMOTE_INPUT_SPINNER);
@@ -5239,11 +5229,10 @@
* Construct a RemoteViews for the final notification header only. This will not be
* colorized.
*
- * @param ambient if true, generate the header for the ambient display layout.
* @hide
*/
- public RemoteViews makeNotificationHeader(boolean ambient) {
- return makeNotificationHeader(mParams.reset().ambient(ambient).fillTextsFrom(this));
+ public RemoteViews makeNotificationHeader() {
+ return makeNotificationHeader(mParams.reset().fillTextsFrom(this));
}
/**
@@ -5256,8 +5245,7 @@
// Headers on their own are never colorized
p.disallowColorization();
RemoteViews header = new BuilderRemoteViews(mContext.getApplicationInfo(),
- p.ambient ? R.layout.notification_template_ambient_header
- : R.layout.notification_template_header);
+ R.layout.notification_template_header);
resetNotificationHeader(header);
bindNotificationHeader(header, p);
return header;
@@ -5269,11 +5257,7 @@
* @hide
*/
public RemoteViews makeAmbientNotification() {
- RemoteViews ambient = applyStandardTemplateWithActions(
- R.layout.notification_template_material_ambient,
- mParams.reset().ambient(true).fillTextsFrom(this).hasProgress(false),
- null /* result */);
- return ambient;
+ return createHeadsUpContentView(false /* increasedHeight */);
}
private void hideLine1Text(RemoteViews result) {
@@ -5377,14 +5361,8 @@
}
mN.extras = publicExtras;
RemoteViews view;
- if (ambient) {
- publicExtras.putCharSequence(EXTRA_TITLE,
- mContext.getString(com.android.internal.R.string.notification_hidden_text));
- view = makeAmbientNotification();
- } else{
- view = makeNotificationHeader(false /* ambient */);
- view.setBoolean(R.id.notification_header, "setExpandOnlyOnButton", true);
- }
+ view = makeNotificationHeader();
+ view.setBoolean(R.id.notification_header, "setExpandOnlyOnButton", true);
mN.extras = savedBundle;
mN.mLargeIcon = largeIcon;
mN.largeIcon = largeIconLegacy;
@@ -5404,7 +5382,6 @@
public RemoteViews makeLowPriorityContentView(boolean useRegularSubtext) {
StandardTemplateParams p = mParams.reset()
.forceDefaultColor()
- .ambient(false)
.fillTextsFrom(this);
if (!useRegularSubtext || TextUtils.isEmpty(mParams.summaryText)) {
p.summaryText(createSummaryText());
@@ -5495,8 +5472,7 @@
if (isColorized(p)) {
setTextViewColorPrimary(button, R.id.action0, p);
} else if (getRawColor(p) != COLOR_DEFAULT && mTintActionButtons) {
- button.setTextColor(R.id.action0,
- p.ambient ? resolveAmbientColor(p) : resolveContrastColor(p));
+ button.setTextColor(R.id.action0, resolveContrastColor(p));
}
}
button.setIntTag(R.id.action0, R.id.notification_action_index_tag,
@@ -5589,13 +5565,8 @@
}
private CharSequence processLegacyText(CharSequence charSequence) {
- return processLegacyText(charSequence, false /* ambient */);
- }
-
- private CharSequence processLegacyText(CharSequence charSequence, boolean ambient) {
boolean isAlreadyLightText = isLegacy() || textColorsNeedInversion();
- boolean wantLightText = ambient;
- if (isAlreadyLightText != wantLightText) {
+ if (isAlreadyLightText) {
return getColorUtil().invertCharSequenceColors(charSequence);
} else {
return charSequence;
@@ -5609,9 +5580,7 @@
StandardTemplateParams p) {
boolean colorable = !isLegacy() || getColorUtil().isGrayscaleIcon(mContext, smallIcon);
int color;
- if (p.ambient) {
- color = resolveAmbientColor(p);
- } else if (isColorized(p)) {
+ if (isColorized(p)) {
color = getPrimaryTextColor(p);
} else {
color = resolveContrastColor(p);
@@ -5698,17 +5667,6 @@
return mNeutralColor;
}
- int resolveAmbientColor(StandardTemplateParams p) {
- int rawColor = getRawColor(p);
- if (mCachedAmbientColorIsFor == rawColor && mCachedAmbientColorIsFor != COLOR_INVALID) {
- return mCachedAmbientColor;
- }
- final int contrasted = ContrastColorUtil.resolveAmbientColor(mContext, rawColor);
-
- mCachedAmbientColorIsFor = rawColor;
- return mCachedAmbientColor = contrasted;
- }
-
/**
* Apply the unstyled operations and return a new {@link Notification} object.
* @hide
@@ -10144,7 +10102,6 @@
private static class StandardTemplateParams {
boolean hasProgress = true;
- boolean ambient = false;
CharSequence title;
CharSequence text;
CharSequence headerTextSecondary;
@@ -10157,7 +10114,6 @@
final StandardTemplateParams reset() {
hasProgress = true;
- ambient = false;
title = null;
text = null;
summaryText = null;
@@ -10213,22 +10169,15 @@
return this;
}
- final StandardTemplateParams ambient(boolean ambient) {
- Preconditions.checkState(title == null && text == null, "must set ambient before text");
- this.ambient = ambient;
- return this;
- }
-
final StandardTemplateParams fillTextsFrom(Builder b) {
Bundle extras = b.mN.extras;
- this.title = b.processLegacyText(extras.getCharSequence(EXTRA_TITLE), ambient);
+ this.title = b.processLegacyText(extras.getCharSequence(EXTRA_TITLE));
- // Big text notifications should contain their content when viewed in ambient mode.
CharSequence text = extras.getCharSequence(EXTRA_BIG_TEXT);
- if (!ambient || TextUtils.isEmpty(text)) {
+ if (TextUtils.isEmpty(text)) {
text = extras.getCharSequence(EXTRA_TEXT);
}
- this.text = b.processLegacyText(text, ambient);
+ this.text = b.processLegacyText(text);
this.summaryText = extras.getCharSequence(EXTRA_SUB_TEXT);
return this;
}
diff --git a/core/res/res/layout/notification_template_ambient_header.xml b/core/res/res/layout/notification_template_ambient_header.xml
deleted file mode 100644
index be5d9b4..0000000
--- a/core/res/res/layout/notification_template_ambient_header.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2017 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<!-- hack to work around <include /> not being supported at the top level -->
-<FrameLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:paddingStart="@dimen/notification_extra_margin_ambient"
- android:paddingEnd="@dimen/notification_extra_margin_ambient"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content">
- <include
- layout="@layout/notification_template_header"
- android:theme="@style/Theme.DeviceDefault.Notification.Ambient"/>
-</FrameLayout>
diff --git a/core/res/res/layout/notification_template_material_ambient.xml b/core/res/res/layout/notification_template_material_ambient.xml
deleted file mode 100644
index 2c6064e..0000000
--- a/core/res/res/layout/notification_template_material_ambient.xml
+++ /dev/null
@@ -1,94 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2017 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/status_bar_latest_event_content"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:tag="ambient"
- android:paddingStart="@dimen/notification_extra_margin_ambient"
- android:paddingEnd="@dimen/notification_extra_margin_ambient"
- >
- <include layout="@layout/notification_template_ambient_header"
- android:theme="@style/Theme.DeviceDefault.Notification.Ambient" />
-
- <LinearLayout
- android:id="@+id/notification_action_list_margin_target"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_gravity="top"
- android:layout_marginTop="@dimen/notification_content_margin_top"
- android:layout_marginBottom="@dimen/notification_action_list_height"
- android:paddingTop="4dp"
- android:paddingBottom="6dp"
- android:clipToPadding="false"
- android:orientation="vertical">
-
- <LinearLayout
- android:id="@+id/notification_main_column"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="top"
- android:layout_weight="1"
- android:paddingStart="@dimen/notification_content_margin_start"
- android:paddingEnd="@dimen/notification_content_margin_end"
- android:clipToPadding="false"
- android:minHeight="@dimen/notification_min_content_height"
- android:orientation="vertical"
- >
- <TextView android:id="@+id/title"
- android:textAppearance="@style/TextAppearance.DeviceDefault.Notification.Title"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="top|center_horizontal"
- android:singleLine="true"
- android:ellipsize="marquee"
- android:fadingEdge="horizontal"
- android:textSize="@dimen/notification_ambient_title_text_size"
- android:textColor="#ffffffff"
- />
- <TextView android:id="@+id/text"
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:textAppearance="@style/TextAppearance.DeviceDefault.Notification"
- android:singleLine="false"
- android:layout_weight="1"
- android:gravity="top|center_horizontal"
- android:visibility="gone"
- android:textSize="@dimen/notification_ambient_text_size"
- android:textColor="#eeffffff"
- android:layout_marginTop="4dp"
- android:ellipsize="end"
- android:maxLines="3"
- />
- </LinearLayout>
- <FrameLayout android:id="@+id/actions_container"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="bottom">
- <com.android.internal.widget.NotificationActionListLayout
- android:id="@+id/actions"
- android:layout_width="match_parent"
- android:layout_height="@dimen/notification_action_list_height"
- android:paddingEnd="4dp"
- android:orientation="horizontal"
- android:gravity="center"
- android:visibility="gone"
- />
- </FrameLayout>
- </LinearLayout>
-</FrameLayout>
diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml
index 05a156b..c870683 100644
--- a/core/res/res/values/dimens.xml
+++ b/core/res/res/values/dimens.xml
@@ -194,9 +194,6 @@
<!-- The margin for text at the end of the image view for media notifications -->
<dimen name="notification_media_image_margin_end">72dp</dimen>
- <!-- The additional margin on the sides of the ambient view. -->
- <dimen name="notification_extra_margin_ambient">16dp</dimen>
-
<!-- The height of the notification action list -->
<dimen name="notification_action_list_height">60dp</dimen>
@@ -233,9 +230,6 @@
<!-- The bottom padding for the notification header -->
<dimen name="notification_header_padding_bottom">16dp</dimen>
- <!-- The margin at the top of the notification header when dozing. -->
- <dimen name="notification_header_margin_top_ambient">3dp</dimen>
-
<!-- The margin at the bottom of the notification header. -->
<dimen name="notification_header_margin_bottom">0dp</dimen>
@@ -400,11 +394,6 @@
<dimen name="notification_title_text_size">14sp</dimen>
<!-- Size of smaller notification text (see TextAppearance.StatusBar.EventContent.Line2, Info, Time) -->
<dimen name="notification_subtext_size">12sp</dimen>
- <!-- Size of notification text (see TextAppearance.StatusBar.EventContent) -->
- <dimen name="notification_ambient_text_size">16sp</dimen>
- <!-- Size of notification text titles (see TextAppearance.StatusBar.EventContent.Title) -->
- <dimen name="notification_ambient_title_text_size">24sp</dimen>
-
<!-- Top padding for notifications in the standard layout. -->
<dimen name="notification_top_pad">10dp</dimen>
diff --git a/core/res/res/values/styles_device_defaults.xml b/core/res/res/values/styles_device_defaults.xml
index 200ef2f..79afe69 100644
--- a/core/res/res/values/styles_device_defaults.xml
+++ b/core/res/res/values/styles_device_defaults.xml
@@ -271,9 +271,6 @@
<style name="TextAppearance.DeviceDefault.Notification.Info" parent="TextAppearance.Material.Notification.Info">
<item name="fontFamily">@string/config_bodyFontFamily</item>
</style>
- <style name="TextAppearance.DeviceDefault.Notification.Info.Ambient" parent="TextAppearance.Material.Notification.Info.Ambient">
- <item name="fontFamily">@string/config_bodyFontFamily</item>
- </style>
<style name="TextAppearance.DeviceDefault.Widget" parent="TextAppearance.Material.Widget">
<item name="fontFamily">@string/config_bodyFontFamily</item>
</style>
diff --git a/core/res/res/values/styles_material.xml b/core/res/res/values/styles_material.xml
index 5a7199d..63ac0e6 100644
--- a/core/res/res/values/styles_material.xml
+++ b/core/res/res/values/styles_material.xml
@@ -487,10 +487,6 @@
<style name="TextAppearance.Material.Notification.Time" parent="TextAppearance.Material.Notification.Info" />
- <style name="TextAppearance.Material.Notification.Info.Ambient">
- <item name="textSize">@dimen/notification_text_size</item>
- </style>
-
<style name="TextAppearance.Material.Notification.Emphasis">
<item name="textColor">#66000000</item>
</style>
@@ -1308,10 +1304,5 @@
<item name="gravity">top</item>
</style>
- <style name="Notification.Header.Ambient">
- <item name="layout_marginTop">@dimen/notification_header_margin_top_ambient</item>
- <item name="gravity">top|center_horizontal</item>
- </style>
-
</resources>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index a7c8c1e..5da802f 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -3076,8 +3076,6 @@
<java-symbol type="dimen" name="config_appTransitionAnimationDurationScaleDefault" />
- <java-symbol type="layout" name="notification_template_material_ambient" />
-
<!-- Network Recommendation -->
<java-symbol type="string" name="config_defaultNetworkRecommendationProviderPackage" />
@@ -3237,8 +3235,6 @@
<java-symbol type="string" name="time_picker_text_input_mode_description"/>
<java-symbol type="string" name="time_picker_radial_mode_description"/>
- <java-symbol type="layout" name="notification_template_ambient_header" />
-
<!-- resolver activity -->
<java-symbol type="drawable" name="resolver_icon_placeholder" />
diff --git a/core/res/res/values/themes_device_defaults.xml b/core/res/res/values/themes_device_defaults.xml
index d60313a..75a727b 100644
--- a/core/res/res/values/themes_device_defaults.xml
+++ b/core/res/res/values/themes_device_defaults.xml
@@ -1711,8 +1711,4 @@
<item name="notificationHeaderTextAppearance">@style/TextAppearance.DeviceDefault.Notification.Info</item>
</style>
- <style name="Theme.DeviceDefault.Notification.Ambient" parent="@style/Theme.Material.Notification.Ambient">
- <item name="notificationHeaderTextAppearance">@style/TextAppearance.DeviceDefault.Notification.Info.Ambient</item>
- </style>
-
</resources>
diff --git a/core/res/res/values/themes_material.xml b/core/res/res/values/themes_material.xml
index ccaf041..6b7698e 100644
--- a/core/res/res/values/themes_material.xml
+++ b/core/res/res/values/themes_material.xml
@@ -1341,14 +1341,6 @@
<item name="notificationHeaderIconSize">@dimen/notification_header_icon_size</item>
</style>
- <!-- Theme for inflating ambient notification -->
- <style name="Theme.Material.Notification.Ambient">
- <item name="notificationHeaderStyle">@style/Notification.Header.Ambient</item>
- <item name="notificationHeaderTextAppearance">@style/TextAppearance.Material.Notification.Info.Ambient</item>
- <item name="notificationHeaderAppNameVisibility">gone</item>
- <item name="notificationHeaderIconSize">@dimen/notification_header_icon_size_ambient</item>
- </style>
-
<!-- Default theme for Settings and activities launched from Settings. -->
<style name="Theme.Material.Settings" parent="Theme.Material.Light.LightStatusBar">
<item name="homeAsUpIndicator">@drawable/ic_ab_back_material_settings</item>