Limit the number of highlighted hashtags at the bottom of messages

This commit is contained in:
Thomas 2025-07-24 17:31:15 +02:00
parent fe5c59bdd0
commit 96ed973163
4 changed files with 22 additions and 0 deletions

View file

@ -175,6 +175,8 @@ public class Status implements Serializable, Cloneable {
public transient Spannable contentSpan;
public transient String[] bottomTags;
public boolean bottomTagsAllDisplayed = false;
public transient Spannable contentSpoilerSpan;
public transient Spannable contentTranslateSpan;
public transient MathJaxView mathJaxView;

View file

@ -1520,7 +1520,22 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
if (statusToDeal.getBottomTags().length > 0) {
holder.binding.statusHashtags.setVisibility(View.VISIBLE);
holder.binding.statusHashtags.removeAllViews();
int index = 0;
for (String tag : statusToDeal.getBottomTags()) {
if(!statusToDeal.bottomTagsAllDisplayed && index > 2 && statusToDeal.getBottomTags().length > 3) {
Chip chip = new Chip(context);
chip.setClickable(true);
chip.setEnsureMinTouchTargetSize(false);
int remaining = statusToDeal.getBottomTags().length - 3;
chip.setText(context.getString(R.string.remaining_tags, remaining));
chip.setTextColor(ThemeHelper.getAttColor(context, R.attr.colorPrimary));
chip.setOnClickListener(v -> {
statusToDeal.bottomTagsAllDisplayed = true;
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
});
holder.binding.statusHashtags.addView(chip);
break;
}
Chip chip = new Chip(context);
chip.setClickable(true);
chip.setEnsureMinTouchTargetSize(false);
@ -1539,6 +1554,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
});
});
holder.binding.statusHashtags.addView(chip);
index++;
}
} else {
holder.binding.statusHashtags.setVisibility(View.GONE);

View file

@ -2096,6 +2096,7 @@
<string name="truncate_links">Truncate links</string>
<string name="underline_bottom_hashtags">Highlight bottom hashtags</string>
<string name="remaining_tags">…and %d more</string>
<string name="underline_links">Underline clickable elements</string>
<string name="truncate_links_max">Max chars in links</string>

View file

@ -1,6 +1,9 @@
Added:
- Quote support for Mastodon
Changed:
- Limit the number of highlighted hashtags at the bottom of messages
Fixed:
- Fix a crash with threads
- Fix empty Hashtags