diff options
author | iNPUTmice <daniel@gultsch.de> | 2015-01-21 17:24:02 +0100 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2015-01-21 17:24:02 +0100 |
commit | 4e50098e319b9ccd65801acf1774bc6212b75621 (patch) | |
tree | de61bd47acac7fb3cde2faa902f14f2fda1d1d2d /src/main/java/eu | |
parent | 2dc69eea682997229b632f9009facd21b85b47f5 (diff) |
show checkbox to hide offline contacts
Diffstat (limited to 'src/main/java/eu')
-rw-r--r-- | src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java index 2154754b..ff46ffd8 100644 --- a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java @@ -59,6 +59,7 @@ import eu.siacs.conversations.entities.Bookmark; import eu.siacs.conversations.entities.Contact; import eu.siacs.conversations.entities.Conversation; import eu.siacs.conversations.entities.ListItem; +import eu.siacs.conversations.entities.Presences; import eu.siacs.conversations.services.XmppConnectionService.OnRosterUpdate; import eu.siacs.conversations.ui.adapter.KnownHostsAdapter; import eu.siacs.conversations.ui.adapter.ListItemAdapter; @@ -114,6 +115,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU return true; } }; + private boolean mHideOfflineContacts = false; private TabListener mTabListener = new TabListener() { @Override @@ -159,7 +161,6 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU } }; private MenuItem mMenuSearchView; - private String mInitialJid; private ListItemAdapter.OnTagClickedListener mOnTagClickedListener = new ListItemAdapter.OnTagClickedListener() { @Override public void onTagClicked(String tag) { @@ -171,6 +172,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU } } }; + private String mInitialJid; @Override public void onRosterUpdate() { @@ -245,6 +247,8 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU } }); + this.mHideOfflineContacts = getPreferences().getBoolean("hide_offline", false); + } protected void openConversationForContact(int position) { @@ -496,10 +500,10 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU public boolean onCreateOptionsMenu(Menu menu) { this.mOptionsMenu = menu; getMenuInflater().inflate(R.menu.start_conversation, menu); - MenuItem menuCreateContact = menu - .findItem(R.id.action_create_contact); - MenuItem menuCreateConference = menu - .findItem(R.id.action_join_conference); + MenuItem menuCreateContact = menu.findItem(R.id.action_create_contact); + MenuItem menuCreateConference = menu.findItem(R.id.action_join_conference); + MenuItem menuHideOffline = menu.findItem(R.id.action_hide_offline); + menuHideOffline.setChecked(this.mHideOfflineContacts); mMenuSearchView = menu.findItem(R.id.action_search); mMenuSearchView.setOnActionExpandListener(mOnActionExpandListener); View mSearchView = mMenuSearchView.getActionView(); @@ -531,6 +535,13 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU case R.id.action_scan_qr_code: new IntentIntegrator(this).initiateScan(); return true; + case R.id.action_hide_offline: + mHideOfflineContacts = !item.isChecked(); + getPreferences().edit().putBoolean("hide_offline", mHideOfflineContacts).commit(); + if (mSearchEditText != null) { + filter(mSearchEditText.getText().toString()); + } + invalidateOptionsMenu(); } return super.onOptionsItemSelected(item); } @@ -667,7 +678,9 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU for (Account account : xmppConnectionService.getAccounts()) { if (account.getStatus() != Account.State.DISABLED) { for (Contact contact : account.getRoster().getContacts()) { - if (contact.showInRoster() && contact.match(needle)) { + if (contact.showInRoster() && contact.match(needle) + && (!this.mHideOfflineContacts + || contact.getPresences().getMostAvailableStatus() < Presences.OFFLINE)) { this.contacts.add(contact); } } |