Improvements & fixes related to phone numbers

This commit is contained in:
Sylvain Berfini 2016-10-13 12:43:41 +02:00
parent 3ab5835059
commit b01e60aaed
3 changed files with 27 additions and 24 deletions

View file

@ -118,8 +118,9 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
for (LinphoneNumberOrAddress noa : contact.getNumbersOrAddresses()) { for (LinphoneNumberOrAddress noa : contact.getNumbersOrAddresses()) {
boolean skip = false; boolean skip = false;
View v = inflater.inflate(R.layout.contact_control_row, null); View v = inflater.inflate(R.layout.contact_control_row, null);
String displayednumberOrAddress = LinphoneUtils.getDisplayableUsernameFromAddress(noa.getValue()); String value = noa.getValue();
String displayednumberOrAddress = LinphoneUtils.getDisplayableUsernameFromAddress(value);
TextView label = (TextView) v.findViewById(R.id.address_label); TextView label = (TextView) v.findViewById(R.id.address_label);
if (noa.isSIPAddress()) { if (noa.isSIPAddress()) {
@ -133,40 +134,35 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
TextView tv = (TextView) v.findViewById(R.id.numeroOrAddress); TextView tv = (TextView) v.findViewById(R.id.numeroOrAddress);
tv.setText(displayednumberOrAddress); tv.setText(displayednumberOrAddress);
tv.setSelected(true); tv.setSelected(true);
LinphoneProxyConfig lpc = LinphoneManager.getLc().getDefaultProxyConfig();
if (lpc != null) {
String username = lpc.normalizePhoneNumber(displayednumberOrAddress);
value = LinphoneUtils.getFullAddressFromUsername(username);
}
String contactAddress = contact.getPresenceModelForUri(noa.getValue()); String contactAddress = contact.getPresenceModelForUri(noa.getValue());
if(contactAddress != null) { if (contactAddress != null) {
v.findViewById(R.id.friendLinphone).setVisibility(View.VISIBLE); v.findViewById(R.id.friendLinphone).setVisibility(View.VISIBLE);
} }
if (!displayChatAddressOnly) { if (!displayChatAddressOnly) {
v.findViewById(R.id.contact_call).setOnClickListener(dialListener); v.findViewById(R.id.contact_call).setOnClickListener(dialListener);
if(contactAddress != null){ if (contactAddress != null) {
v.findViewById(R.id.contact_call).setTag(contact.getPresenceModelForUri(noa.getValue())); v.findViewById(R.id.contact_call).setTag(contactAddress);
} else { } else {
v.findViewById(R.id.contact_call).setTag(displayednumberOrAddress); v.findViewById(R.id.contact_call).setTag(value);
} }
} else { } else {
v.findViewById(R.id.contact_call).setVisibility(View.GONE); v.findViewById(R.id.contact_call).setVisibility(View.GONE);
} }
v.findViewById(R.id.contact_chat).setOnClickListener(chatListener); v.findViewById(R.id.contact_chat).setOnClickListener(chatListener);
LinphoneProxyConfig lpc = LinphoneManager.getLc().getDefaultProxyConfig(); if (contactAddress != null) {
if (lpc != null) { v.findViewById(R.id.contact_chat).setTag(contactAddress);
String username = lpc.normalizePhoneNumber(LinphoneUtils.getUsernameFromAddress(noa.getValue()));
String tag = LinphoneUtils.getFullAddressFromUsername(username);
if(contactAddress != null){
v.findViewById(R.id.contact_chat).setTag(contact.getPresenceModelForUri(noa.getValue()));
} else {
v.findViewById(R.id.contact_chat).setTag(tag);
}
} else { } else {
if(contactAddress != null){ v.findViewById(R.id.contact_chat).setTag(value);
v.findViewById(R.id.contact_chat).setTag(contact.getPresenceModelForUri(noa.getValue()));
} else {
v.findViewById(R.id.contact_chat).setTag(noa.getValue());
}
} }
if (getResources().getBoolean(R.bool.disable_chat)) { if (getResources().getBoolean(R.bool.disable_chat)) {

View file

@ -743,6 +743,9 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
if (isSIP && !number.startsWith("sip:")) { if (isSIP && !number.startsWith("sip:")) {
number = "sip:" + number; number = "sip:" + number;
} }
if (isSIP && !number.contains("@")) {
number = number + "@" + ContactsManager.getInstance().getString(R.string.default_domain);
}
result.add(new LinphoneNumberOrAddress(number, isSIP)); result.add(new LinphoneNumberOrAddress(number, isSIP));
} }
} }

View file

@ -471,15 +471,19 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
// return; // return;
// } // }
LinphoneProxyConfig lpc = getLc().getDefaultProxyConfig();
if (lpc != null) {
to = lpc.normalizePhoneNumber(to);
}
LinphoneAddress lAddress; LinphoneAddress lAddress;
try { try {
lAddress = mLc.interpretUrl(to); lAddress = mLc.interpretUrl(to);
LinphoneProxyConfig lpc = mLc.getDefaultProxyConfig(); if (mR.getBoolean(R.bool.forbid_self_call) && lpc != null && lAddress.asStringUriOnly().equals(lpc.getIdentity())) {
if (mR.getBoolean(R.bool.forbid_self_call) && lpc!=null && lAddress.asStringUriOnly().equals(lpc.getIdentity())) {
return; return;
} }
} catch (LinphoneCoreException e) { } catch (LinphoneCoreException e) {
Log.e(e);
return; return;
} }
lAddress.setDisplayName(displayName); lAddress.setDisplayName(displayName);