Update all conversations screen

Update text, and filter the lower section to match the new
header

Test: atest
Fixes: 151765526
Change-Id: I5bc052813745908df8602bf397434a76b294ba6c
This commit is contained in:
Julia Reynolds
2020-03-24 15:25:38 -04:00
parent 87c0179c01
commit 2f0bd6552c
6 changed files with 38 additions and 22 deletions

View File

@@ -8312,10 +8312,10 @@
<string name="manage_conversations">Manage conversations</string> <string name="manage_conversations">Manage conversations</string>
<!-- [CHAR LIMIT=100] preference category title --> <!-- [CHAR LIMIT=100] preference category title -->
<string name="important_conversations">Important conversations</string> <string name="important_conversations">Priority conversations</string>
<!-- [CHAR LIMIT=100] preference category title --> <!-- [CHAR LIMIT=100] preference category title -->
<string name="all_conversations">All conversations</string> <string name="other_conversations">Other conversations</string>
<!-- [CHAR LIMIT=100] Setting to automatically bubble all notifications from favorite conversations --> <!-- [CHAR LIMIT=100] Setting to automatically bubble all notifications from favorite conversations -->
<string name="important_bubble">Bubble important conversations</string> <string name="important_bubble">Bubble important conversations</string>

View File

@@ -39,8 +39,8 @@
<!--Other conversations added here --> <!--Other conversations added here -->
<PreferenceCategory <PreferenceCategory
android:title="@string/all_conversations" android:title="@string/other_conversations"
android:key="all_conversations" android:key="other_conversations"
settings:allowDividerAbove="true" settings:allowDividerAbove="true"
settings:allowDividerBelow="false" /> settings:allowDividerBelow="false" />

View File

@@ -30,7 +30,7 @@ import java.util.List;
public class AllConversationsPreferenceController extends ConversationListPreferenceController { public class AllConversationsPreferenceController extends ConversationListPreferenceController {
private static final String KEY = "all_conversations"; private static final String KEY = "other_conversations";
private List<ConversationChannelWrapper> mConversations; private List<ConversationChannelWrapper> mConversations;
@@ -49,6 +49,11 @@ public class AllConversationsPreferenceController extends ConversationListPrefer
return true; return true;
} }
@Override
boolean matchesFilter(ConversationChannelWrapper conversation) {
return !conversation.getNotificationChannel().isImportantConversation();
}
@Override @Override
public void updateState(Preference preference) { public void updateState(Preference preference) {
PreferenceCategory pref = (PreferenceCategory) preference; PreferenceCategory pref = (PreferenceCategory) preference;
@@ -66,7 +71,7 @@ public class AllConversationsPreferenceController extends ConversationListPrefer
if (mContext == null) { if (mContext == null) {
return; return;
} }
populateList(mConversations, pref, pref); populateList(mConversations, pref);
} }
}.execute(); }.execute();
} }

View File

