Added back contacts search filter
This commit is contained in:
parent
448355136b
commit
100ab5b679
2 changed files with 25 additions and 2 deletions
|
@ -325,10 +325,10 @@ public class ContactsListFragment extends Fragment implements OnClickListener, O
|
|||
|
||||
if (onlyDisplayLinphoneContacts) {
|
||||
contactsList.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE);
|
||||
contactsList.setAdapter(new ContactsListAdapter(ContactsManager.getInstance().getSIPContacts()));
|
||||
contactsList.setAdapter(new ContactsListAdapter(ContactsManager.getInstance().getSIPContacts(search)));
|
||||
} else {
|
||||
contactsList.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE);
|
||||
contactsList.setAdapter(new ContactsListAdapter(ContactsManager.getInstance().getContacts()));
|
||||
contactsList.setAdapter(new ContactsListAdapter(ContactsManager.getInstance().getContacts(search)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.linphone;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.linphone.compatibility.Compatibility;
|
||||
import org.linphone.core.LinphoneAddress;
|
||||
|
@ -119,6 +120,28 @@ public class ContactsManager extends ContentObserver {
|
|||
return sipContacts;
|
||||
}
|
||||
|
||||
public synchronized List<LinphoneContact> getContacts(String search) {
|
||||
search = search.toLowerCase(Locale.getDefault());
|
||||
List<LinphoneContact> searchContacts = new ArrayList<LinphoneContact>();
|
||||
for (LinphoneContact contact : contacts) {
|
||||
if (contact.getFullName().toLowerCase(Locale.getDefault()).contains(search)) {
|
||||
searchContacts.add(contact);
|
||||
}
|
||||
}
|
||||
return searchContacts;
|
||||
}
|
||||
|
||||
public synchronized List<LinphoneContact> getSIPContacts(String search) {
|
||||
search = search.toLowerCase(Locale.getDefault());
|
||||
List<LinphoneContact> searchContacts = new ArrayList<LinphoneContact>();
|
||||
for (LinphoneContact contact : sipContacts) {
|
||||
if (contact.getFullName().toLowerCase(Locale.getDefault()).contains(search)) {
|
||||
searchContacts.add(contact);
|
||||
}
|
||||
}
|
||||
return searchContacts;
|
||||
}
|
||||
|
||||
public void enableContactsAccess() {
|
||||
hasContactAccess = true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue