diff options
8 files changed, 217 insertions, 108 deletions
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 47967ba..f7300aa 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -2579,20 +2579,35 @@ public class Notification implements Parcelable return bitmap; } + private boolean addProfileBadge(RemoteViews contentView, int resId) { + Bitmap profileBadge = getProfileBadge(); + + contentView.setViewVisibility(R.id.profile_badge_large_template, View.GONE); + contentView.setViewVisibility(R.id.profile_badge_line2, View.GONE); + contentView.setViewVisibility(R.id.profile_badge_line3, View.GONE); + + if (profileBadge != null) { + contentView.setImageViewBitmap(resId, profileBadge); + contentView.setViewVisibility(resId, View.VISIBLE); + + // Make sure Line 3 is visible. As badge will be here if there + // is no text to display. + if (resId == R.id.profile_badge_line3) { + contentView.setViewVisibility(R.id.line3, View.VISIBLE); + } + return true; + } + return false; + } + private RemoteViews applyStandardTemplate(int resId) { - Bitmap profileIcon = getProfileBadge(); RemoteViews contentView = new BuilderRemoteViews(mContext.getPackageName(), mOriginatingUserId, resId); boolean showLine3 = false; boolean showLine2 = false; + boolean contentTextInLine2 = false; - if (profileIcon != null) { - contentView.setImageViewBitmap(R.id.profile_icon, profileIcon); - contentView.setViewVisibility(R.id.profile_icon, View.VISIBLE); - } else { - contentView.setViewVisibility(R.id.profile_icon, View.GONE); - } if (mLargeIcon != null) { contentView.setImageViewBitmap(R.id.icon, mLargeIcon); processLargeIcon(mLargeIcon, contentView); @@ -2639,6 +2654,7 @@ public class Notification implements Parcelable contentView.setTextViewText(R.id.text2, processLegacyText(mContentText)); contentView.setViewVisibility(R.id.text2, View.VISIBLE); showLine2 = true; + contentTextInLine2 = true; } else { contentView.setViewVisibility(R.id.text2, View.GONE); } @@ -2681,6 +2697,15 @@ public class Notification implements Parcelable hasThreeLines(), mContext.getResources().getConfiguration().fontScale), 0, 0); + // We want to add badge to first line of text. + boolean addedBadge = addProfileBadge(contentView, + contentTextInLine2 ? R.id.profile_badge_line2 : R.id.profile_badge_line3); + // If we added the badge to line 3 then we should show line 3. + if (addedBadge && !contentTextInLine2) { + showLine3 = true; + } + + // Note getStandardView may hide line 3 again. contentView.setViewVisibility(R.id.line3, showLine3 ? View.VISIBLE : View.GONE); contentView.setViewVisibility(R.id.overflow_divider, showLine3 ? View.VISIBLE : View.GONE); return contentView; @@ -3347,6 +3372,8 @@ public class Notification implements Parcelable contentView.setViewVisibility(R.id.overflow_divider, View.VISIBLE); contentView.setViewVisibility(R.id.line3, View.VISIBLE); } else { + // Clear text in case we use the line to show the profile badge. + contentView.setTextViewText(R.id.text, ""); contentView.setViewVisibility(R.id.overflow_divider, View.GONE); contentView.setViewVisibility(R.id.line3, View.GONE); } @@ -3507,6 +3534,9 @@ public class Notification implements Parcelable applyTopPadding(contentView); + boolean twoTextLines = mBuilder.mSubText != null && mBuilder.mContentText != null; + mBuilder.addProfileBadge(contentView, + twoTextLines ? R.id.profile_badge_line2 : R.id.profile_badge_line3); return contentView; } @@ -3632,6 +3662,8 @@ public class Notification implements Parcelable applyTopPadding(contentView); + mBuilder.addProfileBadge(contentView, R.id.profile_badge_large_template); + return contentView; } @@ -3769,6 +3801,8 @@ public class Notification implements Parcelable applyTopPadding(contentView); + mBuilder.addProfileBadge(contentView, R.id.profile_badge_large_template); + return contentView; } diff --git a/core/res/res/layout/notification_template_material_big_base.xml b/core/res/res/layout/notification_template_material_big_base.xml index 3d8a527..f264b7b 100644 --- a/core/res/res/layout/notification_template_material_big_base.xml +++ b/core/res/res/layout/notification_template_material_big_base.xml @@ -37,14 +37,30 @@ > <include layout="@layout/notification_template_part_line1" /> <include layout="@layout/notification_template_part_line2" /> - <TextView android:id="@+id/big_text" - android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent" + <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginEnd="8dp" - android:singleLine="false" - android:visibility="gone" - /> + android:orientation="horizontal" + android:gravity="top" + > + <TextView android:id="@+id/big_text" + android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:singleLine="false" + android:visibility="gone" + /> + <ImageView android:id="@+id/profile_badge_large_template" + android:layout_width="20dp" + android:layout_height="20dp" + android:layout_weight="0" + android:layout_marginStart="4dp" + android:scaleType="fitCenter" + android:visibility="gone" + /> + </LinearLayout> <include layout="@layout/notification_template_part_line3" android:layout_width="match_parent" diff --git a/core/res/res/layout/notification_template_material_big_text.xml b/core/res/res/layout/notification_template_material_big_text.xml index 36f8701..d9120f6 100644 --- a/core/res/res/layout/notification_template_material_big_text.xml +++ b/core/res/res/layout/notification_template_material_big_text.xml @@ -37,14 +37,31 @@ > <include layout="@layout/notification_template_part_line1" /> <include layout="@layout/notification_template_part_line2" /> - <TextView android:id="@+id/big_text" - android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent" + <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginEnd="8dp" android:layout_marginBottom="10dp" - android:visibility="gone" - /> + android:orientation="horizontal" + android:gravity="top" + > + <TextView android:id="@+id/big_text" + android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:singleLine="false" + android:visibility="gone" + /> + <ImageView android:id="@+id/profile_badge_large_template" + android:layout_width="20dp" + android:layout_height="20dp" + android:layout_weight="0" + android:layout_marginStart="4dp" + android:scaleType="fitCenter" + android:visibility="gone" + /> + </LinearLayout> <ImageView android:layout_width="match_parent" android:layout_height="1dp" diff --git a/core/res/res/layout/notification_template_material_inbox.xml b/core/res/res/layout/notification_template_material_inbox.xml index ef6cbd0..38b3ae2 100644 --- a/core/res/res/layout/notification_template_material_inbox.xml +++ b/core/res/res/layout/notification_template_material_inbox.xml @@ -37,79 +37,102 @@ > <include layout="@layout/notification_template_part_line1" /> <include layout="@layout/notification_template_part_line2" /> - <TextView android:id="@+id/inbox_text0" - android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent" + <LinearLayout android:layout_width="match_parent" - android:layout_height="0dp" - android:singleLine="true" - android:ellipsize="end" - android:visibility="gone" - android:layout_weight="1" - /> - <TextView android:id="@+id/inbox_text1" - android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent" - android:layout_width="match_parent" - android:layout_height="0dp" - android:singleLine="true" - android:ellipsize="end" - android:visibility="gone" - android:layout_weight="1" - /> - <TextView android:id="@+id/inbox_text2" - android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent" - android:layout_width="match_parent" - android:layout_height="0dp" - android:singleLine="true" - android:ellipsize="end" - android:visibility="gone" - android:layout_weight="1" - /> - <TextView android:id="@+id/inbox_text3" - android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent" - android:layout_width="match_parent" - android:layout_height="0dp" - android:singleLine="true" - android:ellipsize="end" - android:visibility="gone" - android:layout_weight="1" - /> - <TextView android:id="@+id/inbox_text4" - android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent" - android:layout_width="match_parent" - android:layout_height="0dp" - android:singleLine="true" - android:ellipsize="end" - android:visibility="gone" - android:layout_weight="1" - /> - <TextView android:id="@+id/inbox_text5" - android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent" - android:layout_width="match_parent" - android:layout_height="0dp" - android:singleLine="true" - android:ellipsize="end" - android:visibility="gone" - android:layout_weight="1" - /> - <TextView android:id="@+id/inbox_text6" - android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent" - android:layout_width="match_parent" - android:layout_height="0dp" - android:singleLine="true" - android:ellipsize="end" - android:visibility="gone" - android:layout_weight="1" - /> - <TextView android:id="@+id/inbox_more" - android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent" - android:layout_width="match_parent" - android:layout_height="0dp" - android:singleLine="true" - android:ellipsize="end" - android:visibility="gone" - android:layout_weight="1" - android:text="@android:string/ellipsis" - /> + android:layout_height="wrap_content" + android:orientation="horizontal" + android:gravity="top" + > + <LinearLayout + android:layout_width="0dp" + android:layout_weight="1" + android:layout_height="wrap_content" + android:orientation="vertical" + > + <TextView android:id="@+id/inbox_text0" + android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent" + android:layout_width="match_parent" + android:layout_height="0dp" + android:singleLine="true" + android:ellipsize="end" + android:visibility="gone" + android:layout_weight="1" + /> + <TextView android:id="@+id/inbox_text1" + android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent" + android:layout_width="match_parent" + android:layout_height="0dp" + android:singleLine="true" + android:ellipsize="end" + android:visibility="gone" + android:layout_weight="1" + /> + <TextView android:id="@+id/inbox_text2" + android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent" + android:layout_width="match_parent" + android:layout_height="0dp" + android:singleLine="true" + android:ellipsize="end" + android:visibility="gone" + android:layout_weight="1" + /> + <TextView android:id="@+id/inbox_text3" + android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent" + android:layout_width="match_parent" + android:layout_height="0dp" + android:singleLine="true" + android:ellipsize="end" + android:visibility="gone" + android:layout_weight="1" + /> + <TextView android:id="@+id/inbox_text4" + android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent" + android:layout_width="match_parent" + android:layout_height="0dp" + android:singleLine="true" + android:ellipsize="end" + android:visibility="gone" + android:layout_weight="1" + /> + <TextView android:id="@+id/inbox_text5" + android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent" + android:layout_width="match_parent" + android:layout_height="0dp" + android:singleLine="true" + android:ellipsize="end" + android:visibility="gone" + android:layout_weight="1" + /> + <TextView android:id="@+id/inbox_text6" + android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent" + android:layout_width="match_parent" + android:layout_height="0dp" + android:singleLine="true" + android:ellipsize="end" + android:visibility="gone" + android:layout_weight="1" + /> + <TextView android:id="@+id/inbox_more" + android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent" + android:layout_width="match_parent" + android:layout_height="0dp" + android:singleLine="true" + android:ellipsize="end" + android:visibility="gone" + android:layout_weight="1" + android:text="@android:string/ellipsis" + /> + </LinearLayout> + <ImageView android:id="@+id/profile_badge_large_template" + android:layout_width="20dp" + android:layout_height="20dp" + android:layout_weight="0" + android:layout_marginStart="4dp" + android:layout_marginEnd="8dp" + android:scaleType="fitCenter" + android:visibility="gone" + /> + </LinearLayout> <FrameLayout android:id="@+id/inbox_end_pad" android:layout_width="match_parent" diff --git a/core/res/res/layout/notification_template_part_line2.xml b/core/res/res/layout/notification_template_part_line2.xml index d3f202f..1f95150 100644 --- a/core/res/res/layout/notification_template_part_line2.xml +++ b/core/res/res/layout/notification_template_part_line2.xml @@ -16,20 +16,37 @@ --> <merge xmlns:android="http://schemas.android.com/apk/res/android"> - <TextView - android:id="@+id/text2" - android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent.Line2" + <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginEnd="8dp" - android:layout_marginTop="-1dp" - android:layout_marginBottom="-1dp" - android:singleLine="true" - android:fadingEdge="horizontal" - android:ellipsize="marquee" android:visibility="gone" android:layout_weight="0" + android:orientation="horizontal" + android:gravity="center_vertical" + > + <TextView + android:id="@+id/text2" + android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent.Line2" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_marginTop="-1dp" + android:layout_marginBottom="-1dp" + android:singleLine="true" + android:fadingEdge="horizontal" + android:ellipsize="marquee" + android:visibility="gone" + android:layout_weight="1" /> + <ImageView android:id="@+id/profile_badge_line2" + android:layout_width="20dp" + android:layout_height="20dp" + android:layout_weight="0" + android:layout_marginStart="4dp" + android:scaleType="fitCenter" + android:visibility="gone" + /> + </LinearLayout> <ProgressBar android:id="@android:id/progress" android:layout_width="match_parent" diff --git a/core/res/res/layout/notification_template_part_line3.xml b/core/res/res/layout/notification_template_part_line3.xml index dd2779d..06de2a5 100644 --- a/core/res/res/layout/notification_template_part_line3.xml +++ b/core/res/res/layout/notification_template_part_line3.xml @@ -43,13 +43,13 @@ android:gravity="center" android:paddingStart="8dp" /> - <ImageView android:id="@+id/profile_icon" - android:layout_width="24dp" - android:layout_height="24dp" + <ImageView android:id="@+id/profile_badge_line3" + android:layout_width="20dp" + android:layout_height="20dp" android:layout_gravity="center" android:layout_weight="0" - android:layout_marginStart="8dp" - android:scaleType="centerInside" + android:layout_marginStart="4dp" + android:scaleType="fitCenter" android:visibility="gone" /> </LinearLayout> diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index af73c02..a9a9f26 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -216,7 +216,9 @@ <java-symbol type="id" name="pin_confirm_text" /> <java-symbol type="id" name="pin_error_message" /> <java-symbol type="id" name="timePickerLayout" /> - <java-symbol type="id" name="profile_icon" /> + <java-symbol type="id" name="profile_badge_large_template" /> + <java-symbol type="id" name="profile_badge_line2" /> + <java-symbol type="id" name="profile_badge_line3" /> <java-symbol type="id" name="transitionPosition" /> <java-symbol type="attr" name="actionModeShareDrawable" /> diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java index 3a20b00..e3f034d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java @@ -1169,8 +1169,8 @@ public abstract class BaseStatusBar extends SystemUI implements final ImageView icon = (ImageView) publicViewLocal.findViewById( com.android.internal.R.id.icon); - final ImageView profileIcon = (ImageView) publicViewLocal.findViewById( - com.android.internal.R.id.profile_icon); + final ImageView profileBadge = (ImageView) publicViewLocal.findViewById( + com.android.internal.R.id.profile_badge_line3); final StatusBarIcon ic = new StatusBarIcon(entry.notification.getPackageName(), entry.notification.getUser(), @@ -1189,14 +1189,14 @@ public abstract class BaseStatusBar extends SystemUI implements icon.setPadding(padding, padding, padding, padding); } - if (profileIcon != null) { + if (profileBadge != null) { Drawable profileDrawable = mUserManager.getBadgeForUser(entry.notification.getUser(), 0); if (profileDrawable != null) { - profileIcon.setImageDrawable(profileDrawable); - profileIcon.setVisibility(View.VISIBLE); + profileBadge.setImageDrawable(profileDrawable); + profileBadge.setVisibility(View.VISIBLE); } else { - profileIcon.setVisibility(View.GONE); + profileBadge.setVisibility(View.GONE); } } |