Improved logs in contacts manager find friend + improved description for prefix field in account settings

This commit is contained in:
Sylvain Berfini 2019-05-24 17:37:05 +02:00
parent 7df97a84b1
commit 0d044872af
3 changed files with 26 additions and 6 deletions

View file

@ -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;
}

View file

@ -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" />
<org.linphone.settings.widget.SwitchSetting

View file

@ -367,6 +367,7 @@
<string name="pref_display_name">Display name</string>
<string name="pref_help_display_name">Enter display name (optional)</string>
<string name="pref_prefix">Prefix</string>
<string name="pref_prefix_desc">Prefix for your country (without the +)</string>
<string name="pref_transport">Transport</string>
<string name="pref_transport_udp">UDP</string>
<string name="pref_transport_tcp">TCP</string>