Skip to content

Commit

Permalink
3771: Show generic reply message if account info does not exist locally
Browse files Browse the repository at this point in the history
  • Loading branch information
Lakoja committed Oct 3, 2023
1 parent 420d3b9 commit 9e7fcff
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,29 +67,31 @@ public void setupWithStatus(@NonNull StatusViewData.Concrete status,
@NonNull StatusDisplayOptions statusDisplayOptions,
@Nullable Object payloads) {
if (payloads == null) {

boolean sensitive = !TextUtils.isEmpty(status.getActionable().getSpoilerText());
boolean expanded = status.isExpanded();

setupCollapsedState(sensitive, expanded, status, listener);

Status reblogging = status.getRebloggingStatus();
TimelineAccount repliedTo = status.getInReplyToAccount();
boolean isReplyOnly = repliedTo != null && reblogging == null;
boolean isReply = status.getStatus().getInReplyToId() != null;
boolean isReplyOnly = isReply && reblogging == null;

boolean hasStatusContext = reblogging != null || repliedTo != null;
boolean hasStatusContext = reblogging != null || isReply;

if (!hasStatusContext || status.getFilterAction() == Filter.Action.WARN) {
hideStatusInfo();
} else {
String accountName = "<unknown>";
String accountName = "";
List<Emoji> emojis = Collections.emptyList();
if (reblogging != null) {
accountName = reblogging.getAccount().getName();
emojis = reblogging.getAccount().getEmojis();
} else if (repliedTo != null) { // TODO Why would this be always != null (as code inspection warns)?
accountName = repliedTo.getName();
emojis = repliedTo.getEmojis();
} else if (isReply) {
TimelineAccount repliedTo = status.getInReplyToAccount();
if (repliedTo != null) {
accountName = repliedTo.getName();
emojis = repliedTo.getEmojis();
}
}

setStatusInfoText(isReplyOnly, accountName, emojis, statusDisplayOptions);
Expand All @@ -110,13 +112,18 @@ private void setStatusInfoText(final boolean isReply,
final CharSequence name,
final List<Emoji> accountEmoji,
final StatusDisplayOptions statusDisplayOptions) {

Context context = statusInfo.getContext();
CharSequence wrappedName = StringUtils.unicodeWrap(name);
CharSequence statusContextText = context.getString(isReply ? R.string.post_replied_format : R.string.post_boosted_format, wrappedName);
CharSequence emojifiedText = CustomEmojiHelper.emojify(
if (name.length() > 0) {
CharSequence wrappedName = StringUtils.unicodeWrap(name);
CharSequence statusContextText = context.getString(isReply ? R.string.post_replied_format : R.string.post_boosted_format, wrappedName);
CharSequence emojifiedText = CustomEmojiHelper.emojify(
statusContextText, accountEmoji, statusInfo, statusDisplayOptions.animateEmojis()
);
statusInfo.setText(emojifiedText);
);
statusInfo.setText(emojifiedText);
} else {
statusInfo.setText(context.getString(R.string.post_replied));
}
statusInfo.setCompoundDrawablesWithIntrinsicBounds(isReply ? R.drawable.ic_reply_all_24dp : R.drawable.ic_reblog_24dp, 0, 0, 0);

statusInfo.setVisibility(View.VISIBLE);
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@

<string name="post_username_format">\@%s</string>
<string name="post_boosted_format">%s boosted</string>
<string name="post_replied">Replied</string>
<string name="post_replied_format">In reply to %s</string>
<string name="post_sensitive_media_title">Sensitive content</string>
<string name="post_media_hidden_title">Media hidden</string>
Expand Down

0 comments on commit 9e7fcff

Please sign in to comment.