Keep linphone contacts filter choice in memory
This commit is contained in:
parent
b01a4d19de
commit
ab5aa6fd9c
2 changed files with 23 additions and 4 deletions
|
@ -82,14 +82,10 @@ public class ContactsFragment extends Fragment implements OnClickListener, OnIte
|
|||
int id = v.getId();
|
||||
|
||||
if (id == R.id.allContacts) {
|
||||
allContacts.setEnabled(false);
|
||||
linphoneContacts.setEnabled(true);
|
||||
onlyDisplayLinphoneContacts = false;
|
||||
changeContactsAdapter();
|
||||
}
|
||||
else if (id == R.id.linphoneContacts) {
|
||||
allContacts.setEnabled(true);
|
||||
linphoneContacts.setEnabled(false);
|
||||
onlyDisplayLinphoneContacts = true;
|
||||
changeContactsAdapter();
|
||||
|
||||
|
@ -101,6 +97,8 @@ public class ContactsFragment extends Fragment implements OnClickListener, OnIte
|
|||
}
|
||||
|
||||
private void changeContactsAdapter() {
|
||||
changeContactsToggle();
|
||||
|
||||
Cursor allContactsCursor = LinphoneActivity.instance().getAllContactsCursor();
|
||||
Cursor sipContactsCursor = LinphoneActivity.instance().getSIPContactsCursor();
|
||||
|
||||
|
@ -111,6 +109,17 @@ public class ContactsFragment extends Fragment implements OnClickListener, OnIte
|
|||
indexer = new AlphabetIndexer(allContactsCursor, Compatibility.getCursorDisplayNameColumnIndex(allContactsCursor), " ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
||||
contactsList.setAdapter(new ContactsListAdapter(LinphoneActivity.instance().getAllContacts(), allContactsCursor));
|
||||
}
|
||||
LinphoneActivity.instance().setLinphoneContactsPrefered(onlyDisplayLinphoneContacts);
|
||||
}
|
||||
|
||||
private void changeContactsToggle() {
|
||||
if (onlyDisplayLinphoneContacts) {
|
||||
allContacts.setEnabled(true);
|
||||
linphoneContacts.setEnabled(false);
|
||||
} else {
|
||||
allContacts.setEnabled(false);
|
||||
linphoneContacts.setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -124,6 +133,7 @@ public class ContactsFragment extends Fragment implements OnClickListener, OnIte
|
|||
super.onResume();
|
||||
if (LinphoneActivity.isInstanciated()) {
|
||||
LinphoneActivity.instance().selectMenu(FragmentsAvailable.CONTACTS);
|
||||
onlyDisplayLinphoneContacts = LinphoneActivity.instance().isLinphoneContactsPrefered();
|
||||
}
|
||||
|
||||
if (contactsList.getAdapter() == null) {
|
||||
|
|
|
@ -83,6 +83,7 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
|||
private Fragment dialerFragment, messageListenerFragment;
|
||||
private SavedState dialerSavedState;
|
||||
private ChatStorage chatStorage;
|
||||
private boolean preferLinphoneContacts = false;
|
||||
private Handler mHandler = new Handler();
|
||||
private List<Contact> contactList, sipContactList;
|
||||
private Cursor contactCursor, sipContactCursor;
|
||||
|
@ -584,6 +585,14 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
|||
return sipContactCursor;
|
||||
}
|
||||
|
||||
public void setLinphoneContactsPrefered(boolean isPrefered) {
|
||||
preferLinphoneContacts = isPrefered;
|
||||
}
|
||||
|
||||
public boolean isLinphoneContactsPrefered() {
|
||||
return preferLinphoneContacts;
|
||||
}
|
||||
|
||||
private void prepareContactsInBackground() {
|
||||
contactCursor = Compatibility.getContactsCursor(getContentResolver());
|
||||
sipContactCursor = Compatibility.getSIPContactsCursor(getContentResolver());
|
||||
|
|
Loading…
Reference in a new issue