Prevent duplicated contacts with different ids to show in contacts list
This commit is contained in:
parent
fba1be573e
commit
08f1b48aac
3 changed files with 19 additions and 7 deletions
|
@ -445,7 +445,7 @@ public final class LinphoneService extends Service {
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
mLastNotificationId = 8; // To not interfere with other notifs ids
|
mLastNotificationId = 8; // To not interfere with other notifs ids
|
||||||
mChatNotifMap = new HashMap<String, Notified>();
|
mChatNotifMap = new HashMap<>();
|
||||||
|
|
||||||
setupActivityMonitor();
|
setupActivityMonitor();
|
||||||
// In case restart after a crash. Main in LinphoneActivity
|
// In case restart after a crash. Main in LinphoneActivity
|
||||||
|
|
|
@ -75,7 +75,17 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
|
||||||
if (fullName.equals(contactFullName)) {
|
if (fullName.equals(contactFullName)) {
|
||||||
if (getAndroidId() != null) {
|
if (getAndroidId() != null) {
|
||||||
if (contact.getAndroidId() != null) {
|
if (contact.getAndroidId() != null) {
|
||||||
return getAndroidId().compareTo(contact.getAndroidId());
|
int idComp = getAndroidId().compareTo(contact.getAndroidId());
|
||||||
|
if (idComp == 0) return 0;
|
||||||
|
List<LinphoneNumberOrAddress> noas1 = getNumbersOrAddresses();
|
||||||
|
List<LinphoneNumberOrAddress> noas2 = contact.getNumbersOrAddresses();
|
||||||
|
if (noas1.size() == noas2.size()) {
|
||||||
|
if (noas1.containsAll(noas2) && noas2.containsAll(noas1)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return ((Integer)noas1.size()).compareTo(noas2.size());
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,12 +49,14 @@ public class LinphoneNumberOrAddress implements Serializable, Comparable<Linphon
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(LinphoneNumberOrAddress noa) {
|
public int compareTo(LinphoneNumberOrAddress noa) {
|
||||||
String value = noa.getValue();
|
if (value != null) {
|
||||||
if (noa.isSIPAddress() == isSIPAddress() && value != null) {
|
if (noa.isSIPAddress() && isSIPAddress()) {
|
||||||
return value.compareTo(getValue());
|
return value.compareTo(noa.getValue());
|
||||||
} else {
|
} else if (!noa.isSIPAddress() && !isSIPAddress()) {
|
||||||
return isSIPAddress() ? -1 : 1;
|
return getNormalizedPhone().compareTo(noa.getNormalizedPhone());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue