diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-09-11 21:10:33 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-09-11 21:10:33 +0200 |
commit | 8c6030e0bf8e90a3ba67dbc6155adb2ff9000d1c (patch) | |
tree | c97423f39aae21929b93fe7f96c8d82788eafb61 /src/main/java/de | |
parent | bcafe9a16ec636256b6b3a62732b78f66ea136c2 (diff) |
show jids from address book in Start Conversation screen if only one account is used
Diffstat (limited to 'src/main/java/de')
-rw-r--r-- | src/main/java/de/pixart/messenger/entities/Contact.java | 7 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/StartConversationActivity.java | 16 |
2 files changed, 21 insertions, 2 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/Contact.java b/src/main/java/de/pixart/messenger/entities/Contact.java index 40bd69976..6d07c5901 100644 --- a/src/main/java/de/pixart/messenger/entities/Contact.java +++ b/src/main/java/de/pixart/messenger/entities/Contact.java @@ -159,6 +159,9 @@ public class Contact implements ListItem, Blockable { if (isBlocked()) { tags.add(new Tag(context.getString(R.string.blocked), 0xff2e2f3b, 0)); } + if (showInPhoneBook()) { + tags.add(new Tag(context.getString(R.string.phone_book), 0xFF1E88E5, 0)); + } return tags; } @@ -384,6 +387,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"); diff --git a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java index 4e02df3ea..663905b7d 100644 --- a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java +++ b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java @@ -874,11 +874,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)) { @@ -891,6 +893,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()) { |