Change summary
src/main/java/eu/siacs/conversations/entities/Contact.java | 7
src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java | 16
src/main/res/values/strings.xml | 1
3 files changed, 22 insertions(+), 2 deletions(-)
Detailed changes
@@ -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");
@@ -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()) {
@@ -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>