From 2d60b732a97141ebe2a434c9c6b2ccfe5886a8da Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Sat, 18 Apr 2020 22:14:17 +0800 Subject: Add awards background and text color to custom theme. Show only the number of awards on Post Compact Layout. --- .../Adapter/PostRecyclerViewAdapter.java | 38 ++++++-------- .../infinityforreddit/CustomTheme/CustomTheme.java | 60 ++++++++++++---------- .../CustomTheme/CustomThemeSettingsItem.java | 10 ++++ .../CustomTheme/CustomThemeWrapper.java | 32 ++++++++++++ .../infinityforreddit/RedditDataRoomDatabase.java | 13 ++++- .../Utils/CustomThemeSharedPreferencesUtils.java | 2 + app/src/main/res/layout/item_post.xml | 1 - app/src/main/res/layout/item_post_compact.xml | 17 +++--- app/src/main/res/values/strings.xml | 4 ++ 9 files changed, 118 insertions(+), 59 deletions(-) (limited to 'app/src') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java index fd9b8f44..bce56b5c 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java @@ -2,7 +2,6 @@ package ml.docilealligator.infinityforreddit.Adapter; import android.content.Intent; import android.content.res.ColorStateList; -import android.graphics.Color; import android.graphics.ColorFilter; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; @@ -120,6 +119,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter { @@ -1006,26 +1009,12 @@ public class PostRecyclerViewAdapter extends PagedListAdapter= android.os.Build.VERSION_CODES.N) { - flairHTML = (Spannable) Html.fromHtml(flair, Html.FROM_HTML_MODE_LEGACY, glideImageGetter, null); - } else { - flairHTML = (Spannable) Html.fromHtml(flair, glideImageGetter, null); - } - ((PostCompactViewHolder) holder).flairTextView.setText(flairHTML); + Utils.setHTMLWithImageToTextView(((PostCompactViewHolder) holder).flairTextView, flair); } - if (awards != null && !awards.equals("")) { + if (nAwards > 0) { ((PostCompactViewHolder) holder).awardsTextView.setVisibility(View.VISIBLE); - Spannable awardsHTML; - GlideImageGetter glideImageGetter = new GlideImageGetter(((PostCompactViewHolder) holder).awardsTextView); - if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) { - awardsHTML = (Spannable) Html.fromHtml(awards, Html.FROM_HTML_MODE_LEGACY, glideImageGetter, null); - } else { - awardsHTML = (Spannable) Html.fromHtml(awards, glideImageGetter, null); - } - ((PostCompactViewHolder) holder).awardsTextView.setText(awardsHTML); + ((PostCompactViewHolder) holder).awardsTextView.setText(mActivity.getString(R.string.n_awards, post.getnAwards())); } switch (voteType) { @@ -1682,11 +1671,12 @@ public class PostRecyclerViewAdapter extends PagedListAdapter + + - - Applied to: Background of the flair tag Flair Text Color Applied to: Text color of the flair tag + Awards Background Color + Applied to: Background of the awards tag + Awards Text Color + Applied to: Text color of the awards tag Archived Icon Color Applied to: Archived icon Locked Icon Color -- cgit v1.2.3