diff --git a/app/src/main/java/org/linphone/contacts/ContactsManager.java b/app/src/main/java/org/linphone/contacts/ContactsManager.java index 7e6b49d77..0303baf3b 100644 --- a/app/src/main/java/org/linphone/contacts/ContactsManager.java +++ b/app/src/main/java/org/linphone/contacts/ContactsManager.java @@ -350,26 +350,44 @@ public class ContactsManager extends ContentObserver implements FriendListListen public synchronized LinphoneContact findContactFromPhoneNumber(String phoneNumber) { if (phoneNumber == null) return null; + + if (!android.util.Patterns.PHONE.matcher(phoneNumber).matches()) { + Log.w( + "[Contacts Manager] Expected phone number but doesn't look like it: " + + phoneNumber); + return null; + } + Core core = LinphoneManager.getCore(); ProxyConfig lpc = null; if (core != null) { lpc = core.getDefaultProxyConfig(); } - if (lpc == null) return null; + if (lpc == null) { + Log.i("[Contacts Manager] Couldn't find default proxy config..."); + return null; + } + String normalized = lpc.normalizePhoneNumber(phoneNumber); - if (normalized == null) normalized = phoneNumber; + if (normalized == null) { + Log.w("[Contacts Manager] Couldn't normalize phone number " + phoneNumber + ", default proxy config prefix is " + lpc.getDialPrefix()); + normalized = phoneNumber; + } Address addr = lpc.normalizeSipUri(normalized); if (addr == null) { + Log.w("[Contacts Manager] Couldn't normalize SIP URI " + normalized); return null; } + + // Without this, the hashmap inside liblinphone won't find it... addr.setUriParam("user", "phone"); - Friend lf = - core.findFriend( - addr); // Without this, the hashmap inside liblinphone won't find it... + Friend lf = core.findFriend(addr); if (lf != null) { return (LinphoneContact) lf.getUserData(); } + + Log.w("[Contacts Manager] Couldn't find friend..."); return null; } diff --git a/app/src/main/res/layout/settings_account.xml b/app/src/main/res/layout/settings_account.xml index 5c5083888..99b818395 100644 --- a/app/src/main/res/layout/settings_account.xml +++ b/app/src/main/res/layout/settings_account.xml @@ -137,7 +137,8 @@ android:id="@+id/pref_prefix" android:layout_width="match_parent" android:layout_height="wrap_content" - linphone:hint="@string/pref_prefix" + linphone:hint="@string/pref_prefix_desc" + linphone:subtitle="@string/pref_prefix_desc" linphone:title="@string/pref_prefix" /> Display name Enter display name (optional) Prefix + Prefix for your country (without the +) Transport UDP TCP