deduplicate tags + translate 'blocked' tag
This commit is contained in:
parent
13f1a23889
commit
582178991b
|
@ -13,10 +13,13 @@ import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import eu.siacs.conversations.Config;
|
import eu.siacs.conversations.Config;
|
||||||
|
import eu.siacs.conversations.R;
|
||||||
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;
|
||||||
|
@ -143,7 +146,7 @@ public class Contact implements ListItem, Blockable {
|
||||||
@Override
|
@Override
|
||||||
public List<Tag> getTags(Context context) {
|
public List<Tag> getTags(Context context) {
|
||||||
final ArrayList<Tag> tags = new ArrayList<>();
|
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)));
|
tags.add(new Tag(group, UIHelper.getColorForName(group)));
|
||||||
}
|
}
|
||||||
Presence.Status status = getShownStatus();
|
Presence.Status status = getShownStatus();
|
||||||
|
@ -151,7 +154,7 @@ public class Contact implements ListItem, Blockable {
|
||||||
tags.add(UIHelper.getTagForStatus(context, status));
|
tags.add(UIHelper.getTagForStatus(context, status));
|
||||||
}
|
}
|
||||||
if (isBlocked()) {
|
if (isBlocked()) {
|
||||||
tags.add(new Tag("blocked", 0xff2e2f3b));
|
tags.add(new Tag(context.getString(R.string.blocked), 0xff2e2f3b));
|
||||||
}
|
}
|
||||||
return tags;
|
return tags;
|
||||||
}
|
}
|
||||||
|
@ -281,8 +284,8 @@ public class Contact implements ListItem, Blockable {
|
||||||
this.systemAccount = account;
|
this.systemAccount = account;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> getGroups() {
|
private Collection<String> getGroups(final boolean unique) {
|
||||||
ArrayList<String> groups = new ArrayList<>();
|
final Collection<String> groups = unique ? new HashSet<>() : new ArrayList<>();
|
||||||
for (int i = 0; i < this.groups.length(); ++i) {
|
for (int i = 0; i < this.groups.length(); ++i) {
|
||||||
try {
|
try {
|
||||||
groups.add(this.groups.getString(i));
|
groups.add(this.groups.getString(i));
|
||||||
|
@ -387,7 +390,7 @@ public class Contact implements ListItem, Blockable {
|
||||||
if (this.serverName != null) {
|
if (this.serverName != null) {
|
||||||
item.setAttribute("name", this.serverName);
|
item.setAttribute("name", this.serverName);
|
||||||
}
|
}
|
||||||
for (String group : getGroups()) {
|
for (String group : getGroups(false)) {
|
||||||
item.addChild("group").setContent(group);
|
item.addChild("group").setContent(group);
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
<string name="block_domain_text">Block all contacts from %s?</string>
|
<string name="block_domain_text">Block all contacts from %s?</string>
|
||||||
<string name="unblock_domain_text">Unblock 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="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="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="register_account">Register new account on server</string>
|
||||||
<string name="change_password_on_server">Change password on server</string>
|
<string name="change_password_on_server">Change password on server</string>
|
||||||
|
|
Loading…
Reference in New Issue