Fix search showing received mention messages as note to self.

This commit is contained in:
Clark
2023-07-24 13:04:10 -04:00
committed by Greyson Parrelli
parent 9d33690f34
commit d78e73bd6f
3 changed files with 17 additions and 8 deletions

View File

@@ -48,9 +48,13 @@ public class FromTextView extends SimpleEmojiTextView {
}
public void setText(Recipient recipient, @Nullable CharSequence fromString, boolean read, @Nullable String suffix) {
setText(recipient, fromString, read, suffix, true);
}
public void setText(Recipient recipient, @Nullable CharSequence fromString, boolean read, @Nullable String suffix, boolean asThread) {
SpannableStringBuilder builder = new SpannableStringBuilder();
if (recipient.isSelf()) {
if (asThread && recipient.isSelf()) {
builder.append(getContext().getString(R.string.note_to_self));
} else {
builder.append(fromString);
@@ -60,7 +64,7 @@ public class FromTextView extends SimpleEmojiTextView {
builder.append(suffix);
}
if (recipient.showVerified()) {
if (asThread && recipient.showVerified()) {
Drawable official = ContextUtil.requireDrawable(getContext(), R.drawable.ic_official_20);
official.setBounds(0, 0, ViewUtil.dpToPx(20), ViewUtil.dpToPx(20));

View File

@@ -325,7 +325,7 @@ public final class ConversationListItem extends ConstraintLayout implements Bind
joinMembersDisposable.dispose();
setSubjectViewText(null);
fromView.setText(recipient.get(), false);
fromView.setText(recipient.get(), recipient.get().getDisplayNameOrUsername(getContext()), false, null, false);
setSubjectViewText(SearchUtil.getHighlightedSpan(locale, searchStyleFactory, messageResult.getBodySnippet(), highlightSubstring, SearchUtil.MATCH_ALL));
dateView.setText(DateUtils.getBriefRelativeTimeSpanString(getContext(), locale, messageResult.getReceivedTimestampMs()));
archivedView.setVisibility(GONE);
@@ -336,7 +336,7 @@ public final class ConversationListItem extends ConstraintLayout implements Bind
setSelectedConversations(new ConversationSet());
setBadgeFromRecipient(recipient.get());
contactPhotoImage.setAvatar(glideRequests, recipient.get(), !batchMode);
contactPhotoImage.setAvatar(glideRequests, recipient.get(), !batchMode, true);
}
public void bindGroupWithMembers(@NonNull LifecycleOwner lifecycleOwner,
@@ -555,12 +555,17 @@ public final class ConversationListItem extends ConstraintLayout implements Bind
}
if (highlightSubstring != null) {
String name = recipient.isSelf() ? getContext().getString(R.string.note_to_self) : recipient.getDisplayName(getContext());
fromView.setText(recipient, SearchUtil.getHighlightedSpan(locale, searchStyleFactory, new SpannableString(name), highlightSubstring, SearchUtil.MATCH_ALL), true, null);
String name;
if (thread != null && recipient.isSelf()) {
name = getContext().getString(R.string.note_to_self);
} else {
name = recipient.getDisplayName(getContext());
}
fromView.setText(recipient, SearchUtil.getHighlightedSpan(locale, searchStyleFactory, new SpannableString(name), highlightSubstring, SearchUtil.MATCH_ALL), true, null, thread != null);
} else {
fromView.setText(recipient, false);
}
contactPhotoImage.setAvatar(glideRequests, recipient, !batchMode);
contactPhotoImage.setAvatar(glideRequests, recipient, !batchMode, thread != null);
setBadgeFromRecipient(recipient);
}

View File

@@ -367,7 +367,7 @@ public class SearchRepository {
CharSequence updatedBody = MentionUtil.updateBodyAndMentionsWithDisplayNames(context, body, mentions).getBody();
CharSequence updatedSnippet = makeSnippet(cleanQueries, Objects.requireNonNull(updatedBody));
results.add(new MessageResult(record.getToRecipient(), record.getFromRecipient(), updatedBody, updatedSnippet, record.getThreadId(), record.getId(), record.getDateReceived(), true));
results.add(new MessageResult(record.getFromRecipient(), record.getToRecipient(), updatedBody, updatedSnippet, record.getThreadId(), record.getId(), record.getDateReceived(), true));
}
}
}