Only display username but save SIP addresses with sip: prefix and the domain from default proxy config
This commit is contained in:
parent
fae6f62cdd
commit
ccff156889
2 changed files with 22 additions and 2 deletions
|
@ -129,6 +129,9 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
|
|||
if (displayednumberOrAddress.startsWith("sip:")) {
|
||||
displayednumberOrAddress = displayednumberOrAddress.replace("sip:", "");
|
||||
}
|
||||
if (displayednumberOrAddress.contains("@")) {
|
||||
displayednumberOrAddress = displayednumberOrAddress.split("@")[0];
|
||||
}
|
||||
|
||||
TextView label = (TextView) v.findViewById(R.id.address_label);
|
||||
if (noa.isSIPAddress()) {
|
||||
|
|
|
@ -25,6 +25,8 @@ import java.io.Serializable;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.linphone.core.LinphoneCore;
|
||||
import org.linphone.core.LinphoneProxyConfig;
|
||||
import org.linphone.mediastream.Log;
|
||||
import org.linphone.mediastream.Version;
|
||||
|
||||
|
@ -124,6 +126,10 @@ public class ContactEditorFragment extends Fragment {
|
|||
ok.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||
LinphoneProxyConfig lpc = lc != null ? lc.getDefaultProxyConfig() : null;
|
||||
String defaultDomain = lpc != null ? lpc.getDomain() : null;
|
||||
|
||||
if (isNewContact) {
|
||||
boolean areAllFielsEmpty = true;
|
||||
for (LinphoneNumberOrAddress nounoa : numbersAndAddresses) {
|
||||
|
@ -142,8 +148,16 @@ public class ContactEditorFragment extends Fragment {
|
|||
if (photoToAdd != null) {
|
||||
contact.setPhoto(photoToAdd);
|
||||
}
|
||||
for (LinphoneNumberOrAddress numberOrAddress : numbersAndAddresses) {
|
||||
contact.addOrUpdateNumberOrAddress(numberOrAddress);
|
||||
for (LinphoneNumberOrAddress noa : numbersAndAddresses) {
|
||||
if (noa.isSIPAddress() && noa.getValue() != null) {
|
||||
if (!noa.getValue().contains("@") && defaultDomain != null) {
|
||||
noa.setValue(noa.getValue() + "@" + defaultDomain);
|
||||
}
|
||||
if (!noa.getValue().startsWith("sip:")) {
|
||||
noa.setValue("sip:" + noa.getValue());
|
||||
}
|
||||
}
|
||||
contact.addOrUpdateNumberOrAddress(noa);
|
||||
}
|
||||
contact.save();
|
||||
getFragmentManager().popBackStackImmediate();
|
||||
|
@ -472,6 +486,9 @@ public class ContactEditorFragment extends Fragment {
|
|||
firstSipAddressIndex = controls.getChildCount();
|
||||
}
|
||||
numberOrAddress = numberOrAddress.replace("sip:", "");
|
||||
if (numberOrAddress.contains("@")) {
|
||||
numberOrAddress = numberOrAddress.split("@")[0];
|
||||
}
|
||||
}
|
||||
if ((getResources().getBoolean(R.bool.hide_phone_numbers_in_editor) && !isSIP) || (getResources().getBoolean(R.bool.hide_sip_addresses_in_editor) && isSIP)) {
|
||||
if (forceAddNumber)
|
||||
|
|
Loading…
Reference in a new issue