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;
|
onRefreshListener = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getSelectedMembersSize() {
|
||||||
|
return contactSearchMediator.getSelectedMembersSize();
|
||||||
|
}
|
||||||
|
|
||||||
private @NonNull Bundle safeArguments() {
|
private @NonNull Bundle safeArguments() {
|
||||||
return getArguments() != null ? getArguments() : new Bundle();
|
return getArguments() != null ? getArguments() : new Bundle();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -133,6 +133,10 @@ class ContactSearchMediator(
|
|||||||
viewModel.clearSelection()
|
viewModel.clearSelection()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getSelectedMembersSize(): Int {
|
||||||
|
return viewModel.getSelectedMembersSize()
|
||||||
|
}
|
||||||
|
|
||||||
fun getSelectedContacts(): Set<ContactSearchKey> {
|
fun getSelectedContacts(): Set<ContactSearchKey> {
|
||||||
return viewModel.getSelectedContacts()
|
return viewModel.getSelectedContacts()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,10 +55,14 @@ class ContactSearchViewModel(
|
|||||||
val selectionState: LiveData<Set<ContactSearchKey>> = selectionStore.stateLiveData
|
val selectionState: LiveData<Set<ContactSearchKey>> = selectionStore.stateLiveData
|
||||||
val errorEventsStream: Observable<ContactSearchError> = errorEvents
|
val errorEventsStream: Observable<ContactSearchError> = errorEvents
|
||||||
|
|
||||||
|
private var selectionSize = 0;
|
||||||
override fun onCleared() {
|
override fun onCleared() {
|
||||||
disposables.clear()
|
disposables.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getSelectedMembersSize(): Int {
|
||||||
|
return selectionSize
|
||||||
|
}
|
||||||
fun setConfiguration(contactSearchConfiguration: ContactSearchConfiguration) {
|
fun setConfiguration(contactSearchConfiguration: ContactSearchConfiguration) {
|
||||||
val pagedDataSource = ContactSearchPagedDataSource(
|
val pagedDataSource = ContactSearchPagedDataSource(
|
||||||
contactSearchConfiguration,
|
contactSearchConfiguration,
|
||||||
@@ -90,7 +94,7 @@ class ContactSearchViewModel(
|
|||||||
|
|
||||||
val newSelectionEntries = results.filter { it.isSelectable }.map { it.key } - getSelectedContacts()
|
val newSelectionEntries = results.filter { it.isSelectable }.map { it.key } - getSelectedContacts()
|
||||||
val newSelectionSize = newSelectionEntries.size + getSelectedContacts().size
|
val newSelectionSize = newSelectionEntries.size + getSelectedContacts().size
|
||||||
|
selectionSize = newSelectionSize
|
||||||
if (selectionLimits.hasRecommendedLimit() && getSelectedContacts().size < selectionLimits.recommendedLimit && newSelectionSize >= selectionLimits.recommendedLimit) {
|
if (selectionLimits.hasRecommendedLimit() && getSelectedContacts().size < selectionLimits.recommendedLimit && newSelectionSize >= selectionLimits.recommendedLimit) {
|
||||||
errorEvents.onNext(ContactSearchError.RECOMMENDED_LIMIT_REACHED)
|
errorEvents.onNext(ContactSearchError.RECOMMENDED_LIMIT_REACHED)
|
||||||
} else if (selectionLimits.hasHardLimit() && newSelectionSize > selectionLimits.hardLimit) {
|
} else if (selectionLimits.hasHardLimit() && newSelectionSize > selectionLimits.hardLimit) {
|
||||||
@@ -107,6 +111,8 @@ class ContactSearchViewModel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun setKeysNotSelected(contactSearchKeys: Set<ContactSearchKey>) {
|
fun setKeysNotSelected(contactSearchKeys: Set<ContactSearchKey>) {
|
||||||
|
val newSelectionSize = getSelectedContacts().size - contactSearchKeys.size
|
||||||
|
selectionSize = newSelectionSize
|
||||||
selectionStore.update { it - contactSearchKeys }
|
selectionStore.update { it - contactSearchKeys }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -121,11 +121,12 @@ public class CreateGroupActivity extends ContactSelectionActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSelectionChanged() {
|
public void onSelectionChanged() {
|
||||||
|
int selectedMembers = contactsFragment.getSelectedMembersSize();
|
||||||
int selectedContactsCount = contactsFragment.getTotalMemberCount();
|
int selectedContactsCount = contactsFragment.getTotalMemberCount();
|
||||||
if (selectedContactsCount == 0) {
|
if (selectedContactsCount == 0) {
|
||||||
getToolbar().setTitle(getString(R.string.CreateGroupActivity__select_members));
|
getToolbar().setTitle(getString(R.string.CreateGroupActivity__select_members));
|
||||||
} else {
|
} 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