diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2016-06-30 23:08:55 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2016-07-01 16:26:04 +0200 |
commit | f0151ac61a67df4a630c01a37f7a51142b9a9ea1 (patch) | |
tree | 6e0a2edcdb4da28f5c154cccfb3099872188c21f | |
parent | 63731c4567806d7809b4486fc44dd7ca954199a9 (diff) |
use dnd as overriding status
4 files changed, 15 insertions, 14 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/Contact.java b/src/main/java/eu/siacs/conversations/entities/Contact.java index fa6c79ece..f48a052f8 100644 --- a/src/main/java/eu/siacs/conversations/entities/Contact.java +++ b/src/main/java/eu/siacs/conversations/entities/Contact.java @@ -148,7 +148,7 @@ public class Contact implements ListItem, Blockable { for (final String group : getGroups()) { tags.add(new Tag(group, UIHelper.getColorForName(group))); } - Presence.Status status = getMostAvailableStatus(); + Presence.Status status = getShownStatus(); if (status != Presence.Status.OFFLINE) { tags.add(UIHelper.getTagForStatus(context, status)); } @@ -237,13 +237,8 @@ public class Contact implements ListItem, Blockable { this.resetOption(Options.PENDING_SUBSCRIPTION_REQUEST); } - public Presence.Status getMostAvailableStatus() { - Presence p = this.presences.getMostAvailablePresence(); - if (p == null) { - return Presence.Status.OFFLINE; - } - - return p.getStatus(); + public Presence.Status getShownStatus() { + return this.presences.getShownStatus(); } public boolean setPhotoUri(String uri) { diff --git a/src/main/java/eu/siacs/conversations/entities/Presences.java b/src/main/java/eu/siacs/conversations/entities/Presences.java index b3e8966a7..b9e3e3ab1 100644 --- a/src/main/java/eu/siacs/conversations/entities/Presences.java +++ b/src/main/java/eu/siacs/conversations/entities/Presences.java @@ -30,11 +30,18 @@ public class Presences { } } - public Presence getMostAvailablePresence() { + public Presence.Status getShownStatus() { + Presence.Status status = Presence.Status.OFFLINE; synchronized (this.presences) { - if (presences.size() < 1) { return null; } - return Collections.min(presences.values()); + for(Presence p : presences.values()) { + if (p.getStatus() == Presence.Status.DND) { + return p.getStatus(); + } else if (p.getStatus().compareTo(status) < 0){ + status = p.getStatus(); + } + } } + return status; } public int size() { diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index 9a77896f9..336f2abe6 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -1094,7 +1094,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa if (activity.useSendButtonToIndicateStatus() && c != null && c.getAccount().getStatus() == Account.State.ONLINE) { if (c.getMode() == Conversation.MODE_SINGLE) { - status = c.getContact().getMostAvailableStatus(); + status = c.getContact().getShownStatus(); } else { status = c.getMucOptions().online() ? Presence.Status.ONLINE : Presence.Status.OFFLINE; } diff --git a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java index 3a515703f..f94184d48 100644 --- a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java @@ -892,8 +892,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU for (Account account : xmppConnectionService.getAccounts()) { if (account.getStatus() != Account.State.DISABLED) { for (Contact contact : account.getRoster().getContacts()) { - Presence p = contact.getPresences().getMostAvailablePresence(); - Presence.Status s = p == null ? Presence.Status.OFFLINE : p.getStatus(); + Presence.Status s = contact.getShownStatus(); if (contact.showInRoster() && contact.match(this, needle) && (!this.mHideOfflineContacts || (needle != null && !needle.trim().isEmpty()) |