Skip to content

Commit

Permalink
Fix bug allowing creation of new and sending in existing MMS groups.
Browse files Browse the repository at this point in the history
  • Loading branch information
cody-signal authored and greyson-signal committed Nov 16, 2023
1 parent df4bd1f commit 1962636
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
Expand Up @@ -133,10 +133,16 @@ class DisabledInputView @JvmOverloads constructor(
existingView = inviteToSignal,
create = { inflater.inflate(R.layout.conversation_activity_sms_export_stub, this, false) },
bind = {
findViewById<TextView>(R.id.export_sms_message).text = context.getString(R.string.ConversationActivity__sms_messaging_is_no_longer_supported_in_signal_invite_s_to_to_signal_to_keep_the_conversation_here, recipient.getDisplayName(context))
findViewById<TextView>(R.id.export_sms_message).text = if (recipient.isMmsGroup) {
context.getString(R.string.ConversationActivity__sms_messaging_is_no_longer_supported)
} else {
context.getString(R.string.ConversationActivity__sms_messaging_is_no_longer_supported_in_signal_invite_s_to_to_signal_to_keep_the_conversation_here, recipient.getDisplayName(context))
}

findViewById<MaterialButton>(R.id.export_sms_button).apply {
setText(R.string.ConversationActivity__invite_to_signal)
setOnClickListener { listener?.onInviteToSignal(recipient) }
visible = !recipient.isMmsGroup
}
}
)
Expand Down
Expand Up @@ -28,7 +28,7 @@ class InputReadyState(
val isRequestingMember: Boolean? = selfMemberLevel?.equals(GroupTable.MemberLevel.REQUESTING_MEMBER)

fun shouldShowInviteToSignal(): Boolean {
return !conversationRecipient.isGroup &&
return !conversationRecipient.isPushGroup &&
!conversationRecipient.isRegistered &&
!conversationRecipient.isReleaseNotes
}
Expand Down
Expand Up @@ -10,6 +10,7 @@
import androidx.annotation.Nullable;

import com.google.android.material.button.MaterialButton;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.floatingactionbutton.FloatingActionButton;

import org.signal.core.util.DimensionUnit;
Expand Down Expand Up @@ -155,7 +156,7 @@ private void handleNextPressed() {
stopwatch.split("resolve");

Set<Recipient> registeredChecks = resolved.stream()
.filter(r -> r.getRegistered() == RecipientTable.RegisteredState.UNKNOWN)
.filter(r -> !r.isRegistered() || !r.hasServiceId())
.collect(Collectors.toSet());

Log.i(TAG, "Need to do " + registeredChecks.size() + " registration checks.");
Expand All @@ -170,11 +171,22 @@ private void handleNextPressed() {

stopwatch.split("registered");

return ids;
}, recipientIds -> {
return Recipient.resolvedList(ids);
}, recipients -> {
dismissibleDialog.dismiss();
stopwatch.stop(TAG);
startActivityForResult(AddGroupDetailsActivity.newIntent(this, recipientIds), REQUEST_CODE_ADD_DETAILS);

List<Recipient> notRegistered = recipients.stream().filter(r -> !r.isRegistered() || !r.hasServiceId()).collect(Collectors.toList());

if (notRegistered.isEmpty()) {
startActivityForResult(AddGroupDetailsActivity.newIntent(this, recipients.stream().map(Recipient::getId).collect(Collectors.toList())), REQUEST_CODE_ADD_DETAILS);
} else {
String notRegisteredNames = notRegistered.stream().map(r -> r.getDisplayName(this)).collect(Collectors.joining(", "));
new MaterialAlertDialogBuilder(this)
.setMessage(getResources().getQuantityString(R.plurals.CreateGroupActivity_not_signal_users, notRegistered.size(), notRegisteredNames))
.setPositiveButton(android.R.string.ok, null)
.show();
}
});
}
}
7 changes: 7 additions & 0 deletions app/src/main/res/values/strings.xml
Expand Up @@ -405,6 +405,8 @@

<string name="ConversationActivity_error_sending_media">Error sending media</string>

<!-- Message shown when opening an MMS group conversation with SMS disabled and there are no exported messages -->
<string name="ConversationActivity__sms_messaging_is_no_longer_supported">SMS messaging is no longer supported in Signal.</string>
<!-- Message shown when opening an SMS conversation with SMS disabled and there are no exported messages -->
<string name="ConversationActivity__sms_messaging_is_no_longer_supported_in_signal_invite_s_to_to_signal_to_keep_the_conversation_here">SMS messaging is no longer supported in Signal. Invite %1$s to Signal to keep the conversation here.</string>
<!-- Action button shown when opening an SMS conversation with SMS disabled and there are no exported messages -->
Expand Down Expand Up @@ -4581,6 +4583,11 @@
<string name="NewConversationActivity__s_is_not_a_signal_user">%1$s is not a Signal user</string>
<!-- Error message shown when we could not get a user from the username link -->
<string name="NewConversationActivity__">%1$s is not a Signal user</string>
<!-- Error message shown in a dialog when trying to create a new group with non-signal users (e.g., unregistered or phone number only contacts) -->
<plurals name="CreateGroupActivity_not_signal_users">
<item quantity="one">%1$s is not a Signal user</item>
<item quantity="other">%1$s are not Signal users</item>
</plurals>

<!-- ContactFilterView -->
<string name="ContactFilterView__search_name_or_number">Search name or number</string>
Expand Down

0 comments on commit 1962636

Please sign in to comment.