Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 79fd5811 authored by Julia Reynolds's avatar Julia Reynolds Committed by Android (Google) Code Review
Browse files

Merge "Update all conversations screen" into rvc-dev

parents 8d3741fb 2f0bd655
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -8312,10 +8312,10 @@
    <string name="manage_conversations">Manage conversations</string>
    <!-- [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 -->
    <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 -->
    <string name="important_bubble">Bubble important conversations</string>
+2 −2
Original line number Diff line number Diff line
@@ -39,8 +39,8 @@

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

+7 −2
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ import java.util.List;

public class AllConversationsPreferenceController extends ConversationListPreferenceController {

    private static final String KEY = "all_conversations";
    private static final String KEY = "other_conversations";

    private List<ConversationChannelWrapper> mConversations;

@@ -49,6 +49,11 @@ public class AllConversationsPreferenceController extends ConversationListPrefer
        return true;
    }

    @Override
    boolean matchesFilter(ConversationChannelWrapper conversation) {
        return !conversation.getNotificationChannel().isImportantConversation();
    }

    @Override
    public void updateState(Preference preference) {
        PreferenceCategory pref = (PreferenceCategory) preference;
@@ -66,7 +71,7 @@ public class AllConversationsPreferenceController extends ConversationListPrefer
                if (mContext == null) {
                    return;
                }
                populateList(mConversations, pref, pref);
                populateList(mConversations, pref);
            }
        }.execute();
    }
+12 −8
Original line number Diff line number Diff line
@@ -61,21 +61,25 @@ public abstract class ConversationListPreferenceController extends AbstractPrefe
    }

    protected void populateList(List<ConversationChannelWrapper> conversations,
            PreferenceGroup outerContainer, PreferenceGroup innerContainer) {
            PreferenceGroup containerGroup) {
        // TODO: if preference has children, compare with newly loaded list
        if (conversations.isEmpty()) {
            outerContainer.setVisible(false);
        } else {
            outerContainer.setVisible(true);
            populateConversations(conversations, innerContainer);
        containerGroup.removeAll();
        if (conversations != null) {
            populateConversations(conversations, containerGroup);
        }

        if (containerGroup.getPreferenceCount() == 0) {
            containerGroup.setVisible(false);
        }
    }

    abstract boolean matchesFilter(ConversationChannelWrapper conversation);

    protected void populateConversations(List<ConversationChannelWrapper> conversations,
            PreferenceGroup containerGroup) {
        containerGroup.removeAll();
        for (ConversationChannelWrapper conversation : conversations) {
            if (conversation.getNotificationChannel().isDemoted()) {
            if (conversation.getNotificationChannel().isDemoted()
                    || !matchesFilter(conversation)) {
                continue;
            }
            containerGroup.addPreference(createConversationPref(conversation));
+6 −2
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@ public class PriorityConversationsPreferenceController extends
        ConversationListPreferenceController {

    private static final String KEY = "important_conversations";
    private static final String LIST_KEY = "important_conversations_list";
    private List<ConversationChannelWrapper> mConversations;

    public PriorityConversationsPreferenceController(Context context,
@@ -50,6 +49,11 @@ public class PriorityConversationsPreferenceController extends
        return true;
    }

    @Override
    boolean matchesFilter(ConversationChannelWrapper conversation) {
        return conversation.getNotificationChannel().isImportantConversation();
    }

    @Override
    public void updateState(Preference preference) {
        PreferenceCategory pref = (PreferenceCategory) preference;
@@ -67,7 +71,7 @@ public class PriorityConversationsPreferenceController extends
                if (mContext == null) {
                    return;
                }
                populateList(mConversations, pref, pref.findPreference(LIST_KEY));
                populateList(mConversations, pref);
            }
        }.execute();

Loading