From 3218ca3fe3fcb0e3281b47145290662d6de1b773 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 30 Jun 2018 12:14:42 +0200 Subject: [PATCH] shorten read markers to 'everyone has read up to this point' when > 4 user --- .../java/eu/siacs/conversations/entities/ReadByMarker.java | 7 +++++++ .../eu/siacs/conversations/ui/ConversationFragment.java | 2 ++ src/main/res/values/strings.xml | 1 + 3 files changed, 10 insertions(+) diff --git a/src/main/java/eu/siacs/conversations/entities/ReadByMarker.java b/src/main/java/eu/siacs/conversations/entities/ReadByMarker.java index 0d9ea1b06..c492b4c81 100644 --- a/src/main/java/eu/siacs/conversations/entities/ReadByMarker.java +++ b/src/main/java/eu/siacs/conversations/entities/ReadByMarker.java @@ -6,6 +6,7 @@ import org.json.JSONObject; import java.util.Collection; import java.util.HashSet; +import java.util.List; import java.util.Set; import rocks.xmpp.addr.Jid; @@ -162,4 +163,10 @@ public class ReadByMarker { return true; } + public static boolean allUsersRepresented(Collection users, Set markers, ReadByMarker marker) { + HashSet markersCopy = new HashSet<>(markers); + markersCopy.add(marker); + return allUsersRepresented(users, markersCopy); + } + } diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index 7d844c4ed..fd593054b 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -2197,6 +2197,8 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke final String body; if (size <= 4) { body = getString(R.string.contacts_have_read_up_to_this_point, UIHelper.concatNames(shownMarkers)); + } else if (ReadByMarker.allUsersRepresented(allUsers, markersForMessage, markerForSender)) { + body = getString(R.string.everyone_has_read_up_to_this_point); } else { body = getString(R.string.contacts_and_n_more_have_read_up_to_this_point, UIHelper.concatNames(shownMarkers, 3), size - 3); } diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 10761ff5d..a16c26955 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -237,6 +237,7 @@ %s has read up to this point %s have read up to this point %1$s +%2$d more have read up to this point + Everyone has read up to this point Publish Touch avatar to select picture from gallery Publishing…