@@ -61,21 +61,25 @@ public abstract class ConversationListPreferenceController extends AbstractPrefe
} }
protected void populateList(List<ConversationChannelWrapper> conversations, protected void populateList(List<ConversationChannelWrapper> conversations,
PreferenceGroup outerContainer, PreferenceGroup innerContainer) { PreferenceGroup containerGroup) {
// TODO: if preference has children, compare with newly loaded list // TODO: if preference has children, compare with newly loaded list
if (conversations.isEmpty()) { containerGroup.removeAll();
outerContainer.setVisible(false); if (conversations != null) {
} else { populateConversations(conversations, containerGroup);
outerContainer.setVisible(true); }
populateConversations(conversations, innerContainer);
if (containerGroup.getPreferenceCount() == 0) {
containerGroup.setVisible(false);
} }
} }
abstract boolean matchesFilter(ConversationChannelWrapper conversation);
protected void populateConversations(List<ConversationChannelWrapper> conversations, protected void populateConversations(List<ConversationChannelWrapper> conversations,
PreferenceGroup containerGroup) { PreferenceGroup containerGroup) {
containerGroup.removeAll();
for (ConversationChannelWrapper conversation : conversations) { for (ConversationChannelWrapper conversation : conversations) {
if (conversation.getNotificationChannel().isDemoted()) { if (conversation.getNotificationChannel().isDemoted()
|| !matchesFilter(conversation)) {
continue; continue;
} }
containerGroup.addPreference(createConversationPref(conversation)); containerGroup.addPreference(createConversationPref(conversation));

View File

@@ -32,7 +32,6 @@ public class PriorityConversationsPreferenceController extends
ConversationListPreferenceController { ConversationListPreferenceController {
private static final String KEY = "important_conversations"; private static final String KEY = "important_conversations";
private static final String LIST_KEY = "important_conversations_list";
private List<ConversationChannelWrapper> mConversations; private List<ConversationChannelWrapper> mConversations;
public PriorityConversationsPreferenceController(Context context, public PriorityConversationsPreferenceController(Context context,
@@ -50,6 +49,11 @@ public class PriorityConversationsPreferenceController extends
return true; return true;
} }
@Override
boolean matchesFilter(ConversationChannelWrapper conversation) {
return conversation.getNotificationChannel().isImportantConversation();
}
@Override @Override
public void updateState(Preference preference) { public void updateState(Preference preference) {
PreferenceCategory pref = (PreferenceCategory) preference; PreferenceCategory pref = (PreferenceCategory) preference;
@@ -67,7 +71,7 @@ public class PriorityConversationsPreferenceController extends
if (mContext == null) { if (mContext == null) {
return; return;
} }
populateList(mConversations, pref, pref.findPreference(LIST_KEY)); populateList(mConversations, pref);
} }
}.execute(); }.execute();

View File

@@ -95,18 +95,16 @@ public class ConversationListPreferenceControllerTest {
@Test @Test
public void testPopulateList_hideIfNoConversations() { public void testPopulateList_hideIfNoConversations() {
PreferenceCategory outerContainer = mock(PreferenceCategory.class); PreferenceCategory outerContainer = mock(PreferenceCategory.class);
PreferenceCategory innerContainer = mock(PreferenceCategory.class);
mController.populateList(new ArrayList<>(), outerContainer, innerContainer); mController.populateList(new ArrayList<>(), outerContainer);
verify(outerContainer).setVisible(false); verify(outerContainer).setVisible(false);
verify(innerContainer, never()).addPreference(any()); verify(outerContainer, never()).addPreference(any());
} }
@Test @Test
public void testPopulateList_validConversations() { public void testPopulateList_validConversations() {
PreferenceCategory outerContainer = mock(PreferenceCategory.class); PreferenceCategory outerContainer = mock(PreferenceCategory.class);
PreferenceCategory innerContainer = mock(PreferenceCategory.class);
ConversationChannelWrapper ccw = new ConversationChannelWrapper(); ConversationChannelWrapper ccw = new ConversationChannelWrapper();
ccw.setNotificationChannel(mock(NotificationChannel.class)); ccw.setNotificationChannel(mock(NotificationChannel.class));
@@ -117,10 +115,10 @@ public class ConversationListPreferenceControllerTest {
ArrayList<ConversationChannelWrapper> list = new ArrayList<>(); ArrayList<ConversationChannelWrapper> list = new ArrayList<>();
list.add(ccw); list.add(ccw);
mController.populateList(list, outerContainer, innerContainer); mController.populateList(list, outerContainer);
verify(outerContainer).setVisible(true); verify(outerContainer).setVisible(true);
verify(innerContainer, times(1)).addPreference(any()); verify(outerContainer, times(1)).addPreference(any());
} }
@Test @Test
@@ -233,6 +231,11 @@ public class ConversationListPreferenceControllerTest {
super(context, backend); super(context, backend);
} }
@Override
boolean matchesFilter(ConversationChannelWrapper conversation) {
return true;
}
@Override @Override
public String getPreferenceKey() { public String getPreferenceKey() {
return "test"; return "test";