Fixing magic search bar
This commit is contained in:
parent
43a6dc4d82
commit
e5b5c47026
10 changed files with 124 additions and 51 deletions
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,6 +1,6 @@
|
||||||
#Tue Aug 29 16:02:50 CEST 2017
|
#Wed May 16 15:22:42 CEST 2018
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-all.zip
|
||||||
|
|
|
@ -28,8 +28,8 @@ configurations {
|
||||||
apply plugin: 'com.android.library'
|
apply plugin: 'com.android.library'
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation group: 'org.apache.commons', name: 'commons-compress', version: '1.16.1'
|
compile 'org.apache.commons:commons-compress:1.16.1'
|
||||||
javadocDeps group: 'org.apache.commons', name: 'commons-compress', version: '1.16.1'
|
javadocDeps 'org.apache.commons:commons-compress:1.16.1'
|
||||||
}
|
}
|
||||||
|
|
||||||
def srcDir = ['submodules/mediastreamer2/java/src', 'src/linphone-wrapper']
|
def srcDir = ['submodules/mediastreamer2/java/src', 'src/linphone-wrapper']
|
||||||
|
@ -44,6 +44,7 @@ excludePackage.add('**/LICENSE.txt')
|
||||||
android {
|
android {
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
compileSdkVersion 26
|
compileSdkVersion 26
|
||||||
|
buildToolsVersion "26.0.0"
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,11 +29,11 @@ allprojects {
|
||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
androidTestCompile group: 'org.apache.commons', name: 'commons-compress', version: '+'
|
androidTestCompile 'org.apache.commons:commons-compress:1.16.1'
|
||||||
androidTestCompile group: 'junit', name: 'junit', version: '+'
|
androidTestCompile group: 'junit', name: 'junit', version: '+'
|
||||||
androidTestCompile group: 'com.jayway.android.robotium', name: 'robotium', version: '+'
|
androidTestCompile group: 'com.jayway.android.robotium', name: 'robotium', version: '+'
|
||||||
androidTestCompile fileTree(dir: 'libs', include: 'android-junit-report*.jar')
|
androidTestCompile fileTree(dir: 'libs', include: 'android-junit-report*.jar')
|
||||||
compile group: 'org.apache.commons', name: 'commons-compress', version: '+'
|
compile 'org.apache.commons:commons-compress:1.16.1'
|
||||||
compile group: 'junit', name: 'junit', version: '+'
|
compile group: 'junit', name: 'junit', version: '+'
|
||||||
compile group: 'com.jayway.android.robotium', name: 'robotium-solo', version: '+'
|
compile group: 'com.jayway.android.robotium', name: 'robotium-solo', version: '+'
|
||||||
compile fileTree(dir: 'libs', include: 'android-junit-report*.jar')
|
compile fileTree(dir: 'libs', include: 'android-junit-report*.jar')
|
||||||
|
|
|
@ -373,7 +373,7 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
|
||||||
public void changeStatusToOnThePhone() {
|
public void changeStatusToOnThePhone() {
|
||||||
Core lc = getLcIfManagerNotDestroyedOrNull();
|
Core lc = getLcIfManagerNotDestroyedOrNull();
|
||||||
if (lc == null) return;
|
if (lc == null) return;
|
||||||
|
|
||||||
if (isInstanciated() && isPresenceModelActivitySet() && lc.getPresenceModel().getActivity().getType() != PresenceActivity.Type.OnThePhone) {
|
if (isInstanciated() && isPresenceModelActivitySet() && lc.getPresenceModel().getActivity().getType() != PresenceActivity.Type.OnThePhone) {
|
||||||
lc.getPresenceModel().getActivity().setType(PresenceActivity.Type.OnThePhone);
|
lc.getPresenceModel().getActivity().setType(PresenceActivity.Type.OnThePhone);
|
||||||
} else if (isInstanciated() && !isPresenceModelActivitySet()) {
|
} else if (isInstanciated() && !isPresenceModelActivitySet()) {
|
||||||
|
@ -687,7 +687,7 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
|
||||||
Class<?> firebaseClass = Class.forName("com.google.firebase.iid.FirebaseInstanceId");
|
Class<?> firebaseClass = Class.forName("com.google.firebase.iid.FirebaseInstanceId");
|
||||||
Object firebaseInstance = firebaseClass.getMethod("getInstance").invoke(null);
|
Object firebaseInstance = firebaseClass.getMethod("getInstance").invoke(null);
|
||||||
final String refreshedToken = (String)firebaseClass.getMethod("getToken").invoke(firebaseInstance);
|
final String refreshedToken = (String)firebaseClass.getMethod("getToken").invoke(firebaseInstance);
|
||||||
|
|
||||||
//final String refreshedToken = com.google.firebase.iid.FirebaseInstanceId.getInstance().getToken();
|
//final String refreshedToken = com.google.firebase.iid.FirebaseInstanceId.getInstance().getToken();
|
||||||
if (refreshedToken != null) {
|
if (refreshedToken != null) {
|
||||||
Log.i("[Push Notification] current token is: " + refreshedToken);
|
Log.i("[Push Notification] current token is: " + refreshedToken);
|
||||||
|
@ -1620,6 +1620,12 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
|
||||||
Log.d("Notify received for event "+eventName);
|
Log.d("Notify received for event "+eventName);
|
||||||
if (content!=null) Log.d("with content "+content.getType()+"/"+content.getSubtype()+" data:"+content.getStringBuffer());
|
if (content!=null) Log.d("with content "+content.getType()+"/"+content.getSubtype()+" data:"+content.getStringBuffer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSubscribeReceived(Core lc, Event lev, String subscribeEvent, Content body) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPublishStateChanged(Core lc, Event ev, PublishState state) {
|
public void onPublishStateChanged(Core lc, Event ev, PublishState state) {
|
||||||
Log.d("Publish state changed to " + state + " for event name " + ev.getName());
|
Log.d("Publish state changed to " + state + " for event name " + ev.getName());
|
||||||
|
|
|
@ -41,11 +41,13 @@ import org.linphone.LinphoneManager;
|
||||||
import org.linphone.LinphonePreferences;
|
import org.linphone.LinphonePreferences;
|
||||||
import org.linphone.contacts.ContactAddress;
|
import org.linphone.contacts.ContactAddress;
|
||||||
import org.linphone.contacts.ContactsManager;
|
import org.linphone.contacts.ContactsManager;
|
||||||
|
import org.linphone.contacts.LinphoneNumberOrAddress;
|
||||||
import org.linphone.contacts.SearchContactsListAdapter;
|
import org.linphone.contacts.SearchContactsListAdapter;
|
||||||
import org.linphone.core.Address;
|
import org.linphone.core.Address;
|
||||||
import org.linphone.core.ChatRoom;
|
import org.linphone.core.ChatRoom;
|
||||||
import org.linphone.core.ChatRoomListenerStub;
|
import org.linphone.core.ChatRoomListenerStub;
|
||||||
import org.linphone.core.Core;
|
import org.linphone.core.Core;
|
||||||
|
import org.linphone.core.Factory;
|
||||||
import org.linphone.core.ProxyConfig;
|
import org.linphone.core.ProxyConfig;
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
import org.linphone.ui.ContactSelectView;
|
import org.linphone.ui.ContactSelectView;
|
||||||
|
@ -249,12 +251,22 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
||||||
|
|
||||||
private int getIndexOfCa(ContactAddress ca, List<ContactAddress> caList) {
|
private int getIndexOfCa(ContactAddress ca, List<ContactAddress> caList) {
|
||||||
for (int i = 0 ; i < caList.size() ; i++) {
|
for (int i = 0 ; i < caList.size() ; i++) {
|
||||||
if (caList.get(i).getAddressAsDisplayableString().compareTo(ca.getAddressAsDisplayableString()) == 0)
|
if (ca.getAddress() != null && ca.getAddress().getUsername() != null) {
|
||||||
return i;
|
if (caList.get(i).getAddressAsDisplayableString().compareTo(ca.getAddressAsDisplayableString()) == 0)
|
||||||
|
return i;
|
||||||
|
} else if (ca.getPhoneNumber() != null && caList.get(i).getPhoneNumber() !=null) {
|
||||||
|
if (ca.getPhoneNumber().compareTo(caList.get(i).getPhoneNumber()) == 0)
|
||||||
|
return i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void resetAndResearch() {
|
||||||
|
ContactsManager.getInstance().getMagicSearch().resetSearchCache();
|
||||||
|
mSearchAdapter.searchContacts(mSearchField.getText().toString(), mContactsList);
|
||||||
|
}
|
||||||
|
|
||||||
private void addSelectedContactAddress(ContactAddress ca) {
|
private void addSelectedContactAddress(ContactAddress ca) {
|
||||||
View viewContact = LayoutInflater.from(LinphoneActivity.instance()).inflate(R.layout.contact_selected, null);
|
View viewContact = LayoutInflater.from(LinphoneActivity.instance()).inflate(R.layout.contact_selected, null);
|
||||||
if (ca.getContact() != null) {
|
if (ca.getContact() != null) {
|
||||||
|
@ -323,6 +335,7 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
||||||
mLinphoneContactsButton.setEnabled(true);
|
mLinphoneContactsButton.setEnabled(true);
|
||||||
mLinphoneContactsSelected.setVisibility(View.INVISIBLE);
|
mLinphoneContactsSelected.setVisibility(View.INVISIBLE);
|
||||||
updateList();
|
updateList();
|
||||||
|
resetAndResearch();
|
||||||
} else if (id == R.id.linphone_contacts) {
|
} else if (id == R.id.linphone_contacts) {
|
||||||
mSearchAdapter.setOnlySipContact(true);
|
mSearchAdapter.setOnlySipContact(true);
|
||||||
mLinphoneContactsSelected.setVisibility(View.VISIBLE);
|
mLinphoneContactsSelected.setVisibility(View.VISIBLE);
|
||||||
|
@ -330,6 +343,7 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
||||||
mAllContactsButton.setEnabled(mOnlyDisplayLinphoneContacts = true);
|
mAllContactsButton.setEnabled(mOnlyDisplayLinphoneContacts = true);
|
||||||
mAllContactsSelected.setVisibility(View.INVISIBLE);
|
mAllContactsSelected.setVisibility(View.INVISIBLE);
|
||||||
updateList();
|
updateList();
|
||||||
|
resetAndResearch();
|
||||||
} else if (id == R.id.back) {
|
} else if (id == R.id.back) {
|
||||||
if (LinphoneActivity.instance().isTablet()) {
|
if (LinphoneActivity.instance().isTablet()) {
|
||||||
LinphoneActivity.instance().goToChatList();
|
LinphoneActivity.instance().goToChatList();
|
||||||
|
|
|
@ -69,7 +69,6 @@ import org.linphone.core.ChatRoomCapabilities;
|
||||||
import org.linphone.core.ChatRoomListener;
|
import org.linphone.core.ChatRoomListener;
|
||||||
import org.linphone.core.Content;
|
import org.linphone.core.Content;
|
||||||
import org.linphone.core.Core;
|
import org.linphone.core.Core;
|
||||||
import org.linphone.core.Event;
|
|
||||||
import org.linphone.core.EventLog;
|
import org.linphone.core.EventLog;
|
||||||
import org.linphone.core.Factory;
|
import org.linphone.core.Factory;
|
||||||
import org.linphone.core.LimeState;
|
import org.linphone.core.LimeState;
|
||||||
|
@ -160,7 +159,7 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
||||||
String displayName = LinphoneUtils.getAddressDisplayName(a);
|
String displayName = LinphoneUtils.getAddressDisplayName(a);
|
||||||
c.setFullName(displayName);
|
c.setFullName(displayName);
|
||||||
}
|
}
|
||||||
ContactAddress ca = new ContactAddress(c, a.asString(), c.isFriend(), p.isAdmin());
|
ContactAddress ca = new ContactAddress(c, a.asString(), "", c.isFriend(), p.isAdmin());
|
||||||
participants.add(ca);
|
participants.add(ca);
|
||||||
}
|
}
|
||||||
LinphoneActivity.instance().goToChatGroupInfos(mRemoteSipAddress.asString(), participants, mChatRoom.getSubject(), mChatRoom.getMe() != null ? mChatRoom.getMe().isAdmin() : false, false);
|
LinphoneActivity.instance().goToChatGroupInfos(mRemoteSipAddress.asString(), participants, mChatRoom.getSubject(), mChatRoom.getMe() != null ? mChatRoom.getMe().isAdmin() : false, false);
|
||||||
|
@ -697,7 +696,7 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
||||||
public void onConferenceAddressGeneration(ChatRoom cr) {
|
public void onConferenceAddressGeneration(ChatRoom cr) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onParticipantDeviceFetchRequested(ChatRoom cr, Address addr) {
|
public void onParticipantDeviceFetchRequested(ChatRoom cr, Address addr) {
|
||||||
|
|
||||||
|
@ -705,7 +704,7 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
||||||
@Override
|
@Override
|
||||||
public void onParticipantRegistrationSubscriptionRequested(ChatRoom cr, Address participantAddr){
|
public void onParticipantRegistrationSubscriptionRequested(ChatRoom cr, Address participantAddr){
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onParticipantRegistrationUnsubscriptionRequested(ChatRoom cr, Address participantAddr){
|
public void onParticipantRegistrationUnsubscriptionRequested(ChatRoom cr, Address participantAddr){
|
||||||
}
|
}
|
||||||
|
@ -752,7 +751,7 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/*@Override
|
||||||
public void onAllInformationReceived(ChatRoom cr) {
|
public void onAllInformationReceived(ChatRoom cr) {
|
||||||
// Currently flexisip doesn't send the participants list in the INVITE
|
// Currently flexisip doesn't send the participants list in the INVITE
|
||||||
// So we have to refresh the display when information is available
|
// So we have to refresh the display when information is available
|
||||||
|
@ -763,7 +762,7 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
||||||
}
|
}
|
||||||
getContactsForParticipants();
|
getContactsForParticipants();
|
||||||
displayChatRoomHeader();
|
displayChatRoomHeader();
|
||||||
}
|
}*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onChatMessageReceived(ChatRoom cr, EventLog event) {
|
public void onChatMessageReceived(ChatRoom cr, EventLog event) {
|
||||||
|
@ -853,6 +852,16 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onConferenceJoined(ChatRoom cr, EventLog eventLog) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onConferenceLeft(ChatRoom cr, EventLog eventLog) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onParticipantRemoved(ChatRoom cr, EventLog event) {
|
public void onParticipantRemoved(ChatRoom cr, EventLog event) {
|
||||||
getContactsForParticipants();
|
getContactsForParticipants();
|
||||||
|
|
|
@ -348,7 +348,7 @@ public class GroupInfoFragment extends Fragment implements ChatRoomListener {
|
||||||
String displayName = LinphoneUtils.getAddressDisplayName(a);
|
String displayName = LinphoneUtils.getAddressDisplayName(a);
|
||||||
c.setFullName(displayName);
|
c.setFullName(displayName);
|
||||||
}
|
}
|
||||||
ContactAddress ca = new ContactAddress(c, a.asString(), c.isFriend(), p.isAdmin());
|
ContactAddress ca = new ContactAddress(c, a.asString(), "", c.isFriend(), p.isAdmin());
|
||||||
mParticipants.add(ca);
|
mParticipants.add(ca);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -448,6 +448,16 @@ public class GroupInfoFragment extends Fragment implements ChatRoomListener {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onConferenceJoined(ChatRoom cr, EventLog eventLog) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onConferenceLeft(ChatRoom cr, EventLog eventLog) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onParticipantDeviceAdded(ChatRoom cr, EventLog event_log) {
|
public void onParticipantDeviceAdded(ChatRoom cr, EventLog event_log) {
|
||||||
|
|
||||||
|
@ -458,16 +468,11 @@ public class GroupInfoFragment extends Fragment implements ChatRoomListener {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAllInformationReceived(ChatRoom cr) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStateChanged(ChatRoom cr, ChatRoom.State newState) {
|
public void onStateChanged(ChatRoom cr, ChatRoom.State newState) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onParticipantDeviceFetchRequested(ChatRoom cr, Address addr) {
|
public void onParticipantDeviceFetchRequested(ChatRoom cr, Address addr) {
|
||||||
|
|
||||||
|
@ -475,7 +480,7 @@ public class GroupInfoFragment extends Fragment implements ChatRoomListener {
|
||||||
@Override
|
@Override
|
||||||
public void onParticipantRegistrationSubscriptionRequested(ChatRoom cr, Address participantAddr){
|
public void onParticipantRegistrationSubscriptionRequested(ChatRoom cr, Address participantAddr){
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onParticipantRegistrationUnsubscriptionRequested(ChatRoom cr, Address participantAddr){
|
public void onParticipantRegistrationUnsubscriptionRequested(ChatRoom cr, Address participantAddr){
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ public class ContactAddress implements Serializable {
|
||||||
private LinphoneContact contact;
|
private LinphoneContact contact;
|
||||||
private SearchResult result;
|
private SearchResult result;
|
||||||
private String address;
|
private String address;
|
||||||
|
private String phoneNumber;
|
||||||
private boolean isLinphoneContact;
|
private boolean isLinphoneContact;
|
||||||
private boolean isSelect = false;
|
private boolean isSelect = false;
|
||||||
private boolean isAdmin = false;
|
private boolean isAdmin = false;
|
||||||
|
@ -69,11 +70,13 @@ public class ContactAddress implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAddressAsDisplayableString() {
|
public String getAddressAsDisplayableString() {
|
||||||
|
Address addr = getAddress();
|
||||||
|
if (addr != null && addr.getUsername() != null) return addr.asStringUriOnly();
|
||||||
return address;
|
return address;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Address getAddress() {
|
public Address getAddress() {
|
||||||
String presence = contact.getPresenceModelForUriOrTel(address);
|
String presence = contact.getPresenceModelForUriOrTel((phoneNumber != null && !phoneNumber.isEmpty()) ? phoneNumber: address);
|
||||||
Address addr = Factory.instance().createAddress(presence != null ? presence : address);
|
Address addr = Factory.instance().createAddress(presence != null ? presence : address);
|
||||||
// Remove the user=phone URI param if existing, it will break everything otherwise
|
// Remove the user=phone URI param if existing, it will break everything otherwise
|
||||||
if (addr.hasUriParam("user")) {
|
if (addr.hasUriParam("user")) {
|
||||||
|
@ -82,6 +85,10 @@ public class ContactAddress implements Serializable {
|
||||||
return addr;
|
return addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPhoneNumber() {
|
||||||
|
return phoneNumber;
|
||||||
|
}
|
||||||
|
|
||||||
public void setSelect(boolean select) {
|
public void setSelect(boolean select) {
|
||||||
isSelect = select;
|
isSelect = select;
|
||||||
}
|
}
|
||||||
|
@ -90,16 +97,19 @@ public class ContactAddress implements Serializable {
|
||||||
return isLinphoneContact;
|
return isLinphoneContact;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContactAddress(LinphoneContact c, String a, boolean isLC){
|
private void init(LinphoneContact c, String a, String pn, boolean isLC) {
|
||||||
this.contact = c;
|
this.contact = c;
|
||||||
this.address = a;
|
this.address = a;
|
||||||
|
this.phoneNumber = pn;
|
||||||
this.isLinphoneContact = isLC;
|
this.isLinphoneContact = isLC;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContactAddress(LinphoneContact c, String a, boolean isLC, boolean isAdmin){
|
public ContactAddress(LinphoneContact c, String a, String pn, boolean isLC) {
|
||||||
this.contact = c;
|
init(c, a, pn, isLC);
|
||||||
this.address = a;
|
}
|
||||||
this.isLinphoneContact = isLC;
|
|
||||||
|
public ContactAddress(LinphoneContact c, String a, String pn, boolean isLC, boolean isAdmin) {
|
||||||
|
init(c, a, pn, isLC);
|
||||||
this.isAdmin = isAdmin;
|
this.isAdmin = isAdmin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ import org.linphone.LinphoneUtils;
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
import org.linphone.activities.LinphoneActivity;
|
import org.linphone.activities.LinphoneActivity;
|
||||||
import org.linphone.core.Address;
|
import org.linphone.core.Address;
|
||||||
|
import org.linphone.core.ProxyConfig;
|
||||||
import org.linphone.core.SearchResult;
|
import org.linphone.core.SearchResult;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -87,8 +88,13 @@ public class SearchContactsListAdapter extends BaseAdapter {
|
||||||
private boolean contactIsSelected(ContactAddress ca) {
|
private boolean contactIsSelected(ContactAddress ca) {
|
||||||
for (ContactAddress c : contactsSelected) {
|
for (ContactAddress c : contactsSelected) {
|
||||||
Address addr = c.getAddress();
|
Address addr = c.getAddress();
|
||||||
if (addr == null) continue;
|
if (addr.getUsername() != null && ca.getAddress() != null) {
|
||||||
if (addr.asStringUriOnly().compareTo(ca.getAddress().asStringUriOnly()) == 0) return true;
|
if (addr.asStringUriOnly().compareTo(ca.getAddress().asStringUriOnly()) == 0) return true;
|
||||||
|
} else {
|
||||||
|
if (c.getPhoneNumber() != null && ca.getPhoneNumber() != null) {
|
||||||
|
if (c.getPhoneNumber().compareTo(ca.getPhoneNumber()) == 0) return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -122,11 +128,18 @@ public class SearchContactsListAdapter extends BaseAdapter {
|
||||||
for (LinphoneContact contact : contacts) {
|
for (LinphoneContact contact : contacts) {
|
||||||
for (LinphoneNumberOrAddress noa : contact.getNumbersOrAddresses()) {
|
for (LinphoneNumberOrAddress noa : contact.getNumbersOrAddresses()) {
|
||||||
if (!mOnlySipContact || (mOnlySipContact && (noa.isSIPAddress() || contact.getPresenceModelForUriOrTel(noa.getValue()) != null))) {
|
if (!mOnlySipContact || (mOnlySipContact && (noa.isSIPAddress() || contact.getPresenceModelForUriOrTel(noa.getValue()) != null))) {
|
||||||
Address address = LinphoneManager.getLc().interpretUrl(noa.getValue());
|
ContactAddress ca = null;
|
||||||
if (address != null) {
|
if (noa.isSIPAddress()) {
|
||||||
ContactAddress ca = new ContactAddress(contact, address.asString(), contact.isFriend());
|
Address address = LinphoneManager.getLc().interpretUrl(noa.getValue());
|
||||||
list.add(ca);
|
if (address != null) {
|
||||||
|
ca = new ContactAddress(contact, address.asString(), "", contact.isFriend());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ProxyConfig prx = LinphoneManager.getLc().getDefaultProxyConfig();
|
||||||
|
String number = (prx != null) ? prx.normalizePhoneNumber(noa.getValue()) : noa.getValue();
|
||||||
|
ca = new ContactAddress(contact, "", number, contact.isFriend());
|
||||||
}
|
}
|
||||||
|
if (ca != null) list.add(ca);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -166,8 +179,12 @@ public class SearchContactsListAdapter extends BaseAdapter {
|
||||||
search = search.trim();
|
search = search.trim();
|
||||||
List<ContactAddress> result = new ArrayList<>();
|
List<ContactAddress> result = new ArrayList<>();
|
||||||
|
|
||||||
SearchResult[] results = ContactsManager.getInstance().getMagicSearch().getContactListFromFilter(search, "");
|
String domain = "";
|
||||||
|
ProxyConfig prx = LinphoneManager.getLc().getDefaultProxyConfig();
|
||||||
|
if (prx != null) domain = prx.getDomain();
|
||||||
|
SearchResult[] results = ContactsManager.getInstance().getMagicSearch().getContactListFromFilter(search, mOnlySipContact ? domain :"");
|
||||||
for (SearchResult sr : results) {
|
for (SearchResult sr : results) {
|
||||||
|
boolean found = false;
|
||||||
LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(sr.getAddress());
|
LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(sr.getAddress());
|
||||||
if (contact == null) {
|
if (contact == null) {
|
||||||
contact = new LinphoneContact();
|
contact = new LinphoneContact();
|
||||||
|
@ -176,21 +193,23 @@ public class SearchContactsListAdapter extends BaseAdapter {
|
||||||
contact.refresh();
|
contact.refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sr.getAddress() != null) {
|
if (sr.getAddress() != null || sr.getPhoneNumber() != null) {
|
||||||
if (contact.getFullName() == null) {
|
|
||||||
contact.setFullName(search);
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean found = false;
|
|
||||||
for (ContactAddress ca : result) {
|
for (ContactAddress ca : result) {
|
||||||
if (ca.getAddress().asStringUriOnly().equals(sr.getAddress().asStringUriOnly())) {
|
String normalizedPhoneNumber = (ca.getPhoneNumber() != null) ? prx.normalizePhoneNumber(ca.getPhoneNumber()) : null;
|
||||||
|
if ((sr.getAddress() != null && ca.getAddress() != null
|
||||||
|
&& ca.getAddress().asStringUriOnly().equals(sr.getAddress().asStringUriOnly()))
|
||||||
|
|| (sr.getPhoneNumber() != null && normalizedPhoneNumber != null
|
||||||
|
&& sr.getPhoneNumber().equals(normalizedPhoneNumber))) {
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found) {
|
}
|
||||||
result.add(new ContactAddress(contact, sr.getAddress().asStringUriOnly(), contact.isFriend()));
|
if (!found) {
|
||||||
}
|
result.add(new ContactAddress(contact,
|
||||||
|
(sr.getAddress() != null) ? sr.getAddress().asStringUriOnly() : "",
|
||||||
|
sr.getPhoneNumber(),
|
||||||
|
contact.isFriend()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,7 +234,7 @@ public class SearchContactsListAdapter extends BaseAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
ContactAddress contact = getItem(position);
|
ContactAddress contact = getItem(position);
|
||||||
final String a = contact.getAddressAsDisplayableString();
|
final String a = (contact.getAddressAsDisplayableString().isEmpty()) ? contact.getPhoneNumber() : contact.getAddressAsDisplayableString();
|
||||||
LinphoneContact c = contact.getContact();
|
LinphoneContact c = contact.getContact();
|
||||||
|
|
||||||
holder.avatar.setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap());
|
holder.avatar.setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap());
|
||||||
|
@ -223,11 +242,20 @@ public class SearchContactsListAdapter extends BaseAdapter {
|
||||||
LinphoneUtils.setThumbnailPictureFromUri(LinphoneActivity.instance(), holder.avatar, c.getThumbnailUri());
|
LinphoneUtils.setThumbnailPictureFromUri(LinphoneActivity.instance(), holder.avatar, c.getThumbnailUri());
|
||||||
}
|
}
|
||||||
|
|
||||||
String address = null;
|
String address = contact.getAddressAsDisplayableString();
|
||||||
if (c != null && c.getFullName() != null) {
|
if (c != null && c.getFullName() != null) {
|
||||||
address = c.getPresenceModelForUriOrTel(a);
|
if (address == null)
|
||||||
|
address = c.getPresenceModelForUriOrTel(a);
|
||||||
holder.name.setVisibility(View.VISIBLE);
|
holder.name.setVisibility(View.VISIBLE);
|
||||||
holder.name.setText(c.getFullName());
|
holder.name.setText(c.getFullName());
|
||||||
|
} else if (contact.getAddress() != null) {
|
||||||
|
if (contact.getAddress().getUsername() != null) {
|
||||||
|
holder.name.setVisibility(View.VISIBLE);
|
||||||
|
holder.name.setText(contact.getAddress().getUsername());
|
||||||
|
} else if (contact.getAddress().getDisplayName() != null) {
|
||||||
|
holder.name.setVisibility(View.VISIBLE);
|
||||||
|
holder.name.setText(contact.getAddress().getDisplayName());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
holder.name.setVisibility(View.GONE);
|
holder.name.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 1f5c297c224816abf90e621b909f4cb7ab60ac09
|
Subproject commit 64fc28497ffb0cf93ec851f2f2f6cfd72f116c3a
|
Loading…
Reference in a new issue