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

@ -3,10 +3,16 @@
package com.keylesspalace.tusky.util
import android.text.Spanned
import java.util.regex.Pattern
import kotlin.random.Random
private const val POSSIBLE_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
const val WORD_BREAK_EXPRESSION = """(^|$|[^\p{L}\p{N}_])"""
const val WORD_BREAK_FROM_SPACE_EXPRESSION = """(^|$|\s)"""
const val HASHTAG_EXPRESSION = "([\\w_]*[\\p{Alpha}_][\\w_]*)"
val hashtagPattern = Pattern.compile(HASHTAG_EXPRESSION, Pattern.CASE_INSENSITIVE or Pattern.MULTILINE)
fun randomAlphanumericString(count: Int): String {
val chars = CharArray(count)
for (i in 0 until count) {