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,

View File

@ -1442,6 +1442,7 @@
<string name="ContactSelectionListFragment_s_is_not_a_signal_user">"%1$s" is not a Signal user. Please check the username and try again.</string>
<string name="ContactSelectionListFragment_okay">Okay</string>
<string name="ContactSelectionListFragment_the_group_is_full">The group is full</string>
<string name="ContactSelectionListFragment_you_do_not_need_to_add_yourself_to_the_group">You do not need to add yourself to the group</string>
<!-- blocked_contacts_fragment -->
<string name="blocked_contacts_fragment__no_blocked_contacts">No blocked contacts</string>