Loading res/drawable/button_border_selected.xml +1 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ <solid android:color="@color/notification_importance_selection_bg" /> <stroke android:width="1dp" android:width="2dp" android:color="@color/notification_importance_button_selected"/> <corners android:radius="@dimen/rect_button_radius" /> </shape> res/layout/notif_importance_preference.xml +6 −4 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ android:focusable="true"> <ImageView android:id="@+id/alert_icon" android:src="@drawable/ic_notification_alert" android:src="@drawable/ic_notifications" android:background="@android:color/transparent" android:layout_gravity="center" android:layout_width="wrap_content" Loading Loading @@ -63,7 +63,8 @@ android:ellipsize="end" android:maxLines="2" android:layout_below="@id/alert_icon" android:textAppearance="@style/TextAppearance.NotificationImportanceDetail"/> android:textAppearance="@style/TextAppearance.NotificationImportanceDetail" android:visibility="gone" /> </RelativeLayout> <RelativeLayout Loading @@ -76,7 +77,7 @@ android:focusable="true"> <ImageView android:id="@+id/silence_icon" android:src="@drawable/ic_notification_silence" android:src="@drawable/ic_notifications_off_24dp" android:background="@android:color/transparent" android:layout_gravity="center" android:layout_width="wrap_content" Loading Loading @@ -106,7 +107,8 @@ android:ellipsize="end" android:maxLines="2" android:layout_below="@id/silence_icon" android:textAppearance="@style/TextAppearance.NotificationImportanceDetail"/> android:textAppearance="@style/TextAppearance.NotificationImportanceDetail" android:visibility="gone" /> </RelativeLayout> </LinearLayout> No newline at end of file res/values/strings.xml +3 −12 Original line number Diff line number Diff line Loading @@ -8100,7 +8100,7 @@ <string name="notification_block_title">Block</string> <!-- [CHAR LIMIT=100] Notification Importance title --> <string name="notification_silence_title">Gentle</string> <string name="notification_silence_title">Silent</string> <!-- [CHAR LIMIT=100] Notification Importance title --> <string name="notification_alert_title">Prioritized</string> Loading @@ -8117,19 +8117,10 @@ <string name="notification_channel_summary_min">In the pull-down shade, collapse notifications to one line</string> <!-- [CHAR LIMIT=150] Notification Importance title: low importance level summary --> <string name="notification_channel_summary_low">Helps you focus with notifications only in the pull-down shade. Always silent.</string> <!-- [CHAR LIMIT=150] Notification Importance title: low importance level summary --> <string name="notification_channel_summary_low_status">Displays below priority notifications. Always silent.</string> <!-- [CHAR LIMIT=150] Notification Importance title: low importance level summary --> <string name="notification_channel_summary_low_lock">Displays below priority notifications. Always silent.</string> <!-- [CHAR LIMIT=150] Notification Importance title: low importance level summary --> <string name="notification_channel_summary_low_status_lock">Displays below priority notifications. Always silent.</string> <string name="notification_channel_summary_low">Helps you focus without sound or vibration</string> <!-- [CHAR LIMIT=150] Notification Importance title: normal importance level summary --> <string name="notification_channel_summary_default">Gets your attention with sound & a status bar icon. Shows on lock screen.</string> <string name="notification_channel_summary_default">Gets your attention with sound or vibration</string> <!-- [CHAR LIMIT=150] Notification Importance title: high importance level summary --> <string name="notification_channel_summary_high">When device is unlocked, show notifications as a banner across the top of the screen</string> src/com/android/settings/notification/ImportancePreference.java +28 −11 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import static android.view.View.GONE; import static android.view.View.VISIBLE; import android.content.Context; import android.content.res.ColorStateList; import android.graphics.drawable.Drawable; import android.transition.AutoTransition; import android.transition.TransitionManager; Loading @@ -31,8 +32,10 @@ import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.ImageView; import android.widget.TextView; import com.android.settings.Utils; import com.android.settingslib.R; import androidx.preference.Preference; Loading @@ -50,6 +53,7 @@ public class ImportancePreference extends Preference { Drawable selectedBackground; Drawable unselectedBackground; private static final int BUTTON_ANIM_TIME_MS = 100; private static final boolean SHOW_BUTTON_SUMMARY = false; public ImportancePreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { Loading Loading @@ -140,32 +144,45 @@ public class ImportancePreference extends Preference { }); } private ColorStateList getAccentTint() { return Utils.getColorAccent(getContext()); } private ColorStateList getRegularTint() { return Utils.getColorAttr(getContext(), android.R.attr.textColorPrimary); } void setImportanceSummary(ViewGroup parent, int importance, boolean fromUser) { if (fromUser) { AutoTransition transition = new AutoTransition(); transition.setDuration(BUTTON_ANIM_TIME_MS); TransitionManager.beginDelayedTransition(parent, transition); } ColorStateList colorAccent = getAccentTint(); ColorStateList colorNormal = getRegularTint(); if (importance >= IMPORTANCE_DEFAULT) { parent.findViewById(R.id.silence_summary).setVisibility(GONE); ((ImageView) parent.findViewById(R.id.silence_icon)).setImageTintList(colorNormal); ((TextView) parent.findViewById(R.id.silence_label)).setTextColor(colorNormal); ((ImageView) parent.findViewById(R.id.alert_icon)).setImageTintList(colorAccent); ((TextView) parent.findViewById(R.id.alert_label)).setTextColor(colorAccent); TextView view = parent.findViewById(R.id.alert_summary); view.setText(R.string.notification_channel_summary_default); view.setVisibility(VISIBLE); } else { parent.findViewById(R.id.alert_summary).setVisibility(GONE); ((ImageView) parent.findViewById(R.id.alert_icon)).setImageTintList(colorNormal); ((TextView) parent.findViewById(R.id.alert_label)).setTextColor(colorNormal); ((ImageView) parent.findViewById(R.id.silence_icon)).setImageTintList(colorAccent); ((TextView) parent.findViewById(R.id.silence_label)).setTextColor(colorAccent); TextView view = parent.findViewById(R.id.silence_summary); view.setVisibility(VISIBLE); if (mDisplayInStatusBar) { if (mDisplayOnLockscreen) { view.setText(R.string.notification_channel_summary_low_status_lock); } else { view.setText(R.string.notification_channel_summary_low_status); } } else if (mDisplayOnLockscreen) { view.setText(R.string.notification_channel_summary_low_lock); } else { view.setText(R.string.notification_channel_summary_low); } } } } tests/robotests/src/com/android/settings/notification/ImportancePreferenceTest.java +21 −60 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; Loading Loading @@ -143,84 +144,44 @@ public class ImportancePreferenceTest { } @Test public void setImportanceSummary_status() { ViewGroup parent = new LinearLayout(mContext); TextView tv = new TextView(mContext); tv.setId(R.id.silence_summary); parent.addView(tv); TextView other = new TextView(mContext); other.setId(R.id.alert_summary); parent.addView(other); public void setImportanceSummary() { final ImportancePreference preference = spy(new ImportancePreference(mContext)); final LayoutInflater inflater = LayoutInflater.from(mContext); final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests( inflater.inflate(R.layout.notif_importance_preference, null)); preference.setDisplayInStatusBar(true); preference.setDisplayOnLockscreen(false); preference.setImportanceSummary(parent, IMPORTANCE_LOW, true); assertThat(tv.getText()).isEqualTo( mContext.getString(R.string.notification_channel_summary_low_status)); } @Test public void setImportanceSummary_lock() { ViewGroup parent = new LinearLayout(mContext); TextView tv = new TextView(mContext); tv.setId(R.id.silence_summary); parent.addView(tv); TextView other = new TextView(mContext); other.setId(R.id.alert_summary); parent.addView(other); preference.setConfigurable(true); preference.setImportance(IMPORTANCE_DEFAULT); preference.onBindViewHolder(holder); final ImportancePreference preference = spy(new ImportancePreference(mContext)); TextView tv = holder.itemView.findViewById(R.id.silence_summary); preference.setDisplayInStatusBar(false); preference.setDisplayInStatusBar(true); preference.setDisplayOnLockscreen(true); preference.setImportanceSummary(parent, IMPORTANCE_LOW, true); preference.setImportanceSummary((ViewGroup) holder.itemView, IMPORTANCE_LOW, true); assertThat(tv.getText()).isEqualTo( mContext.getString(R.string.notification_channel_summary_low_lock)); mContext.getString(R.string.notification_channel_summary_low)); } @Test public void setImportanceSummary_statusLock() { ViewGroup parent = new LinearLayout(mContext); TextView tv = new TextView(mContext); tv.setId(R.id.silence_summary); parent.addView(tv); TextView other = new TextView(mContext); other.setId(R.id.alert_summary); parent.addView(other); public void setImportanceSummary_default() { final ImportancePreference preference = spy(new ImportancePreference(mContext)); final LayoutInflater inflater = LayoutInflater.from(mContext); final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests( inflater.inflate(R.layout.notif_importance_preference, null)); preference.setDisplayInStatusBar(true); preference.setDisplayOnLockscreen(true); preference.setImportanceSummary(parent, IMPORTANCE_LOW, true); assertThat(tv.getText()).isEqualTo( mContext.getString(R.string.notification_channel_summary_low_status_lock)); } @Test public void setImportanceSummary_statusLock_default() { ViewGroup parent = new LinearLayout(mContext); TextView tv = new TextView(mContext); tv.setId(R.id.alert_summary); parent.addView(tv); TextView other = new TextView(mContext); other.setId(R.id.silence_summary); parent.addView(other); preference.setConfigurable(true); preference.setImportance(IMPORTANCE_DEFAULT); preference.onBindViewHolder(holder); final ImportancePreference preference = spy(new ImportancePreference(mContext)); TextView tv = holder.itemView.findViewById(R.id.alert_summary); preference.setDisplayInStatusBar(true); preference.setDisplayOnLockscreen(true); preference.setImportanceSummary(parent, IMPORTANCE_DEFAULT, true); preference.setImportanceSummary((ViewGroup) holder.itemView, IMPORTANCE_DEFAULT, true); assertThat(tv.getText()).isEqualTo( mContext.getString(R.string.notification_channel_summary_default)); Loading Loading
res/drawable/button_border_selected.xml +1 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ <solid android:color="@color/notification_importance_selection_bg" /> <stroke android:width="1dp" android:width="2dp" android:color="@color/notification_importance_button_selected"/> <corners android:radius="@dimen/rect_button_radius" /> </shape>
res/layout/notif_importance_preference.xml +6 −4 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ android:focusable="true"> <ImageView android:id="@+id/alert_icon" android:src="@drawable/ic_notification_alert" android:src="@drawable/ic_notifications" android:background="@android:color/transparent" android:layout_gravity="center" android:layout_width="wrap_content" Loading Loading @@ -63,7 +63,8 @@ android:ellipsize="end" android:maxLines="2" android:layout_below="@id/alert_icon" android:textAppearance="@style/TextAppearance.NotificationImportanceDetail"/> android:textAppearance="@style/TextAppearance.NotificationImportanceDetail" android:visibility="gone" /> </RelativeLayout> <RelativeLayout Loading @@ -76,7 +77,7 @@ android:focusable="true"> <ImageView android:id="@+id/silence_icon" android:src="@drawable/ic_notification_silence" android:src="@drawable/ic_notifications_off_24dp" android:background="@android:color/transparent" android:layout_gravity="center" android:layout_width="wrap_content" Loading Loading @@ -106,7 +107,8 @@ android:ellipsize="end" android:maxLines="2" android:layout_below="@id/silence_icon" android:textAppearance="@style/TextAppearance.NotificationImportanceDetail"/> android:textAppearance="@style/TextAppearance.NotificationImportanceDetail" android:visibility="gone" /> </RelativeLayout> </LinearLayout> No newline at end of file
res/values/strings.xml +3 −12 Original line number Diff line number Diff line Loading @@ -8100,7 +8100,7 @@ <string name="notification_block_title">Block</string> <!-- [CHAR LIMIT=100] Notification Importance title --> <string name="notification_silence_title">Gentle</string> <string name="notification_silence_title">Silent</string> <!-- [CHAR LIMIT=100] Notification Importance title --> <string name="notification_alert_title">Prioritized</string> Loading @@ -8117,19 +8117,10 @@ <string name="notification_channel_summary_min">In the pull-down shade, collapse notifications to one line</string> <!-- [CHAR LIMIT=150] Notification Importance title: low importance level summary --> <string name="notification_channel_summary_low">Helps you focus with notifications only in the pull-down shade. Always silent.</string> <!-- [CHAR LIMIT=150] Notification Importance title: low importance level summary --> <string name="notification_channel_summary_low_status">Displays below priority notifications. Always silent.</string> <!-- [CHAR LIMIT=150] Notification Importance title: low importance level summary --> <string name="notification_channel_summary_low_lock">Displays below priority notifications. Always silent.</string> <!-- [CHAR LIMIT=150] Notification Importance title: low importance level summary --> <string name="notification_channel_summary_low_status_lock">Displays below priority notifications. Always silent.</string> <string name="notification_channel_summary_low">Helps you focus without sound or vibration</string> <!-- [CHAR LIMIT=150] Notification Importance title: normal importance level summary --> <string name="notification_channel_summary_default">Gets your attention with sound & a status bar icon. Shows on lock screen.</string> <string name="notification_channel_summary_default">Gets your attention with sound or vibration</string> <!-- [CHAR LIMIT=150] Notification Importance title: high importance level summary --> <string name="notification_channel_summary_high">When device is unlocked, show notifications as a banner across the top of the screen</string>
src/com/android/settings/notification/ImportancePreference.java +28 −11 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import static android.view.View.GONE; import static android.view.View.VISIBLE; import android.content.Context; import android.content.res.ColorStateList; import android.graphics.drawable.Drawable; import android.transition.AutoTransition; import android.transition.TransitionManager; Loading @@ -31,8 +32,10 @@ import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.ImageView; import android.widget.TextView; import com.android.settings.Utils; import com.android.settingslib.R; import androidx.preference.Preference; Loading @@ -50,6 +53,7 @@ public class ImportancePreference extends Preference { Drawable selectedBackground; Drawable unselectedBackground; private static final int BUTTON_ANIM_TIME_MS = 100; private static final boolean SHOW_BUTTON_SUMMARY = false; public ImportancePreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { Loading Loading @@ -140,32 +144,45 @@ public class ImportancePreference extends Preference { }); } private ColorStateList getAccentTint() { return Utils.getColorAccent(getContext()); } private ColorStateList getRegularTint() { return Utils.getColorAttr(getContext(), android.R.attr.textColorPrimary); } void setImportanceSummary(ViewGroup parent, int importance, boolean fromUser) { if (fromUser) { AutoTransition transition = new AutoTransition(); transition.setDuration(BUTTON_ANIM_TIME_MS); TransitionManager.beginDelayedTransition(parent, transition); } ColorStateList colorAccent = getAccentTint(); ColorStateList colorNormal = getRegularTint(); if (importance >= IMPORTANCE_DEFAULT) { parent.findViewById(R.id.silence_summary).setVisibility(GONE); ((ImageView) parent.findViewById(R.id.silence_icon)).setImageTintList(colorNormal); ((TextView) parent.findViewById(R.id.silence_label)).setTextColor(colorNormal); ((ImageView) parent.findViewById(R.id.alert_icon)).setImageTintList(colorAccent); ((TextView) parent.findViewById(R.id.alert_label)).setTextColor(colorAccent); TextView view = parent.findViewById(R.id.alert_summary); view.setText(R.string.notification_channel_summary_default); view.setVisibility(VISIBLE); } else { parent.findViewById(R.id.alert_summary).setVisibility(GONE); ((ImageView) parent.findViewById(R.id.alert_icon)).setImageTintList(colorNormal); ((TextView) parent.findViewById(R.id.alert_label)).setTextColor(colorNormal); ((ImageView) parent.findViewById(R.id.silence_icon)).setImageTintList(colorAccent); ((TextView) parent.findViewById(R.id.silence_label)).setTextColor(colorAccent); TextView view = parent.findViewById(R.id.silence_summary); view.setVisibility(VISIBLE); if (mDisplayInStatusBar) { if (mDisplayOnLockscreen) { view.setText(R.string.notification_channel_summary_low_status_lock); } else { view.setText(R.string.notification_channel_summary_low_status); } } else if (mDisplayOnLockscreen) { view.setText(R.string.notification_channel_summary_low_lock); } else { view.setText(R.string.notification_channel_summary_low); } } } }
tests/robotests/src/com/android/settings/notification/ImportancePreferenceTest.java +21 −60 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; Loading Loading @@ -143,84 +144,44 @@ public class ImportancePreferenceTest { } @Test public void setImportanceSummary_status() { ViewGroup parent = new LinearLayout(mContext); TextView tv = new TextView(mContext); tv.setId(R.id.silence_summary); parent.addView(tv); TextView other = new TextView(mContext); other.setId(R.id.alert_summary); parent.addView(other); public void setImportanceSummary() { final ImportancePreference preference = spy(new ImportancePreference(mContext)); final LayoutInflater inflater = LayoutInflater.from(mContext); final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests( inflater.inflate(R.layout.notif_importance_preference, null)); preference.setDisplayInStatusBar(true); preference.setDisplayOnLockscreen(false); preference.setImportanceSummary(parent, IMPORTANCE_LOW, true); assertThat(tv.getText()).isEqualTo( mContext.getString(R.string.notification_channel_summary_low_status)); } @Test public void setImportanceSummary_lock() { ViewGroup parent = new LinearLayout(mContext); TextView tv = new TextView(mContext); tv.setId(R.id.silence_summary); parent.addView(tv); TextView other = new TextView(mContext); other.setId(R.id.alert_summary); parent.addView(other); preference.setConfigurable(true); preference.setImportance(IMPORTANCE_DEFAULT); preference.onBindViewHolder(holder); final ImportancePreference preference = spy(new ImportancePreference(mContext)); TextView tv = holder.itemView.findViewById(R.id.silence_summary); preference.setDisplayInStatusBar(false); preference.setDisplayInStatusBar(true); preference.setDisplayOnLockscreen(true); preference.setImportanceSummary(parent, IMPORTANCE_LOW, true); preference.setImportanceSummary((ViewGroup) holder.itemView, IMPORTANCE_LOW, true); assertThat(tv.getText()).isEqualTo( mContext.getString(R.string.notification_channel_summary_low_lock)); mContext.getString(R.string.notification_channel_summary_low)); } @Test public void setImportanceSummary_statusLock() { ViewGroup parent = new LinearLayout(mContext); TextView tv = new TextView(mContext); tv.setId(R.id.silence_summary); parent.addView(tv); TextView other = new TextView(mContext); other.setId(R.id.alert_summary); parent.addView(other); public void setImportanceSummary_default() { final ImportancePreference preference = spy(new ImportancePreference(mContext)); final LayoutInflater inflater = LayoutInflater.from(mContext); final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests( inflater.inflate(R.layout.notif_importance_preference, null)); preference.setDisplayInStatusBar(true); preference.setDisplayOnLockscreen(true); preference.setImportanceSummary(parent, IMPORTANCE_LOW, true); assertThat(tv.getText()).isEqualTo( mContext.getString(R.string.notification_channel_summary_low_status_lock)); } @Test public void setImportanceSummary_statusLock_default() { ViewGroup parent = new LinearLayout(mContext); TextView tv = new TextView(mContext); tv.setId(R.id.alert_summary); parent.addView(tv); TextView other = new TextView(mContext); other.setId(R.id.silence_summary); parent.addView(other); preference.setConfigurable(true); preference.setImportance(IMPORTANCE_DEFAULT); preference.onBindViewHolder(holder); final ImportancePreference preference = spy(new ImportancePreference(mContext)); TextView tv = holder.itemView.findViewById(R.id.alert_summary); preference.setDisplayInStatusBar(true); preference.setDisplayOnLockscreen(true); preference.setImportanceSummary(parent, IMPORTANCE_DEFAULT, true); preference.setImportanceSummary((ViewGroup) holder.itemView, IMPORTANCE_DEFAULT, true); assertThat(tv.getText()).isEqualTo( mContext.getString(R.string.notification_channel_summary_default)); Loading