From 6f4fc732620bf97c0cb0315a47b707f80a6449c6 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Fri, 26 Feb 2021 16:12:14 +0800 Subject: Upvote ratio and different username color for comments sent by the current account. --- .../infinityforreddit/RedditDataRoomDatabase.java | 13 ++- .../CommentAndPostRecyclerViewAdapter.java | 76 ++++++++++++----- .../infinityforreddit/customtheme/CustomTheme.java | 56 +++++++------ .../customtheme/CustomThemeSettingsItem.java | 10 +++ .../customtheme/CustomThemeWrapper.java | 32 ++++++++ .../infinityforreddit/post/ParsePost.java | 94 +++++++++++----------- .../infinityforreddit/post/Post.java | 31 ++++--- .../utils/CustomThemeSharedPreferencesUtils.java | 4 + .../infinityforreddit/utils/JSONUtils.java | 1 + app/src/main/res/drawable/ic_upvote_ratio.xml | 9 +++ .../main/res/layout/item_post_detail_gallery.xml | 10 ++- .../item_post_detail_image_and_gif_autoplay.xml | 10 ++- app/src/main/res/layout/item_post_detail_link.xml | 10 ++- .../res/layout/item_post_detail_no_preview.xml | 10 ++- app/src/main/res/layout/item_post_detail_text.xml | 10 ++- .../item_post_detail_video_and_gif_preview.xml | 10 ++- .../res/layout/item_post_detail_video_autoplay.xml | 10 ++- app/src/main/res/values/strings.xml | 4 + 18 files changed, 288 insertions(+), 112 deletions(-) create mode 100644 app/src/main/res/drawable/ic_upvote_ratio.xml (limited to 'app/src/main') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java b/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java index 6c975dec..641f508a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java @@ -35,7 +35,7 @@ import ml.docilealligator.infinityforreddit.user.UserData; @Database(entities = {Account.class, SubredditData.class, SubscribedSubredditData.class, UserData.class, SubscribedUserData.class, MultiReddit.class, CustomTheme.class, RecentSearchQuery.class, - ReadPost.class, PostFilter.class, PostFilterUsage.class}, version = 17) + ReadPost.class, PostFilter.class, PostFilterUsage.class}, version = 18) public abstract class RedditDataRoomDatabase extends RoomDatabase { private static RedditDataRoomDatabase INSTANCE; @@ -48,7 +48,8 @@ public abstract class RedditDataRoomDatabase extends RoomDatabase { .addMigrations(MIGRATION_1_2, MIGRATION_2_3, MIGRATION_3_4, MIGRATION_4_5, MIGRATION_5_6, MIGRATION_6_7, MIGRATION_7_8, MIGRATION_8_9, MIGRATION_9_10, MIGRATION_10_11, MIGRATION_11_12, MIGRATION_12_13, - MIGRATION_13_14, MIGRATION_14_15, MIGRATION_15_16, MIGRATION_16_17) + MIGRATION_13_14, MIGRATION_14_15, MIGRATION_15_16, MIGRATION_16_17, + MIGRATION_17_18) .build(); } } @@ -316,4 +317,12 @@ public abstract class RedditDataRoomDatabase extends RoomDatabase { database.execSQL("UPDATE accounts SET is_current_user = 0"); } }; + + private static final Migration MIGRATION_17_18 = new Migration(17, 18) { + @Override + public void migrate(@NonNull SupportSQLiteDatabase database) { + database.execSQL("ALTER TABLE custom_themes ADD COLUMN current_user INTEGER DEFAULT " + Color.parseColor("#A202EE") + " NOT NULL"); + database.execSQL("ALTER TABLE custom_themes ADD COLUMN upvote_ratio_icon_tint INTEGER DEFAULT " + Color.parseColor("#0256EE") + " NOT NULL"); + } + }; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java index ad040c64..1ceec9a5 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java @@ -206,6 +206,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter