mastodon-web-like trailing hashtag bar (#4761)

Rationale: Since the mastodon web UI has started stripping "trailing"
hashtags from post content and shoving it into an ellipsized section at
the bottom of posts, the general hashtag : content ratio is rising.

This is an attempt at adopting a similar functionality for Tusky.

Before:

<img width="420" alt="Screenshot of a hashtag-heavy post on Tusky
nightly"
src="https://github.com/user-attachments/assets/09c286e8-6822-482a-904c-5cb3323ea0e1">


After:
![Screenshot of the same post on this
branch](https://github.com/user-attachments/assets/fa99964d-a057-4727-b9f0-1251a199d5f8)
This commit is contained in:
Levi Bard 2024-11-28 19:15:31 +01:00 committed by GitHub
commit d3feca3a10
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 190 additions and 15 deletions

View file

@ -121,6 +121,7 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
protected final ConstraintLayout statusContainer;
private final TextView translationStatusView;
private final Button untranslateButton;
private final TextView trailingHashtagView;
private final NumberFormat numberFormat = NumberFormat.getNumberInstance();
@ -183,6 +184,7 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
translationStatusView = itemView.findViewById(R.id.status_translation_status);
untranslateButton = itemView.findViewById(R.id.status_button_untranslate);
trailingHashtagView = itemView.findViewById(R.id.status_trailing_hashtags_content);
this.avatarRadius48dp = itemView.getContext().getResources().getDimensionPixelSize(R.dimen.avatar_radius_48dp);
this.avatarRadius36dp = itemView.getContext().getResources().getDimensionPixelSize(R.dimen.avatar_radius_36dp);
@ -284,7 +286,7 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
if (expanded) {
CharSequence emojifiedText = CustomEmojiHelper.emojify(content, emojis, this.content, statusDisplayOptions.animateEmojis());
LinkHelper.setClickableText(this.content, emojifiedText, mentions, tags, listener);
LinkHelper.setClickableText(this.content, emojifiedText, mentions, tags, listener, this.trailingHashtagView);
for (int i = 0; i < mediaLabels.length; ++i) {
updateMediaLabel(i, sensitive, true);
}
@ -295,6 +297,9 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
}
} else {
hidePoll();
if (trailingHashtagView != null) {
trailingHashtagView.setVisibility(View.GONE);
}
LinkHelper.setClickableMentions(this.content, mentions, listener);
}
if (TextUtils.isEmpty(this.content.getText())) {