From a9d3e22de1e6c04b637502a092d047a3cbc56a84 Mon Sep 17 00:00:00 2001 From: Jeff DeCew Date: Fri, 5 Mar 2021 14:30:16 -0500 Subject: [PATCH] Move text to new line in big base style This was only used when progress was shown, did not exist for headerless, and was then hidden for all styles; this just left the big base template, where it needed more room. Now we just only set the text with progress when using that template. Note: The line1 container is used for margin adjustments, so removing it is non-trivial; I'll do that in a followup CL. Bug: 181048615 Test: visual inspection Change-Id: I465f7be95249b90ae8906b2bc951c9ff6066550a --- core/java/android/app/Notification.java | 28 ++++++++----------- ...tification_template_material_big_media.xml | 17 ++--------- .../notification_template_material_media.xml | 17 ++--------- .../notification_template_part_line1.xml | 17 ++--------- core/res/res/values/symbols.xml | 1 - 5 files changed, 20 insertions(+), 60 deletions(-) diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 96159568f8b4b..3c26738eca28c 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -92,7 +92,6 @@ import android.util.proto.ProtoOutputStream; import android.view.ContextThemeWrapper; import android.view.Gravity; import android.view.View; -import android.view.ViewGroup; import android.view.contentcapture.ContentCaptureContext; import android.widget.ProgressBar; import android.widget.RemoteViews; @@ -4970,8 +4969,6 @@ public class Notification implements Parcelable contentView.setTextViewText(R.id.title, null); contentView.setViewVisibility(R.id.text, View.GONE); contentView.setTextViewText(R.id.text, null); - contentView.setViewVisibility(R.id.text_line_1, View.GONE); - contentView.setTextViewText(R.id.text_line_1, null); } /** @@ -5001,6 +4998,7 @@ public class Notification implements Parcelable TemplateBindResult result) { p.headerless(resId == getBaseLayoutResource() || resId == getHeadsUpBaseLayoutResource()); + p.allowTextWithProgress(resId == getBigBaseLayoutResource()); RemoteViews contentView = new BuilderRemoteViews(mContext.getApplicationInfo(), resId); resetStandardTemplate(contentView); @@ -5015,14 +5013,10 @@ public class Notification implements Parcelable contentView.setViewVisibility(R.id.title, View.VISIBLE); contentView.setTextViewText(R.id.title, processTextSpans(p.title)); setTextViewColorPrimary(contentView, R.id.title, p); - contentView.setViewLayoutWidth(R.id.title, showProgress - ? ViewGroup.LayoutParams.WRAP_CONTENT - : ViewGroup.LayoutParams.MATCH_PARENT, - TypedValue.COMPLEX_UNIT_PX); } - if (p.text != null && p.text.length() != 0) { - int textId = showProgress ? com.android.internal.R.id.text_line_1 - : com.android.internal.R.id.text; + if (p.text != null && p.text.length() != 0 + && (!showProgress || p.mAllowTextWithProgress)) { + int textId = com.android.internal.R.id.text; contentView.setTextViewText(textId, processTextSpans(p.text)); setTextViewColorSecondary(contentView, textId, p); contentView.setViewVisibility(textId, View.VISIBLE); @@ -5746,7 +5740,6 @@ public class Notification implements Parcelable } if (mStyle != null) { result = mStyle.makeBigContentView(); - hideLine1Text(result); if (fullyCustomViewRequiresDecoration(true /* fromStyle */)) { result = minimallyDecoratedBigContentView(result); } @@ -5829,12 +5822,6 @@ public class Notification implements Parcelable return createContentView(); } - private void hideLine1Text(RemoteViews result) { - if (result != null) { - result.setViewVisibility(R.id.text_line_1, View.GONE); - } - } - /** * Adapt the Notification header if this view is used as an expanded view. * @@ -12070,6 +12057,7 @@ public class Notification implements Parcelable boolean mHideSnoozeButton; boolean mPromotePicture; boolean mAllowActionIcons; + boolean mAllowTextWithProgress; CharSequence title; CharSequence text; CharSequence headerTextSecondary; @@ -12088,6 +12076,7 @@ public class Notification implements Parcelable mHideSnoozeButton = false; mPromotePicture = false; mAllowActionIcons = false; + mAllowTextWithProgress = false; title = null; text = null; summaryText = null; @@ -12132,6 +12121,11 @@ public class Notification implements Parcelable return this; } + final StandardTemplateParams allowTextWithProgress(boolean allowTextWithProgress) { + this.mAllowTextWithProgress = allowTextWithProgress; + return this; + } + final StandardTemplateParams hideSnoozeButton(boolean hideSnoozeButton) { this.mHideSnoozeButton = hideSnoozeButton; return this; diff --git a/core/res/res/layout/notification_template_material_big_media.xml b/core/res/res/layout/notification_template_material_big_media.xml index bdd4430a7985f..b4cd170221b96 100644 --- a/core/res/res/layout/notification_template_material_big_media.xml +++ b/core/res/res/layout/notification_template_material_big_media.xml @@ -59,32 +59,21 @@ - - - + --> - - - + - - - + diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index cc32a697c0d19..e6326924560ec 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -2902,7 +2902,6 @@ -