suggest quicksy.im when user enters e164 in enter jid dialog
This commit is contained in:
parent
c9abe1c610
commit
f7addc5d89
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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<String> {
|
||||
|
||||
private static Pattern E164_PATTERN = Pattern.compile("^\\+?[1-9]\\d{1,14}$");
|
||||
|
||||
private ArrayList<String> domains;
|
||||
private Filter domainFilter = new Filter() {
|
||||
|
||||
|
@ -19,8 +26,12 @@ public class KnownHostsAdapter extends ArrayAdapter<String> {
|
|||
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<String> {
|
|||
public KnownHostsAdapter(Context context, int viewResourceId, Collection<String> 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<String> {
|
|||
|
||||
public void refresh(Collection<String> knownHosts) {
|
||||
domains = new ArrayList<>(knownHosts);
|
||||
Collections.sort(domains);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue