mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-23 20:48:43 +00:00
Fix issue with new group members count.
This commit is contained in:
committed by
Cody Henthorne
parent
c00943591d
commit
b7eaa9e353
@@ -423,6 +423,10 @@ public final class ContactSelectionListFragment extends LoggingFragment {
|
||||
onRefreshListener = null;
|
||||
}
|
||||
|
||||
public int getSelectedMembersSize() {
|
||||
return contactSearchMediator.getSelectedMembersSize();
|
||||
}
|
||||
|
||||
private @NonNull Bundle safeArguments() {
|
||||
return getArguments() != null ? getArguments() : new Bundle();
|
||||
}
|
||||
|
||||
@@ -133,6 +133,10 @@ class ContactSearchMediator(
|
||||
viewModel.clearSelection()
|
||||
}
|
||||
|
||||
fun getSelectedMembersSize(): Int {
|
||||
return viewModel.getSelectedMembersSize()
|
||||
}
|
||||
|
||||
fun getSelectedContacts(): Set<ContactSearchKey> {
|
||||
return viewModel.getSelectedContacts()
|
||||
}
|
||||
|
||||
@@ -55,10 +55,14 @@ class ContactSearchViewModel(
|
||||
val selectionState: LiveData<Set<ContactSearchKey>> = selectionStore.stateLiveData
|
||||
val errorEventsStream: Observable<ContactSearchError> = errorEvents
|
||||
|
||||
private var selectionSize = 0;
|
||||
override fun onCleared() {
|
||||
disposables.clear()
|
||||
}
|
||||
|
||||
fun getSelectedMembersSize(): Int {
|
||||
return selectionSize
|
||||
}
|
||||
fun setConfiguration(contactSearchConfiguration: ContactSearchConfiguration) {
|
||||
val pagedDataSource = ContactSearchPagedDataSource(
|
||||
contactSearchConfiguration,
|
||||
@@ -90,7 +94,7 @@ class ContactSearchViewModel(
|
||||
|
||||
val newSelectionEntries = results.filter { it.isSelectable }.map { it.key } - getSelectedContacts()
|
||||
val newSelectionSize = newSelectionEntries.size + getSelectedContacts().size
|
||||
|
||||
selectionSize = newSelectionSize
|
||||
if (selectionLimits.hasRecommendedLimit() && getSelectedContacts().size < selectionLimits.recommendedLimit && newSelectionSize >= selectionLimits.recommendedLimit) {
|
||||
errorEvents.onNext(ContactSearchError.RECOMMENDED_LIMIT_REACHED)
|
||||
} else if (selectionLimits.hasHardLimit() && newSelectionSize > selectionLimits.hardLimit) {
|
||||
@@ -107,6 +111,8 @@ class ContactSearchViewModel(
|
||||
}
|
||||
|
||||
fun setKeysNotSelected(contactSearchKeys: Set<ContactSearchKey>) {
|
||||
val newSelectionSize = getSelectedContacts().size - contactSearchKeys.size
|
||||
selectionSize = newSelectionSize
|
||||
selectionStore.update { it - contactSearchKeys }
|
||||
}
|
||||
|
||||
|
||||
@@ -121,11 +121,12 @@ public class CreateGroupActivity extends ContactSelectionActivity {
|
||||
|
||||
@Override
|
||||
public void onSelectionChanged() {
|
||||
int selectedMembers = contactsFragment.getSelectedMembersSize();
|
||||
int selectedContactsCount = contactsFragment.getTotalMemberCount();
|
||||
if (selectedContactsCount == 0) {
|
||||
getToolbar().setTitle(getString(R.string.CreateGroupActivity__select_members));
|
||||
} else {
|
||||
getToolbar().setTitle(getResources().getQuantityString(R.plurals.CreateGroupActivity__d_members, selectedContactsCount, selectedContactsCount));
|
||||
getToolbar().setTitle(getResources().getQuantityString(R.plurals.CreateGroupActivity__d_members, selectedMembers, selectedMembers));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user