Update Linphone + searchContactAdapter

This commit is contained in:
Erwan Croze 2017-09-14 11:43:22 +02:00
parent d915a07f3e
commit 50dd5520b3
3 changed files with 26 additions and 23 deletions

View file

@ -74,12 +74,12 @@ public class AboutFragment extends Fragment implements OnClickListener {
resetLogButton = view.findViewById(R.id.reset_log);
resetLogButton.setOnClickListener(this);
resetLogButton.setVisibility(LinphonePreferences.instance().isDebugEnabled() ? View.VISIBLE : View.GONE);
mListener = new LinphoneCoreListenerBase() {
@Override
public void uploadProgressIndication(LinphoneCore lc, int offset, int total) {
}
@Override
public void uploadStateChanged(LinphoneCore lc, LogCollectionUploadState state, String info) {
if (state == LogCollectionUploadState.LogCollectionUploadStateInProgress) {
@ -96,13 +96,13 @@ public class AboutFragment extends Fragment implements OnClickListener {
return view;
}
private void displayUploadLogsInProgress() {
if (uploadInProgress) {
return;
}
uploadInProgress = true;
progress = ProgressDialog.show(LinphoneActivity.instance(), null, null);
Drawable d = new ColorDrawable(ContextCompat.getColor(getActivity(), R.color.colorE));
d.setAlpha(200);
@ -134,7 +134,7 @@ public class AboutFragment extends Fragment implements OnClickListener {
if (lc != null) {
lc.removeListener(mListener);
}
super.onPause();
}
@ -144,11 +144,11 @@ public class AboutFragment extends Fragment implements OnClickListener {
if (lc != null) {
lc.addListener(mListener);
}
if (LinphoneActivity.isInstanciated()) {
LinphoneActivity.instance().selectMenu(FragmentsAvailable.ABOUT);
}
super.onResume();
}
@ -169,7 +169,7 @@ public class AboutFragment extends Fragment implements OnClickListener {
}
}
}
@Override
public void onDestroy() {
super.onDestroy();

View file

@ -28,6 +28,8 @@ import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
import org.linphone.core.LinphoneAddress;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
@ -58,6 +60,7 @@ public class SearchContactsListAdapter extends BaseAdapter {
private ProgressBar progressBar;
private boolean mOnlySipContact = false;
private View.OnClickListener listener;
private int oldSize;
public List<ContactAddress> getContacts() {
return contacts;
@ -76,6 +79,7 @@ public class SearchContactsListAdapter extends BaseAdapter {
progressBar = pB;
setContactsSelectedList(null);
setContactsList(contactsList);
oldSize = 0;
}
public void setContactsList(List<ContactAddress> contactsList) {
@ -99,18 +103,16 @@ public class SearchContactsListAdapter extends BaseAdapter {
public List<ContactAddress> getContactsList() {
List<ContactAddress> list = new ArrayList<ContactAddress>();
if(ContactsManager.getInstance().hasContacts()) {
for (LinphoneContact con : (mOnlySipContact)
? ContactsManager.getInstance().getSIPContacts() : ContactsManager.getInstance().getContacts()) {
for (LinphoneNumberOrAddress noa : con.getNumbersOrAddresses()) {
String value = noa.getValue();
// Fix for sip:username compatibility issue
if (value.startsWith("sip:") && !value.contains("@")) {
value = value.substring(4);
value = LinphoneUtils.getFullAddressFromUsername(value);
}
ContactAddress ca = new ContactAddress(con, value, con.isInLinphoneFriendList());
list.add(ca);
for (LinphoneAddress addr : LinphoneManager.getLc().findContactsByChar("", mOnlySipContact)) {
LinphoneContact cont = ContactsManager.getInstance().findContactFromAddress(addr);
if (cont == null) {
cont = new LinphoneContact();
cont.setFullName(addr.getUserName());
}
// TODO Rechercher si un contact est associé à cette sip uri
// TODO Rechercher si un displayname est associé à cette sip uri
ContactAddress ca = new ContactAddress(cont , addr.asString(), cont.isLinphoneFriend());
list.add(ca);
}
}
@ -143,12 +145,13 @@ public class SearchContactsListAdapter extends BaseAdapter {
if (search == null || search.length() == 0) {
contacts = getContactsList();
resultContactsSearch.setAdapter(this);
oldSize = 0;
return;
}
List<ContactAddress> result = new ArrayList<ContactAddress>();
if(search != null) {
for (ContactAddress c : getContacts()) {
for (ContactAddress c : (search.length() < oldSize) ? getContactsList() : getContacts()) {
String address = c.getAddress();
if (address.startsWith("sip:")) address = address.substring(4);
if (c.getContact().getFullName() != null
@ -158,8 +161,8 @@ public class SearchContactsListAdapter extends BaseAdapter {
}
}
}
setContactsList(result);
oldSize = search.length();
contacts = result;
resultContactsSearch.setAdapter(this);
this.notifyDataSetChanged();
}

@ -1 +1 @@
Subproject commit e095830bb6a6dda714f2ca9889888e2132659f91
Subproject commit 91dad233b55c66d9968771fd613812d0539097a9