Merge "Importance preference updates" into qt-dev
diff --git a/res/drawable/button_border_selected.xml b/res/drawable/button_border_selected.xml
index 2681bf0..9701b38 100644
--- a/res/drawable/button_border_selected.xml
+++ b/res/drawable/button_border_selected.xml
@@ -18,6 +18,6 @@
android:shape="rectangle">
<stroke
android:width="2dp"
- android:color="?android:attr/colorAccent"/>
+ android:color="?android:attr/textColorSecondary"/>
<corners android:radius="@dimen/rect_button_radius" />
-</shape>
\ No newline at end of file
+</shape>
diff --git a/res/drawable/button_border_unselected.xml b/res/drawable/button_border_unselected.xml
index 72e9076..4153303 100644
--- a/res/drawable/button_border_unselected.xml
+++ b/res/drawable/button_border_unselected.xml
@@ -18,7 +18,7 @@
android:shape="rectangle">
<stroke
android:width="2dp"
- android:color="@color/notification_importance_button_unselected"/>
+ android:color="?android:attr/textColorSecondary"/>
<corners android:radius="@dimen/rect_button_radius" />
-</shape>
\ No newline at end of file
+</shape>
diff --git a/res/layout/notif_importance_preference.xml b/res/layout/notif_importance_preference.xml
index bc0d5aa..3507675 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">
- <LinearLayout
- android:id="@+id/buttons"
+ <RelativeLayout
+ android:id="@+id/alert"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/notification_importance_toggle_marginTop"
- android:orientation="horizontal"
- android:gravity="center">
+ android:padding="@dimen/notification_importance_button_padding"
+ android:clickable="true"
+ android:focusable="true">
+ <ImageView
+ android:id="@+id/alert_icon"
+ android:src="@drawable/ic_notification_alert"
+ android:background="@android:color/transparent"
+ android:layout_gravity="center"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:clickable="false"
+ android:focusable="false"/>
+ <TextView
+ android:id="@+id/alert_label"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ellipsize="end"
+ android:maxLines="1"
+ android:clickable="false"
+ android:focusable="false"
+ android:layout_toEndOf="@id/alert_icon"
+ android:layout_marginStart="@dimen/notification_importance_drawable_padding"
+ android:textAppearance="@style/TextAppearance.NotificationImportanceButton.Unselected"
+ android:text="@string/notification_alert_title"/>
+ <TextView
+ android:id="@+id/alert_summary"
+ android:paddingTop="@dimen/notification_importance_button_padding"
+ android:text="@string/notification_channel_summary_default"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:clickable="false"
+ android:focusable="false"
+ android:ellipsize="end"
+ android:maxLines="2"
+ android:layout_below="@id/alert_icon"
+ android:textAppearance="@style/TextAppearance.NotificationImportanceDetail"/>
+ </RelativeLayout>
- <Button
- android:id="@+id/alert"
- android:layout_width="wrap_content"
- android:layout_height="@dimen/notification_importance_toggle_size"
- android:minWidth="@dimen/notification_importance_button_width"
- android:paddingStart="@dimen/notification_importance_button_horiz_padding"
- android:paddingEnd="@dimen/notification_importance_button_horiz_padding"
- android:drawablePadding="@dimen/notification_importance_drawable_padding"
- android:foreground="@drawable/button_ripple_radius"
- android:drawableLeft="@drawable/ic_notification_alert"
- android:text="@string/notification_alert_title" />
-
- <Button
- android:id="@+id/silence"
- android:layout_width="wrap_content"
- android:layout_height="@dimen/notification_importance_toggle_size"
- android:minWidth="@dimen/notification_importance_button_width"
- android:paddingStart="@dimen/notification_importance_button_horiz_padding"
- android:paddingEnd="@dimen/notification_importance_button_horiz_padding"
- android:drawablePadding="@dimen/notification_importance_drawable_padding"
- android:foreground="@drawable/button_ripple_radius"
- android:layout_marginStart="@dimen/notification_importance_button_separation"
- android:drawableLeft="@drawable/ic_notification_silence"
- android:text="@string/notification_silence_title" />
-
- </LinearLayout>
-
- <TextView
- android:id="@+id/description"
+ <RelativeLayout
+ android:id="@+id/silence"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:text="@string/notification_alert_title"
- android:gravity="center"
- android:layout_marginTop="@dimen/notification_importance_text_marginTop"
- android:layout_marginBottom="@dimen/notification_importance_toggle_marginBottom"
- android:paddingStart="@dimen/notification_importance_description_padding"
- android:paddingEnd="@dimen/notification_importance_description_padding"
- android:textAppearance="@style/TextAppearance.NotificationImportanceDetail" />
+ android:padding="@dimen/notification_importance_button_padding"
+ android:layout_marginTop="@dimen/notification_importance_button_separation"
+ android:clickable="true"
+ android:focusable="true">
+ <ImageView
+ android:id="@+id/silence_icon"
+ android:src="@drawable/ic_notification_silence"
+ android:background="@android:color/transparent"
+ android:layout_gravity="center"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:clickable="false"
+ android:focusable="false"/>
+ <TextView
+ android:id="@+id/silence_label"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ellipsize="end"
+ android:maxLines="1"
+ android:clickable="false"
+ android:focusable="false"
+ android:layout_toEndOf="@id/silence_icon"
+ android:layout_marginStart="@dimen/notification_importance_drawable_padding"
+ android:textAppearance="@style/TextAppearance.NotificationImportanceButton.Unselected"
+ android:text="@string/notification_silence_title"/>
+ <TextView
+ android:id="@+id/silence_summary"
+ android:paddingTop="@dimen/notification_importance_button_padding"
+ android:text="@string/notification_channel_summary_default"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:clickable="false"
+ android:focusable="false"
+ android:ellipsize="end"
+ android:maxLines="2"
+ android:layout_below="@id/silence_icon"
+ android:textAppearance="@style/TextAppearance.NotificationImportanceDetail"/>
+ </RelativeLayout>
</LinearLayout>
\ No newline at end of file
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index c871ac8..a348f8a 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -79,6 +79,7 @@
<dimen name="notification_importance_description_padding">20dp</dimen>
<dimen name="notification_importance_description_text">14sp</dimen>
<dimen name="notification_importance_button_text">16sp</dimen>
+ <dimen name="notification_importance_button_padding">14dp</dimen>
<dimen name="zen_schedule_rule_checkbox_padding">7dp</dimen>
<dimen name="zen_schedule_day_margin">17dp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 98892e4..615077c 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -7805,7 +7805,7 @@
<string name="profile_section_header">Work notifications</string>
<!-- Configure Notifications: section header for prioritizer settings [CHAR LIMIT=80] -->
- <string name="smart_notifications_title">Smart notifications</string>
+ <string name="smart_notifications_title">Adaptive notifications</string>
<!-- Configure Notifications: setting title [CHAR LIMIT=80] -->
<string name="asst_capability_prioritizer_title">Automatic Prioritization</string>
@@ -7976,25 +7976,25 @@
<!-- Channel summaries for the app notification page -->
- <!-- [CHAR LIMIT=100] Notification Importance title: min importance level summary -->
+ <!-- [CHAR LIMIT=150] Notification Importance title: min importance level summary -->
<string name="notification_channel_summary_min">In the pull-down shade, collapse notifications to one line</string>
- <!-- [CHAR LIMIT=100] Notification Importance title: low importance level summary -->
- <string name="notification_channel_summary_low">Always silent. Displays in pull-down shade.</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=100] Notification Importance title: low importance level summary -->
- <string name="notification_channel_summary_low_status">Always silent. Displays in pull-down shade & status bar.</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=100] Notification Importance title: low importance level summary -->
- <string name="notification_channel_summary_low_lock">Always silent. Displays in pull-down shade & on lock screen.</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=100] Notification Importance title: low importance level summary -->
- <string name="notification_channel_summary_low_status_lock">Always silent. Displays in pull-down shade, status bar & on lock screen.</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>
- <!-- [CHAR LIMIT=100] Notification Importance title: normal importance level summary -->
- <string name="notification_channel_summary_default">Makes sound and displays in pull-down shade, status bar & on lock screen.</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>
- <!-- [CHAR LIMIT=100] Notification Importance title: high importance level summary -->
+ <!-- [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>
<!-- [CHAR LIMIT=100] Label for on/off toggle -->
diff --git a/src/com/android/settings/notification/ImportancePreference.java b/src/com/android/settings/notification/ImportancePreference.java
index 687782b..f48882d 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_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 @@
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 @@
}
@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 @@
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 46b2ec6..dc59275 100644
--- a/src/com/android/settings/notification/ImportancePreferenceController.java
+++ b/src/com/android/settings/notification/ImportancePreferenceController.java
@@ -22,6 +22,7 @@
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 @@
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 63bc828..b4379aa 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 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 @@
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 @@
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 @@
@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 @@
@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 @@
@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));