mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-08 20:08:35 +00:00
Fix group limit enforcement and display.
This commit is contained in:
parent
40a8d21c15
commit
e316a70b6c
@ -512,7 +512,7 @@ public final class ContactSelectionListFragment extends LoggingFragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean selectionLimitReached() {
|
private boolean selectionLimitReached() {
|
||||||
return getChipCount() >= selectionLimit;
|
return getChipCount() + currentSelection.size() >= selectionLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void markContactSelected(@NonNull SelectedContact selectedContact) {
|
private void markContactSelected(@NonNull SelectedContact selectedContact) {
|
||||||
|
@ -32,6 +32,7 @@ import org.thoughtcrime.securesms.util.concurrent.SignalExecutors;
|
|||||||
import org.thoughtcrime.securesms.util.concurrent.SimpleTask;
|
import org.thoughtcrime.securesms.util.concurrent.SimpleTask;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -197,6 +198,23 @@ final class ManageGroupRepository {
|
|||||||
public int getTotalCapacity() {
|
public int getTotalCapacity() {
|
||||||
return totalCapacity;
|
return totalCapacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getRemainingCapacity() {
|
||||||
|
return totalCapacity - members.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NonNull ArrayList<RecipientId> getMembersWithoutSelf() {
|
||||||
|
ArrayList<RecipientId> recipientIds = new ArrayList<>(members.size());
|
||||||
|
RecipientId selfId = Recipient.self().getId();
|
||||||
|
|
||||||
|
for (RecipientId recipientId : members) {
|
||||||
|
if (!recipientId.equals(selfId)) {
|
||||||
|
recipientIds.add(recipientId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return recipientIds;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -314,15 +314,15 @@ public class ManageGroupViewModel extends ViewModel {
|
|||||||
|
|
||||||
public void onAddMembersClick(@NonNull Fragment fragment, int resultCode) {
|
public void onAddMembersClick(@NonNull Fragment fragment, int resultCode) {
|
||||||
manageGroupRepository.getGroupCapacity(capacity -> {
|
manageGroupRepository.getGroupCapacity(capacity -> {
|
||||||
int remainingCapacity = capacity.getTotalCapacity();
|
int remainingCapacity = capacity.getRemainingCapacity();
|
||||||
if (remainingCapacity <= 0) {
|
if (remainingCapacity <= 0) {
|
||||||
Toast.makeText(fragment.requireContext(), R.string.ContactSelectionListFragment_the_group_is_full, Toast.LENGTH_SHORT).show();
|
Toast.makeText(fragment.requireContext(), R.string.ContactSelectionListFragment_the_group_is_full, Toast.LENGTH_SHORT).show();
|
||||||
} else {
|
} else {
|
||||||
Intent intent = new Intent(fragment.requireActivity(), AddMembersActivity.class);
|
Intent intent = new Intent(fragment.requireActivity(), AddMembersActivity.class);
|
||||||
intent.putExtra(AddMembersActivity.GROUP_ID, manageGroupRepository.getGroupId().toString());
|
intent.putExtra(AddMembersActivity.GROUP_ID, manageGroupRepository.getGroupId().toString());
|
||||||
intent.putExtra(ContactSelectionListFragment.DISPLAY_MODE, ContactsCursorLoader.DisplayMode.FLAG_PUSH);
|
intent.putExtra(ContactSelectionListFragment.DISPLAY_MODE, ContactsCursorLoader.DisplayMode.FLAG_PUSH);
|
||||||
intent.putExtra(ContactSelectionListFragment.TOTAL_CAPACITY, remainingCapacity);
|
intent.putExtra(ContactSelectionListFragment.TOTAL_CAPACITY, capacity.getTotalCapacity() - 1);
|
||||||
intent.putParcelableArrayListExtra(ContactSelectionListFragment.CURRENT_SELECTION, new ArrayList<>(capacity.getMembers()));
|
intent.putParcelableArrayListExtra(ContactSelectionListFragment.CURRENT_SELECTION, capacity.getMembersWithoutSelf());
|
||||||
fragment.startActivityForResult(intent, resultCode);
|
fragment.startActivityForResult(intent, resultCode);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user