From 369f147e8f6c60b88399a9f6c787f9a773240c9d Mon Sep 17 00:00:00 2001 From: Ned Burns Date: Wed, 22 May 2019 21:07:26 -0400 Subject: [PATCH] Update guts to match latest specs - Updates dimens and margins to match specs - Adds selection color for border, icon, and text - Adjusts fonts to be theme-aware Test: manual Bug: 132689331 Change-Id: Ibd2ca853c9a571f25d82151bdd736edb4d5c5d5e --- ...ification_guts_priority_button_bg_fill.xml | 21 +++ ...ication_guts_priority_button_bg_stroke.xml | 21 +++ .../notification_guts_priority_contents.xml | 21 +++ .../res/drawable/button_border_selected.xml | 25 --- .../res/drawable/button_border_unselected.xml | 25 --- .../res/drawable/button_ripple_radius.xml | 26 --- .../notification_guts_priority_button_bg.xml | 27 ++++ .../SystemUI/res/layout/notification_info.xml | 135 +++++++++------- packages/SystemUI/res/values-night/colors.xml | 12 +- packages/SystemUI/res/values/colors.xml | 12 +- packages/SystemUI/res/values/dimens.xml | 9 +- packages/SystemUI/res/values/strings.xml | 17 +- packages/SystemUI/res/values/styles.xml | 23 +-- .../notification/row/NotificationInfo.java | 148 ++++++++---------- 14 files changed, 266 insertions(+), 256 deletions(-) create mode 100644 packages/SystemUI/res/color/notification_guts_priority_button_bg_fill.xml create mode 100644 packages/SystemUI/res/color/notification_guts_priority_button_bg_stroke.xml create mode 100644 packages/SystemUI/res/color/notification_guts_priority_contents.xml delete mode 100644 packages/SystemUI/res/drawable/button_border_selected.xml delete mode 100644 packages/SystemUI/res/drawable/button_border_unselected.xml delete mode 100644 packages/SystemUI/res/drawable/button_ripple_radius.xml create mode 100644 packages/SystemUI/res/drawable/notification_guts_priority_button_bg.xml diff --git a/packages/SystemUI/res/color/notification_guts_priority_button_bg_fill.xml b/packages/SystemUI/res/color/notification_guts_priority_button_bg_fill.xml new file mode 100644 index 0000000000000..8ef1bf9ca5839 --- /dev/null +++ b/packages/SystemUI/res/color/notification_guts_priority_button_bg_fill.xml @@ -0,0 +1,21 @@ + + + + + + diff --git a/packages/SystemUI/res/color/notification_guts_priority_button_bg_stroke.xml b/packages/SystemUI/res/color/notification_guts_priority_button_bg_stroke.xml new file mode 100644 index 0000000000000..7964609f62e01 --- /dev/null +++ b/packages/SystemUI/res/color/notification_guts_priority_button_bg_stroke.xml @@ -0,0 +1,21 @@ + + + + + + diff --git a/packages/SystemUI/res/color/notification_guts_priority_contents.xml b/packages/SystemUI/res/color/notification_guts_priority_contents.xml new file mode 100644 index 0000000000000..56c43f0e5642c --- /dev/null +++ b/packages/SystemUI/res/color/notification_guts_priority_contents.xml @@ -0,0 +1,21 @@ + + + + + + diff --git a/packages/SystemUI/res/drawable/button_border_selected.xml b/packages/SystemUI/res/drawable/button_border_selected.xml deleted file mode 100644 index 01e7099844a9f..0000000000000 --- a/packages/SystemUI/res/drawable/button_border_selected.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/packages/SystemUI/res/drawable/button_border_unselected.xml b/packages/SystemUI/res/drawable/button_border_unselected.xml deleted file mode 100644 index b9c4ced3631bf..0000000000000 --- a/packages/SystemUI/res/drawable/button_border_unselected.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/packages/SystemUI/res/drawable/button_ripple_radius.xml b/packages/SystemUI/res/drawable/button_ripple_radius.xml deleted file mode 100644 index 5c2857a4765c7..0000000000000 --- a/packages/SystemUI/res/drawable/button_ripple_radius.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/packages/SystemUI/res/drawable/notification_guts_priority_button_bg.xml b/packages/SystemUI/res/drawable/notification_guts_priority_button_bg.xml new file mode 100644 index 0000000000000..a0e025fb9bb7c --- /dev/null +++ b/packages/SystemUI/res/drawable/notification_guts_priority_button_bg.xml @@ -0,0 +1,27 @@ + + + + + + + + + diff --git a/packages/SystemUI/res/layout/notification_info.xml b/packages/SystemUI/res/layout/notification_info.xml index 4b672ee0733ff..8ffa2d83cfa2f 100644 --- a/packages/SystemUI/res/layout/notification_info.xml +++ b/packages/SystemUI/res/layout/notification_info.xml @@ -219,106 +219,127 @@ asked for it --> android:gravity="center" android:orientation="vertical"> - - - + + android:orientation="horizontal" + android:gravity="center" + > + + + - + - - - + + android:orientation="horizontal" + android:gravity="center" + > + + + - + + android:layout_height="60dp" + android:gravity="center_vertical" + android:paddingStart="4dp" + android:paddingEnd="4dp" + > android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentEnd="true" - android:gravity="center_vertical|end" - android:maxWidth="125dp" + android:gravity="end|center_vertical" android:minWidth="@dimen/notification_importance_toggle_size" android:minHeight="@dimen/notification_importance_toggle_size" + android:maxWidth="125dp" style="@style/TextAppearance.NotificationInfo.Button"/> diff --git a/packages/SystemUI/res/values-night/colors.xml b/packages/SystemUI/res/values-night/colors.xml index addc10aaeff66..dd3073fb5e65f 100644 --- a/packages/SystemUI/res/values-night/colors.xml +++ b/packages/SystemUI/res/values-night/colors.xml @@ -42,12 +42,16 @@ @*android:color/notification_primary_text_color_dark - @color/GM2_grey_800 - @color/GM2_grey_700 @color/GM2_grey_500 - @color/GM2_grey_200 + @color/GM2_grey_500 @color/GM2_grey_200 - @color/GM2_blue_200 + @color/GM2_blue_300 + @color/GM2_grey_500 + @color/GM2_blue_300 + @color/transparent + @color/GM2_grey_800 + @color/GM2_grey_700 + @color/GM2_grey_700 @color/GM2_grey_200 @color/GM2_grey_500 diff --git a/packages/SystemUI/res/values/colors.xml b/packages/SystemUI/res/values/colors.xml index f41566178d335..3f84b32ee0c27 100644 --- a/packages/SystemUI/res/values/colors.xml +++ b/packages/SystemUI/res/values/colors.xml @@ -91,14 +91,18 @@ @color/GM2_grey_50 - #FFFFFF - #4285F4 @color/GM2_grey_700 @color/GM2_grey_700 @color/GM2_grey_900 #FF32c1de #FFF87B2B - @color/GM2_blue_700 + @color/GM2_blue_700 + @color/GM2_grey_700 + @color/GM2_blue_700 + @color/transparent + #FFFFFF + @color/GM2_grey_300 + @color/GM2_blue_600 @color/GM2_grey_900 @color/GM2_grey_700 @@ -188,6 +192,8 @@ #C5221F #AECBFA + #8AB4F8 + #1A73E8 #1967D2 #FFFBBC04 diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index b27836d640d83..19874948cb544 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -218,7 +218,7 @@ 15dp - 20dp + 16dp 6dp @@ -227,7 +227,7 @@ 28dp 28dp 20dp - 16dp + 8dp 178dp 28dp 8dp @@ -236,8 +236,9 @@ 14sp 16sp 14sp - 16sp - 14dp + 14sp + 16dp + 12dp 8dp diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index 98312505b80d2..8bc84c6d4a44d 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -1677,25 +1677,16 @@ Keep showing notifications from this app? - Gentle + Silent - Prioritized + Alerting - Helps you focus with notifications only in the pull-down shade. Always silent. - - - Displays below priority notifications. Always silent. - - - Displays below priority notifications. Always silent. - - - Displays below priority notifications. Always silent. + Helps you focus without sound or vibration. - Gets your attention with sound & a status bar icon. Shows on lock screen. + Gets your attention with sound or vibration. These notifications can\'t be modified. diff --git a/packages/SystemUI/res/values/styles.xml b/packages/SystemUI/res/values/styles.xml index 9861750a6dcbd..c4926685ee7ed 100644 --- a/packages/SystemUI/res/values/styles.xml +++ b/packages/SystemUI/res/values/styles.xml @@ -459,9 +459,9 @@ @@ -496,18 +496,11 @@ - - - - diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationInfo.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationInfo.java index e4e8c80867b1d..1dc96b82f4a58 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationInfo.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationInfo.java @@ -20,6 +20,10 @@ import static android.app.NotificationManager.IMPORTANCE_DEFAULT; import static android.app.NotificationManager.IMPORTANCE_LOW; import static android.app.NotificationManager.IMPORTANCE_UNSPECIFIED; +import static com.android.systemui.Interpolators.FAST_OUT_SLOW_IN; + +import static java.lang.annotation.RetentionPolicy.SOURCE; + import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; @@ -40,11 +44,12 @@ import android.graphics.drawable.Drawable; import android.metrics.LogMaker; import android.os.Handler; import android.os.RemoteException; -import android.provider.Settings; import android.service.notification.StatusBarNotification; import android.text.TextUtils; -import android.transition.AutoTransition; +import android.transition.ChangeBounds; +import android.transition.Fade; import android.transition.TransitionManager; +import android.transition.TransitionSet; import android.util.AttributeSet; import android.util.Log; import android.view.View; @@ -62,6 +67,7 @@ import com.android.systemui.Interpolators; import com.android.systemui.R; import com.android.systemui.statusbar.notification.logging.NotificationCounters; +import java.lang.annotation.Retention; import java.util.List; import java.util.Set; @@ -92,9 +98,8 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G // standard controls private static final int ACTION_ALERT = 5; - private static final int BUTTON_ANIM_TIME_MS = 200; - - private static final boolean SHOW_BUTTON_SUMMARY = false; + private TextView mPriorityDescriptionView; + private TextView mSilentDescriptionView; private INotificationManager mINotificationManager; private PackageManager mPm; @@ -110,8 +115,6 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G private NotificationChannel mSingleNotificationChannel; private int mStartingChannelImportance; private boolean mWasShownHighPriority; - private boolean mShowOnLockscreen; - private boolean mShowInStatusBar; private boolean mPressedApply; /** @@ -129,8 +132,6 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G private OnSettingsClickListener mOnSettingsClickListener; private OnAppSettingsClickListener mAppSettingsClickListener; private NotificationGuts mGutsContainer; - private Drawable mSelectedBackground; - private Drawable mUnselectedBackground; private Drawable mPkgIcon; /** Whether this view is being shown as part of the blocking helper. */ @@ -145,16 +146,14 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G private OnClickListener mOnAlert = v -> { mExitReason = NotificationCounters.BLOCKING_HELPER_KEEP_SHOWING; mChosenImportance = IMPORTANCE_DEFAULT; - setImportanceSummary(ACTION_ALERT, true); - updateButtons(ACTION_ALERT); + applyAlertingBehavior(BEHAVIOR_ALERTING, true /* userTriggered */); }; // used by standard ui private OnClickListener mOnSilent = v -> { mExitReason = NotificationCounters.BLOCKING_HELPER_DELIVER_SILENTLY; mChosenImportance = IMPORTANCE_LOW; - setImportanceSummary(ACTION_TOGGLE_SILENT, true); - updateButtons(ACTION_TOGGLE_SILENT); + applyAlertingBehavior(BEHAVIOR_SILENT, true /* userTriggered */); }; // used by standard ui @@ -218,6 +217,14 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G super(context, attrs); } + @Override + protected void onFinishInflate() { + super.onFinishInflate(); + + mPriorityDescriptionView = findViewById(R.id.alert_summary); + mSilentDescriptionView = findViewById(R.id.silence_summary); + } + // Specify a CheckSaveListener to override when/if the user's changes are committed. public interface CheckSaveListener { // Invoked when importance has changed and the NotificationInfo wants to try to save it. @@ -293,9 +300,6 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G mDelegatePkg = mSbn.getOpPkg(); mIsDeviceProvisioned = isDeviceProvisioned; - mSelectedBackground = mContext.getDrawable(R.drawable.button_border_selected); - mUnselectedBackground = mContext.getDrawable(R.drawable.button_border_unselected); - int numTotalChannels = mINotificationManager.getNumNotificationChannelsForPackage( pkg, mAppUid, false /* includeDeleted */); if (mNumUniqueChannelsInRow == 0) { @@ -308,11 +312,6 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G && numTotalChannels == 1; } - mShowInStatusBar = !mINotificationManager.shouldHideSilentStatusIcons( - mContext.getPackageName()); - mShowOnLockscreen = Settings.Secure.getInt(mContext.getContentResolver(), - Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 0) == 1; - bindHeader(); bindChannelDetails(); @@ -376,13 +375,9 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G silent.setOnClickListener(mOnSilent); alert.setOnClickListener(mOnAlert); - if (mWasShownHighPriority) { - updateButtons(ACTION_ALERT); - setImportanceSummary(ACTION_ALERT, false); - } else { - updateButtons(ACTION_TOGGLE_SILENT); - setImportanceSummary(ACTION_TOGGLE_SILENT, false); - } + applyAlertingBehavior( + mWasShownHighPriority ? BEHAVIOR_ALERTING : BEHAVIOR_SILENT, + false /* userTriggered */); } private void bindHeader() { @@ -545,66 +540,45 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G } } - private void updateButtons(int blockState) { - View silence = findViewById(R.id.silence); - View alert = findViewById(R.id.alert); - TextView done = findViewById(R.id.done); - switch (blockState) { - case ACTION_TOGGLE_SILENT: - updateButtons(silence, alert); - if (mWasShownHighPriority) { - done.setText(R.string.inline_ok_button); - } else { - done.setText(R.string.inline_done_button); - } - break; - case ACTION_ALERT: - updateButtons(alert, silence); - if (mWasShownHighPriority) { - done.setText(R.string.inline_done_button); - } else { - done.setText(R.string.inline_ok_button); - } - break; - } - } - - private void updateButtons(View selected, View unselected) { - selected.setBackground(mSelectedBackground); - selected.setSelected(true); - unselected.setBackground(mUnselectedBackground); - unselected.setSelected(false); - } - - void setImportanceSummary(int blockState, boolean userTriggered) { + private void applyAlertingBehavior(@AlertingBehavior int behavior, boolean userTriggered) { if (userTriggered) { - AutoTransition transition = new AutoTransition(); - transition.setDuration(BUTTON_ANIM_TIME_MS); + TransitionSet transition = new TransitionSet(); + transition.setOrdering(TransitionSet.ORDERING_TOGETHER); + transition.addTransition(new Fade(Fade.OUT)) + .addTransition(new ChangeBounds()) + .addTransition( + new Fade(Fade.IN) + .setStartDelay(150) + .setDuration(200) + .setInterpolator(FAST_OUT_SLOW_IN)); + transition.setDuration(350); + transition.setInterpolator(FAST_OUT_SLOW_IN); TransitionManager.beginDelayedTransition(this, transition); } - if (SHOW_BUTTON_SUMMARY) { - if (blockState == ACTION_ALERT) { - TextView view = findViewById(R.id.alert_summary); - view.setVisibility(VISIBLE); - findViewById(R.id.silence_summary).setVisibility(GONE); - view.setText(R.string.notification_channel_summary_default); - } else { - TextView view = findViewById(R.id.silence_summary); - view.setVisibility(VISIBLE); - findViewById(R.id.alert_summary).setVisibility(GONE); - if (mShowInStatusBar) { - if (mShowOnLockscreen) { - view.setText(R.string.notification_channel_summary_low_status_lock); - } else { - view.setText(R.string.notification_channel_summary_low_status); - } - } else if (mShowOnLockscreen) { - view.setText(R.string.notification_channel_summary_low_lock); - } else { - view.setText(R.string.notification_channel_summary_low); - } - } + + View alert = findViewById(R.id.alert); + View silence = findViewById(R.id.silence); + + switch (behavior) { + case BEHAVIOR_ALERTING: + alert.setSelected(true); + silence.setSelected(false); + mPriorityDescriptionView.setVisibility(VISIBLE); + mSilentDescriptionView.setVisibility(GONE); + break; + case BEHAVIOR_SILENT: + alert.setSelected(false); + silence.setSelected(true); + mSilentDescriptionView.setVisibility(VISIBLE); + mPriorityDescriptionView.setVisibility(GONE); + break; + default: + throw new IllegalArgumentException("Unrecognized alerting behavior: " + behavior); } + + boolean isAChange = mWasShownHighPriority != (behavior == BEHAVIOR_ALERTING); + TextView done = findViewById(R.id.done); + done.setText(isAChange ? R.string.inline_ok_button : R.string.inline_done_button); } private void saveImportanceAndExitReason(@NotificationInfoAction int action) { @@ -883,4 +857,10 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G .setSubtype(mIsForBlockingHelper ? MetricsEvent.BLOCKING_HELPER_DISPLAY : MetricsEvent.BLOCKING_HELPER_UNKNOWN); } + + @Retention(SOURCE) + @IntDef({BEHAVIOR_ALERTING, BEHAVIOR_SILENT}) + private @interface AlertingBehavior {} + private static final int BEHAVIOR_ALERTING = 0; + private static final int BEHAVIOR_SILENT = 1; }