Terrible gross hack for starting group text

Stephen Paul Weber created

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.

Change summary

src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java | 25 
1 file changed, 22 insertions(+), 3 deletions(-)

Detailed changes

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<Jid> 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();
+                            }
                         }
                     }
                 }