@@ -13,10 +13,13 @@ import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import eu.siacs.conversations.Config;
+import eu.siacs.conversations.R;
import eu.siacs.conversations.utils.JidHelper;
import eu.siacs.conversations.utils.UIHelper;
import eu.siacs.conversations.xml.Element;
@@ -143,7 +146,7 @@ public class Contact implements ListItem, Blockable {
@Override
public List<Tag> getTags(Context context) {
final ArrayList<Tag> tags = new ArrayList<>();
- for (final String group : getGroups()) {
+ for (final String group : getGroups(true)) {
tags.add(new Tag(group, UIHelper.getColorForName(group)));
}
Presence.Status status = getShownStatus();
@@ -151,7 +154,7 @@ public class Contact implements ListItem, Blockable {
tags.add(UIHelper.getTagForStatus(context, status));
}
if (isBlocked()) {
- tags.add(new Tag("blocked", 0xff2e2f3b));
+ tags.add(new Tag(context.getString(R.string.blocked), 0xff2e2f3b));
}
return tags;
}
@@ -281,8 +284,8 @@ public class Contact implements ListItem, Blockable {
this.systemAccount = account;
}
- private List<String> getGroups() {
- ArrayList<String> groups = new ArrayList<>();
+ private Collection<String> getGroups(final boolean unique) {
+ final Collection<String> groups = unique ? new HashSet<>() : new ArrayList<>();
for (int i = 0; i < this.groups.length(); ++i) {
try {
groups.add(this.groups.getString(i));
@@ -387,7 +390,7 @@ public class Contact implements ListItem, Blockable {
if (this.serverName != null) {
item.setAttribute("name", this.serverName);
}
- for (String group : getGroups()) {
+ for (String group : getGroups(false)) {
item.addChild("group").setContent(group);
}
return item;
@@ -42,6 +42,7 @@
<string name="block_domain_text">Block all contacts from %s?</string>
<string name="unblock_domain_text">Unblock all contacts from %s?</string>
<string name="contact_blocked">Contact blocked</string>
+ <string name="blocked">Blocked</string>
<string name="remove_bookmark_text">Would you like to remove %s as a bookmark? The conversation associated with this bookmark will not be removed.</string>
<string name="register_account">Register new account on server</string>
<string name="change_password_on_server">Change password on server</string>