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 | |
parent | bcafe9a16ec636256b6b3a62732b78f66ea136c2 (diff) |
show jids from address book in Start Conversation screen if only one account is used
Diffstat (limited to 'src/main')
-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 | ||||
-rw-r--r-- | src/main/res/values/strings.xml | 1 |
3 files changed, 22 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()) { diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index f5dabc615..0c471ca79 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -812,4 +812,5 @@ <string name="pref_show_record_voice_btn">Show record voice button</string> <string name="pref_use_quick_share_attachment_choice_summary">Replace send button with attachment choice if no message is typed. Otherwise show quick actions, which can be cofigured in the following setting.</string> <string name="pref_quick_share_attachment_choice">Attachment choice</string> + <string name="phone_book">Address book</string> </resources> |