From e31ae3e60ecd1ecf0611682dfe42b711425ed869 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Tue, 18 Oct 2022 22:20:11 -0500 Subject: [PATCH] Terrible gross hack for starting group text This is the first feature to hardcode cheogram.com let's hope we can remove it someday. XEP-0033 does not have good fallback behaviour, and group text doesn't map well to MUC. We could still do a MUC mapping, or think of a better fallback behaviour, or something else, but for now analysis paralysis means we stick to the gross +1...,+1...,+1...@cheogram.com -- but that's not a protocol, it's not something we can detect or design around or expect anyone else to ever do. So just check for cheogram.com because that's the only place we ever expect to see this dirty hack. If starting a new private group and every selected member is @cheogram.com, then ask if we should make a group text instead. --- .../ui/StartConversationActivity.java | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java index 75381aadac18b3c3f4cfb9012b7c4607651f2be3..055b8723a0b52e459a8b058d0edcafebd46753c0 100644 --- a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java @@ -748,9 +748,28 @@ public class StartConversationActivity extends XmppActivity implements XmppConne final String name = intent.getStringExtra(ChooseContactActivity.EXTRA_GROUP_CHAT_NAME); final List jids = ChooseContactActivity.extractJabberIds(intent); if (account != null && jids.size() > 0) { - if (xmppConnectionService.createAdhocConference(account, name, jids, mAdhocConferenceCallback)) { - mToast = Toast.makeText(this, R.string.creating_conference, Toast.LENGTH_LONG); - mToast.show(); + // This hardcodes cheogram.com and is in general a terrible hack + // Ideally this would be based around XEP-0033 but until we think of a good fallback behaviour we keep using this gross commas thing + if (jids.stream().allMatch(jid -> jid.getDomain().toString().equals("cheogram.com"))) { + new AlertDialog.Builder(this) + .setMessage("You appear to be creating a group with only SMS contacts. Would you like to create a channel or an MMS group text?") + .setNeutralButton("Channel", (d, w) -> { + if (xmppConnectionService.createAdhocConference(account, name, jids, mAdhocConferenceCallback)) { + mToast = Toast.makeText(this, R.string.creating_conference, Toast.LENGTH_LONG); + mToast.show(); + } + }).setPositiveButton("Group Text", (d, w) -> { + Jid groupJid = Jid.ofLocalAndDomain(jids.stream().map(jid -> jid.getLocal()).sorted().collect(Collectors.joining(",")), "cheogram.com"); + Contact group = account.getRoster().getContact(groupJid); + if (name != null && !name.equals("")) group.setServerName(name); + xmppConnectionService.createContact(group, true); + switchToConversation(group); + }).create().show(); + } else { + if (xmppConnectionService.createAdhocConference(account, name, jids, mAdhocConferenceCallback)) { + mToast = Toast.makeText(this, R.string.creating_conference, Toast.LENGTH_LONG); + mToast.show(); + } } } }