Fallback mode (or forced mode) using Linphone Friends seems to be working, and mixed Android contacts and Linphone friends also seems to be working
This commit is contained in:
parent
f3a6e1c66f
commit
c96b896f73
5 changed files with 194 additions and 238 deletions
|
@ -12,7 +12,7 @@
|
||||||
<bool name="orientation_portrait_only">false</bool>
|
<bool name="orientation_portrait_only">false</bool>
|
||||||
<bool name="show_statusbar_only_on_dialer">false</bool>
|
<bool name="show_statusbar_only_on_dialer">false</bool>
|
||||||
<bool name="replace_assistant_with_old_interface">false</bool>
|
<bool name="replace_assistant_with_old_interface">false</bool>
|
||||||
|
<bool name="force_use_of_linphone_friends">false</bool>
|
||||||
|
|
||||||
<string name="wizard_url">https://www.linphone.org/wizard.php</string>
|
<string name="wizard_url">https://www.linphone.org/wizard.php</string>
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,8 @@ public class ContactEditorFragment extends Fragment {
|
||||||
view = inflater.inflate(R.layout.contact_edit, container, false);
|
view = inflater.inflate(R.layout.contact_edit, container, false);
|
||||||
|
|
||||||
phoneNumbersSection = (LinearLayout) view.findViewById(R.id.phone_numbers);
|
phoneNumbersSection = (LinearLayout) view.findViewById(R.id.phone_numbers);
|
||||||
if (getResources().getBoolean(R.bool.hide_phone_numbers_in_editor)) {
|
if (getResources().getBoolean(R.bool.hide_phone_numbers_in_editor) || !ContactsManager.getInstance().hasContactsAccess()) {
|
||||||
|
//Currently linphone friends don't support phone numbers, so hide them
|
||||||
phoneNumbersSection.setVisibility(View.GONE);
|
phoneNumbersSection.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -538,162 +539,11 @@ public class ContactEditorFragment extends Fragment {
|
||||||
delete.setOnClickListener(new OnClickListener() {
|
delete.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (contact != null) {
|
|
||||||
contact.removeNumberOrAddress(nounoa);
|
|
||||||
}
|
|
||||||
numbersAndAddresses.remove(nounoa);
|
numbersAndAddresses.remove(nounoa);
|
||||||
view.setVisibility(View.GONE);
|
view.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
controls.addView(view);
|
controls.addView(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*class NewOrUpdatedNumberOrAddress {
|
|
||||||
private String oldNumberOrAddress;
|
|
||||||
private String newNumberOrAddress;
|
|
||||||
private boolean isSipAddress;
|
|
||||||
|
|
||||||
public NewOrUpdatedNumberOrAddress() {
|
|
||||||
oldNumberOrAddress = null;
|
|
||||||
newNumberOrAddress = null;
|
|
||||||
isSipAddress = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public NewOrUpdatedNumberOrAddress(boolean isSip) {
|
|
||||||
oldNumberOrAddress = null;
|
|
||||||
newNumberOrAddress = null;
|
|
||||||
isSipAddress = isSip;
|
|
||||||
}
|
|
||||||
|
|
||||||
public NewOrUpdatedNumberOrAddress(String old, boolean isSip) {
|
|
||||||
oldNumberOrAddress = old;
|
|
||||||
newNumberOrAddress = null;
|
|
||||||
isSipAddress = isSip;
|
|
||||||
}
|
|
||||||
|
|
||||||
public NewOrUpdatedNumberOrAddress(boolean isSip, String newSip) {
|
|
||||||
oldNumberOrAddress = null;
|
|
||||||
newNumberOrAddress = newSip;
|
|
||||||
isSipAddress = isSip;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNewNumberOrAddress(String newN) {
|
|
||||||
newNumberOrAddress = newN;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void save() {
|
|
||||||
if (newNumberOrAddress == null || newNumberOrAddress.equals(oldNumberOrAddress))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (oldNumberOrAddress == null) {
|
|
||||||
// New number to add
|
|
||||||
addNewNumber();
|
|
||||||
} else {
|
|
||||||
// Old number to update
|
|
||||||
updateNumber();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void delete() {
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addNewNumber() {
|
|
||||||
if (newNumberOrAddress == null || newNumberOrAddress.length() == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isNewContact) {
|
|
||||||
if (isSipAddress) {
|
|
||||||
if (newNumberOrAddress.startsWith("sip:"))
|
|
||||||
newNumberOrAddress = newNumberOrAddress.substring(4);
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Compatibility.addSipAddressToContact(getActivity(), ops, newNumberOrAddress);
|
|
||||||
} else {
|
|
||||||
ops.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
|
|
||||||
.withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0)
|
|
||||||
.withValue(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE)
|
|
||||||
.withValue(ContactsContract.CommonDataKinds.Phone.NUMBER, newNumberOrAddress)
|
|
||||||
.withValue(ContactsContract.CommonDataKinds.Phone.TYPE, ContactsContract.CommonDataKinds.Phone.TYPE_CUSTOM)
|
|
||||||
.withValue(ContactsContract.CommonDataKinds.Phone.LABEL, getString(R.string.addressbook_label))
|
|
||||||
.build()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
String rawContactId = contactsManager.findRawContactID(getActivity().getContentResolver(),String.valueOf(contactID));
|
|
||||||
if (isSipAddress) {
|
|
||||||
if (newNumberOrAddress.startsWith("sip:"))
|
|
||||||
newNumberOrAddress = newNumberOrAddress.substring(4);
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Compatibility.addSipAddressToContact(getActivity(), ops, newNumberOrAddress, rawContactId);
|
|
||||||
if (getResources().getBoolean(R.bool.use_linphone_tag)) {
|
|
||||||
Compatibility.addLinphoneContactTag(getActivity(), ops, newNumberOrAddress, contactsManager.findRawLinphoneContactID(String.valueOf(contactID)));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ops.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
|
|
||||||
.withValue(ContactsContract.Data.RAW_CONTACT_ID, rawContactId)
|
|
||||||
.withValue(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE)
|
|
||||||
.withValue(ContactsContract.CommonDataKinds.Phone.NUMBER, newNumberOrAddress)
|
|
||||||
.withValue(ContactsContract.CommonDataKinds.Phone.TYPE, ContactsContract.CommonDataKinds.Phone.TYPE_CUSTOM)
|
|
||||||
.withValue(ContactsContract.CommonDataKinds.Phone.LABEL, getString(R.string.addressbook_label))
|
|
||||||
.build()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateNumber() {
|
|
||||||
if (newNumberOrAddress == null || newNumberOrAddress.length() == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isSipAddress) {
|
|
||||||
if (newNumberOrAddress.startsWith("sip:"))
|
|
||||||
newNumberOrAddress = newNumberOrAddress.substring(4);
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Compatibility.updateSipAddressForContact(ops, oldNumberOrAddress, newNumberOrAddress, String.valueOf(contactID));
|
|
||||||
if (getResources().getBoolean(R.bool.use_linphone_tag)) {
|
|
||||||
Compatibility.updateLinphoneContactTag(getActivity(), ops, newNumberOrAddress, oldNumberOrAddress, contactsManager.findRawLinphoneContactID(String.valueOf(contactID)));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
String select = ContactsContract.Data.CONTACT_ID + "=? AND "
|
|
||||||
+ ContactsContract.Data.MIMETYPE + "='" + ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE + "' AND "
|
|
||||||
+ ContactsContract.CommonDataKinds.Phone.NUMBER + "=?";
|
|
||||||
String[] args = new String[] { String.valueOf(contactID), oldNumberOrAddress };
|
|
||||||
|
|
||||||
ops.add(ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI)
|
|
||||||
.withSelection(select, args)
|
|
||||||
.withValue(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE)
|
|
||||||
.withValue(ContactsContract.CommonDataKinds.Phone.NUMBER, newNumberOrAddress)
|
|
||||||
.build()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
}
|
}
|
|
@ -121,7 +121,7 @@ public class ContactsManager extends ContentObserver {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasContactsAccess() {
|
public boolean hasContactsAccess() {
|
||||||
return hasContactAccess;
|
return hasContactAccess && !context.getResources().getBoolean(R.bool.force_use_of_linphone_friends);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLinphoneContactsPrefered(boolean isPrefered) {
|
public void setLinphoneContactsPrefered(boolean isPrefered) {
|
||||||
|
@ -195,13 +195,12 @@ public class ContactsManager extends ContentObserver {
|
||||||
|
|
||||||
for (LinphoneFriend friend : LinphoneManager.getLc().getFriendList()) {
|
for (LinphoneFriend friend : LinphoneManager.getLc().getFriendList()) {
|
||||||
LinphoneContact contact = new LinphoneContact();
|
LinphoneContact contact = new LinphoneContact();
|
||||||
LinphoneAddress addr = friend.getAddress();
|
contact.setFriend(friend);
|
||||||
contact.setFullName(addr.getDisplayName());
|
contact.refresh();
|
||||||
contact.addNumberOrAddress(new LinphoneNumberOrAddress(addr.asStringUriOnly(), true));
|
|
||||||
contacts.add(contact);
|
contacts.add(contact);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mAccount == null || !hasContactAccess) return contacts;
|
if (mAccount == null || !hasContactsAccess()) return contacts;
|
||||||
|
|
||||||
Cursor c = Compatibility.getContactsCursor(contentResolver, null);
|
Cursor c = Compatibility.getContactsCursor(contentResolver, null);
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
|
|
|
@ -23,6 +23,8 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.linphone.core.LinphoneAddress;
|
import org.linphone.core.LinphoneAddress;
|
||||||
|
import org.linphone.core.LinphoneCore;
|
||||||
|
import org.linphone.core.LinphoneCoreException;
|
||||||
import org.linphone.core.LinphoneCoreFactory;
|
import org.linphone.core.LinphoneCoreFactory;
|
||||||
import org.linphone.core.LinphoneFriend;
|
import org.linphone.core.LinphoneFriend;
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
|
@ -93,7 +95,13 @@ public class LinphoneContact implements Serializable {
|
||||||
|
|
||||||
firstName = fn;
|
firstName = fn;
|
||||||
lastName = ln;
|
lastName = ln;
|
||||||
|
if (firstName != null && lastName != null && firstName.length() > 0 && lastName.length() > 0) {
|
||||||
fullName = firstName + " " + lastName;
|
fullName = firstName + " " + lastName;
|
||||||
|
} else if (firstName != null && firstName.length() > 0) {
|
||||||
|
fullName = firstName;
|
||||||
|
} else if (lastName != null && lastName.length() > 0) {
|
||||||
|
fullName = lastName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFirstName() {
|
public String getFirstName() {
|
||||||
|
@ -125,7 +133,8 @@ public class LinphoneContact implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPhoto(byte[] photo) {
|
public void setPhoto(byte[] photo) {
|
||||||
if (isAndroidContact() && photo != null) {
|
if (photo != null) {
|
||||||
|
if (isAndroidContact()) {
|
||||||
String rawContactId = findRawContactID(getAndroidId());
|
String rawContactId = findRawContactID(getAndroidId());
|
||||||
if (rawContactId != null) {
|
if (rawContactId != null) {
|
||||||
changesToCommit.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
|
changesToCommit.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
|
||||||
|
@ -140,6 +149,9 @@ public class LinphoneContact implements Serializable {
|
||||||
.withValue(ContactsContract.CommonDataKinds.Photo.PHOTO, photo)
|
.withValue(ContactsContract.CommonDataKinds.Photo.PHOTO, photo)
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
} else if (isLinphoneFriend()) {
|
||||||
|
//TODO: prepare photo changes in friend
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,7 +184,8 @@ public class LinphoneContact implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeNumberOrAddress(LinphoneNumberOrAddress noa) {
|
public void removeNumberOrAddress(LinphoneNumberOrAddress noa) {
|
||||||
if (isAndroidContact() && noa.getOldValue() != null) {
|
if (noa != null && noa.getOldValue() != null) {
|
||||||
|
if (isAndroidContact()) {
|
||||||
String select;
|
String select;
|
||||||
if (noa.isSIPAddress()) {
|
if (noa.isSIPAddress()) {
|
||||||
select = ContactsContract.Data.CONTACT_ID + "=? AND " + ContactsContract.Data.MIMETYPE + "='" + ContactsContract.CommonDataKinds.SipAddress.CONTENT_ITEM_TYPE + "' AND " + ContactsContract.CommonDataKinds.SipAddress.SIP_ADDRESS + "=?";
|
select = ContactsContract.Data.CONTACT_ID + "=? AND " + ContactsContract.Data.MIMETYPE + "='" + ContactsContract.CommonDataKinds.SipAddress.CONTENT_ITEM_TYPE + "' AND " + ContactsContract.CommonDataKinds.SipAddress.SIP_ADDRESS + "=?";
|
||||||
|
@ -185,10 +198,28 @@ public class LinphoneContact implements Serializable {
|
||||||
.withSelection(select, args)
|
.withSelection(select, args)
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isLinphoneFriend()) {
|
||||||
|
if (!noa.getOldValue().startsWith("sip:")) {
|
||||||
|
noa.setOldValue("sip:" + noa.getOldValue());
|
||||||
|
}
|
||||||
|
LinphoneNumberOrAddress toRemove = null;
|
||||||
|
for (LinphoneNumberOrAddress address : addresses) {
|
||||||
|
if (noa.getOldValue().equals(address.getValue())) {
|
||||||
|
toRemove = address;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (toRemove != null) {
|
||||||
|
addresses.remove(toRemove);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addOrUpdateNumberOrAddress(LinphoneNumberOrAddress noa) {
|
public void addOrUpdateNumberOrAddress(LinphoneNumberOrAddress noa) {
|
||||||
if (isAndroidContact() && noa.getValue() != null) {
|
if (noa != null && noa.getValue() != null) {
|
||||||
|
if (isAndroidContact()) {
|
||||||
if (noa.getOldValue() == null) {
|
if (noa.getOldValue() == null) {
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
if (noa.isSIPAddress()) {
|
if (noa.isSIPAddress()) {
|
||||||
|
@ -239,6 +270,25 @@ public class LinphoneContact implements Serializable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (isLinphoneFriend()) {
|
||||||
|
if (!noa.getValue().startsWith("sip:")) {
|
||||||
|
noa.setValue("sip:" + noa.getValue());
|
||||||
|
}
|
||||||
|
if (noa.getOldValue() != null) {
|
||||||
|
if (!noa.getOldValue().startsWith("sip:")) {
|
||||||
|
noa.setOldValue("sip:" + noa.getOldValue());
|
||||||
|
}
|
||||||
|
for (LinphoneNumberOrAddress address : addresses) {
|
||||||
|
if (noa.getOldValue().equals(address.getValue())) {
|
||||||
|
address.setValue(noa.getValue());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
addresses.add(noa);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAndroidId(String id) {
|
public void setAndroidId(String id) {
|
||||||
|
@ -259,9 +309,37 @@ public class LinphoneContact implements Serializable {
|
||||||
changesToCommit = new ArrayList<ContentProviderOperation>();
|
changesToCommit = new ArrayList<ContentProviderOperation>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isLinphoneFriend()) {
|
if (isLinphoneFriend()) {
|
||||||
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
|
if (lc == null) return;
|
||||||
|
|
||||||
|
friend.edit();
|
||||||
friend.setName(fullName);
|
friend.setName(fullName);
|
||||||
|
//TODO: handle removal of all existing SIP addresses
|
||||||
|
for (LinphoneNumberOrAddress address : addresses) {
|
||||||
|
try {
|
||||||
|
// Currently we only support 1 address / friend
|
||||||
|
LinphoneAddress addr = lc.interpretUrl(address.getValue());
|
||||||
|
if (addr != null) {
|
||||||
|
friend.setAddress(addr);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
} catch (LinphoneCoreException e) {
|
||||||
|
Log.e(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
friend.done();
|
||||||
|
|
||||||
|
if (!isAndroidContact() && friend.getAddress() != null) {
|
||||||
|
if (lc.findFriendByAddress(friend.getAddress().asString()) == null) {
|
||||||
|
try {
|
||||||
|
lc.addFriend(friend);
|
||||||
|
ContactsManager.getInstance().fetchContacts();
|
||||||
|
} catch (LinphoneCoreException e) {
|
||||||
|
Log.e(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,8 +350,10 @@ public class LinphoneContact implements Serializable {
|
||||||
changesToCommit.add(ContentProviderOperation.newDelete(ContactsContract.RawContacts.CONTENT_URI).withSelection(select, args).build());
|
changesToCommit.add(ContentProviderOperation.newDelete(ContactsContract.RawContacts.CONTENT_URI).withSelection(select, args).build());
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
if (isLinphoneFriend()) {
|
||||||
deleteFriend();
|
deleteFriend();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void deleteFriend() {
|
public void deleteFriend() {
|
||||||
if (friend != null) {
|
if (friend != null) {
|
||||||
|
@ -283,19 +363,18 @@ public class LinphoneContact implements Serializable {
|
||||||
|
|
||||||
public void refresh() {
|
public void refresh() {
|
||||||
addresses = new ArrayList<LinphoneNumberOrAddress>();
|
addresses = new ArrayList<LinphoneNumberOrAddress>();
|
||||||
if (friend != null) {
|
hasSipAddress = false;
|
||||||
LinphoneAddress addr = friend.getAddress();
|
|
||||||
if (addr != null) {
|
|
||||||
addresses.add(new LinphoneNumberOrAddress(addr.asStringUriOnly(), true));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isAndroidContact()) {
|
if (!isAndroidContact() && isLinphoneFriend()) {
|
||||||
fullName = friend.getName();
|
fullName = friend.getName();
|
||||||
thumbnailUri = null;
|
thumbnailUri = null;
|
||||||
photoUri = null;
|
photoUri = null;
|
||||||
} else {
|
LinphoneAddress addr = friend.getAddress();
|
||||||
hasSipAddress = false;
|
if (addr != null) {
|
||||||
|
addresses.add(new LinphoneNumberOrAddress(addr.asStringUriOnly(), true));
|
||||||
|
hasSipAddress = true;
|
||||||
|
}
|
||||||
|
} else if (isAndroidContact()) {
|
||||||
String id = getAndroidId();
|
String id = getAndroidId();
|
||||||
fullName = getName(id);
|
fullName = getName(id);
|
||||||
lastName = getContactLastName(id);
|
lastName = getContactLastName(id);
|
||||||
|
@ -305,6 +384,26 @@ public class LinphoneContact implements Serializable {
|
||||||
for (LinphoneNumberOrAddress noa : getAddressesAndNumbersForAndroidContact(id)) {
|
for (LinphoneNumberOrAddress noa : getAddressesAndNumbersForAndroidContact(id)) {
|
||||||
addNumberOrAddress(noa);
|
addNumberOrAddress(noa);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (friend == null) {
|
||||||
|
friend = LinphoneCoreFactory.instance().createLinphoneFriend();
|
||||||
|
friend.setRefKey(id);
|
||||||
|
friend.setName(fullName);
|
||||||
|
if (hasSipAddress) {
|
||||||
|
for (LinphoneNumberOrAddress noa : getAddressesAndNumbersForAndroidContact(id)) {
|
||||||
|
if (noa.isSIPAddress()) {
|
||||||
|
try {
|
||||||
|
LinphoneAddress addr = LinphoneManager.getLc().interpretUrl(noa.getValue());
|
||||||
|
if (addr != null) {
|
||||||
|
friend.setAddress(addr);
|
||||||
|
}
|
||||||
|
} catch (LinphoneCoreException e) {
|
||||||
|
Log.e(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,6 +415,10 @@ public class LinphoneContact implements Serializable {
|
||||||
return friend != null;
|
return friend != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setFriend(LinphoneFriend f) {
|
||||||
|
friend = f;
|
||||||
|
}
|
||||||
|
|
||||||
public static LinphoneContact createContact() {
|
public static LinphoneContact createContact() {
|
||||||
if (ContactsManager.getInstance().hasContactsAccess()) {
|
if (ContactsManager.getInstance().hasContactsAccess()) {
|
||||||
return createAndroidContact();
|
return createAndroidContact();
|
||||||
|
|
|
@ -49,6 +49,10 @@ public class LinphoneNumberOrAddress implements Serializable {
|
||||||
return oldValueForUpdatePurpose;
|
return oldValueForUpdatePurpose;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setOldValue(String v) {
|
||||||
|
oldValueForUpdatePurpose = v;
|
||||||
|
}
|
||||||
|
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue