From 2c31fbae787164c58e7a085bc889e87b5e48f70c Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Wed, 31 Oct 2018 10:52:14 +0100 Subject: [PATCH] show synced contacts in choose contact activity --- .../java/eu/siacs/conversations/entities/Contact.java | 9 ++------- .../eu/siacs/conversations/entities/Conversation.java | 3 +-- .../java/eu/siacs/conversations/entities/Message.java | 2 +- .../eu/siacs/conversations/ui/ChooseContactActivity.java | 2 +- .../conversations/ui/StartConversationActivity.java | 3 +-- src/main/res/values/strings.xml | 1 - 6 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/entities/Contact.java b/src/main/java/eu/siacs/conversations/entities/Contact.java index 26204a1dd..f1f3b58c0 100644 --- a/src/main/java/eu/siacs/conversations/entities/Contact.java +++ b/src/main/java/eu/siacs/conversations/entities/Contact.java @@ -4,7 +4,6 @@ import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.net.Uri; -import android.provider.ContactsContract; import android.support.annotation.NonNull; import android.text.TextUtils; @@ -22,7 +21,6 @@ import eu.siacs.conversations.Config; import eu.siacs.conversations.R; import eu.siacs.conversations.android.AbstractPhoneContact; import eu.siacs.conversations.android.JabberIdContact; -import eu.siacs.conversations.android.PhoneNumberContact; import eu.siacs.conversations.utils.JidHelper; import eu.siacs.conversations.utils.UIHelper; import eu.siacs.conversations.xml.Element; @@ -165,9 +163,6 @@ 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; } @@ -341,8 +336,8 @@ public class Contact implements ListItem, Blockable { || (this.getOption(Contact.Options.DIRTY_PUSH)); } - public boolean showInPhoneBook() { - return systemAccount != null; + public boolean showInContactList() { + return showInRoster() || getOption(Options.SYNCED_VIA_OTHER); } public void parseSubscriptionFromElement(Element item) { diff --git a/src/main/java/eu/siacs/conversations/entities/Conversation.java b/src/main/java/eu/siacs/conversations/entities/Conversation.java index f40ede2e9..bcde9eeb5 100644 --- a/src/main/java/eu/siacs/conversations/entities/Conversation.java +++ b/src/main/java/eu/siacs/conversations/entities/Conversation.java @@ -929,9 +929,8 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl final Contact contact = getContact(); return mode == MODE_SINGLE && !contact.isOwnServer() - && !contact.showInRoster() + && !contact.showInContactList() && !contact.isSelf() - && !contact.showInPhoneBook() && sentMessagesCount() == 0; } diff --git a/src/main/java/eu/siacs/conversations/entities/Message.java b/src/main/java/eu/siacs/conversations/entities/Message.java index 6cbcad7d6..0ba7b1516 100644 --- a/src/main/java/eu/siacs/conversations/entities/Message.java +++ b/src/main/java/eu/siacs/conversations/entities/Message.java @@ -660,7 +660,7 @@ public class Message extends AbstractEntity { public boolean trusted() { Contact contact = this.getContact(); - return status > STATUS_RECEIVED || (contact != null && (contact.showInRoster() || contact.isSelf())); + return status > STATUS_RECEIVED || (contact != null && (contact.showInContactList() || contact.isSelf())); } public boolean fixCounterpart() { diff --git a/src/main/java/eu/siacs/conversations/ui/ChooseContactActivity.java b/src/main/java/eu/siacs/conversations/ui/ChooseContactActivity.java index f44174780..3fce16b38 100644 --- a/src/main/java/eu/siacs/conversations/ui/ChooseContactActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ChooseContactActivity.java @@ -263,7 +263,7 @@ public class ChooseContactActivity extends AbstractSearchableListItemActivity im for (final Account account : xmppConnectionService.getAccounts()) { if (account.getStatus() != Account.State.DISABLED) { for (final Contact contact : account.getRoster().getContacts()) { - if (contact.showInRoster() && + if (contact.showInContactList() && !filterContacts.contains(contact.getJid().asBareJid().toString()) && contact.match(this, needle)) { getListItems().add(contact); diff --git a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java index 56a38877c..598bfc3c6 100644 --- a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java @@ -860,12 +860,11 @@ public class StartConversationActivity extends XmppActivity implements XmppConne protected void filterContacts(String needle) { this.contacts.clear(); final List 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() || (singleAccountActive && contact.showInPhoneBook())) && contact.match(this, needle) + if (contact.showInContactList() && contact.match(this, needle) && (!this.mHideOfflineContacts || (needle != null && !needle.trim().isEmpty()) || s.compareTo(Presence.Status.OFFLINE) < 0)) { diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 74f597d70..c49652c3c 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -725,7 +725,6 @@ Providing a name is optional Group chat name This group chat has been destroyed - Address book Unable to save recording Foreground service This notification category is used to display a permanent notification indicating that Conversations is running.