aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2016-06-30 23:08:55 +0200
committerDaniel Gultsch <daniel@gultsch.de>2016-06-30 23:08:55 +0200
commit30110431ba0d0833519b5bbb5427d6373f247c85 (patch)
tree6114e6e774b6468a739b5c8e26bda238cb6f3cf1 /src
parent91c3732c630064b0d23b910b951495c65447e194 (diff)
use dnd as overriding status
Diffstat (limited to 'src')
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Contact.java11
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Presences.java13
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConversationFragment.java2
-rw-r--r--src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java4
4 files changed, 15 insertions, 15 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/Contact.java b/src/main/java/eu/siacs/conversations/entities/Contact.java
index 551b6aab..f061413b 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 9e94ff2b..6391f5bb 100644
--- a/src/main/java/eu/siacs/conversations/entities/Presences.java
+++ b/src/main/java/eu/siacs/conversations/entities/Presences.java
@@ -34,11 +34,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 2755a661..6dfd3c2d 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
@@ -1083,7 +1083,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 17f9944f..f94184d4 100644
--- a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java
@@ -56,7 +56,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import java.util.concurrent.RunnableFuture;
import java.util.concurrent.atomic.AtomicBoolean;
import eu.siacs.conversations.Config;
@@ -893,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())