Always display labels in contact search.

This commit is contained in:
Alex Hart 2020-06-05 15:16:55 -03:00 committed by GitHub
parent 3bbf0741ee
commit 04a000a8a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -115,52 +115,73 @@ public class ContactsCursorLoader extends CursorLoader {
private List<Cursor> getUnfilteredResults() { private List<Cursor> getUnfilteredResults() {
ArrayList<Cursor> cursorList = new ArrayList<>(); ArrayList<Cursor> cursorList = new ArrayList<>();
if (recents) { addRecentsSection(cursorList);
Cursor recentConversations = getRecentConversationsCursor(); addContactsSection(cursorList);
if (recentConversations.getCount() > 0) {
cursorList.add(getRecentsHeaderCursor());
cursorList.add(recentConversations);
cursorList.add(getContactsHeaderCursor());
}
}
cursorList.addAll(getContactsCursors());
return cursorList; return cursorList;
} }
private List<Cursor> getFilteredResults() { private List<Cursor> getFilteredResults() {
ArrayList<Cursor> cursorList = new ArrayList<>(); ArrayList<Cursor> cursorList = new ArrayList<>();
if (groupsEnabled(mode)) { addContactsSection(cursorList);
Cursor groups = getGroupsCursor(); addGroupsSection(cursorList);
if (groups.getCount() > 0) { addNewNumberSection(cursorList);
List<Cursor> contacts = getContactsCursors(); addUsernameSearchSection(cursorList);
if (!isCursorListEmpty(contacts)) {
cursorList.add(getContactsHeaderCursor()); return cursorList;
cursorList.addAll(contacts);
cursorList.add(getGroupsHeaderCursor());
}
cursorList.add(groups);
} else {
cursorList.addAll(getContactsCursors());
}
} else {
cursorList.addAll(getContactsCursors());
} }
private void addRecentsSection(@NonNull List<Cursor> cursorList) {
if (!recents) {
return;
}
Cursor recentConversations = getRecentConversationsCursor();
if (recentConversations.getCount() > 0) {
cursorList.add(getRecentsHeaderCursor());
cursorList.add(recentConversations);
}
}
private void addContactsSection(@NonNull List<Cursor> cursorList) {
List<Cursor> contacts = getContactsCursors();
if (!isCursorListEmpty(contacts)) {
cursorList.add(getContactsHeaderCursor());
cursorList.addAll(getContactsCursors());
}
}
private void addGroupsSection(@NonNull List<Cursor> cursorList) {
if (!groupsEnabled(mode)) {
return;
}
Cursor groups = getGroupsCursor();
if (groups.getCount() > 0) {
cursorList.add(getGroupsHeaderCursor());
cursorList.add(getGroupsCursor());
}
}
private void addNewNumberSection(@NonNull List<Cursor> cursorList) {
if (FeatureFlags.usernames() && NumberUtil.isVisuallyValidNumberOrEmail(filter)) { if (FeatureFlags.usernames() && NumberUtil.isVisuallyValidNumberOrEmail(filter)) {
cursorList.add(getPhoneNumberSearchHeaderCursor()); cursorList.add(getPhoneNumberSearchHeaderCursor());
cursorList.add(getNewNumberCursor()); cursorList.add(getNewNumberCursor());
} else if (!FeatureFlags.usernames() && NumberUtil.isValidSmsOrEmail(filter)){ } else if (!FeatureFlags.usernames() && NumberUtil.isValidSmsOrEmail(filter)){
cursorList.add(getContactsHeaderCursor()); cursorList.add(getPhoneNumberSearchHeaderCursor());
cursorList.add(getNewNumberCursor()); cursorList.add(getNewNumberCursor());
} }
}
private void addUsernameSearchSection(@NonNull List<Cursor> cursorList) {
if (FeatureFlags.usernames() && UsernameUtil.isValidUsernameForSearch(filter)) { if (FeatureFlags.usernames() && UsernameUtil.isValidUsernameForSearch(filter)) {
cursorList.add(getUsernameSearchHeaderCursor()); cursorList.add(getUsernameSearchHeaderCursor());
cursorList.add(getUsernameSearchCursor()); cursorList.add(getUsernameSearchCursor());
} }
return cursorList;
} }
private Cursor getRecentsHeaderCursor() { private Cursor getRecentsHeaderCursor() {