Skip to content

Commit 3506f2d

Browse files
caschebergmoxie0
authored andcommitted
Improve group update descriptions
Closes signalapp#5416 // FREEBIE
1 parent 66c9fd4 commit 3506f2d

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

res/values/strings.xml

+3-2
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,8 @@
408408
<!-- MessageRecord -->
409409
<string name="MessageRecord_message_encrypted_with_a_legacy_protocol_version_that_is_no_longer_supported">Received a message encrypted using an old version of Signal that is no longer supported. Please ask the sender to update to the most recent version and resend the message.</string>
410410
<string name="MessageRecord_left_group">You have left the group.</string>
411-
<string name="MessageRecord_updated_group">Updated the group.</string>
411+
<string name="MessageRecord_you_updated_group">You updated the group.</string>
412+
<string name="MessageRecord_s_updated_group">%s updated the group.</string>
412413
<string name="MessageRecord_s_called_you">%s called you</string>
413414
<string name="MessageRecord_called_s">Called %s</string>
414415
<string name="MessageRecord_missed_call_from">Missed call from %s</string>
@@ -575,6 +576,7 @@
575576
<string name="SmsMessageRecord_duplicate_message">Duplicate message.</string>
576577

577578
<!-- ThreadRecord -->
579+
<string name="ThreadRecord_group_updated">Group updated</string>
578580
<string name="ThreadRecord_left_the_group">Left the group</string>
579581
<string name="ThreadRecord_secure_session_reset">Secure session reset.</string>
580582
<string name="ThreadRecord_draft">Draft:</string>
@@ -886,7 +888,6 @@
886888
<item quantity="one">%1$s joined the group.</item>
887889
<item quantity="other">%1$s joined the group.</item>
888890
</plurals>
889-
<string name="GroupUtil_group_updated">Group updated.</string>
890891
<string name="GroupUtil_group_name_is_now">Group name is now \'%1$s\'.</string>
891892

892893
<!-- prompt_passphrase_activity -->

src/org/thoughtcrime/securesms/database/model/MessageRecord.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
import org.thoughtcrime.securesms.R;
2626
import org.thoughtcrime.securesms.database.MmsSmsColumns;
2727
import org.thoughtcrime.securesms.database.SmsDatabase;
28-
import org.thoughtcrime.securesms.database.documents.NetworkFailure;
2928
import org.thoughtcrime.securesms.database.documents.IdentityKeyMismatch;
29+
import org.thoughtcrime.securesms.database.documents.NetworkFailure;
3030
import org.thoughtcrime.securesms.recipients.Recipient;
3131
import org.thoughtcrime.securesms.recipients.Recipients;
3232
import org.thoughtcrime.securesms.util.ExpirationUtil;
@@ -93,9 +93,9 @@ public boolean isAsymmetricEncryption() {
9393
@Override
9494
public SpannableString getDisplayBody() {
9595
if (isGroupUpdate() && isOutgoing()) {
96-
return emphasisAdded(context.getString(R.string.MessageRecord_updated_group));
96+
return emphasisAdded(context.getString(R.string.MessageRecord_you_updated_group));
9797
} else if (isGroupUpdate()) {
98-
return emphasisAdded(GroupUtil.getDescription(context, getBody().getBody()).toString());
98+
return emphasisAdded(GroupUtil.getDescription(context, getBody().getBody()).toString(getIndividualRecipient()));
9999
} else if (isGroupQuit() && isOutgoing()) {
100100
return emphasisAdded(context.getString(R.string.MessageRecord_left_group));
101101
} else if (isGroupQuit()) {

src/org/thoughtcrime/securesms/database/model/ThreadRecord.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@
2828
import org.thoughtcrime.securesms.R;
2929
import org.thoughtcrime.securesms.database.MmsSmsColumns;
3030
import org.thoughtcrime.securesms.database.SmsDatabase;
31-
import org.thoughtcrime.securesms.database.ThreadDatabase;
3231
import org.thoughtcrime.securesms.recipients.Recipients;
3332
import org.thoughtcrime.securesms.util.ExpirationUtil;
34-
import org.thoughtcrime.securesms.util.GroupUtil;
3533

3634
/**
3735
* The message record model which represents thread heading messages.
@@ -75,7 +73,7 @@ public SpannableString getDisplayBody() {
7573
if (SmsDatabase.Types.isDecryptInProgressType(type)) {
7674
return emphasisAdded(context.getString(R.string.MessageDisplayHelper_decrypting_please_wait));
7775
} else if (isGroupUpdate()) {
78-
return emphasisAdded(GroupUtil.getDescription(context, getBody().getBody()).toString());
76+
return emphasisAdded(context.getString(R.string.ThreadRecord_group_updated));
7977
} else if (isGroupQuit()) {
8078
return emphasisAdded(context.getString(R.string.ThreadRecord_left_the_group));
8179
} else if (isKeyExchange()) {

src/org/thoughtcrime/securesms/util/GroupUtil.java

+12-11
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import android.util.Log;
77

88
import org.thoughtcrime.securesms.R;
9+
import org.thoughtcrime.securesms.recipients.Recipient;
910
import org.thoughtcrime.securesms.recipients.RecipientFactory;
1011
import org.thoughtcrime.securesms.recipients.Recipients;
1112

@@ -61,33 +62,33 @@ public GroupDescription(@NonNull Context context, @Nullable GroupContext groupCo
6162
if (groupContext == null || groupContext.getMembersList().isEmpty()) {
6263
this.members = null;
6364
} else {
64-
this.members = RecipientFactory.getRecipientsFromString(context, Util.join(groupContext.getMembersList(), ", "), true);
65+
this.members = RecipientFactory.getRecipientsFromStrings(context, groupContext.getMembersList(), true);
6566
}
6667
}
6768

68-
public String toString() {
69+
public String toString(Recipient sender) {
70+
StringBuilder description = new StringBuilder();
71+
description.append(context.getString(R.string.MessageRecord_s_updated_group, sender.toShortString()));
72+
6973
if (groupContext == null) {
70-
return context.getString(R.string.GroupUtil_group_updated);
74+
return description.toString();
7175
}
7276

73-
StringBuilder description = new StringBuilder();
74-
String title = groupContext.getName();
77+
String title = groupContext.getName();
7578

7679
if (members != null) {
80+
description.append("\n");
7781
description.append(context.getResources().getQuantityString(R.plurals.GroupUtil_joined_the_group,
7882
members.getRecipientsList().size(), members.toShortString()));
7983
}
8084

8185
if (title != null && !title.trim().isEmpty()) {
82-
if (description.length() > 0) description.append(" ");
86+
if (members != null) description.append(" ");
87+
else description.append("\n");
8388
description.append(context.getString(R.string.GroupUtil_group_name_is_now, title));
8489
}
8590

86-
if (description.length() > 0) {
87-
return description.toString();
88-
} else {
89-
return context.getString(R.string.GroupUtil_group_updated);
90-
}
91+
return description.toString();
9192
}
9293

9394
public void addListener(Recipients.RecipientsModifiedListener listener) {

0 commit comments

Comments
 (0)