kopia lustrzana https://github.com/ryukoposting/Signal-Android
Fix issue where search results could flicker.
Shoutout to @clauz9 for the help in researching this bug!fork-5.53.8
rodzic
bde4700e87
commit
cb77165b53
|
@ -71,7 +71,6 @@ import org.thoughtcrime.securesms.recipients.RecipientForeverObserver;
|
||||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||||
import org.thoughtcrime.securesms.search.MessageResult;
|
import org.thoughtcrime.securesms.search.MessageResult;
|
||||||
import org.thoughtcrime.securesms.util.DateUtils;
|
import org.thoughtcrime.securesms.util.DateUtils;
|
||||||
import org.thoughtcrime.securesms.util.Debouncer;
|
|
||||||
import org.thoughtcrime.securesms.util.ExpirationUtil;
|
import org.thoughtcrime.securesms.util.ExpirationUtil;
|
||||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||||
import org.thoughtcrime.securesms.util.SearchUtil;
|
import org.thoughtcrime.securesms.util.SearchUtil;
|
||||||
|
@ -122,8 +121,6 @@ public final class ConversationListItem extends ConstraintLayout
|
||||||
private int unreadCount;
|
private int unreadCount;
|
||||||
private AvatarImageView contactPhotoImage;
|
private AvatarImageView contactPhotoImage;
|
||||||
|
|
||||||
private final Debouncer subjectViewClearDebouncer = new Debouncer(150);
|
|
||||||
|
|
||||||
private LiveData<SpannableString> displayBody;
|
private LiveData<SpannableString> displayBody;
|
||||||
|
|
||||||
public ConversationListItem(Context context) {
|
public ConversationListItem(Context context) {
|
||||||
|
@ -175,7 +172,6 @@ public final class ConversationListItem extends ConstraintLayout
|
||||||
{
|
{
|
||||||
observeRecipient(thread.getRecipient().live());
|
observeRecipient(thread.getRecipient().live());
|
||||||
observeDisplayBody(null);
|
observeDisplayBody(null);
|
||||||
setSubjectViewText(null);
|
|
||||||
|
|
||||||
this.threadId = thread.getThreadId();
|
this.threadId = thread.getThreadId();
|
||||||
this.glideRequests = glideRequests;
|
this.glideRequests = glideRequests;
|
||||||
|
@ -188,7 +184,7 @@ public final class ConversationListItem extends ConstraintLayout
|
||||||
if (highlightSubstring != null) {
|
if (highlightSubstring != null) {
|
||||||
String name = recipient.get().isSelf() ? getContext().getString(R.string.note_to_self) : recipient.get().getDisplayName(getContext());
|
String name = recipient.get().isSelf() ? getContext().getString(R.string.note_to_self) : recipient.get().getDisplayName(getContext());
|
||||||
|
|
||||||
this.fromView.setText(recipient.get(), SearchUtil.getHighlightedSpan(locale, SpanUtil::getMediumBoldSpan, name, highlightSubstring, SearchUtil.MATCH_ALL), false, null);
|
this.fromView.setText(recipient.get(), SearchUtil.getHighlightedSpan(locale, SpanUtil::getMediumBoldSpan, name, highlightSubstring, SearchUtil.MATCH_ALL), true, null);
|
||||||
} else {
|
} else {
|
||||||
this.fromView.setText(recipient.get(), false);
|
this.fromView.setText(recipient.get(), false);
|
||||||
}
|
}
|
||||||
|
@ -196,7 +192,9 @@ public final class ConversationListItem extends ConstraintLayout
|
||||||
this.typingThreads = typingThreads;
|
this.typingThreads = typingThreads;
|
||||||
updateTypingIndicator(typingThreads);
|
updateTypingIndicator(typingThreads);
|
||||||
|
|
||||||
observeDisplayBody(getThreadDisplayBody(getContext(), thread, glideRequests, thumbSize, thumbTarget));
|
LiveData<SpannableString> displayBody = getThreadDisplayBody(getContext(), thread, glideRequests, thumbSize, thumbTarget);
|
||||||
|
setSubjectViewText(displayBody.getValue());
|
||||||
|
observeDisplayBody(displayBody);
|
||||||
|
|
||||||
if (thread.getDate() > 0) {
|
if (thread.getDate() > 0) {
|
||||||
CharSequence date = DateUtils.getBriefRelativeTimeSpanString(getContext(), locale, thread.getDate());
|
CharSequence date = DateUtils.getBriefRelativeTimeSpanString(getContext(), locale, thread.getDate());
|
||||||
|
@ -382,9 +380,8 @@ public final class ConversationListItem extends ConstraintLayout
|
||||||
|
|
||||||
private void setSubjectViewText(@Nullable CharSequence text) {
|
private void setSubjectViewText(@Nullable CharSequence text) {
|
||||||
if (text == null) {
|
if (text == null) {
|
||||||
subjectViewClearDebouncer.publish(() -> subjectView.setText(null));
|
subjectView.setText(null);
|
||||||
} else {
|
} else {
|
||||||
subjectViewClearDebouncer.clear();
|
|
||||||
subjectView.setText(text);
|
subjectView.setText(text);
|
||||||
subjectView.setVisibility(VISIBLE);
|
subjectView.setVisibility(VISIBLE);
|
||||||
}
|
}
|
||||||
|
@ -535,11 +532,11 @@ public final class ConversationListItem extends ConstraintLayout
|
||||||
return emphasisAdded(context, context.getString(thread.isOutgoing() ? R.string.ThreadRecord_you_deleted_this_message : R.string.ThreadRecord_this_message_was_deleted), defaultTint);
|
return emphasisAdded(context, context.getString(thread.isOutgoing() ? R.string.ThreadRecord_you_deleted_this_message : R.string.ThreadRecord_this_message_was_deleted), defaultTint);
|
||||||
} else {
|
} else {
|
||||||
String body = removeNewlines(thread.getBody());
|
String body = removeNewlines(thread.getBody());
|
||||||
LiveData<SpannableString> finalBody = LiveDataUtil.mapAsync(createFinalBodyWithMediaIcon(context, body, thread, glideRequests, thumbSize, thumbTarget), updatedBody -> {
|
LiveData<SpannableString> finalBody = Transformations.map(createFinalBodyWithMediaIcon(context, body, thread, glideRequests, thumbSize, thumbTarget), updatedBody -> {
|
||||||
if (thread.getRecipient().isGroup()) {
|
if (thread.getRecipient().isGroup()) {
|
||||||
RecipientId groupMessageSender = thread.getGroupMessageSender();
|
RecipientId groupMessageSender = thread.getGroupMessageSender();
|
||||||
if (!groupMessageSender.isUnknown()) {
|
if (!groupMessageSender.isUnknown()) {
|
||||||
return createGroupMessageUpdateString(context, updatedBody, Recipient.resolved(groupMessageSender), thread.isRead());
|
return createGroupMessageUpdateString(context, updatedBody, Recipient.resolved(groupMessageSender));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -605,8 +602,7 @@ public final class ConversationListItem extends ConstraintLayout
|
||||||
|
|
||||||
private static SpannableString createGroupMessageUpdateString(@NonNull Context context,
|
private static SpannableString createGroupMessageUpdateString(@NonNull Context context,
|
||||||
@NonNull CharSequence body,
|
@NonNull CharSequence body,
|
||||||
@NonNull Recipient recipient,
|
@NonNull Recipient recipient)
|
||||||
boolean read)
|
|
||||||
{
|
{
|
||||||
String sender = (recipient.isSelf() ? context.getString(R.string.MessageRecord_you)
|
String sender = (recipient.isSelf() ? context.getString(R.string.MessageRecord_you)
|
||||||
: recipient.getShortDisplayName(context)) + ": ";
|
: recipient.getShortDisplayName(context)) + ": ";
|
||||||
|
|
|
@ -107,7 +107,7 @@ class ConversationListSearchAdapter extends RecyclerView.Adapter<Conversation
|
||||||
|
|
||||||
void updateResults(@NonNull SearchResult result) {
|
void updateResults(@NonNull SearchResult result) {
|
||||||
this.searchResult = result;
|
this.searchResult = result;
|
||||||
notifyDataSetChanged();
|
notifyItemRangeChanged(0, getItemCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|
Ładowanie…
Reference in New Issue