From 299b3302ef6ea5094f094e92f384853aa012172b Mon Sep 17 00:00:00 2001 From: Selim Cinek Date: Thu, 14 Sep 2017 17:09:25 -0700 Subject: [PATCH] Increased the text size for colorized notifications Increased the text sizes a bit to make them more prominent. Test: add colorized notifications of all styles Change-Id: Ie22053edcb0297e7c3ee0c43b29cdd0e7b6a4516 Fixes: 35925915 --- core/java/android/app/Notification.java | 25 +++++++++++++++++++ core/res/res/values/dimens.xml | 5 ++++ core/res/res/values/symbols.xml | 3 +++ packages/SystemUI/res/values/dimens.xml | 6 +++++ .../statusbar/ExpandableNotificationRow.java | 10 +++++++- .../NotificationTemplateViewWrapper.java | 17 ++++++++++++- .../notification/NotificationViewWrapper.java | 10 ++++++++ 7 files changed, 74 insertions(+), 2 deletions(-) diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 9511f3fd7cef1..4497e0bd08850 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -67,6 +67,7 @@ import android.text.style.TextAppearanceSpan; import android.util.ArraySet; import android.util.Log; import android.util.SparseArray; +import android.util.TypedValue; import android.view.Gravity; import android.view.NotificationHeaderView; import android.view.View; @@ -3898,6 +3899,7 @@ public class Notification implements Parcelable if (p.title != null) { contentView.setViewVisibility(R.id.title, View.VISIBLE); contentView.setTextViewText(R.id.title, processTextSpans(p.title)); + updateTextSizePrimary(contentView, R.id.title); if (!p.ambient) { setTextViewColorPrimary(contentView, R.id.title); } @@ -3909,6 +3911,7 @@ public class Notification implements Parcelable int textId = showProgress ? com.android.internal.R.id.text_line_1 : com.android.internal.R.id.text; contentView.setTextViewText(textId, processTextSpans(p.text)); + updateTextSizeSecondary(contentView, textId); if (!p.ambient) { setTextViewColorSecondary(contentView, textId); } @@ -3920,6 +3923,25 @@ public class Notification implements Parcelable return contentView; } + private void updateTextSizeSecondary(RemoteViews contentView, int textId) { + updateTextSizeColorized(contentView, textId, + com.android.internal.R.dimen.notification_text_size_colorized, + com.android.internal.R.dimen.notification_text_size); + } + + private void updateTextSizePrimary(RemoteViews contentView, int textId) { + updateTextSizeColorized(contentView, textId, + com.android.internal.R.dimen.notification_title_text_size_colorized, + com.android.internal.R.dimen.notification_title_text_size); + } + + private void updateTextSizeColorized(RemoteViews contentView, int textId, + int colorizedDimen, int normalDimen) { + int size = mContext.getResources().getDimensionPixelSize(isColorized() + ? colorizedDimen : normalDimen); + contentView.setTextViewTextSize(textId, TypedValue.COMPLEX_UNIT_PX, size); + } + private CharSequence processTextSpans(CharSequence text) { if (hasForegroundColor()) { return NotificationColorUtil.clearColorSpans(text); @@ -5845,6 +5867,7 @@ public class Notification implements Parcelable builder.setTextViewColorSecondary(contentView, R.id.big_text); contentView.setViewVisibility(R.id.big_text, TextUtils.isEmpty(bigTextText) ? View.GONE : View.VISIBLE); + builder.updateTextSizeSecondary(contentView, R.id.big_text); contentView.setBoolean(R.id.big_text, "setHasImage", builder.mN.hasLargeIcon()); } } @@ -6178,6 +6201,7 @@ public class Notification implements Parcelable contentView.setViewVisibility(rowId, View.VISIBLE); contentView.setTextViewText(rowId, mBuilder.processTextSpans( makeMessageLine(m, mBuilder))); + mBuilder.updateTextSizeSecondary(contentView, rowId); mBuilder.setTextViewColorSecondary(contentView, rowId); if (contractedMessage == m) { @@ -6545,6 +6569,7 @@ public class Notification implements Parcelable contentView.setViewVisibility(rowIds[i], View.VISIBLE); contentView.setTextViewText(rowIds[i], mBuilder.processTextSpans(mBuilder.processLegacyText(str))); + mBuilder.updateTextSizeSecondary(contentView, rowIds[i]); mBuilder.setTextViewColorSecondary(contentView, rowIds[i]); contentView.setViewPadding(rowIds[i], 0, topPadding, 0, 0); handleInboxImageMargin(contentView, rowIds[i], first); diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml index 9b1ebc8773843..a835f7ffedfa1 100644 --- a/core/res/res/values/dimens.xml +++ b/core/res/res/values/dimens.xml @@ -346,6 +346,11 @@ 14sp 14sp + + + 16sp + + 20sp 12sp diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 8c10a8db891ca..ba6601141531c 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -3048,6 +3048,9 @@ + + + diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index bcaafccd7acbe..a485712a803df 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -80,6 +80,12 @@ 64dp + + 11sp + + + 13sp + 284dp diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java index 7bc1a39dfff5f..b48f15c13ef74 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java @@ -64,10 +64,10 @@ import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin; import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin.MenuItem; import com.android.systemui.statusbar.NotificationGuts.GutsContent; import com.android.systemui.statusbar.notification.AboveShelfChangedListener; -import com.android.systemui.statusbar.notification.AboveShelfObserver; import com.android.systemui.statusbar.notification.HybridNotificationView; import com.android.systemui.statusbar.notification.NotificationInflater; import com.android.systemui.statusbar.notification.NotificationUtils; +import com.android.systemui.statusbar.notification.NotificationViewWrapper; import com.android.systemui.statusbar.notification.VisualStabilityManager; import com.android.systemui.statusbar.phone.NotificationGroupManager; import com.android.systemui.statusbar.phone.StatusBar; @@ -421,6 +421,9 @@ public class ExpandableNotificationRow extends ActivatableNotificationView } else { minHeight = mNotificationMinHeight; } + NotificationViewWrapper collapsedWrapper = layout.getVisibleWrapper( + NotificationContentView.VISIBLE_TYPE_CONTRACTED); + minHeight += collapsedWrapper.getMinHeightIncrease(mUseIncreasedCollapsedHeight); boolean headsUpCustom = layout.getHeadsUpChild() != null && layout.getHeadsUpChild().getId() != com.android.internal.R.id.status_bar_latest_event_content; @@ -432,6 +435,11 @@ public class ExpandableNotificationRow extends ActivatableNotificationView } else { headsUpheight = mMaxHeadsUpHeight; } + NotificationViewWrapper headsUpWrapper = layout.getVisibleWrapper( + NotificationContentView.VISIBLE_TYPE_HEADSUP); + if (headsUpWrapper != null) { + headsUpheight += headsUpWrapper.getMinHeightIncrease(mUseIncreasedCollapsedHeight); + } layout.setHeights(minHeight, headsUpheight, mNotificationMaxHeight, mNotificationAmbientHeight); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationTemplateViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationTemplateViewWrapper.java index bb979ebd1288b..9bfa7a9752a8b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationTemplateViewWrapper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationTemplateViewWrapper.java @@ -25,6 +25,7 @@ import android.widget.ImageView; import android.widget.ProgressBar; import android.widget.TextView; +import com.android.systemui.R; import com.android.systemui.statusbar.CrossFadeHelper; import com.android.systemui.statusbar.ExpandableNotificationRow; import com.android.systemui.statusbar.TransformableView; @@ -47,6 +48,7 @@ public class NotificationTemplateViewWrapper extends NotificationHeaderViewWrapp private int mContentHeight; private int mMinHeightHint; + private boolean mColorized; protected NotificationTemplateViewWrapper(Context ctx, View view, ExpandableNotificationRow row) { @@ -162,7 +164,9 @@ public class NotificationTemplateViewWrapper extends NotificationHeaderViewWrapp public void onContentUpdated(ExpandableNotificationRow row) { // Reinspect the notification. Before the super call, because the super call also updates // the transformation types and we need to have our values set by then. - resolveTemplateViews(row.getStatusBarNotification()); + StatusBarNotification sbn = row.getStatusBarNotification(); + resolveTemplateViews(sbn); + mColorized = sbn.getNotification().isColorized(); super.onContentUpdated(row); } @@ -265,6 +269,17 @@ public class NotificationTemplateViewWrapper extends NotificationHeaderViewWrapp updateActionOffset(); } + @Override + public int getMinHeightIncrease(boolean useIncreasedCollapsedHeight) { + if (mColorized) { + int dimen = useIncreasedCollapsedHeight + ? R.dimen.notification_height_increase_colorized_increased + : R.dimen.notification_height_increase_colorized; + return mRow.getResources().getDimensionPixelSize(dimen); + } + return super.getMinHeightIncrease(useIncreasedCollapsedHeight); + } + private void updateActionOffset() { if (mActionsContainer != null) { // We should never push the actions higher than they are in the headsup view. diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationViewWrapper.java index 5200d6962ed5d..085bce971ffcc 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationViewWrapper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationViewWrapper.java @@ -190,4 +190,14 @@ public abstract class NotificationViewWrapper implements TransformableView { public boolean disallowSingleClick(float x, float y) { return false; } + + /** + * Get the amount that the minheight is allowed to be increased based on this layout. + * + * @param increasedHeight is the view allowed to show even bigger, i.e for messaging layouts + * @return + */ + public int getMinHeightIncrease(boolean increasedHeight) { + return 0; + } }