summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jeff DeCew <jeffdq@google.com> 2021-03-05 14:30:16 -0500
committer Jeff DeCew <jeffdq@google.com> 2021-03-05 15:34:57 -0500
commita9d3e22de1e6c04b637502a092d047a3cbc56a84 (patch)
tree1c92d3b241e85a2a2d355a44efeb258b675657aa
parent27127e1b7b5fbd3b0d1af1d72d5bf0603c9ed401 (diff)
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
-rw-r--r--core/java/android/app/Notification.java30
-rw-r--r--core/res/res/layout/notification_template_material_big_media.xml17
-rw-r--r--core/res/res/layout/notification_template_material_media.xml17
-rw-r--r--core/res/res/layout/notification_template_part_line1.xml17
-rw-r--r--core/res/res/values/symbols.xml1
5 files changed, 21 insertions, 61 deletions
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 96159568f8b4..3c26738eca28 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 bdd4430a7985..b4cd170221b9 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 @@
<!--<include layout="@layout/notification_template_part_line1"/>-->
<!--<include layout="@layout/notification_template_text"/>-->
- <LinearLayout
+ <FrameLayout
android:id="@+id/line1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:orientation="horizontal"
>
<TextView android:id="@+id/title"
android:textAppearance="@style/TextAppearance.DeviceDefault.Notification.Title"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:singleLine="true"
- android:ellipsize="marquee"
- android:fadingEdge="horizontal"
- android:textAlignment="viewStart"
- />
- <TextView android:id="@+id/text_line_1"
- style="@style/Widget.DeviceDefault.Notification.Text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:gravity="end|bottom"
- android:layout_marginStart="16dp"
android:singleLine="true"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
+ android:textAlignment="viewStart"
/>
- </LinearLayout>
+ </FrameLayout>
<com.android.internal.widget.ImageFloatingTextView
style="@style/Widget.DeviceDefault.Notification.Text"
diff --git a/core/res/res/layout/notification_template_material_media.xml b/core/res/res/layout/notification_template_material_media.xml
index baffdd5ac0f1..0481f0d4e4f7 100644
--- a/core/res/res/layout/notification_template_material_media.xml
+++ b/core/res/res/layout/notification_template_material_media.xml
@@ -63,32 +63,21 @@
<!--<include layout="@layout/notification_template_part_line1"/>-->
<!--<include layout="@layout/notification_template_text"/>-->
- <LinearLayout
+ <FrameLayout
android:id="@+id/line1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:orientation="horizontal"
>
<TextView android:id="@+id/title"
android:textAppearance="@style/TextAppearance.DeviceDefault.Notification.Title"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:singleLine="true"
- android:ellipsize="marquee"
- android:fadingEdge="horizontal"
- android:textAlignment="viewStart"
- />
- <TextView android:id="@+id/text_line_1"
- style="@style/Widget.DeviceDefault.Notification.Text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:gravity="end|bottom"
- android:layout_marginStart="16dp"
android:singleLine="true"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
+ android:textAlignment="viewStart"
/>
- </LinearLayout>
+ </FrameLayout>
<com.android.internal.widget.ImageFloatingTextView
style="@style/Widget.DeviceDefault.Notification.Text"
diff --git a/core/res/res/layout/notification_template_part_line1.xml b/core/res/res/layout/notification_template_part_line1.xml
index fc5bd9cc6c0b..002b7eba05ab 100644
--- a/core/res/res/layout/notification_template_part_line1.xml
+++ b/core/res/res/layout/notification_template_part_line1.xml
@@ -15,29 +15,18 @@
~ limitations under the License
-->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/line1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:orientation="horizontal"
>
<TextView android:id="@+id/title"
android:textAppearance="@style/TextAppearance.DeviceDefault.Notification.BigTitle"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:singleLine="true"
- android:ellipsize="marquee"
- android:fadingEdge="horizontal"
- android:textAlignment="viewStart"
- />
- <TextView android:id="@+id/text_line_1"
- style="@style/Widget.DeviceDefault.Notification.Text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:gravity="end|bottom"
- android:layout_marginStart="16dp"
android:singleLine="true"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
+ android:textAlignment="viewStart"
/>
-</LinearLayout>
+</FrameLayout>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index cc32a697c0d1..e6326924560e 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -2902,7 +2902,6 @@
<java-symbol type="id" name="time_divider" />
<java-symbol type="id" name="header_text_divider" />
<java-symbol type="id" name="header_text_secondary_divider" />
- <java-symbol type="id" name="text_line_1" />
<java-symbol type="drawable" name="ic_expand_notification" />
<java-symbol type="drawable" name="ic_collapse_notification" />
<java-symbol type="drawable" name="ic_expand_bundle" />