diff options
author | hlad <hladma@gmail.com> | 2015-09-04 14:33:50 +0200 |
---|---|---|
committer | Christian S <christian@pix-art.de> | 2015-10-22 19:19:49 +0200 |
commit | 887de0becc791889299ff7d13bee0bc7feac97a1 (patch) | |
tree | e8e5e25898f262fd85a719d0f9fb32420ed77c93 /src/main/java | |
parent | b54b4ca78a85055292ea54b5acfaaec25c43f412 (diff) |
show resource in dynamic tags
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/eu/siacs/conversations/entities/Contact.java | 7 | ||||
-rw-r--r-- | src/main/java/eu/siacs/conversations/entities/Presences.java | 15 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/Contact.java b/src/main/java/eu/siacs/conversations/entities/Contact.java index f924c05a1..f5fa88d7a 100644 --- a/src/main/java/eu/siacs/conversations/entities/Contact.java +++ b/src/main/java/eu/siacs/conversations/entities/Contact.java @@ -149,6 +149,9 @@ public class Contact implements ListItem, Blockable { if (isBlocked()) { tags.add(new Tag("blocked", 0xff2e2f3b)); } + if (!getMostAvailableResource().equals("")){ + tags.add(new Tag(getMostAvailableResource(), 0xff37b8a9)); + } return tags; } @@ -239,6 +242,10 @@ public class Contact implements ListItem, Blockable { return this.presences.getMostAvailableStatus(); } + public String getMostAvailableResource() { + return this.presences.getMostAvailableResource(); + } + public boolean setPhotoUri(String uri) { if (uri != null && !uri.equals(this.photoUri)) { this.photoUri = uri; diff --git a/src/main/java/eu/siacs/conversations/entities/Presences.java b/src/main/java/eu/siacs/conversations/entities/Presences.java index bccf31170..f233d015f 100644 --- a/src/main/java/eu/siacs/conversations/entities/Presences.java +++ b/src/main/java/eu/siacs/conversations/entities/Presences.java @@ -52,6 +52,21 @@ public class Presences { return status; } + public String getMostAvailableResource() { + int status = OFFLINE; + String resource = ""; + synchronized (this.presences) { + Iterator<Entry<String, Integer>> it = presences.entrySet().iterator(); + while (it.hasNext()) { + Entry<String, Integer> entry = it.next(); + if (entry.getValue() < status) + status = entry.getValue(); + resource = entry.getKey(); + } + } + return resource; + } + public static int parseShow(Element show) { if ((show == null) || (show.getContent() == null)) { return Presences.ONLINE; |