mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-05 00:35:01 -05:00
show checkbox to hide offline contacts
This commit is contained in:
parent
2dc69eea68
commit
4e50098e31
@ -59,6 +59,7 @@ import eu.siacs.conversations.entities.Bookmark;
|
|||||||
import eu.siacs.conversations.entities.Contact;
|
import eu.siacs.conversations.entities.Contact;
|
||||||
import eu.siacs.conversations.entities.Conversation;
|
import eu.siacs.conversations.entities.Conversation;
|
||||||
import eu.siacs.conversations.entities.ListItem;
|
import eu.siacs.conversations.entities.ListItem;
|
||||||
|
import eu.siacs.conversations.entities.Presences;
|
||||||
import eu.siacs.conversations.services.XmppConnectionService.OnRosterUpdate;
|
import eu.siacs.conversations.services.XmppConnectionService.OnRosterUpdate;
|
||||||
import eu.siacs.conversations.ui.adapter.KnownHostsAdapter;
|
import eu.siacs.conversations.ui.adapter.KnownHostsAdapter;
|
||||||
import eu.siacs.conversations.ui.adapter.ListItemAdapter;
|
import eu.siacs.conversations.ui.adapter.ListItemAdapter;
|
||||||
@ -114,6 +115,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
private boolean mHideOfflineContacts = false;
|
||||||
private TabListener mTabListener = new TabListener() {
|
private TabListener mTabListener = new TabListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -159,7 +161,6 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
private MenuItem mMenuSearchView;
|
private MenuItem mMenuSearchView;
|
||||||
private String mInitialJid;
|
|
||||||
private ListItemAdapter.OnTagClickedListener mOnTagClickedListener = new ListItemAdapter.OnTagClickedListener() {
|
private ListItemAdapter.OnTagClickedListener mOnTagClickedListener = new ListItemAdapter.OnTagClickedListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onTagClicked(String tag) {
|
public void onTagClicked(String tag) {
|
||||||
@ -171,6 +172,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
private String mInitialJid;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRosterUpdate() {
|
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) {
|
protected void openConversationForContact(int position) {
|
||||||
@ -496,10 +500,10 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
|
|||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
this.mOptionsMenu = menu;
|
this.mOptionsMenu = menu;
|
||||||
getMenuInflater().inflate(R.menu.start_conversation, menu);
|
getMenuInflater().inflate(R.menu.start_conversation, menu);
|
||||||
MenuItem menuCreateContact = menu
|
MenuItem menuCreateContact = menu.findItem(R.id.action_create_contact);
|
||||||
.findItem(R.id.action_create_contact);
|
MenuItem menuCreateConference = menu.findItem(R.id.action_join_conference);
|
||||||
MenuItem menuCreateConference = menu
|
MenuItem menuHideOffline = menu.findItem(R.id.action_hide_offline);
|
||||||
.findItem(R.id.action_join_conference);
|
menuHideOffline.setChecked(this.mHideOfflineContacts);
|
||||||
mMenuSearchView = menu.findItem(R.id.action_search);
|
mMenuSearchView = menu.findItem(R.id.action_search);
|
||||||
mMenuSearchView.setOnActionExpandListener(mOnActionExpandListener);
|
mMenuSearchView.setOnActionExpandListener(mOnActionExpandListener);
|
||||||
View mSearchView = mMenuSearchView.getActionView();
|
View mSearchView = mMenuSearchView.getActionView();
|
||||||
@ -531,6 +535,13 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
|
|||||||
case R.id.action_scan_qr_code:
|
case R.id.action_scan_qr_code:
|
||||||
new IntentIntegrator(this).initiateScan();
|
new IntentIntegrator(this).initiateScan();
|
||||||
return true;
|
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);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
@ -667,7 +678,9 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
|
|||||||
for (Account account : xmppConnectionService.getAccounts()) {
|
for (Account account : xmppConnectionService.getAccounts()) {
|
||||||
if (account.getStatus() != Account.State.DISABLED) {
|
if (account.getStatus() != Account.State.DISABLED) {
|
||||||
for (Contact contact : account.getRoster().getContacts()) {
|
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);
|
this.contacts.add(contact);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,14 @@
|
|||||||
android:id="@+id/action_scan_qr_code"
|
android:id="@+id/action_scan_qr_code"
|
||||||
android:showAsAction="never"
|
android:showAsAction="never"
|
||||||
android:title="@string/scan_qr_code" />
|
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
|
<item
|
||||||
android:id="@+id/action_accounts"
|
android:id="@+id/action_accounts"
|
||||||
android:orderInCategory="90"
|
android:orderInCategory="90"
|
||||||
|
@ -443,4 +443,5 @@
|
|||||||
<string name="avatar_has_been_published">Avatar has been published!</string>
|
<string name="avatar_has_been_published">Avatar has been published!</string>
|
||||||
<string name="sending_x_file">Sending %s</string>
|
<string name="sending_x_file">Sending %s</string>
|
||||||
<string name="offering_x_file">Offering %s</string>
|
<string name="offering_x_file">Offering %s</string>
|
||||||
|
<string name="hide_offline">Hide offline</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user