From 1d0e2858160dbbe9a90b9e0506077240d00b7711 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Mon, 7 Mar 2022 13:49:32 -0500 Subject: [PATCH] Change input type based on gateway type --- .../conversations/ui/EnterJidDialog.java | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/EnterJidDialog.java b/src/main/java/eu/siacs/conversations/ui/EnterJidDialog.java index d54ce3d02..83229453a 100644 --- a/src/main/java/eu/siacs/conversations/ui/EnterJidDialog.java +++ b/src/main/java/eu/siacs/conversations/ui/EnterJidDialog.java @@ -405,7 +405,16 @@ public class EnterJidDialog extends DialogFragment implements OnBackendConnected binding.jidLayout.setHint(R.string.account_settings_jabber_id); } else { binding.jid.setThreshold(999999); // do not autocomplete - binding.jid.setInputType(InputType.TYPE_CLASS_TEXT); + + String type = getType(i); + if (type.equals("pstn") || type.equals("sms")) { + binding.jid.setInputType(InputType.TYPE_CLASS_PHONE); + } else if (type.equals("email") || type.equals("sip")) { + binding.jid.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS); + } else { + binding.jid.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); + } + binding.jidLayout.setHint(this.gateways.get(i-1).second); binding.jid.setHint(null); binding.jid.setOnFocusChangeListener((v, hasFocus) -> {}); @@ -418,6 +427,15 @@ public class EnterJidDialog extends DialogFragment implements OnBackendConnected public String getLabel(int i) { if (i == 0) return null; + String type = getType(i); + if (type != null) return type; + + return gateways.get(i-1).first.getDisplayName(); + } + + public String getType(int i) { + if (i == 0) return null; + for(Presence p : this.gateways.get(i-1).first.getPresences().getPresences()) { ServiceDiscoveryResult.Identity id; if(p.getServiceDiscoveryResult() != null && (id = p.getServiceDiscoveryResult().getIdentity("gateway", null)) != null) { @@ -425,11 +443,7 @@ public class EnterJidDialog extends DialogFragment implements OnBackendConnected } } - return gateways.get(i-1).first.getDisplayName(); - } - - public String getSelectedLabel() { - return getLabel(selected); + return null; } public Pair> getSelected() {