diff --git a/src/main/java/eu/siacs/conversations/Config.java b/src/main/java/eu/siacs/conversations/Config.java index 55a778714..66d0ffef4 100644 --- a/src/main/java/eu/siacs/conversations/Config.java +++ b/src/main/java/eu/siacs/conversations/Config.java @@ -41,6 +41,7 @@ public final class Config { public static final String DOMAIN_LOCK = null; //only allow account creation for this domain public static final String MAGIC_CREATE_DOMAIN = "conversations.im"; + public static final String QUICKSY_DOMAIN = "quicksy.im"; public static final boolean DISALLOW_REGISTRATION_IN_UI = false; //hide the register checkbox public static final boolean USE_RANDOM_RESOURCE_ON_EVERY_BIND = false; diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 8ea0582d1..0d5b075cf 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -3544,12 +3544,15 @@ public class XmppConnectionService extends Service { for (final Contact contact : account.getRoster().getContacts()) { if (contact.showInRoster()) { final String server = contact.getServer(); - if (server != null && !hosts.contains(server)) { + if (server != null) { hosts.add(server); } } } } + if (Config.QUICKSY_DOMAIN != null) { + hosts.remove(Config.QUICKSY_DOMAIN); //we only want to show this when we type a e164 number + } if (Config.DOMAIN_LOCK != null) { hosts.add(Config.DOMAIN_LOCK); } diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/KnownHostsAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/KnownHostsAdapter.java index 2f2b1e7ac..e0ade6491 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/KnownHostsAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/KnownHostsAdapter.java @@ -7,9 +7,16 @@ import android.widget.Filter; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.Locale; +import java.util.regex.Pattern; + +import eu.siacs.conversations.Config; public class KnownHostsAdapter extends ArrayAdapter { + + private static Pattern E164_PATTERN = Pattern.compile("^\\+?[1-9]\\d{1,14}$"); + private ArrayList domains; private Filter domainFilter = new Filter() { @@ -19,8 +26,12 @@ public class KnownHostsAdapter extends ArrayAdapter { final String[] split = constraint == null ? new String[0] : constraint.toString().split("@"); if (split.length == 1) { final String local = split[0].toLowerCase(Locale.ENGLISH); - for (String domain : domains) { - suggestions.add(local + "@" + domain); + if (Config.QUICKSY_DOMAIN != null && E164_PATTERN.matcher(local).matches()) { + suggestions.add(local + '@' + Config.QUICKSY_DOMAIN); + } else { + for (String domain : domains) { + suggestions.add(local + '@' + domain); + } } } else if (split.length == 2) { final String localPart = split[0].toLowerCase(Locale.ENGLISH); @@ -56,6 +67,7 @@ public class KnownHostsAdapter extends ArrayAdapter { public KnownHostsAdapter(Context context, int viewResourceId, Collection mKnownHosts) { super(context, viewResourceId, new ArrayList<>()); domains = new ArrayList<>(mKnownHosts); + Collections.sort(domains); } public KnownHostsAdapter(Context context, int viewResourceId) { @@ -65,6 +77,7 @@ public class KnownHostsAdapter extends ArrayAdapter { public void refresh(Collection knownHosts) { domains = new ArrayList<>(knownHosts); + Collections.sort(domains); notifyDataSetChanged(); } diff --git a/src/quick/java/eu/siacs/conversations/services/QuickConversationsService.java b/src/quick/java/eu/siacs/conversations/services/QuickConversationsService.java index ed6259173..a1aee5795 100644 --- a/src/quick/java/eu/siacs/conversations/services/QuickConversationsService.java +++ b/src/quick/java/eu/siacs/conversations/services/QuickConversationsService.java @@ -125,7 +125,7 @@ public class QuickConversationsService { private void createAccountAndWait(Phonenumber.PhoneNumber phoneNumber, final long timestamp) { String local = PhoneNumberUtilWrapper.normalize(service, phoneNumber); Log.d(Config.LOGTAG, "requesting verification for " + PhoneNumberUtilWrapper.normalize(service, phoneNumber)); - Jid jid = Jid.of(local, "quick.conversations.im", null); + Jid jid = Jid.of(local, Config.QUICKSY_DOMAIN, null); Account account = AccountUtils.getFirst(service); if (account == null || !account.getJid().asBareJid().equals(jid.asBareJid())) { if (account != null) {