Improved logs in contacts manager find friend + improved description for prefix field in account settings
This commit is contained in:
parent
7df97a84b1
commit
0d044872af
3 changed files with 26 additions and 6 deletions
|
@ -350,26 +350,44 @@ public class ContactsManager extends ContentObserver implements FriendListListen
|
||||||
|
|
||||||
public synchronized LinphoneContact findContactFromPhoneNumber(String phoneNumber) {
|
public synchronized LinphoneContact findContactFromPhoneNumber(String phoneNumber) {
|
||||||
if (phoneNumber == null) return null;
|
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();
|
Core core = LinphoneManager.getCore();
|
||||||
ProxyConfig lpc = null;
|
ProxyConfig lpc = null;
|
||||||
if (core != null) {
|
if (core != null) {
|
||||||
lpc = core.getDefaultProxyConfig();
|
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);
|
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);
|
Address addr = lpc.normalizeSipUri(normalized);
|
||||||
if (addr == null) {
|
if (addr == null) {
|
||||||
|
Log.w("[Contacts Manager] Couldn't normalize SIP URI " + normalized);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Without this, the hashmap inside liblinphone won't find it...
|
||||||
addr.setUriParam("user", "phone");
|
addr.setUriParam("user", "phone");
|
||||||
Friend lf =
|
Friend lf = core.findFriend(addr);
|
||||||
core.findFriend(
|
|
||||||
addr); // Without this, the hashmap inside liblinphone won't find it...
|
|
||||||
if (lf != null) {
|
if (lf != null) {
|
||||||
return (LinphoneContact) lf.getUserData();
|
return (LinphoneContact) lf.getUserData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Log.w("[Contacts Manager] Couldn't find friend...");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -137,7 +137,8 @@
|
||||||
android:id="@+id/pref_prefix"
|
android:id="@+id/pref_prefix"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
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" />
|
linphone:title="@string/pref_prefix" />
|
||||||
|
|
||||||
<org.linphone.settings.widget.SwitchSetting
|
<org.linphone.settings.widget.SwitchSetting
|
||||||
|
|
|
@ -367,6 +367,7 @@
|
||||||
<string name="pref_display_name">Display name</string>
|
<string name="pref_display_name">Display name</string>
|
||||||
<string name="pref_help_display_name">Enter display name (optional)</string>
|
<string name="pref_help_display_name">Enter display name (optional)</string>
|
||||||
<string name="pref_prefix">Prefix</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">Transport</string>
|
||||||
<string name="pref_transport_udp">UDP</string>
|
<string name="pref_transport_udp">UDP</string>
|
||||||
<string name="pref_transport_tcp">TCP</string>
|
<string name="pref_transport_tcp">TCP</string>
|
||||||
|
|
Loading…
Reference in a new issue