shorten read markers to 'everyone has read up to this point' when > 4 user

Daniel Gultsch created

Change summary

src/main/java/eu/siacs/conversations/entities/ReadByMarker.java   | 7 +
src/main/java/eu/siacs/conversations/ui/ConversationFragment.java | 2 
src/main/res/values/strings.xml                                   | 1 
3 files changed, 10 insertions(+)

Detailed changes

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<MucOptions.User> users, Set<ReadByMarker> markers, ReadByMarker marker) {
+		HashSet<ReadByMarker> markersCopy = new HashSet<>(markers);
+		markersCopy.add(marker);
+		return allUsersRepresented(users, markersCopy);
+	}
+
 }

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);
 							}

src/main/res/values/strings.xml 🔗

@@ -237,6 +237,7 @@
     <string name="contact_has_read_up_to_this_point">%s has read up to this point</string>
     <string name="contacts_have_read_up_to_this_point">%s have read up to this point</string>
     <string name="contacts_and_n_more_have_read_up_to_this_point">%1$s +%2$d more have read up to this point</string>
+    <string name="everyone_has_read_up_to_this_point">Everyone has read up to this point</string>
     <string name="publish">Publish</string>
     <string name="touch_to_choose_picture">Touch avatar to select picture from gallery</string>
     <string name="publishing">Publishing…</string>