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();
|
int id = v.getId();
|
||||||
|
|
||||||
if (id == R.id.allContacts) {
|
if (id == R.id.allContacts) {
|
||||||
allContacts.setEnabled(false);
|
|
||||||
linphoneContacts.setEnabled(true);
|
|
||||||
onlyDisplayLinphoneContacts = false;
|
onlyDisplayLinphoneContacts = false;
|
||||||
changeContactsAdapter();
|
changeContactsAdapter();
|
||||||
}
|
}
|
||||||
else if (id == R.id.linphoneContacts) {
|
else if (id == R.id.linphoneContacts) {
|
||||||
allContacts.setEnabled(true);
|
|
||||||
linphoneContacts.setEnabled(false);
|
|
||||||
onlyDisplayLinphoneContacts = true;
|
onlyDisplayLinphoneContacts = true;
|
||||||
changeContactsAdapter();
|
changeContactsAdapter();
|
||||||
|
|
||||||
|
@ -101,6 +97,8 @@ public class ContactsFragment extends Fragment implements OnClickListener, OnIte
|
||||||
}
|
}
|
||||||
|
|
||||||
private void changeContactsAdapter() {
|
private void changeContactsAdapter() {
|
||||||
|
changeContactsToggle();
|
||||||
|
|
||||||
Cursor allContactsCursor = LinphoneActivity.instance().getAllContactsCursor();
|
Cursor allContactsCursor = LinphoneActivity.instance().getAllContactsCursor();
|
||||||
Cursor sipContactsCursor = LinphoneActivity.instance().getSIPContactsCursor();
|
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");
|
indexer = new AlphabetIndexer(allContactsCursor, Compatibility.getCursorDisplayNameColumnIndex(allContactsCursor), " ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
||||||
contactsList.setAdapter(new ContactsListAdapter(LinphoneActivity.instance().getAllContacts(), allContactsCursor));
|
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
|
@Override
|
||||||
|
@ -124,6 +133,7 @@ public class ContactsFragment extends Fragment implements OnClickListener, OnIte
|
||||||
super.onResume();
|
super.onResume();
|
||||||
if (LinphoneActivity.isInstanciated()) {
|
if (LinphoneActivity.isInstanciated()) {
|
||||||
LinphoneActivity.instance().selectMenu(FragmentsAvailable.CONTACTS);
|
LinphoneActivity.instance().selectMenu(FragmentsAvailable.CONTACTS);
|
||||||
|
onlyDisplayLinphoneContacts = LinphoneActivity.instance().isLinphoneContactsPrefered();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (contactsList.getAdapter() == null) {
|
if (contactsList.getAdapter() == null) {
|
||||||
|
|
|
@ -83,6 +83,7 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
||||||
private Fragment dialerFragment, messageListenerFragment;
|
private Fragment dialerFragment, messageListenerFragment;
|
||||||
private SavedState dialerSavedState;
|
private SavedState dialerSavedState;
|
||||||
private ChatStorage chatStorage;
|
private ChatStorage chatStorage;
|
||||||
|
private boolean preferLinphoneContacts = false;
|
||||||
private Handler mHandler = new Handler();
|
private Handler mHandler = new Handler();
|
||||||
private List<Contact> contactList, sipContactList;
|
private List<Contact> contactList, sipContactList;
|
||||||
private Cursor contactCursor, sipContactCursor;
|
private Cursor contactCursor, sipContactCursor;
|
||||||
|
@ -584,6 +585,14 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
||||||
return sipContactCursor;
|
return sipContactCursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setLinphoneContactsPrefered(boolean isPrefered) {
|
||||||
|
preferLinphoneContacts = isPrefered;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isLinphoneContactsPrefered() {
|
||||||
|
return preferLinphoneContacts;
|
||||||
|
}
|
||||||
|
|
||||||
private void prepareContactsInBackground() {
|
private void prepareContactsInBackground() {
|
||||||
contactCursor = Compatibility.getContactsCursor(getContentResolver());
|
contactCursor = Compatibility.getContactsCursor(getContentResolver());
|
||||||
sipContactCursor = Compatibility.getSIPContactsCursor(getContentResolver());
|
sipContactCursor = Compatibility.getSIPContactsCursor(getContentResolver());
|
||||||
|
|
Loading…
Reference in a new issue