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 | |
parent | 2dc69eea682997229b632f9009facd21b85b47f5 (diff) |
show checkbox to hide offline contacts
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java | 25 | ||||
-rw-r--r-- | src/main/res/menu/start_conversation.xml | 8 | ||||
-rw-r--r-- | src/main/res/values/strings.xml | 1 |
3 files changed, 28 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 2154754b6..ff46ffd8f 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); } } diff --git a/src/main/res/menu/start_conversation.xml b/src/main/res/menu/start_conversation.xml index 2c23af591..3dd09e90d 100644 --- a/src/main/res/menu/start_conversation.xml +++ b/src/main/res/menu/start_conversation.xml @@ -21,6 +21,14 @@ android:id="@+id/action_scan_qr_code" android:showAsAction="never" android:title="@string/scan_qr_code" /> + + <item + android:id="@+id/action_hide_offline" + android:checkable="true" + android:checked="false" + android:orderInCategory="85" + android:showAsAction="never" + android:title="@string/hide_offline"/> <item android:id="@+id/action_accounts" android:orderInCategory="90" diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index dc4c1bdbb..3d3d69a3e 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -443,4 +443,5 @@ <string name="avatar_has_been_published">Avatar has been published!</string> <string name="sending_x_file">Sending %s</string> <string name="offering_x_file">Offering %s</string> + <string name="hide_offline">Hide offline</string> </resources> |