Only set LinphoneFriend's name if it has at least an address + use the multiple SIP addresses in one LinphoneFriend feature
This commit is contained in:
parent
c7b47c68a1
commit
7ffa7c0471
1 changed files with 18 additions and 12 deletions
|
@ -313,24 +313,30 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isLinphoneFriend()) {
|
if (isLinphoneFriend()) {
|
||||||
|
boolean hasAddr = false;
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
if (lc == null) return;
|
if (lc == null) return;
|
||||||
|
|
||||||
friend.edit();
|
friend.edit();
|
||||||
//TODO: handle removal of all existing SIP addresses
|
for (LinphoneAddress address : friend.getAddresses()) {
|
||||||
|
friend.removeAddress(address);
|
||||||
|
}
|
||||||
for (LinphoneNumberOrAddress address : addresses) {
|
for (LinphoneNumberOrAddress address : addresses) {
|
||||||
|
if (address.isSIPAddress()) {
|
||||||
try {
|
try {
|
||||||
// Currently we only support 1 address / friend
|
|
||||||
LinphoneAddress addr = lc.interpretUrl(address.getValue());
|
LinphoneAddress addr = lc.interpretUrl(address.getValue());
|
||||||
if (addr != null) {
|
if (addr != null) {
|
||||||
friend.setAddress(addr);
|
friend.addAddress(addr);
|
||||||
|
hasAddr = true;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
} catch (LinphoneCoreException e) {
|
} catch (LinphoneCoreException e) {
|
||||||
Log.e(e);
|
Log.e(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (hasAddr) {
|
||||||
friend.setName(fullName);
|
friend.setName(fullName);
|
||||||
|
}
|
||||||
friend.done();
|
friend.done();
|
||||||
|
|
||||||
if (friend.getAddress() != null) {
|
if (friend.getAddress() != null) {
|
||||||
|
@ -389,7 +395,7 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
|
||||||
try {
|
try {
|
||||||
LinphoneAddress addr = LinphoneManager.getLc().interpretUrl(noa.getValue());
|
LinphoneAddress addr = LinphoneManager.getLc().interpretUrl(noa.getValue());
|
||||||
if (addr != null) {
|
if (addr != null) {
|
||||||
friend.setAddress(addr);
|
friend.addAddress(addr);
|
||||||
}
|
}
|
||||||
} catch (LinphoneCoreException e) {
|
} catch (LinphoneCoreException e) {
|
||||||
Log.e(e);
|
Log.e(e);
|
||||||
|
@ -397,9 +403,9 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
friend.setName(fullName);
|
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
if (lc != null && friend.getAddress() != null) {
|
if (lc != null && friend.getAddress() != null) {
|
||||||
|
friend.setName(fullName);
|
||||||
try {
|
try {
|
||||||
lc.addFriend(friend);
|
lc.addFriend(friend);
|
||||||
} catch (LinphoneCoreException e) {
|
} catch (LinphoneCoreException e) {
|
||||||
|
|
Loading…
Reference in a new issue