Fix adding infinitely address for no android contact
This commit is contained in:
parent
3fe5f7c3cd
commit
5d518f0642
1 changed files with 8 additions and 8 deletions
|
@ -66,7 +66,7 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
|
||||||
changesToCommit2 = new ArrayList<ContentProviderOperation>();
|
changesToCommit2 = new ArrayList<ContentProviderOperation>();
|
||||||
hasSipAddress = false;
|
hasSipAddress = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(LinphoneContact contact) {
|
public int compareTo(LinphoneContact contact) {
|
||||||
String fullName = getFullName() != null ? getFullName().toUpperCase(Locale.getDefault()) : "";
|
String fullName = getFullName() != null ? getFullName().toUpperCase(Locale.getDefault()) : "";
|
||||||
|
@ -400,7 +400,7 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
|
||||||
public String getAndroidId() {
|
public String getAndroidId() {
|
||||||
return androidId;
|
return androidId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LinphoneFriend getLinphoneFriend() {
|
public LinphoneFriend getLinphoneFriend() {
|
||||||
return friend;
|
return friend;
|
||||||
}
|
}
|
||||||
|
@ -408,7 +408,7 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
|
||||||
private void createOrUpdateFriend() {
|
private void createOrUpdateFriend() {
|
||||||
boolean created = false;
|
boolean created = false;
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
|
|
||||||
if (!isLinphoneFriend()) {
|
if (!isLinphoneFriend()) {
|
||||||
friend = LinphoneManager.getLc().createFriend();
|
friend = LinphoneManager.getLc().createFriend();
|
||||||
friend.enableSubscribes(false);
|
friend.enableSubscribes(false);
|
||||||
|
@ -427,7 +427,7 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
|
||||||
if (organization != null) {
|
if (organization != null) {
|
||||||
friend.setOrganization(organization);
|
friend.setOrganization(organization);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!created) {
|
if (!created) {
|
||||||
for (LinphoneAddress address : friend.getAddresses()) {
|
for (LinphoneAddress address : friend.getAddresses()) {
|
||||||
friend.removeAddress(address);
|
friend.removeAddress(address);
|
||||||
|
@ -459,7 +459,7 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
|
||||||
Log.e(e);
|
Log.e(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ContactsManager.getInstance().hasContactsAccess()) {
|
if (!ContactsManager.getInstance().hasContactsAccess()) {
|
||||||
// This refresh is only needed if app has no contacts permission to refresh the list of LinphoneFriends.
|
// This refresh is only needed if app has no contacts permission to refresh the list of LinphoneFriends.
|
||||||
// Otherwise contacts will be refreshed due to changes in native contact and the handler in ContactsManager
|
// Otherwise contacts will be refreshed due to changes in native contact and the handler in ContactsManager
|
||||||
|
@ -502,12 +502,12 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refresh() {
|
public void refresh() {
|
||||||
|
addresses = new ArrayList<LinphoneNumberOrAddress>();
|
||||||
if (isAndroidContact()) {
|
if (isAndroidContact()) {
|
||||||
getContactNames();
|
getContactNames();
|
||||||
getNativeContactOrganization();
|
getNativeContactOrganization();
|
||||||
getAndroidIds();
|
getAndroidIds();
|
||||||
hasSipAddress = false;
|
hasSipAddress = false;
|
||||||
addresses = new ArrayList<LinphoneNumberOrAddress>();
|
|
||||||
for (LinphoneNumberOrAddress noa : getAddressesAndNumbersForAndroidContact()) {
|
for (LinphoneNumberOrAddress noa : getAddressesAndNumbersForAndroidContact()) {
|
||||||
addNumberOrAddress(noa);
|
addNumberOrAddress(noa);
|
||||||
}
|
}
|
||||||
|
@ -575,7 +575,7 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
|
||||||
friend = f;
|
friend = f;
|
||||||
((LinphoneFriendImpl)friend).setUserData(this);
|
((LinphoneFriendImpl)friend).setUserData(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getAndroidIds() {
|
public void getAndroidIds() {
|
||||||
androidRawId = findRawContactID();
|
androidRawId = findRawContactID();
|
||||||
if (LinphoneManager.getInstance().getContext().getResources().getBoolean(R.bool.use_linphone_tag)) {
|
if (LinphoneManager.getInstance().getContext().getResources().getBoolean(R.bool.use_linphone_tag)) {
|
||||||
|
@ -599,7 +599,7 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
|
||||||
Uri person = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, Long.parseLong(getAndroidId()));
|
Uri person = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, Long.parseLong(getAndroidId()));
|
||||||
return Uri.withAppendedPath(person, ContactsContract.Contacts.Photo.DISPLAY_PHOTO);
|
return Uri.withAppendedPath(person, ContactsContract.Contacts.Photo.DISPLAY_PHOTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getContactNames() {
|
private void getContactNames() {
|
||||||
ContentResolver resolver = ContactsManager.getInstance().getContentResolver();
|
ContentResolver resolver = ContactsManager.getInstance().getContentResolver();
|
||||||
String[] proj = new String[]{ ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME, ContactsContract.CommonDataKinds.StructuredName.FAMILY_NAME };
|
String[] proj = new String[]{ ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME, ContactsContract.CommonDataKinds.StructuredName.FAMILY_NAME };
|
||||||
|
|
Loading…
Reference in a new issue