show jids from address book in Start Conversation screen if only one account is used

This commit is contained in:
Daniel Gultsch 2018-08-30 18:45:22 +02:00
parent af724a6697
commit 2febbe1b8d
3 changed files with 22 additions and 2 deletions

View File

@ -156,6 +156,9 @@ public class Contact implements ListItem, Blockable {
if (isBlocked()) {
tags.add(new Tag(context.getString(R.string.blocked), 0xff2e2f3b));
}
if (showInPhoneBook()) {
tags.add(new Tag(context.getString(R.string.phone_book), 0xFF1E88E5));
}
return tags;
}
@ -336,6 +339,10 @@ public class Contact implements ListItem, Blockable {
|| (this.getOption(Contact.Options.DIRTY_PUSH));
}
public boolean showInPhoneBook() {
return systemAccount != null && !systemAccount.trim().isEmpty();
}
public void parseSubscriptionFromElement(Element item) {
String ask = item.getAttribute("ask");
String subscription = item.getAttribute("subscription");

View File

@ -858,11 +858,13 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
protected void filterContacts(String needle) {
this.contacts.clear();
for (Account account : xmppConnectionService.getAccounts()) {
final List<Account> accounts = xmppConnectionService.getAccounts();
final boolean singleAccountActive = isSingleAccountActive(accounts);
for (Account account : accounts) {
if (account.getStatus() != Account.State.DISABLED) {
for (Contact contact : account.getRoster().getContacts()) {
Presence.Status s = contact.getShownStatus();
if (contact.showInRoster() && contact.match(this, needle)
if ((contact.showInRoster() || (singleAccountActive && contact.showInPhoneBook())) && contact.match(this, needle)
&& (!this.mHideOfflineContacts
|| (needle != null && !needle.trim().isEmpty())
|| s.compareTo(Presence.Status.OFFLINE) < 0)) {
@ -875,6 +877,16 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
mContactsAdapter.notifyDataSetChanged();
}
private static boolean isSingleAccountActive(final List<Account> accounts) {
int i = 0;
for(Account account : accounts) {
if (account.getStatus() != Account.State.DISABLED) {
++i;
}
}
return i == 1;
}
protected void filterConferences(String needle) {
this.conferences.clear();
for (Account account : xmppConnectionService.getAccounts()) {

View File

@ -724,4 +724,5 @@
<string name="providing_a_name_is_optional">Providing a name is optional</string>
<string name="create_dialog_group_chat_name">Group chat name</string>
<string name="conference_destroyed">This group chat has been destroyed</string>
<string name="phone_book">Address book</string>
</resources>