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
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
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'
|
||||
|
||||
dependencies {
|
||||
implementation group: 'org.apache.commons', name: 'commons-compress', version: '1.16.1'
|
||||
javadocDeps group: 'org.apache.commons', name: 'commons-compress', version: '1.16.1'
|
||||
compile 'org.apache.commons:commons-compress:1.16.1'
|
||||
javadocDeps 'org.apache.commons:commons-compress:1.16.1'
|
||||
}
|
||||
|
||||
def srcDir = ['submodules/mediastreamer2/java/src', 'src/linphone-wrapper']
|
||||
|
@ -44,6 +44,7 @@ excludePackage.add('**/LICENSE.txt')
|
|||
android {
|
||||
defaultConfig {
|
||||
compileSdkVersion 26
|
||||
buildToolsVersion "26.0.0"
|
||||
multiDexEnabled true
|
||||
}
|
||||
|
||||
|
|
|
@ -29,11 +29,11 @@ allprojects {
|
|||
apply plugin: 'com.android.application'
|
||||
|
||||
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: 'com.jayway.android.robotium', name: 'robotium', version: '+'
|
||||
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: 'com.jayway.android.robotium', name: 'robotium-solo', version: '+'
|
||||
compile fileTree(dir: 'libs', include: 'android-junit-report*.jar')
|
||||
|
|
|
@ -373,7 +373,7 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
|
|||
public void changeStatusToOnThePhone() {
|
||||
Core lc = getLcIfManagerNotDestroyedOrNull();
|
||||
if (lc == null) return;
|
||||
|
||||
|
||||
if (isInstanciated() && isPresenceModelActivitySet() && lc.getPresenceModel().getActivity().getType() != PresenceActivity.Type.OnThePhone) {
|
||||
lc.getPresenceModel().getActivity().setType(PresenceActivity.Type.OnThePhone);
|
||||
} else if (isInstanciated() && !isPresenceModelActivitySet()) {
|
||||
|
@ -687,7 +687,7 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
|
|||
Class<?> firebaseClass = Class.forName("com.google.firebase.iid.FirebaseInstanceId");
|
||||
Object firebaseInstance = firebaseClass.getMethod("getInstance").invoke(null);
|
||||
final String refreshedToken = (String)firebaseClass.getMethod("getToken").invoke(firebaseInstance);
|
||||
|
||||
|
||||
//final String refreshedToken = com.google.firebase.iid.FirebaseInstanceId.getInstance().getToken();
|
||||
if (refreshedToken != null) {
|
||||
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);
|
||||
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
|
||||
public void onPublishStateChanged(Core lc, Event ev, PublishState state) {
|
||||
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.contacts.ContactAddress;
|
||||
import org.linphone.contacts.ContactsManager;
|
||||
import org.linphone.contacts.LinphoneNumberOrAddress;
|
||||
import org.linphone.contacts.SearchContactsListAdapter;
|
||||
import org.linphone.core.Address;
|
||||
import org.linphone.core.ChatRoom;
|
||||
import org.linphone.core.ChatRoomListenerStub;
|
||||
import org.linphone.core.Core;
|
||||
import org.linphone.core.Factory;
|
||||
import org.linphone.core.ProxyConfig;
|
||||
import org.linphone.mediastream.Log;
|
||||
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) {
|
||||
for (int i = 0 ; i < caList.size() ; i++) {
|
||||
if (caList.get(i).getAddressAsDisplayableString().compareTo(ca.getAddressAsDisplayableString()) == 0)
|
||||
return i;
|
||||
if (ca.getAddress() != null && ca.getAddress().getUsername() != null) {
|
||||
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;
|
||||
}
|
||||
|
||||
private void resetAndResearch() {
|
||||
ContactsManager.getInstance().getMagicSearch().resetSearchCache();
|
||||
mSearchAdapter.searchContacts(mSearchField.getText().toString(), mContactsList);
|
||||
}
|
||||
|
||||
private void addSelectedContactAddress(ContactAddress ca) {
|
||||
View viewContact = LayoutInflater.from(LinphoneActivity.instance()).inflate(R.layout.contact_selected, null);
|
||||
if (ca.getContact() != null) {
|
||||
|
@ -323,6 +335,7 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
|||
mLinphoneContactsButton.setEnabled(true);
|
||||
mLinphoneContactsSelected.setVisibility(View.INVISIBLE);
|
||||
updateList();
|
||||
resetAndResearch();
|
||||
} else if (id == R.id.linphone_contacts) {
|
||||
mSearchAdapter.setOnlySipContact(true);
|
||||
mLinphoneContactsSelected.setVisibility(View.VISIBLE);
|
||||
|
@ -330,6 +343,7 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
|||
mAllContactsButton.setEnabled(mOnlyDisplayLinphoneContacts = true);
|
||||
mAllContactsSelected.setVisibility(View.INVISIBLE);
|
||||
updateList();
|
||||
resetAndResearch();
|
||||
} else if (id == R.id.back) {
|
||||
if (LinphoneActivity.instance().isTablet()) {
|
||||
LinphoneActivity.instance().goToChatList();
|
||||
|
|
|
@ -69,7 +69,6 @@ import org.linphone.core.ChatRoomCapabilities;
|
|||
import org.linphone.core.ChatRoomListener;
|
||||
import org.linphone.core.Content;
|
||||
import org.linphone.core.Core;
|
||||
import org.linphone.core.Event;
|
||||
import org.linphone.core.EventLog;
|
||||
import org.linphone.core.Factory;
|
||||
import org.linphone.core.LimeState;
|
||||
|
@ -160,7 +159,7 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
|||
String displayName = LinphoneUtils.getAddressDisplayName(a);
|
||||
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);
|
||||
}
|
||||
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) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onParticipantDeviceFetchRequested(ChatRoom cr, Address addr) {
|
||||
|
||||
|
@ -705,7 +704,7 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
|||
@Override
|
||||
public void onParticipantRegistrationSubscriptionRequested(ChatRoom cr, Address participantAddr){
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
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) {
|
||||
// Currently flexisip doesn't send the participants list in the INVITE
|
||||
// So we have to refresh the display when information is available
|
||||
|
@ -763,7 +762,7 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
|||
}
|
||||
getContactsForParticipants();
|
||||
displayChatRoomHeader();
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
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
|
||||
public void onParticipantRemoved(ChatRoom cr, EventLog event) {
|
||||
getContactsForParticipants();
|
||||
|
|
|
@ -348,7 +348,7 @@ public class GroupInfoFragment extends Fragment implements ChatRoomListener {
|
|||
String displayName = LinphoneUtils.getAddressDisplayName(a);
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
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
|
||||
public void onStateChanged(ChatRoom cr, ChatRoom.State newState) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onParticipantDeviceFetchRequested(ChatRoom cr, Address addr) {
|
||||
|
||||
|
@ -475,7 +480,7 @@ public class GroupInfoFragment extends Fragment implements ChatRoomListener {
|
|||
@Override
|
||||
public void onParticipantRegistrationSubscriptionRequested(ChatRoom cr, Address participantAddr){
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onParticipantRegistrationUnsubscriptionRequested(ChatRoom cr, Address participantAddr){
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ public class ContactAddress implements Serializable {
|
|||
private LinphoneContact contact;
|
||||
private SearchResult result;
|
||||
private String address;
|
||||
private String phoneNumber;
|
||||
private boolean isLinphoneContact;
|
||||
private boolean isSelect = false;
|
||||
private boolean isAdmin = false;
|
||||
|
@ -69,11 +70,13 @@ public class ContactAddress implements Serializable {
|
|||
}
|
||||
|
||||
public String getAddressAsDisplayableString() {
|
||||
Address addr = getAddress();
|
||||
if (addr != null && addr.getUsername() != null) return addr.asStringUriOnly();
|
||||
return address;
|
||||
}
|
||||
|
||||
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);
|
||||
// Remove the user=phone URI param if existing, it will break everything otherwise
|
||||
if (addr.hasUriParam("user")) {
|
||||
|
@ -82,6 +85,10 @@ public class ContactAddress implements Serializable {
|
|||
return addr;
|
||||
}
|
||||
|
||||
public String getPhoneNumber() {
|
||||
return phoneNumber;
|
||||
}
|
||||
|
||||
public void setSelect(boolean select) {
|
||||
isSelect = select;
|
||||
}
|
||||
|
@ -90,16 +97,19 @@ public class ContactAddress implements Serializable {
|
|||
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.address = a;
|
||||
this.phoneNumber = pn;
|
||||
this.isLinphoneContact = isLC;
|
||||
}
|
||||
|
||||
public ContactAddress(LinphoneContact c, String a, boolean isLC, boolean isAdmin){
|
||||
this.contact = c;
|
||||
this.address = a;
|
||||
this.isLinphoneContact = isLC;
|
||||
public ContactAddress(LinphoneContact c, String a, String pn, boolean isLC) {
|
||||
init(c, a, pn, isLC);
|
||||
}
|
||||
|
||||
public ContactAddress(LinphoneContact c, String a, String pn, boolean isLC, boolean isAdmin) {
|
||||
init(c, a, pn, isLC);
|
||||
this.isAdmin = isAdmin;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.linphone.LinphoneUtils;
|
|||
import org.linphone.R;
|
||||
import org.linphone.activities.LinphoneActivity;
|
||||
import org.linphone.core.Address;
|
||||
import org.linphone.core.ProxyConfig;
|
||||
import org.linphone.core.SearchResult;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -87,8 +88,13 @@ public class SearchContactsListAdapter extends BaseAdapter {
|
|||
private boolean contactIsSelected(ContactAddress ca) {
|
||||
for (ContactAddress c : contactsSelected) {
|
||||
Address addr = c.getAddress();
|
||||
if (addr == null) continue;
|
||||
if (addr.asStringUriOnly().compareTo(ca.getAddress().asStringUriOnly()) == 0) return true;
|
||||
if (addr.getUsername() != null && ca.getAddress() != null) {
|
||||
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;
|
||||
}
|
||||
|
@ -122,11 +128,18 @@ public class SearchContactsListAdapter extends BaseAdapter {
|
|||
for (LinphoneContact contact : contacts) {
|
||||
for (LinphoneNumberOrAddress noa : contact.getNumbersOrAddresses()) {
|
||||
if (!mOnlySipContact || (mOnlySipContact && (noa.isSIPAddress() || contact.getPresenceModelForUriOrTel(noa.getValue()) != null))) {
|
||||
Address address = LinphoneManager.getLc().interpretUrl(noa.getValue());
|
||||
if (address != null) {
|
||||
ContactAddress ca = new ContactAddress(contact, address.asString(), contact.isFriend());
|
||||
list.add(ca);
|
||||
ContactAddress ca = null;
|
||||
if (noa.isSIPAddress()) {
|
||||
Address address = LinphoneManager.getLc().interpretUrl(noa.getValue());
|
||||
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();
|
||||
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) {
|
||||
boolean found = false;
|
||||
LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(sr.getAddress());
|
||||
if (contact == null) {
|
||||
contact = new LinphoneContact();
|
||||
|
@ -176,21 +193,23 @@ public class SearchContactsListAdapter extends BaseAdapter {
|
|||
contact.refresh();
|
||||
}
|
||||
}
|
||||
if (sr.getAddress() != null) {
|
||||
if (contact.getFullName() == null) {
|
||||
contact.setFullName(search);
|
||||
}
|
||||
|
||||
boolean found = false;
|
||||
if (sr.getAddress() != null || sr.getPhoneNumber() != null) {
|
||||
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;
|
||||
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);
|
||||
final String a = contact.getAddressAsDisplayableString();
|
||||
final String a = (contact.getAddressAsDisplayableString().isEmpty()) ? contact.getPhoneNumber() : contact.getAddressAsDisplayableString();
|
||||
LinphoneContact c = contact.getContact();
|
||||
|
||||
holder.avatar.setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap());
|
||||
|
@ -223,11 +242,20 @@ public class SearchContactsListAdapter extends BaseAdapter {
|
|||
LinphoneUtils.setThumbnailPictureFromUri(LinphoneActivity.instance(), holder.avatar, c.getThumbnailUri());
|
||||
}
|
||||
|
||||
String address = null;
|
||||
String address = contact.getAddressAsDisplayableString();
|
||||
if (c != null && c.getFullName() != null) {
|
||||
address = c.getPresenceModelForUriOrTel(a);
|
||||
if (address == null)
|
||||
address = c.getPresenceModelForUriOrTel(a);
|
||||
holder.name.setVisibility(View.VISIBLE);
|
||||
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 {
|
||||
holder.name.setVisibility(View.GONE);
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 1f5c297c224816abf90e621b909f4cb7ab60ac09
|
||||
Subproject commit 64fc28497ffb0cf93ec851f2f2f6cfd72f116c3a
|
Loading…
Reference in a new issue