In contact details, display SIP addresses first + use all SIP addresses and phone numbers from LinphoneFriend if available

This commit is contained in:
Sylvain Berfini 2016-07-25 14:11:04 +02:00
parent 99a4738c52
commit f2c7048a0b
6 changed files with 39 additions and 16 deletions

View file

@ -41,7 +41,6 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="20dp"
android:gravity="center"
android:orientation="horizontal">

View file

@ -25,6 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
/**
* @author Sylvain Berfini
* @deprecated
*/
public class ChatMessage {
private String message;

View file

@ -20,6 +20,7 @@ package org.linphone;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
@ -65,6 +66,15 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
hasSipAddress = false;
}
@Override
public int compareTo(LinphoneContact contact) {
String fullName = getFullName();
String contactFullName = contact.getFullName();
String firstLetter = fullName == null || fullName.isEmpty() ? "" : fullName.substring(0, 1).toUpperCase(Locale.getDefault());
String contactfirstLetter = contactFullName == null || contactFullName.isEmpty() ? "" : contactFullName.substring(0, 1).toUpperCase(Locale.getDefault());
return firstLetter.compareTo(contactfirstLetter);
}
public void setFullName(String name) {
fullName = name;
}
@ -496,11 +506,23 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
thumbnailUri = null;
photoUri = null;
LinphoneAddress addr = friend.getAddress();
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
if (lc != null && lc.isVCardSupported()) {
for (LinphoneAddress addr : friend.getAddresses()) {
if (addr != null) {
addNumberOrAddress(new LinphoneNumberOrAddress(addr.asStringUriOnly(), true));
}
}
for (String tel : friend.getPhoneNumbers()) {
if (tel != null) {
addNumberOrAddress(new LinphoneNumberOrAddress(tel, false));
}
}
} else {
LinphoneAddress addr = friend.getAddress();
addNumberOrAddress(new LinphoneNumberOrAddress(addr.asStringUriOnly(), true));
}
}
}
public boolean isAndroidContact() {
@ -526,15 +548,6 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
return createLinphoneFriend();
}
@Override
public int compareTo(LinphoneContact contact) {
String fullName = getFullName();
String contactFullName = contact.getFullName();
String firstLetter = fullName == null || fullName.isEmpty() ? "" : fullName.substring(0, 1).toUpperCase(Locale.getDefault());
String contactfirstLetter = contactFullName == null || contactFullName.isEmpty() ? "" : contactFullName.substring(0, 1).toUpperCase(Locale.getDefault());
return firstLetter.compareTo(contactfirstLetter);
}
private Uri getContactThumbnailPictureUri() {
Uri person = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, Long.parseLong(getAndroidId()));
return Uri.withAppendedPath(person, ContactsContract.Contacts.Photo.CONTENT_DIRECTORY);
@ -610,7 +623,7 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
}
c.close();
}
Collections.sort(result);
return result;
}

View file

@ -161,7 +161,7 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
mLinphoneFactoryConfigFile = basePath + "/linphonerc";
mLinphoneConfigFile = basePath + "/.linphonerc";
mLinphoneRootCaFile = basePath + "/rootca.pem";
mRingSoundFile = basePath + "/notes_of_the_optimistic.mkv";
mRingSoundFile = basePath + "/ringtone.mkv";
mRingbackSoundFile = basePath + "/ringback.wav";
mPauseSoundFile = basePath + "/hold.mkv";
mChatDatabaseFile = basePath + "/linphone-history.db";
@ -1100,6 +1100,7 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
private synchronized void startRinging() {
if (!LinphonePreferences.instance().isDeviceRingtoneEnabled()) {
// Enable speaker audio route, linphone library will do the ringing itself automatically
routeAudioToSpeaker();
return;
}

View file

@ -21,7 +21,7 @@ package org.linphone;
import java.io.Serializable;
public class LinphoneNumberOrAddress implements Serializable {
public class LinphoneNumberOrAddress implements Serializable, Comparable<LinphoneNumberOrAddress> {
/**
*
*/
@ -41,6 +41,15 @@ public class LinphoneNumberOrAddress implements Serializable {
oldValueForUpdatePurpose = old;
}
@Override
public int compareTo(LinphoneNumberOrAddress noa) {
if (noa.isSIPAddress() == isSIPAddress()) {
return noa.getValue().compareTo(getValue());
} else {
return isSIPAddress() ? -1 : 1;
}
}
public boolean isSIPAddress() {
return isSIPAddress;
}

@ -1 +1 @@
Subproject commit 7bd469baa080f657cfe3fd015f58ae32f57dbafc
Subproject commit 94396dacec147c3a223e92a1c8c1da3ff61b127d