diff --git a/res/drawable/button_border_selected.xml b/res/drawable/button_border_selected.xml
index 2681bf051b4..9701b382540 100644
--- a/res/drawable/button_border_selected.xml
+++ b/res/drawable/button_border_selected.xml
@@ -18,6 +18,6 @@
android:shape="rectangle">
+ android:color="?android:attr/textColorSecondary"/>
-
\ No newline at end of file
+
diff --git a/res/drawable/button_border_unselected.xml b/res/drawable/button_border_unselected.xml
index 72e9076ccf2..4153303667d 100644
--- a/res/drawable/button_border_unselected.xml
+++ b/res/drawable/button_border_unselected.xml
@@ -18,7 +18,7 @@
android:shape="rectangle">
+ android:color="?android:attr/textColorSecondary"/>
-
\ No newline at end of file
+
diff --git a/res/layout/notif_importance_preference.xml b/res/layout/notif_importance_preference.xml
index bc0d5aa90b3..3507675c44a 100644
--- a/res/layout/notif_importance_preference.xml
+++ b/res/layout/notif_importance_preference.xml
@@ -21,53 +21,92 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
+ android:padding="@dimen/notification_importance_toggle_marginTop"
android:orientation="vertical">
-
+ android:padding="@dimen/notification_importance_button_padding"
+ android:clickable="true"
+ android:focusable="true">
+
+
+
+
-
-
-
-
-
-
-
+ android:padding="@dimen/notification_importance_button_padding"
+ android:layout_marginTop="@dimen/notification_importance_button_separation"
+ android:clickable="true"
+ android:focusable="true">
+
+
+
+
\ No newline at end of file
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index c871ac8b525..a348f8ad4fc 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -79,6 +79,7 @@
20dp
14sp
16sp
+ 14dp
7dp
17dp
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 98892e40b06..615077c6c13 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -7805,7 +7805,7 @@
Work notifications
- Smart notifications
+ Adaptive notifications
Automatic Prioritization
@@ -7976,25 +7976,25 @@
-
+
In the pull-down shade, collapse notifications to one line
-
- Always silent. Displays in pull-down shade.
+
+ Helps you focus with notifications only in the pull-down shade. Always silent.
-
- Always silent. Displays in pull-down shade & status bar.
+
+ Displays below priority notifications. Always silent.
-
- Always silent. Displays in pull-down shade & on lock screen.
+
+ Displays below priority notifications. Always silent.
-
- Always silent. Displays in pull-down shade, status bar & on lock screen.
+
+ Displays below priority notifications. Always silent.
-
- Makes sound and displays in pull-down shade, status bar & on lock screen.
+
+ Gets your attention with sound & a status bar icon. Shows on lock screen.
-
+
When device is unlocked, show notifications as a banner across the top of the screen
diff --git a/src/com/android/settings/notification/ImportancePreference.java b/src/com/android/settings/notification/ImportancePreference.java
index 687782bdc0d..f48882d8518 100644
--- a/src/com/android/settings/notification/ImportancePreference.java
+++ b/src/com/android/settings/notification/ImportancePreference.java
@@ -20,10 +20,16 @@ import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
import static android.app.NotificationManager.IMPORTANCE_HIGH;
import static android.app.NotificationManager.IMPORTANCE_LOW;
import static android.app.NotificationManager.IMPORTANCE_MIN;
+import static android.view.View.GONE;
+import static android.view.View.VISIBLE;
import android.content.Context;
import android.graphics.drawable.Drawable;
+import android.transition.AutoTransition;
+import android.transition.TransitionManager;
import android.util.AttributeSet;
+import android.view.View;
+import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
@@ -38,11 +44,12 @@ public class ImportancePreference extends Preference {
private int mImportance;
private boolean mDisplayInStatusBar;
private boolean mDisplayOnLockscreen;
- private Button mSilenceButton;
- private Button mAlertButton;
+ private View mSilenceButton;
+ private View mAlertButton;
private Context mContext;
Drawable selectedBackground;
Drawable unselectedBackground;
+ private static final int BUTTON_ANIM_TIME_MS = 100;
public ImportancePreference(Context context, AttributeSet attrs,
int defStyleAttr, int defStyleRes) {
@@ -89,13 +96,12 @@ public class ImportancePreference extends Preference {
}
@Override
- public void onBindViewHolder(PreferenceViewHolder holder) {
+ public void onBindViewHolder(final PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
holder.itemView.setClickable(false);
- TextView textView = (TextView) holder.findViewById(R.id.description);
- mSilenceButton = (Button) holder.findViewById(R.id.silence);
- mAlertButton = (Button) holder.findViewById(R.id.alert);
+ mSilenceButton = holder.findViewById(R.id.silence);
+ mAlertButton = holder.findViewById(R.id.alert);
if (!mIsConfigurable) {
mSilenceButton.setEnabled(false);
@@ -114,34 +120,41 @@ public class ImportancePreference extends Preference {
mAlertButton.setBackground(selectedBackground);
break;
}
- setImportanceSummary(textView, mImportance);
+ setImportanceSummary((ViewGroup) holder.itemView, mImportance, false);
mSilenceButton.setOnClickListener(v -> {
callChangeListener(IMPORTANCE_LOW);
mAlertButton.setBackground(unselectedBackground);
+ mAlertButton.setSelected(false);
mSilenceButton.setBackground(selectedBackground);
- mSilenceButton.setTextAppearance(
- R.style.TextAppearance_NotificationImportanceButton_Selected);
- mAlertButton.setTextAppearance(
- R.style.TextAppearance_NotificationImportanceButton_Unselected);
- setImportanceSummary(textView, IMPORTANCE_LOW);
+ mSilenceButton.setSelected(true);
+ setImportanceSummary((ViewGroup) holder.itemView, IMPORTANCE_LOW, true);
});
mAlertButton.setOnClickListener(v -> {
callChangeListener(IMPORTANCE_DEFAULT);
mSilenceButton.setBackground(unselectedBackground);
+ mSilenceButton.setSelected(false);
mAlertButton.setBackground(selectedBackground);
- mAlertButton.setTextAppearance(
- R.style.TextAppearance_NotificationImportanceButton_Selected);
- mSilenceButton.setTextAppearance(
- R.style.TextAppearance_NotificationImportanceButton_Unselected);
- setImportanceSummary(textView, IMPORTANCE_DEFAULT);
+ mAlertButton.setSelected(true);
+ setImportanceSummary((ViewGroup) holder.itemView, IMPORTANCE_DEFAULT, true);
});
}
- void setImportanceSummary(TextView view, int importance) {
+ void setImportanceSummary(ViewGroup parent, int importance, boolean fromUser) {
+ if (fromUser) {
+ AutoTransition transition = new AutoTransition();
+ transition.setDuration(BUTTON_ANIM_TIME_MS);
+ TransitionManager.beginDelayedTransition(parent, transition);
+ }
if (importance >= IMPORTANCE_DEFAULT) {
+ parent.findViewById(R.id.silence_summary).setVisibility(GONE);
+ 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);
+ 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);
diff --git a/src/com/android/settings/notification/ImportancePreferenceController.java b/src/com/android/settings/notification/ImportancePreferenceController.java
index 46b2ec6ca78..dc592754c7d 100644
--- a/src/com/android/settings/notification/ImportancePreferenceController.java
+++ b/src/com/android/settings/notification/ImportancePreferenceController.java
@@ -22,6 +22,7 @@ import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
import android.app.NotificationChannel;
import android.content.Context;
import android.media.RingtoneManager;
+import android.provider.Settings;
import com.android.settings.core.PreferenceControllerMixin;
@@ -64,7 +65,8 @@ public class ImportancePreferenceController extends NotificationPreferenceContro
pref.setConfigurable(!mChannel.isImportanceLockedByOEM());
pref.setImportance(mChannel.getImportance());
pref.setDisplayInStatusBar(mBackend.showSilentInStatusBar(mContext.getPackageName()));
- // TODO: b/128445911 pass along lock screen setting
+ pref.setDisplayOnLockscreen(Settings.Secure.getInt(mContext.getContentResolver(),
+ Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 0) == 1);
}
}
diff --git a/tests/robotests/src/com/android/settings/notification/ImportancePreferenceTest.java b/tests/robotests/src/com/android/settings/notification/ImportancePreferenceTest.java
index 63bc8284255..b4379aadc44 100644
--- a/tests/robotests/src/com/android/settings/notification/ImportancePreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ImportancePreferenceTest.java
@@ -29,7 +29,10 @@ import static org.mockito.Mockito.verify;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
import android.widget.Button;
+import android.widget.LinearLayout;
import android.widget.TextView;
import com.android.settings.R;
@@ -110,8 +113,8 @@ public class ImportancePreferenceTest {
assertThat(holder.itemView.findViewById(R.id.alert).getBackground()).isEqualTo(selected);
assertThat(holder.itemView.findViewById(R.id.silence).getBackground())
.isEqualTo(unselected);
- assertThat(((TextView) holder.itemView.findViewById(R.id.description)).getText()).isEqualTo(
- mContext.getString(R.string.notification_channel_summary_default));
+ assertThat(((TextView) holder.itemView.findViewById(R.id.alert_summary)).getText())
+ .isEqualTo(mContext.getString(R.string.notification_channel_summary_default));
}
@Test
@@ -129,28 +132,32 @@ public class ImportancePreferenceTest {
preference.setImportance(IMPORTANCE_DEFAULT);
preference.onBindViewHolder(holder);
- Button silenceButton = holder.itemView.findViewById(R.id.silence);
+ View silenceButton = holder.itemView.findViewById(R.id.silence);
silenceButton.callOnClick();
assertThat(holder.itemView.findViewById(R.id.alert).getBackground()).isEqualTo(unselected);
assertThat(holder.itemView.findViewById(R.id.silence).getBackground()).isEqualTo(selected);
- assertThat(((TextView) holder.itemView.findViewById(R.id.description)).getText()).isEqualTo(
- mContext.getString(R.string.notification_channel_summary_low));
verify(preference, times(1)).callChangeListener(IMPORTANCE_LOW);
}
@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);
final ImportancePreference preference = spy(new ImportancePreference(mContext));
preference.setDisplayInStatusBar(true);
preference.setDisplayOnLockscreen(false);
- preference.setImportanceSummary(tv, IMPORTANCE_LOW);
+ preference.setImportanceSummary(parent, IMPORTANCE_LOW, true);
assertThat(tv.getText()).isEqualTo(
mContext.getString(R.string.notification_channel_summary_low_status));
@@ -158,14 +165,20 @@ public class ImportancePreferenceTest {
@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);
final ImportancePreference preference = spy(new ImportancePreference(mContext));
preference.setDisplayInStatusBar(false);
preference.setDisplayOnLockscreen(true);
- preference.setImportanceSummary(tv, IMPORTANCE_LOW);
+ preference.setImportanceSummary(parent, IMPORTANCE_LOW, true);
assertThat(tv.getText()).isEqualTo(
mContext.getString(R.string.notification_channel_summary_low_lock));
@@ -173,14 +186,20 @@ public class ImportancePreferenceTest {
@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);
final ImportancePreference preference = spy(new ImportancePreference(mContext));
preference.setDisplayInStatusBar(true);
preference.setDisplayOnLockscreen(true);
- preference.setImportanceSummary(tv, IMPORTANCE_LOW);
+ preference.setImportanceSummary(parent, IMPORTANCE_LOW, true);
assertThat(tv.getText()).isEqualTo(
mContext.getString(R.string.notification_channel_summary_low_status_lock));
@@ -188,14 +207,20 @@ public class ImportancePreferenceTest {
@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);
final ImportancePreference preference = spy(new ImportancePreference(mContext));
preference.setDisplayInStatusBar(true);
preference.setDisplayOnLockscreen(true);
- preference.setImportanceSummary(tv, IMPORTANCE_DEFAULT);
+ preference.setImportanceSummary(parent, IMPORTANCE_DEFAULT, true);
assertThat(tv.getText()).isEqualTo(
mContext.getString(R.string.notification_channel_summary_default));