diff --git a/res/layout/zen_mode_senders_overlay_image.xml b/res/layout/zen_mode_senders_overlay_image.xml
new file mode 100644
index 00000000000..6976df30d8f
--- /dev/null
+++ b/res/layout/zen_mode_senders_overlay_image.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 79071ed3a05..6984ca1132b 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -89,6 +89,7 @@
16dp
7dp
17dp
+ 56dp
8dp
diff --git a/res/values/strings.xml b/res/values/strings.xml
index ad4b3643213..139fd5f6865 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -7809,6 +7809,8 @@
Display options for hidden notifications
+
+ When Do Not Disturb is on
No sound from notifications
diff --git a/res/xml/zen_mode_calls_settings.xml b/res/xml/zen_mode_calls_settings.xml
index 0b44875a3ec..f54c496fa33 100644
--- a/res/xml/zen_mode_calls_settings.xml
+++ b/res/xml/zen_mode_calls_settings.xml
@@ -29,7 +29,8 @@
+ android:layout="@layout/zen_mode_senders_image"
+ android:selectable="false"/>
diff --git a/res/xml/zen_mode_conversations_settings.xml b/res/xml/zen_mode_conversations_settings.xml
index 773a8b28819..e72d03ccb6a 100644
--- a/res/xml/zen_mode_conversations_settings.xml
+++ b/res/xml/zen_mode_conversations_settings.xml
@@ -21,6 +21,11 @@
-
+
+
+
\ No newline at end of file
diff --git a/res/xml/zen_mode_messages_settings.xml b/res/xml/zen_mode_messages_settings.xml
index 31cad2a5347..fa71efd265b 100644
--- a/res/xml/zen_mode_messages_settings.xml
+++ b/res/xml/zen_mode_messages_settings.xml
@@ -27,7 +27,8 @@
+ android:layout="@layout/zen_mode_senders_image"
+ android:selectable="false"/>
diff --git a/res/xml/zen_mode_restrict_notifications_settings.xml b/res/xml/zen_mode_restrict_notifications_settings.xml
index 0bf8c267c03..f5e7615d5e9 100644
--- a/res/xml/zen_mode_restrict_notifications_settings.xml
+++ b/res/xml/zen_mode_restrict_notifications_settings.xml
@@ -22,7 +22,7 @@
+ android:title="@string/zen_mode_restrict_notifications_category">
mConversationDrawables = new ArrayList<>();
+ private final NotificationBackend mNotificationBackend;
+
+ private ViewGroup mViewGroup;
+ private LayoutPreference mPreference;
+
+ public ZenModeConversationsImagePreferenceController(Context context, String key,
+ Lifecycle lifecycle, NotificationBackend notificationBackend) {
+ super(context, key, lifecycle);
+ mNotificationBackend = notificationBackend;
+ mIconSizePx =
+ mContext.getResources().getDimensionPixelSize(R.dimen.zen_conversations_icon_size);
+ mIconOffsetPx = mIconSizePx * 3 / 4;
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ mPreference = (LayoutPreference) screen.findPreference(KEY);
+ mViewGroup =
+ (ViewGroup) mPreference.findViewById(R.id.zen_mode_settings_senders_overlay_view);
+ loadConversations();
+ }
+
+ @Override
+ public boolean isAvailable() {
+ return true;
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY;
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ loadConversations();
+
+ mViewGroup.removeAllViews();
+ final int conversationSenders = mBackend.getPriorityConversationSenders();
+ if (conversationSenders == CONVERSATION_SENDERS_ANYONE) {
+ mViewGroup.setContentDescription(
+ mContext.getResources().getString(R.string.zen_mode_from_all_conversations));
+ } else if (conversationSenders == CONVERSATION_SENDERS_IMPORTANT) {
+ mViewGroup.setContentDescription(
+ mContext.getResources().getString(
+ R.string.zen_mode_from_important_conversations));
+ } else {
+ mViewGroup.setContentDescription(null);
+ }
+
+ final int numDrawablesToShow = Math.min(MAX_CONVERSATIONS_SHOWN,
+ mConversationDrawables.size());
+ for (int i = 0; i < numDrawablesToShow; i++) {
+ ImageView iv = new ImageView(mContext);
+ iv.setImageDrawable(mConversationDrawables.get(i));
+ iv.setLayoutParams(new ViewGroup.LayoutParams(mIconSizePx, mIconSizePx));
+
+ FrameLayout fl = new FrameLayout(mContext);
+ fl.addView(iv);
+ fl.setPadding((numDrawablesToShow - i - 1) * mIconOffsetPx, 0, 0, 0);
+ mViewGroup.addView(fl);
+ }
+ }
+
+ private void loadConversations() {
+ // Load conversations
+ new AsyncTask() {
+ private List mDrawables = new ArrayList<>();
+ @Override
+ protected Void doInBackground(Void... unused) {
+ mDrawables.clear();
+ final int conversationSenders = mBackend.getPriorityConversationSenders();
+ if (conversationSenders == CONVERSATION_SENDERS_NONE) {
+ return null;
+ }
+ ParceledListSlice conversations =
+ mNotificationBackend.getConversations(
+ conversationSenders == CONVERSATION_SENDERS_IMPORTANT);
+ if (conversations != null) {
+ for (ConversationChannelWrapper conversation : conversations.getList()) {
+ if (!conversation.getNotificationChannel().isDemoted()) {
+ Drawable drawable = mNotificationBackend.getConversationDrawable(
+ mContext,
+ conversation.getShortcutInfo(),
+ conversation.getPkg(),
+ conversation.getUid(),
+ conversation.getNotificationChannel()
+ .isImportantConversation());
+ if (drawable != null) {
+ mDrawables.add(drawable);
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+ @Override
+ protected void onPostExecute(Void unused) {
+ if (mContext == null) {
+ return;
+ }
+ mConversationDrawables.clear();
+ mConversationDrawables.addAll(mDrawables);
+ updateState(mPreference);
+ }
+ }.execute();
+ }
+}
diff --git a/src/com/android/settings/notification/zen/ZenModeConversationsSettings.java b/src/com/android/settings/notification/zen/ZenModeConversationsSettings.java
index 3daefd56f14..5c68126f044 100644
--- a/src/com/android/settings/notification/zen/ZenModeConversationsSettings.java
+++ b/src/com/android/settings/notification/zen/ZenModeConversationsSettings.java
@@ -44,6 +44,8 @@ public class ZenModeConversationsSettings extends ZenModeSettingsBase {
private static List buildPreferenceControllers(Context context,
Lifecycle lifecycle, NotificationBackend notificationBackend) {
List controllers = new ArrayList<>();
+ controllers.add(new ZenModeConversationsImagePreferenceController(context,
+ "zen_mode_conversations_image", lifecycle, notificationBackend));
controllers.add(new ZenModePriorityConversationsPreferenceController(context,
"zen_mode_conversations_radio_buttons", lifecycle, notificationBackend));
return controllers;