diff options
author | Christian S <christian@pix-art.de> | 2015-10-22 19:21:02 +0200 |
---|---|---|
committer | Christian S <christian@pix-art.de> | 2015-10-22 19:21:26 +0200 |
commit | 2200ba240ad06096e49268309a5fa2cbc99ab147 (patch) | |
tree | 4ebd4af7b5347c9ac5d6b4658afa3704dc0865d9 /src/main/java/eu | |
parent | e7f0508713713f88f2ce7cd092a061ba65991137 (diff) | |
parent | 887de0becc791889299ff7d13bee0bc7feac97a1 (diff) |
Merge 'hlad/hlad' into development
Diffstat (limited to 'src/main/java/eu')
-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; |