show synced contacts in choose contact activity

This commit is contained in:
Daniel Gultsch 2018-10-31 10:52:14 +01:00
parent 3efb5b7f5c
commit 2c31fbae78
6 changed files with 6 additions and 14 deletions

View file

@ -4,7 +4,6 @@ import android.content.ContentValues;
import android.content.Context; import android.content.Context;
import android.database.Cursor; import android.database.Cursor;
import android.net.Uri; import android.net.Uri;
import android.provider.ContactsContract;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.text.TextUtils; import android.text.TextUtils;
@ -22,7 +21,6 @@ import eu.siacs.conversations.Config;
import eu.siacs.conversations.R; import eu.siacs.conversations.R;
import eu.siacs.conversations.android.AbstractPhoneContact; import eu.siacs.conversations.android.AbstractPhoneContact;
import eu.siacs.conversations.android.JabberIdContact; import eu.siacs.conversations.android.JabberIdContact;
import eu.siacs.conversations.android.PhoneNumberContact;
import eu.siacs.conversations.utils.JidHelper; import eu.siacs.conversations.utils.JidHelper;
import eu.siacs.conversations.utils.UIHelper; import eu.siacs.conversations.utils.UIHelper;
import eu.siacs.conversations.xml.Element; import eu.siacs.conversations.xml.Element;
@ -165,9 +163,6 @@ public class Contact implements ListItem, Blockable {
if (isBlocked()) { if (isBlocked()) {
tags.add(new Tag(context.getString(R.string.blocked), 0xff2e2f3b)); 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; return tags;
} }
@ -341,8 +336,8 @@ public class Contact implements ListItem, Blockable {
|| (this.getOption(Contact.Options.DIRTY_PUSH)); || (this.getOption(Contact.Options.DIRTY_PUSH));
} }
public boolean showInPhoneBook() { public boolean showInContactList() {
return systemAccount != null; return showInRoster() || getOption(Options.SYNCED_VIA_OTHER);
} }
public void parseSubscriptionFromElement(Element item) { public void parseSubscriptionFromElement(Element item) {

View file

@ -929,9 +929,8 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
final Contact contact = getContact(); final Contact contact = getContact();
return mode == MODE_SINGLE return mode == MODE_SINGLE
&& !contact.isOwnServer() && !contact.isOwnServer()
&& !contact.showInRoster() && !contact.showInContactList()
&& !contact.isSelf() && !contact.isSelf()
&& !contact.showInPhoneBook()
&& sentMessagesCount() == 0; && sentMessagesCount() == 0;
} }

View file

@ -660,7 +660,7 @@ public class Message extends AbstractEntity {
public boolean trusted() { public boolean trusted() {
Contact contact = this.getContact(); 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() { public boolean fixCounterpart() {

View file

@ -263,7 +263,7 @@ public class ChooseContactActivity extends AbstractSearchableListItemActivity im
for (final Account account : xmppConnectionService.getAccounts()) { for (final Account account : xmppConnectionService.getAccounts()) {
if (account.getStatus() != Account.State.DISABLED) { if (account.getStatus() != Account.State.DISABLED) {
for (final Contact contact : account.getRoster().getContacts()) { for (final Contact contact : account.getRoster().getContacts()) {
if (contact.showInRoster() && if (contact.showInContactList() &&
!filterContacts.contains(contact.getJid().asBareJid().toString()) !filterContacts.contains(contact.getJid().asBareJid().toString())
&& contact.match(this, needle)) { && contact.match(this, needle)) {
getListItems().add(contact); getListItems().add(contact);

View file

@ -860,12 +860,11 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
protected void filterContacts(String needle) { protected void filterContacts(String needle) {
this.contacts.clear(); this.contacts.clear();
final List<Account> accounts = xmppConnectionService.getAccounts(); final List<Account> accounts = xmppConnectionService.getAccounts();
final boolean singleAccountActive = isSingleAccountActive(accounts);
for (Account account : accounts) { for (Account account : accounts) {
if (account.getStatus() != Account.State.DISABLED) { if (account.getStatus() != Account.State.DISABLED) {
for (Contact contact : account.getRoster().getContacts()) { for (Contact contact : account.getRoster().getContacts()) {
Presence.Status s = contact.getShownStatus(); Presence.Status s = contact.getShownStatus();
if ((contact.showInRoster() || (singleAccountActive && contact.showInPhoneBook())) && contact.match(this, needle) if (contact.showInContactList() && contact.match(this, needle)
&& (!this.mHideOfflineContacts && (!this.mHideOfflineContacts
|| (needle != null && !needle.trim().isEmpty()) || (needle != null && !needle.trim().isEmpty())
|| s.compareTo(Presence.Status.OFFLINE) < 0)) { || s.compareTo(Presence.Status.OFFLINE) < 0)) {

View file

@ -725,7 +725,6 @@
<string name="providing_a_name_is_optional">Providing a name is optional</string> <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="create_dialog_group_chat_name">Group chat name</string>
<string name="conference_destroyed">This group chat has been destroyed</string> <string name="conference_destroyed">This group chat has been destroyed</string>
<string name="phone_book">Address book</string>
<string name="unable_to_save_recording">Unable to save recording</string> <string name="unable_to_save_recording">Unable to save recording</string>
<string name="foreground_service_channel_name">Foreground service</string> <string name="foreground_service_channel_name">Foreground service</string>
<string name="foreground_service_channel_description">This notification category is used to display a permanent notification indicating that Conversations is running.</string> <string name="foreground_service_channel_description">This notification category is used to display a permanent notification indicating that Conversations is running.</string>