mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 04:58:45 +00:00
Fix search showing received mention messages as note to self.
This commit is contained in:
@@ -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));
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user