Skip to content

Commit

Permalink
Use matching color for read conversation sender names.
Browse files Browse the repository at this point in the history
  • Loading branch information
alan-signal authored and greyson-signal committed Feb 3, 2021
1 parent af7e736 commit 3e2349c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
Expand Up @@ -493,7 +493,7 @@ public void onRecipientChanged(@NonNull Recipient recipient) {
if (thread.getRecipient().isGroup()) {
RecipientId groupMessageSender = thread.getGroupMessageSender();
if (!groupMessageSender.isUnknown()) {
return describeGroupMessage(context, body, groupMessageSender);
return describeGroupMessage(context, body, groupMessageSender, thread.isRead());
}
}
return LiveDataUtil.just(new SpannableString(body));
Expand All @@ -503,21 +503,24 @@ public void onRecipientChanged(@NonNull Recipient recipient) {

private static LiveData<SpannableString> describeGroupMessage(@NonNull Context context,
@NonNull String body,
@NonNull RecipientId groupMessageSender)
@NonNull RecipientId groupMessageSender,
boolean read)
{
return whileLoadingShow(body, recipientToStringAsync(groupMessageSender,
r -> createGroupMessageUpdateString(context, body, r)));
r -> createGroupMessageUpdateString(context, body, r, read)));
}

private static SpannableString createGroupMessageUpdateString(@NonNull Context context,
@NonNull String body,
@NonNull Recipient recipient)
@NonNull Recipient recipient,
boolean read)
{
String sender = (recipient.isSelf() ? context.getString(R.string.MessageRecord_you)
: recipient.getShortDisplayName(context)) + ": ";

SpannableString spannable = new SpannableString(sender + body);
spannable.setSpan(new TextAppearanceSpan(context, R.style.Signal_Text_Preview_Medium),
spannable.setSpan(new TextAppearanceSpan(context, read ? R.style.Signal_Text_Preview_Medium_Secondary
: R.style.Signal_Text_Preview_Medium_Primary),
0,
sender.length(),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/values/text_styles.xml
Expand Up @@ -26,6 +26,14 @@
<item name="android:fontFamily">sans-serif-medium</item>
</style>

<style name="Signal.Text.Preview.Medium.Primary">
<item name="android:textColor">@color/signal_text_primary</item>
</style>

<style name="Signal.Text.Preview.Medium.Secondary">
<item name="android:textColor">@color/signal_text_secondary</item>
</style>

<style name="Signal.Text.Caption" parent="Base.TextAppearance.AppCompat.Caption">
<item name="android:textSize">12sp</item>
<item name="android:lineSpacingExtra">2sp</item>
Expand Down

0 comments on commit 3e2349c

Please sign in to comment.