Skip to content

Commit 6cf0c33

Browse files
dsandlerAndroid (Google) Code Review
authored andcommitted
Merge "Various notification template cleanups." into jb-dev
2 parents 78fc35b + 619738c commit 6cf0c33

File tree

4 files changed

+28
-11
lines changed

4 files changed

+28
-11
lines changed

core/java/android/app/Notification.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,6 +1614,7 @@ public static abstract class Style
16141614
{
16151615
private CharSequence mBigContentTitle;
16161616
private CharSequence mSummaryText = null;
1617+
private boolean mSummaryTextSet = false;
16171618

16181619
protected Builder mBuilder;
16191620

@@ -1630,6 +1631,7 @@ protected void internalSetBigContentTitle(CharSequence title) {
16301631
*/
16311632
protected void internalSetSummaryText(CharSequence cs) {
16321633
mSummaryText = cs;
1634+
mSummaryTextSet = true;
16331635
}
16341636

16351637
public void setBuilder(Builder builder) {
@@ -1660,9 +1662,13 @@ protected RemoteViews getStandardView(int layoutId) {
16601662
contentView.setViewVisibility(R.id.line1, View.VISIBLE);
16611663
}
16621664

1663-
// The last line defaults to the content text or subtext, but can be replaced by mSummaryText
1664-
if (mSummaryText != null && !mSummaryText.equals("")) {
1665-
contentView.setTextViewText(R.id.text, mSummaryText);
1665+
// The last line defaults to the subtext, but can be replaced by mSummaryText
1666+
final CharSequence overflowText =
1667+
mSummaryTextSet ? mSummaryText
1668+
: mBuilder.mSubText;
1669+
if (overflowText != null) {
1670+
contentView.setTextViewText(R.id.text, overflowText);
1671+
contentView.setViewVisibility(R.id.overflow_divider, View.VISIBLE);
16661672
contentView.setViewVisibility(R.id.line3, View.VISIBLE);
16671673
}
16681674

@@ -1803,9 +1809,16 @@ public BigTextStyle bigText(CharSequence cs) {
18031809
}
18041810

18051811
private RemoteViews makeBigContentView() {
1806-
// Remove the content text so line3 disappears entirely
1812+
// Remove the content text so line3 only shows if you have a summary
1813+
final boolean hadThreeLines = (mBuilder.mContentText != null && mBuilder.mSubText != null);
18071814
mBuilder.mContentText = null;
18081815
RemoteViews contentView = getStandardView(R.layout.notification_template_big_text);
1816+
1817+
if (hadThreeLines) {
1818+
// vertical centering
1819+
contentView.setViewPadding(R.id.line1, 0, 0, 0, 0);
1820+
}
1821+
18091822
contentView.setTextViewText(R.id.big_text, mBigText);
18101823
contentView.setViewVisibility(R.id.big_text, View.VISIBLE);
18111824
contentView.setViewVisibility(R.id.text2, View.GONE);
@@ -1875,7 +1888,10 @@ public InboxStyle addLine(CharSequence cs) {
18751888
}
18761889

18771890
private RemoteViews makeBigContentView() {
1891+
// Remove the content text so line3 disappears unless you have a summary
1892+
mBuilder.mContentText = null;
18781893
RemoteViews contentView = getStandardView(R.layout.notification_template_inbox);
1894+
18791895
contentView.setViewVisibility(R.id.text2, View.GONE);
18801896

18811897
int[] rowIds = {R.id.inbox_text0, R.id.inbox_text1, R.id.inbox_text2, R.id.inbox_text3,

core/res/res/layout/notification_template_big_picture.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
android:layout_width="match_parent"
4747
android:layout_height="wrap_content"
4848
android:layout_marginTop="208dp"
49-
android:layout_marginLeft="64dp"
49+
android:paddingLeft="64dp"
5050
android:layout_gravity="bottom"
5151
android:background="#CC111111"
5252
>

core/res/res/layout/notification_template_big_text.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@
110110
android:layout_height="0dp"
111111
android:layout_marginBottom="8dp"
112112
android:layout_marginRight="8dp"
113+
android:layout_marginTop="2dp"
113114
android:singleLine="false"
114115
android:visibility="gone"
115116
android:maxLines="8"

core/res/res/layout/notification_template_inbox.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,8 @@
191191
<ImageView
192192
android:layout_width="match_parent"
193193
android:layout_height="1px"
194-
android:id="@+id/overflow_divider"
195-
android:layout_marginTop="8dp"
196-
android:visibility="visible"
194+
android:id="@+id/action_divider"
195+
android:visibility="gone"
197196
android:background="?android:attr/dividerHorizontal" />
198197
<include
199198
layout="@layout/notification_action_list"
@@ -204,9 +203,10 @@
204203
<ImageView
205204
android:layout_width="match_parent"
206205
android:layout_height="1px"
207-
android:id="@+id/action_divider"
208-
android:visibility="gone"
209-
android:background="?android:attr/dividerHorizontal" /><!-- note: divider below actions -->
206+
android:id="@+id/overflow_divider"
207+
android:layout_marginTop="8dp"
208+
android:visibility="visible"
209+
android:background="?android:attr/dividerHorizontal" />
210210
<LinearLayout
211211
android:id="@+id/line3"
212212
android:layout_width="match_parent"

0 commit comments

Comments
 (0)