Prevent adding self to group by number.

Fixes #9821
This commit is contained in:
Alan Evans
2020-07-08 11:59:22 -03:00
committed by Greyson Parrelli
parent 1a895db9bd
commit a9e30eefdc
3 changed files with 8 additions and 13 deletions

View File

@@ -462,6 +462,11 @@ public final class ContactSelectionListFragment extends LoggingFragment
SelectedContact selectedContact = contact.isUsernameType() ? SelectedContact.forUsername(contact.getRecipientId().orNull(), contact.getNumber())
: SelectedContact.forPhone(contact.getRecipientId().orNull(), contact.getNumber());
if (isMulti() && Recipient.self().getId().equals(selectedContact.getOrCreateRecipientId(requireContext()))) {
Toast.makeText(requireContext(), R.string.ContactSelectionListFragment_you_do_not_need_to_add_yourself_to_the_group, Toast.LENGTH_SHORT).show();
return;
}
if (!isMulti() || !cursorRecyclerViewAdapter.isSelectedContact(selectedContact)) {
if (selectionLimitReached()) {
Toast.makeText(requireContext(), R.string.ContactSelectionListFragment_the_group_is_full, Toast.LENGTH_SHORT).show();

View File

@@ -49,9 +49,8 @@ import java.util.Objects;
public class AddGroupDetailsFragment extends LoggingFragment {
private static final int AVATAR_PLACEHOLDER_INSET_DP = 18;
private static final short REQUEST_CODE_AVATAR = 27621;
private static final String ARG_RECIPIENT_IDS = "recipient_ids";
private static final int AVATAR_PLACEHOLDER_INSET_DP = 18;
private static final short REQUEST_CODE_AVATAR = 27621;
private CircularProgressButton create;
private Callback callback;
@@ -71,16 +70,6 @@ public class AddGroupDetailsFragment extends LoggingFragment {
}
}
public static Fragment create(@NonNull RecipientId[] recipientIds) {
AddGroupDetailsFragment fragment = new AddGroupDetailsFragment();
Bundle arguments = new Bundle();
arguments.putParcelableArray(ARG_RECIPIENT_IDS, recipientIds);
fragment.setArguments(arguments);
return fragment;
}
@Override
public @Nullable View onCreateView(@NonNull LayoutInflater inflater,
@Nullable ViewGroup container,