|
3 | 3 | import static com.keylesspalace.tusky.viewdata.PollViewDataKt.buildDescription;
|
4 | 4 |
|
5 | 5 | import android.content.Context;
|
| 6 | +import android.graphics.Typeface; |
6 | 7 | import android.graphics.drawable.BitmapDrawable;
|
7 | 8 | import android.graphics.drawable.ColorDrawable;
|
8 | 9 | import android.graphics.drawable.Drawable;
|
9 | 10 | import android.net.Uri;
|
| 11 | +import android.text.Spannable; |
| 12 | +import android.text.SpannableStringBuilder; |
10 | 13 | import android.text.Spanned;
|
11 | 14 | import android.text.TextUtils;
|
12 | 15 | import android.text.format.DateUtils;
|
| 16 | +import android.text.style.StyleSpan; |
13 | 17 | import android.view.Gravity;
|
14 | 18 | import android.view.View;
|
15 | 19 | import android.view.ViewGroup;
|
|
22 | 26 | import androidx.annotation.DrawableRes;
|
23 | 27 | import androidx.annotation.NonNull;
|
24 | 28 | import androidx.annotation.Nullable;
|
| 29 | +import androidx.annotation.PluralsRes; |
25 | 30 | import androidx.appcompat.content.res.AppCompatResources;
|
26 | 31 | import androidx.appcompat.widget.TooltipCompat;
|
27 | 32 | import androidx.constraintlayout.widget.ConstraintLayout;
|
28 |
| -import androidx.core.text.HtmlCompat; |
29 | 33 | import androidx.recyclerview.widget.DefaultItemAnimator;
|
30 | 34 | import androidx.recyclerview.widget.LinearLayoutManager;
|
31 | 35 | import androidx.recyclerview.widget.RecyclerView;
|
@@ -980,14 +984,21 @@ private CharSequence getPollDescription(@NonNull StatusViewData.Concrete status,
|
980 | 984 |
|
981 | 985 | @NonNull
|
982 | 986 | protected CharSequence getFavsText(@NonNull Context context, int count) {
|
983 |
| - String countString = numberFormat.format(count); |
984 |
| - return HtmlCompat.fromHtml(context.getResources().getQuantityString(R.plurals.favs, count, countString), HtmlCompat.FROM_HTML_MODE_LEGACY); |
| 987 | + return getMetaDataText(context, R.plurals.favs, count); |
985 | 988 | }
|
986 | 989 |
|
987 | 990 | @NonNull
|
988 | 991 | protected CharSequence getReblogsText(@NonNull Context context, int count) {
|
| 992 | + return getMetaDataText(context, R.plurals.reblogs, count); |
| 993 | + } |
| 994 | + |
| 995 | + private CharSequence getMetaDataText(@NonNull Context context, @PluralsRes int text, int count) { |
989 | 996 | String countString = numberFormat.format(count);
|
990 |
| - return HtmlCompat.fromHtml(context.getResources().getQuantityString(R.plurals.reblogs, count, countString), HtmlCompat.FROM_HTML_MODE_LEGACY); |
| 997 | + String textString = context.getResources().getQuantityString(text, count, countString); |
| 998 | + SpannableStringBuilder sb = new SpannableStringBuilder(textString); |
| 999 | + int countIndex = textString.indexOf(countString); |
| 1000 | + sb.setSpan(new StyleSpan(Typeface.BOLD), countIndex, countIndex + countString.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); |
| 1001 | + return sb; |
991 | 1002 | }
|
992 | 1003 |
|
993 | 1004 | private void setupPoll(PollViewData poll, List<Emoji> emojis,
|
|
0 commit comments