add default proxy config domain to contact if domain is not specified
This commit is contained in:
parent
69950b81ef
commit
8bfcafa9a3
2 changed files with 36 additions and 12 deletions
|
@ -300,7 +300,7 @@ public class ContactsManager {
|
||||||
public boolean isContactHasAddress(Contact contact, String address){
|
public boolean isContactHasAddress(Contact contact, String address){
|
||||||
if(contact != null) {
|
if(contact != null) {
|
||||||
contact.refresh(contentResolver);
|
contact.refresh(contentResolver);
|
||||||
if (contact.getNumbersOrAddresses().contains(address)) {
|
if (contact.getNumbersOrAddresses().contains(address) || contact.getNumbersOrAddresses().contains("sip:"+ address)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -4,6 +4,7 @@ import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.linphone.compatibility.Compatibility;
|
import org.linphone.compatibility.Compatibility;
|
||||||
|
import org.linphone.core.LinphoneProxyConfig;
|
||||||
import org.linphone.mediastream.Version;
|
import org.linphone.mediastream.Version;
|
||||||
import org.linphone.ui.AvatarWithShadow;
|
import org.linphone.ui.AvatarWithShadow;
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
|
@ -399,6 +400,7 @@ public class EditContactFragment extends Fragment {
|
||||||
contactsManager.createNewFriend(c, numberOrAddress.newNumberOrAddress);
|
contactsManager.createNewFriend(c, numberOrAddress.newNumberOrAddress);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (!contactsManager.isContactHasAddress(contact, numberOrAddress.newNumberOrAddress)){
|
||||||
if (numberOrAddress.oldNumberOrAddress == null) {
|
if (numberOrAddress.oldNumberOrAddress == null) {
|
||||||
contactsManager.createNewFriend(contact, numberOrAddress.newNumberOrAddress);
|
contactsManager.createNewFriend(contact, numberOrAddress.newNumberOrAddress);
|
||||||
} else {
|
} else {
|
||||||
|
@ -409,6 +411,7 @@ public class EditContactFragment extends Fragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class NewOrUpdatedNumberOrAddress {
|
class NewOrUpdatedNumberOrAddress {
|
||||||
private String oldNumberOrAddress;
|
private String oldNumberOrAddress;
|
||||||
|
@ -486,8 +489,15 @@ public class EditContactFragment extends Fragment {
|
||||||
if (isSipAddress) {
|
if (isSipAddress) {
|
||||||
if (newNumberOrAddress.startsWith("sip:"))
|
if (newNumberOrAddress.startsWith("sip:"))
|
||||||
newNumberOrAddress = newNumberOrAddress.substring(4);
|
newNumberOrAddress = newNumberOrAddress.substring(4);
|
||||||
if(!newNumberOrAddress.contains("@"))
|
if(!newNumberOrAddress.contains("@")) {
|
||||||
|
//Use default proxy config domain if it exists
|
||||||
|
LinphoneProxyConfig lpc = LinphoneManager.getLc().getDefaultProxyConfig();
|
||||||
|
if(lpc != null){
|
||||||
|
newNumberOrAddress = newNumberOrAddress + "@" + lpc.getDomain();
|
||||||
|
} else {
|
||||||
newNumberOrAddress = newNumberOrAddress + "@" + getResources().getString(R.string.default_domain);
|
newNumberOrAddress = newNumberOrAddress + "@" + getResources().getString(R.string.default_domain);
|
||||||
|
}
|
||||||
|
}
|
||||||
Compatibility.addSipAddressToContact(getActivity(), ops, newNumberOrAddress);
|
Compatibility.addSipAddressToContact(getActivity(), ops, newNumberOrAddress);
|
||||||
} else {
|
} else {
|
||||||
ops.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
|
ops.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
|
||||||
|
@ -504,8 +514,15 @@ public class EditContactFragment extends Fragment {
|
||||||
if (isSipAddress) {
|
if (isSipAddress) {
|
||||||
if (newNumberOrAddress.startsWith("sip:"))
|
if (newNumberOrAddress.startsWith("sip:"))
|
||||||
newNumberOrAddress = newNumberOrAddress.substring(4);
|
newNumberOrAddress = newNumberOrAddress.substring(4);
|
||||||
if(!newNumberOrAddress.contains("@"))
|
if(!newNumberOrAddress.contains("@")) {
|
||||||
|
//Use default proxy config domain if it exists
|
||||||
|
LinphoneProxyConfig lpc = LinphoneManager.getLc().getDefaultProxyConfig();
|
||||||
|
if(lpc != null){
|
||||||
|
newNumberOrAddress = newNumberOrAddress + "@" + lpc.getDomain();
|
||||||
|
} else {
|
||||||
newNumberOrAddress = newNumberOrAddress + "@" + getResources().getString(R.string.default_domain);
|
newNumberOrAddress = newNumberOrAddress + "@" + getResources().getString(R.string.default_domain);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Compatibility.addSipAddressToContact(getActivity(), ops, newNumberOrAddress, rawContactId);
|
Compatibility.addSipAddressToContact(getActivity(), ops, newNumberOrAddress, rawContactId);
|
||||||
Compatibility.addLinphoneContactTag(getActivity(), ops, newNumberOrAddress, contactsManager.findRawLinphoneContactID(String.valueOf(contactID)));
|
Compatibility.addLinphoneContactTag(getActivity(), ops, newNumberOrAddress, contactsManager.findRawLinphoneContactID(String.valueOf(contactID)));
|
||||||
|
@ -530,8 +547,15 @@ public class EditContactFragment extends Fragment {
|
||||||
if (isSipAddress) {
|
if (isSipAddress) {
|
||||||
if (newNumberOrAddress.startsWith("sip:"))
|
if (newNumberOrAddress.startsWith("sip:"))
|
||||||
newNumberOrAddress = newNumberOrAddress.substring(4);
|
newNumberOrAddress = newNumberOrAddress.substring(4);
|
||||||
if(!newNumberOrAddress.contains("@"))
|
if(!newNumberOrAddress.contains("@")) {
|
||||||
|
//Use default proxy config domain if it exists
|
||||||
|
LinphoneProxyConfig lpc = LinphoneManager.getLc().getDefaultProxyConfig();
|
||||||
|
if(lpc != null){
|
||||||
|
newNumberOrAddress = newNumberOrAddress + "@" + lpc.getDomain();
|
||||||
|
} else {
|
||||||
newNumberOrAddress = newNumberOrAddress + "@" + getResources().getString(R.string.default_domain);
|
newNumberOrAddress = newNumberOrAddress + "@" + getResources().getString(R.string.default_domain);
|
||||||
|
}
|
||||||
|
}
|
||||||
Compatibility.updateSipAddressForContact(ops, oldNumberOrAddress, newNumberOrAddress, String.valueOf(contactID));
|
Compatibility.updateSipAddressForContact(ops, oldNumberOrAddress, newNumberOrAddress, String.valueOf(contactID));
|
||||||
Compatibility.updateLinphoneContactTag(getActivity(), ops, newNumberOrAddress, oldNumberOrAddress, contactsManager.findRawLinphoneContactID(String.valueOf(contactID)));
|
Compatibility.updateLinphoneContactTag(getActivity(), ops, newNumberOrAddress, oldNumberOrAddress, contactsManager.findRawLinphoneContactID(String.valueOf(contactID)));
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue