diff options
author | Alex Ning <chineseperson5@gmail.com> | 2021-02-26 08:12:14 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2021-02-26 08:12:14 +0000 |
commit | 6f4fc732620bf97c0cb0315a47b707f80a6449c6 (patch) | |
tree | b51d05d495969a3f1df9960bb8772600c962fece /app/src/main/java/ml | |
parent | 659cfa511d03924f986450c70e28631eca429912 (diff) | |
download | infinity-for-reddit-6f4fc732620bf97c0cb0315a47b707f80a6449c6.tar infinity-for-reddit-6f4fc732620bf97c0cb0315a47b707f80a6449c6.tar.gz infinity-for-reddit-6f4fc732620bf97c0cb0315a47b707f80a6449c6.tar.bz2 infinity-for-reddit-6f4fc732620bf97c0cb0315a47b707f80a6449c6.tar.lz infinity-for-reddit-6f4fc732620bf97c0cb0315a47b707f80a6449c6.tar.xz infinity-for-reddit-6f4fc732620bf97c0cb0315a47b707f80a6449c6.tar.zst infinity-for-reddit-6f4fc732620bf97c0cb0315a47b707f80a6449c6.zip |
Upvote ratio and different username color for comments sent by the current account.
Diffstat (limited to 'app/src/main/java/ml')
9 files changed, 212 insertions, 105 deletions
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<Recy private int mUsernameColor; private int mSubmitterColor; private int mModeratorColor; + private int mCurrentUserColor; private int mAuthorFlairTextColor; private int mSpoilerBackgroundColor; private int mSpoilerTextColor; @@ -216,6 +217,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy private int mArchivedTintColor; private int mLockedTintColor; private int mCrosspostTintColor; + private int mUpvoteRatioTintColor; private int mNoPreviewPostTypeBackgroundColor; private int mNoPreviewPostTypeIconTint; private int mUpvotedColor; @@ -532,6 +534,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy mPostTypeTextColor = customThemeWrapper.getPostTypeTextColor(); mSubmitterColor = customThemeWrapper.getSubmitter(); mModeratorColor = customThemeWrapper.getModerator(); + mCurrentUserColor = customThemeWrapper.getCurrentUser(); mAuthorFlairTextColor = customThemeWrapper.getAuthorFlairTextColor(); mSpoilerBackgroundColor = customThemeWrapper.getSpoilerBackgroundColor(); mSpoilerTextColor = customThemeWrapper.getSpoilerTextColor(); @@ -540,6 +543,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy mArchivedTintColor = customThemeWrapper.getArchivedIconTint(); mLockedTintColor = customThemeWrapper.getLockedIconTint(); mCrosspostTintColor = customThemeWrapper.getCrosspostIconTint(); + mUpvoteRatioTintColor = customThemeWrapper.getUpvoteRatioIconTint(); mNoPreviewPostTypeBackgroundColor = customThemeWrapper.getNoPreviewPostTypeBackgroundColor(); mNoPreviewPostTypeIconTint = customThemeWrapper.getNoPreviewPostTypeIconTint(); mFlairBackgroundColor = customThemeWrapper.getFlairBackgroundColor(); @@ -857,6 +861,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy Utils.setHTMLWithImageToTextView(((PostDetailBaseViewHolder) holder).mAwardsTextView, mPost.getAwards(), true); } + ((PostDetailBaseViewHolder) holder).mUpvoteRatioTextView.setText(mPost.getUpvoteRatio() + "%"); + if (mPost.isNSFW()) { ((PostDetailBaseViewHolder) holder).mNSFWTextView.setVisibility(View.VISIBLE); } else { @@ -1062,6 +1068,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy Drawable moderatorDrawable = Utils.getTintedDrawable(mActivity, R.drawable.ic_verified_user_14dp, mModeratorColor); ((CommentViewHolder) holder).authorTextView.setCompoundDrawablesWithIntrinsicBounds( moderatorDrawable, null, null, null); + } else if (comment.getAuthor().equals(mAccountName)) { + ((CommentViewHolder) holder).authorTextView.setTextColor(mCurrentUserColor); } if (mShowElapsedTime) { @@ -2073,6 +2081,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy CustomTextView mSpoilerTextView; CustomTextView mFlairTextView; TextView mAwardsTextView; + TextView mUpvoteRatioTextView; ConstraintLayout mBottomConstraintLayout; ImageView mUpvoteButton; TextView mScoreTextView; @@ -2086,26 +2095,27 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy } void setBaseView(AspectRatioGifImageView mIconGifImageView, - TextView mSubredditTextView, - TextView mUserTextView, - TextView mAuthorFlairTextView, - TextView mPostTimeTextView, - TextView mTitleTextView, - CustomTextView mTypeTextView, - ImageView mCrosspostImageView, - ImageView mArchivedImageView, - ImageView mLockedImageView, - CustomTextView mNSFWTextView, - CustomTextView mSpoilerTextView, - CustomTextView mFlairTextView, - TextView mAwardsTextView, - ConstraintLayout mBottomConstraintLayout, - ImageView mUpvoteButton, - TextView mScoreTextView, - ImageView mDownvoteButton, - TextView commentsCountTextView, - ImageView mSaveButton, - ImageView mShareButton) { + TextView mSubredditTextView, + TextView mUserTextView, + TextView mAuthorFlairTextView, + TextView mPostTimeTextView, + TextView mTitleTextView, + CustomTextView mTypeTextView, + ImageView mCrosspostImageView, + ImageView mArchivedImageView, + ImageView mLockedImageView, + CustomTextView mNSFWTextView, + CustomTextView mSpoilerTextView, + CustomTextView mFlairTextView, + TextView mAwardsTextView, + TextView mUpvoteRatioTextView, + ConstraintLayout mBottomConstraintLayout, + ImageView mUpvoteButton, + TextView mScoreTextView, + ImageView mDownvoteButton, + TextView commentsCountTextView, + ImageView mSaveButton, + ImageView mShareButton) { this.mIconGifImageView = mIconGifImageView; this.mSubredditTextView = mSubredditTextView; this.mUserTextView = mUserTextView; @@ -2120,6 +2130,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy this.mSpoilerTextView = mSpoilerTextView; this.mFlairTextView = mFlairTextView; this.mAwardsTextView = mAwardsTextView; + this.mUpvoteRatioTextView = mUpvoteRatioTextView; this.mBottomConstraintLayout = mBottomConstraintLayout; this.mUpvoteButton = mUpvoteButton; this.mScoreTextView = mScoreTextView; @@ -2459,6 +2470,10 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy mLockedImageView.setColorFilter(mLockedTintColor, PorterDuff.Mode.SRC_IN); mCrosspostImageView.setColorFilter(mCrosspostTintColor, PorterDuff.Mode.SRC_IN); mAwardsTextView.setTextColor(mSecondaryTextColor); + Drawable upvoteRatioDrawable = Utils.getTintedDrawable(mActivity, R.drawable.ic_upvote_ratio, mUpvoteRatioTintColor); + mUpvoteRatioTextView.setCompoundDrawablesWithIntrinsicBounds( + upvoteRatioDrawable, null, null, null); + mUpvoteRatioTextView.setTextColor(mSecondaryTextColor); mUpvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN); mScoreTextView.setTextColor(mPostIconAndInfoColor); mDownvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN); @@ -2498,6 +2513,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy CustomTextView mFlairTextView; @BindView(R.id.awards_text_view_item_post_detail_video_autoplay) TextView mAwardsTextView; + @BindView(R.id.upvote_ratio_text_view_item_post_detail_video_autoplay) + TextView mUpvoteRatioTextView; @BindView(R.id.aspect_ratio_frame_layout_item_post_detail_video_autoplay) AspectRatioFrameLayout aspectRatioFrameLayout; @BindView(R.id.player_view_item_post_detail_video_autoplay) @@ -2548,6 +2565,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy mSpoilerTextView, mFlairTextView, mAwardsTextView, + mUpvoteRatioTextView, mBottomConstraintLayout, mUpvoteButton, mScoreTextView, @@ -2741,6 +2759,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy CustomTextView mFlairTextView; @BindView(R.id.awards_text_view_item_post_detail_video_and_gif_preview) TextView mAwardsTextView; + @BindView(R.id.upvote_ratio_text_view_item_post_detail_video_and_gif_preview) + TextView mUpvoteRatioTextView; @BindView(R.id.load_wrapper_item_post_detail_video_and_gif_preview) RelativeLayout mLoadWrapper; @BindView(R.id.progress_bar_item_post_detail_video_and_gif_preview) @@ -2781,6 +2801,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy mSpoilerTextView, mFlairTextView, mAwardsTextView, + mUpvoteRatioTextView, mBottomConstraintLayout, mUpvoteButton, mScoreTextView, @@ -2852,6 +2873,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy CustomTextView mFlairTextView; @BindView(R.id.awards_text_view_item_post_detail_image_and_gif_autoplay) TextView mAwardsTextView; + @BindView(R.id.upvote_ratio_text_view_item_post_detail_image_and_gif_autoplay) + TextView mUpvoteRatioTextView; @BindView(R.id.image_view_wrapper_item_post_detail_image_and_gif_autoplay) RelativeLayout mRelativeLayout; @BindView(R.id.load_wrapper_item_post_detail_image_and_gif_autoplay) @@ -2894,6 +2917,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy mSpoilerTextView, mFlairTextView, mAwardsTextView, + mUpvoteRatioTextView, mBottomConstraintLayout, mUpvoteButton, mScoreTextView, @@ -2956,6 +2980,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy CustomTextView mFlairTextView; @BindView(R.id.awards_text_view_item_post_detail_link) TextView mAwardsTextView; + @BindView(R.id.upvote_ratio_text_view_item_post_detail_link) + TextView mUpvoteRatioTextView; @BindView(R.id.link_text_view_item_post_detail_link) TextView mLinkTextView; @BindView(R.id.image_view_wrapper_item_post_detail_link) @@ -3000,6 +3026,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy mSpoilerTextView, mFlairTextView, mAwardsTextView, + mUpvoteRatioTextView, mBottomConstraintLayout, mUpvoteButton, mScoreTextView, @@ -3053,6 +3080,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy CustomTextView mFlairTextView; @BindView(R.id.awards_text_view_item_post_detail_no_preview_link) TextView mAwardsTextView; + @BindView(R.id.upvote_ratio_text_view_item_post_detail_no_preview_link) + TextView mUpvoteRatioTextView; @BindView(R.id.link_text_view_item_post_detail_no_preview_link) TextView mLinkTextView; @BindView(R.id.image_view_no_preview_post_type_item_post_detail_no_preview_link) @@ -3089,6 +3118,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy mSpoilerTextView, mFlairTextView, mAwardsTextView, + mUpvoteRatioTextView, mBottomConstraintLayout, mUpvoteButton, mScoreTextView, @@ -3182,6 +3212,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy CustomTextView mFlairTextView; @BindView(R.id.awards_text_view_item_post_detail_gallery) TextView mAwardsTextView; + @BindView(R.id.upvote_ratio_text_view_item_post_detail_gallery) + TextView mUpvoteRatioTextView; @BindView(R.id.image_view_wrapper_item_post_detail_gallery) RelativeLayout mRelativeLayout; @BindView(R.id.load_wrapper_item_post_detail_gallery) @@ -3226,6 +3258,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy mSpoilerTextView, mFlairTextView, mAwardsTextView, + mUpvoteRatioTextView, mBottomConstraintLayout, mUpvoteButton, mScoreTextView, @@ -3283,6 +3316,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy CustomTextView mFlairTextView; @BindView(R.id.awards_text_view_item_post_detail_text) TextView mAwardsTextView; + @BindView(R.id.upvote_ratio_text_view_item_post_detail_text) + TextView mUpvoteRatioTextView; @BindView(R.id.bottom_constraint_layout_item_post_detail_text) ConstraintLayout mBottomConstraintLayout; @BindView(R.id.plus_button_item_post_detail_text) @@ -3315,6 +3350,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy mSpoilerTextView, mFlairTextView, mAwardsTextView, + mUpvoteRatioTextView, mBottomConstraintLayout, mUpvoteButton, mScoreTextView, diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/customtheme/CustomTheme.java b/app/src/main/java/ml/docilealligator/infinityforreddit/customtheme/CustomTheme.java index c428efb9..28b3d65a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/customtheme/CustomTheme.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/customtheme/CustomTheme.java @@ -113,6 +113,8 @@ public class CustomTheme { public int lockedIconTint; @ColumnInfo(name = "crosspost_icon_tint") public int crosspostIconTint; + @ColumnInfo(name = "upvote_ratio_icon_tint") + public int upvoteRatioIconTint; @ColumnInfo(name = "stickied_post_icon_tint") public int stickiedPostIconTint; @ColumnInfo(name = "no_preview_post_type_icon_tint") @@ -131,6 +133,8 @@ public class CustomTheme { public int submitter; @ColumnInfo(name = "moderator") public int moderator; + @ColumnInfo(name = "current_user") + public int currentUser; @ColumnInfo(name = "single_comment_thread_background_color") public int singleCommentThreadBackgroundColor; @ColumnInfo(name = "unread_message_background_color") @@ -258,31 +262,33 @@ public class CustomTheme { customTheme.archivedTint = customThemeSettingsItems.get(55).colorValue; customTheme.lockedIconTint = customThemeSettingsItems.get(56).colorValue; customTheme.crosspostIconTint = customThemeSettingsItems.get(57).colorValue; - customTheme.stickiedPostIconTint = customThemeSettingsItems.get(58).colorValue; - customTheme.noPreviewPostTypeIconTint = customThemeSettingsItems.get(59).colorValue; - customTheme.subscribed = customThemeSettingsItems.get(60).colorValue; - customTheme.unsubscribed = customThemeSettingsItems.get(61).colorValue; - customTheme.username = customThemeSettingsItems.get(62).colorValue; - customTheme.subreddit = customThemeSettingsItems.get(63).colorValue; - customTheme.authorFlairTextColor = customThemeSettingsItems.get(64).colorValue; - customTheme.submitter = customThemeSettingsItems.get(65).colorValue; - customTheme.moderator = customThemeSettingsItems.get(66).colorValue; - customTheme.singleCommentThreadBackgroundColor = customThemeSettingsItems.get(67).colorValue; - customTheme.unreadMessageBackgroundColor = customThemeSettingsItems.get(68).colorValue; - customTheme.dividerColor = customThemeSettingsItems.get(69).colorValue; - customTheme.noPreviewPostTypeBackgroundColor = customThemeSettingsItems.get(70).colorValue; - customTheme.voteAndReplyUnavailableButtonColor = customThemeSettingsItems.get(71).colorValue; - customTheme.commentVerticalBarColor1 = customThemeSettingsItems.get(72).colorValue; - customTheme.commentVerticalBarColor2 = customThemeSettingsItems.get(73).colorValue; - customTheme.commentVerticalBarColor3 = customThemeSettingsItems.get(74).colorValue; - customTheme.commentVerticalBarColor4 = customThemeSettingsItems.get(75).colorValue; - customTheme.commentVerticalBarColor5 = customThemeSettingsItems.get(76).colorValue; - customTheme.commentVerticalBarColor6 = customThemeSettingsItems.get(77).colorValue; - customTheme.commentVerticalBarColor7 = customThemeSettingsItems.get(78).colorValue; - customTheme.navBarColor = customThemeSettingsItems.get(79).colorValue; - customTheme.isLightStatusBar = customThemeSettingsItems.get(80).isEnabled; - customTheme.isLightNavBar = customThemeSettingsItems.get(81).isEnabled; - customTheme.isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface = customThemeSettingsItems.get(82).isEnabled; + customTheme.upvoteRatioIconTint = customThemeSettingsItems.get(58).colorValue; + customTheme.stickiedPostIconTint = customThemeSettingsItems.get(59).colorValue; + customTheme.noPreviewPostTypeIconTint = customThemeSettingsItems.get(60).colorValue; + customTheme.subscribed = customThemeSettingsItems.get(61).colorValue; + customTheme.unsubscribed = customThemeSettingsItems.get(62).colorValue; + customTheme.username = customThemeSettingsItems.get(63).colorValue; + customTheme.subreddit = customThemeSettingsItems.get(64).colorValue; + customTheme.authorFlairTextColor = customThemeSettingsItems.get(65).colorValue; + customTheme.submitter = customThemeSettingsItems.get(66).colorValue; + customTheme.moderator = customThemeSettingsItems.get(67).colorValue; + customTheme.currentUser = customThemeSettingsItems.get(68).colorValue; + customTheme.singleCommentThreadBackgroundColor = customThemeSettingsItems.get(69).colorValue; + customTheme.unreadMessageBackgroundColor = customThemeSettingsItems.get(70).colorValue; + customTheme.dividerColor = customThemeSettingsItems.get(71).colorValue; + customTheme.noPreviewPostTypeBackgroundColor = customThemeSettingsItems.get(72).colorValue; + customTheme.voteAndReplyUnavailableButtonColor = customThemeSettingsItems.get(73).colorValue; + customTheme.commentVerticalBarColor1 = customThemeSettingsItems.get(74).colorValue; + customTheme.commentVerticalBarColor2 = customThemeSettingsItems.get(75).colorValue; + customTheme.commentVerticalBarColor3 = customThemeSettingsItems.get(76).colorValue; + customTheme.commentVerticalBarColor4 = customThemeSettingsItems.get(77).colorValue; + customTheme.commentVerticalBarColor5 = customThemeSettingsItems.get(78).colorValue; + customTheme.commentVerticalBarColor6 = customThemeSettingsItems.get(79).colorValue; + customTheme.commentVerticalBarColor7 = customThemeSettingsItems.get(80).colorValue; + customTheme.navBarColor = customThemeSettingsItems.get(81).colorValue; + customTheme.isLightStatusBar = customThemeSettingsItems.get(82).isEnabled; + customTheme.isLightNavBar = customThemeSettingsItems.get(83).isEnabled; + customTheme.isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface = customThemeSettingsItems.get(84).isEnabled; return customTheme; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/customtheme/CustomThemeSettingsItem.java b/app/src/main/java/ml/docilealligator/infinityforreddit/customtheme/CustomThemeSettingsItem.java index e61d87c9..e73ad25d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/customtheme/CustomThemeSettingsItem.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/customtheme/CustomThemeSettingsItem.java @@ -291,6 +291,11 @@ public class CustomThemeSettingsItem implements Parcelable { context.getString(R.string.theme_item_crosspost_icon_tint_detail), customTheme.crosspostIconTint)); customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_upvote_ratio_icon_tint), + context.getString(R.string.theme_item_upvote_ratio_icon_tint_detail), + customTheme.upvoteRatioIconTint + )); + customThemeSettingsItems.add(new CustomThemeSettingsItem( context.getString(R.string.theme_item_stickied_post_icon_tint), context.getString(R.string.theme_item_stickied_post_icon_tint_detail), customTheme.stickiedPostIconTint)); @@ -328,6 +333,11 @@ public class CustomThemeSettingsItem implements Parcelable { context.getString(R.string.theme_item_moderator_color_detail), customTheme.moderator)); customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_current_user_color), + context.getString(R.string.theme_item_current_user_color_detail), + customTheme.currentUser + )); + customThemeSettingsItems.add(new CustomThemeSettingsItem( context.getString(R.string.theme_item_single_comment_thread_background_color), context.getString(R.string.theme_item_single_comment_thread_background_color_detail), customTheme.singleCommentThreadBackgroundColor)); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/customtheme/CustomThemeWrapper.java b/app/src/main/java/ml/docilealligator/infinityforreddit/customtheme/CustomThemeWrapper.java index f0a8c0b7..cbdc58ea 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/customtheme/CustomThemeWrapper.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/customtheme/CustomThemeWrapper.java @@ -277,6 +277,11 @@ public class CustomThemeWrapper { getDefaultColor("#FF4081", "#FF4081", "#FF4081")); } + public int getUpvoteRatioIconTint() { + return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.UPVOTE_RATIO_ICON_TINT, + getDefaultColor("#0256EE", "#0256EE", "#0256EE")); + } + public int getStickiedPostIconTint() { return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.STICKIED_POST_ICON_TINT, getDefaultColor("#0D47A1", "#1565C0", "#1565C0")); @@ -322,6 +327,11 @@ public class CustomThemeWrapper { getDefaultColor("#00BA81", "#00BA81", "#00BA81")); } + public int getCurrentUser() { + return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.CURRENT_USER, + getDefaultColor("#A202EE", "#A202EE", "#A202EE")); + } + public int getSingleCommentThreadBackgroundColor() { return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.SINGLE_COMMENT_THREAD_BACKGROUND_COLOR, getDefaultColor("#B3E5F9", "#123E77", "#123E77")); @@ -544,6 +554,7 @@ public class CustomThemeWrapper { customTheme.archivedTint = Color.parseColor("#B4009F"); customTheme.lockedIconTint = Color.parseColor("#EE7302"); customTheme.crosspostIconTint = Color.parseColor("#FF4081"); + customTheme.upvoteRatioIconTint = Color.parseColor("#0256EE"); customTheme.stickiedPostIconTint = Color.parseColor("#0D47A1"); customTheme.noPreviewPostTypeIconTint = Color.parseColor("#808080"); customTheme.subscribed = Color.parseColor("#FF4081"); @@ -553,6 +564,7 @@ public class CustomThemeWrapper { customTheme.authorFlairTextColor = Color.parseColor("#EE02C4"); customTheme.submitter = Color.parseColor("#EE8A02"); customTheme.moderator = Color.parseColor("#00BA81"); + customTheme.currentUser = Color.parseColor("#A202EE"); customTheme.singleCommentThreadBackgroundColor = Color.parseColor("#B3E5F9"); customTheme.unreadMessageBackgroundColor = Color.parseColor("#B3E5F9"); customTheme.dividerColor = Color.parseColor("#E0E0E0"); @@ -633,6 +645,7 @@ public class CustomThemeWrapper { customTheme.archivedTint = Color.parseColor("#B4009F"); customTheme.lockedIconTint = Color.parseColor("#EE7302"); customTheme.crosspostIconTint = Color.parseColor("#FF4081"); + customTheme.upvoteRatioIconTint = Color.parseColor("#0256EE"); customTheme.stickiedPostIconTint = Color.parseColor("#1565C0"); customTheme.noPreviewPostTypeIconTint = Color.parseColor("#808080"); customTheme.subscribed = Color.parseColor("#FF4081"); @@ -642,6 +655,7 @@ public class CustomThemeWrapper { customTheme.authorFlairTextColor = Color.parseColor("#EE02C4"); customTheme.submitter = Color.parseColor("#EE8A02"); customTheme.moderator = Color.parseColor("#00BA81"); + customTheme.currentUser = Color.parseColor("#A202EE"); customTheme.singleCommentThreadBackgroundColor = Color.parseColor("#123E77"); customTheme.unreadMessageBackgroundColor = Color.parseColor("#123E77"); customTheme.dividerColor = Color.parseColor("#69666C"); @@ -722,6 +736,7 @@ public class CustomThemeWrapper { customTheme.archivedTint = Color.parseColor("#B4009F"); customTheme.lockedIconTint = Color.parseColor("#EE7302"); customTheme.crosspostIconTint = Color.parseColor("#FF4081"); + customTheme.upvoteRatioIconTint = Color.parseColor("#0256EE"); customTheme.stickiedPostIconTint = Color.parseColor("#1565C0"); customTheme.noPreviewPostTypeIconTint = Color.parseColor("#808080"); customTheme.subscribed = Color.parseColor("#FF4081"); @@ -731,6 +746,7 @@ public class CustomThemeWrapper { customTheme.authorFlairTextColor = Color.parseColor("#EE02C4"); customTheme.submitter = Color.parseColor("#EE8A02"); customTheme.moderator = Color.parseColor("#00BA81"); + customTheme.currentUser = Color.parseColor("#A202EE"); customTheme.singleCommentThreadBackgroundColor = Color.parseColor("#123E77"); customTheme.unreadMessageBackgroundColor = Color.parseColor("#123E77"); customTheme.dividerColor = Color.parseColor("#69666C"); @@ -811,6 +827,7 @@ public class CustomThemeWrapper { customTheme.archivedTint = Color.parseColor("#B4009F"); customTheme.lockedIconTint = Color.parseColor("#EE7302"); customTheme.crosspostIconTint = Color.parseColor("#FF4081"); + customTheme.upvoteRatioIconTint = Color.parseColor("#0256EE"); customTheme.stickiedPostIconTint = Color.parseColor("#0D47A1"); customTheme.noPreviewPostTypeIconTint = Color.parseColor("#FFFFFF"); customTheme.subscribed = Color.parseColor("#FF4081"); @@ -820,6 +837,7 @@ public class CustomThemeWrapper { customTheme.authorFlairTextColor = Color.parseColor("#EE02C4"); customTheme.submitter = Color.parseColor("#EE8A02"); customTheme.moderator = Color.parseColor("#00BA81"); + customTheme.currentUser = Color.parseColor("#A202EE"); customTheme.singleCommentThreadBackgroundColor = Color.parseColor("#B3E5F9"); customTheme.unreadMessageBackgroundColor = Color.parseColor("#B3E5F9"); customTheme.dividerColor = Color.parseColor("#E0E0E0"); @@ -900,6 +918,7 @@ public class CustomThemeWrapper { customTheme.archivedTint = Color.parseColor("#B4009F"); customTheme.lockedIconTint = Color.parseColor("#EE7302"); customTheme.crosspostIconTint = Color.parseColor("#FF4081"); + customTheme.upvoteRatioIconTint = Color.parseColor("#0256EE"); customTheme.stickiedPostIconTint = Color.parseColor("#1565C0"); customTheme.noPreviewPostTypeIconTint = Color.parseColor("#FFFFFF"); customTheme.subscribed = Color.parseColor("#FF4081"); @@ -909,6 +928,7 @@ public class CustomThemeWrapper { customTheme.authorFlairTextColor = Color.parseColor("#EE02C4"); customTheme.submitter = Color.parseColor("#EE8A02"); customTheme.moderator = Color.parseColor("#00BA81"); + customTheme.currentUser = Color.parseColor("#A202EE"); customTheme.singleCommentThreadBackgroundColor = Color.parseColor("#123E77"); customTheme.unreadMessageBackgroundColor = Color.parseColor("#123E77"); customTheme.dividerColor = Color.parseColor("#69666C"); @@ -989,6 +1009,7 @@ public class CustomThemeWrapper { customTheme.archivedTint = Color.parseColor("#B4009F"); customTheme.lockedIconTint = Color.parseColor("#EE7302"); customTheme.crosspostIconTint = Color.parseColor("#FF4081"); + customTheme.upvoteRatioIconTint = Color.parseColor("#0256EE"); customTheme.stickiedPostIconTint = Color.parseColor("#1565C0"); customTheme.noPreviewPostTypeIconTint = Color.parseColor("#FFFFFF"); customTheme.subscribed = Color.parseColor("#FF4081"); @@ -998,6 +1019,7 @@ public class CustomThemeWrapper { customTheme.authorFlairTextColor = Color.parseColor("#EE02C4"); customTheme.submitter = Color.parseColor("#EE8A02"); customTheme.moderator = Color.parseColor("#00BA81"); + customTheme.currentUser = Color.parseColor("#A202EE"); customTheme.singleCommentThreadBackgroundColor = Color.parseColor("#123E77"); customTheme.unreadMessageBackgroundColor = Color.parseColor("#123E77"); customTheme.dividerColor = Color.parseColor("#69666C"); @@ -1078,6 +1100,7 @@ public class CustomThemeWrapper { customTheme.archivedTint = Color.parseColor("#B4009F"); customTheme.lockedIconTint = Color.parseColor("#EE7302"); customTheme.crosspostIconTint = Color.parseColor("#FF4081"); + customTheme.upvoteRatioIconTint = Color.parseColor("#0256EE"); customTheme.stickiedPostIconTint = Color.parseColor("#0D47A1"); customTheme.noPreviewPostTypeIconTint = Color.parseColor("#808080"); customTheme.subscribed = Color.parseColor("#FF4081"); @@ -1087,6 +1110,7 @@ public class CustomThemeWrapper { customTheme.authorFlairTextColor = Color.parseColor("#EE02C4"); customTheme.submitter = Color.parseColor("#EE8A02"); customTheme.moderator = Color.parseColor("#00BA81"); + customTheme.currentUser = Color.parseColor("#A202EE"); customTheme.singleCommentThreadBackgroundColor = Color.parseColor("#B3E5F9"); customTheme.unreadMessageBackgroundColor = Color.parseColor("#B3E5F9"); customTheme.dividerColor = Color.parseColor("#E0E0E0"); @@ -1167,6 +1191,7 @@ public class CustomThemeWrapper { customTheme.archivedTint = Color.parseColor("#B4009F"); customTheme.lockedIconTint = Color.parseColor("#EE7302"); customTheme.crosspostIconTint = Color.parseColor("#FF4081"); + customTheme.upvoteRatioIconTint = Color.parseColor("#0256EE"); customTheme.stickiedPostIconTint = Color.parseColor("#1565C0"); customTheme.noPreviewPostTypeIconTint = Color.parseColor("#808080"); customTheme.subscribed = Color.parseColor("#FF4081"); @@ -1176,6 +1201,7 @@ public class CustomThemeWrapper { customTheme.authorFlairTextColor = Color.parseColor("#EE02C4"); customTheme.submitter = Color.parseColor("#EE8A02"); customTheme.moderator = Color.parseColor("#00BA81"); + customTheme.currentUser = Color.parseColor("#A202EE"); customTheme.singleCommentThreadBackgroundColor = Color.parseColor("#123E77"); customTheme.unreadMessageBackgroundColor = Color.parseColor("#123E77"); customTheme.dividerColor = Color.parseColor("#69666C"); @@ -1256,6 +1282,7 @@ public class CustomThemeWrapper { customTheme.archivedTint = Color.parseColor("#B4009F"); customTheme.lockedIconTint = Color.parseColor("#EE7302"); customTheme.crosspostIconTint = Color.parseColor("#FF4081"); + customTheme.upvoteRatioIconTint = Color.parseColor("#0256EE"); customTheme.stickiedPostIconTint = Color.parseColor("#1565C0"); customTheme.noPreviewPostTypeIconTint = Color.parseColor("#808080"); customTheme.subscribed = Color.parseColor("#FF4081"); @@ -1265,6 +1292,7 @@ public class CustomThemeWrapper { customTheme.authorFlairTextColor = Color.parseColor("#EE02C4"); customTheme.submitter = Color.parseColor("#EE8A02"); customTheme.moderator = Color.parseColor("#00BA81"); + customTheme.currentUser = Color.parseColor("#A202EE"); customTheme.singleCommentThreadBackgroundColor = Color.parseColor("#123E77"); customTheme.unreadMessageBackgroundColor = Color.parseColor("#123E77"); customTheme.dividerColor = Color.parseColor("#69666C"); @@ -1345,6 +1373,7 @@ public class CustomThemeWrapper { customTheme.archivedTint = Color.parseColor("#B4009F"); customTheme.lockedIconTint = Color.parseColor("#EE7302"); customTheme.crosspostIconTint = Color.parseColor("#FF4081"); + customTheme.upvoteRatioIconTint = Color.parseColor("#0256EE"); customTheme.stickiedPostIconTint = Color.parseColor("#0D47A1"); customTheme.noPreviewPostTypeIconTint = Color.parseColor("#FFFFFF"); customTheme.subscribed = Color.parseColor("#FF4081"); @@ -1354,6 +1383,7 @@ public class CustomThemeWrapper { customTheme.authorFlairTextColor = Color.parseColor("#EE02C4"); customTheme.submitter = Color.parseColor("#EE8A02"); customTheme.moderator = Color.parseColor("#00BA81"); + customTheme.currentUser = Color.parseColor("#A202EE"); customTheme.singleCommentThreadBackgroundColor = Color.parseColor("#5F5B85"); customTheme.unreadMessageBackgroundColor = Color.parseColor("#5F5B85"); customTheme.dividerColor = Color.parseColor("#69666C"); @@ -1434,6 +1464,7 @@ public class CustomThemeWrapper { customTheme.archivedTint = Color.parseColor("#B4009F"); customTheme.lockedIconTint = Color.parseColor("#EE7302"); customTheme.crosspostIconTint = Color.parseColor("#FF4081"); + customTheme.upvoteRatioIconTint = Color.parseColor("#0256EE"); customTheme.stickiedPostIconTint = Color.parseColor("#0D47A1"); customTheme.noPreviewPostTypeIconTint = Color.parseColor("#808080"); customTheme.subscribed = Color.parseColor("#FF4081"); @@ -1443,6 +1474,7 @@ public class CustomThemeWrapper { customTheme.authorFlairTextColor = Color.parseColor("#EE02C4"); customTheme.submitter = Color.parseColor("#EE8A02"); customTheme.moderator = Color.parseColor("#00BA81"); + customTheme.currentUser = Color.parseColor("#A202EE"); customTheme.singleCommentThreadBackgroundColor = Color.parseColor("#25D5E5"); customTheme.unreadMessageBackgroundColor = Color.parseColor("#25D5E5"); customTheme.dividerColor = Color.parseColor("#E0E0E0"); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java index 2ba685eb..ced8a633 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java @@ -59,6 +59,7 @@ public class ParsePost { int score = data.getInt(JSONUtils.SCORE_KEY); int voteType; int nComments = data.getInt(JSONUtils.NUM_COMMENTS_KEY); + int upvoteRatio = (int) (data.getDouble(JSONUtils.UPVOTE_RATIO) * 100); boolean hidden = data.getBoolean(JSONUtils.HIDDEN_KEY); boolean spoiler = data.getBoolean(JSONUtils.SPOILER_KEY); boolean nsfw = data.getBoolean(JSONUtils.NSFW_KEY); @@ -137,7 +138,7 @@ public class ParsePost { Post post = parseData(data, permalink, id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTMLBuilder.toString(), postTime, title, previews, - score, voteType, nComments, flair, awardingsBuilder.toString(), nAwards, hidden, + score, voteType, nComments, upvoteRatio, flair, awardingsBuilder.toString(), nAwards, hidden, spoiler, nsfw, stickied, archived, locked, saved, true); post.setCrosspostParentId(crosspostParent.getId()); return post; @@ -145,7 +146,7 @@ public class ParsePost { return parseData(data, permalink, id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTMLBuilder.toString(), postTime, title, previews, - score, voteType, nComments, flair, awardingsBuilder.toString(), nAwards, hidden, + score, voteType, nComments, upvoteRatio, flair, awardingsBuilder.toString(), nAwards, hidden, spoiler, nsfw, stickied, archived, locked, saved, false); } } @@ -154,7 +155,7 @@ public class ParsePost { String subredditName, String subredditNamePrefixed, String author, String authorFlair, String authorFlairHTML, long postTimeMillis, String title, ArrayList<Post.Preview> previews, - int score, int voteType, int nComments, String flair, + int score, int voteType, int nComments, int upvoteRatio, String flair, String awards, int nAwards, boolean hidden, boolean spoiler, boolean nsfw, boolean stickied, boolean archived, boolean locked, boolean saved, boolean isCrosspost) throws JSONException { @@ -168,9 +169,9 @@ public class ParsePost { //Text post int postType = Post.TEXT_TYPE; post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, - authorFlair, authorFlairHTML, postTimeMillis, - title, permalink, score, postType, voteType, nComments, flair, awards, nAwards, - hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost); + authorFlair, authorFlairHTML, postTimeMillis, title, permalink, score, postType, + voteType, nComments, upvoteRatio, flair, awards, nAwards, hidden, spoiler, nsfw, + stickied, archived, locked, saved, isCrosspost); if (data.isNull(JSONUtils.SELFTEXT_KEY)) { post.setSelfText(""); } else { @@ -193,9 +194,9 @@ public class ParsePost { int postType = Post.IMAGE_TYPE; post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, - authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, postType, voteType, - nComments, flair, awards, nAwards, hidden, spoiler, nsfw, stickied, archived, - locked, saved, isCrosspost); + authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, + postType, voteType, nComments, upvoteRatio, flair, awards, nAwards, hidden, + spoiler, nsfw, stickied, archived, locked, saved, isCrosspost); if (previews.isEmpty()) { previews.add(new Post.Preview(url, 0, 0)); @@ -205,10 +206,9 @@ public class ParsePost { //No preview link post int postType = Post.NO_PREVIEW_LINK_TYPE; post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, - authorFlair, authorFlairHTML, postTimeMillis, - title, url, permalink, score, postType, - voteType, nComments, flair, awards, nAwards, hidden, spoiler, nsfw, stickied, - archived, locked, saved, isCrosspost); + authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, + postType, voteType, nComments, upvoteRatio, flair, awards, nAwards, hidden, + spoiler, nsfw, stickied, archived, locked, saved, isCrosspost); if (data.isNull(JSONUtils.SELFTEXT_KEY)) { post.setSelfText(""); } else { @@ -244,10 +244,10 @@ public class ParsePost { String videoUrl = Html.fromHtml(redditVideoObject.getString(JSONUtils.HLS_URL_KEY)).toString(); String videoDownloadUrl = redditVideoObject.getString(JSONUtils.FALLBACK_URL_KEY); - post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, - authorFlair, authorFlairHTML, postTimeMillis, title, permalink, score, postType, voteType, - nComments, flair, awards, nAwards, hidden, spoiler, nsfw, stickied, archived, locked, - saved, isCrosspost); + post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, + authorFlairHTML, postTimeMillis, title, permalink, score, postType, voteType, + nComments, upvoteRatio, flair, awards, nAwards, hidden, spoiler, nsfw, stickied, + archived, locked, saved, isCrosspost); post.setPreviews(previews); post.setVideoUrl(videoUrl); @@ -261,10 +261,10 @@ public class ParsePost { String videoDownloadUrl = data.getJSONObject(JSONUtils.PREVIEW_KEY) .getJSONObject(JSONUtils.REDDIT_VIDEO_PREVIEW_KEY).getString(JSONUtils.FALLBACK_URL_KEY); - post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, - authorFlair, authorFlairHTML, postTimeMillis, title, permalink, score, postType, voteType, - nComments, flair, awards, nAwards, hidden, spoiler, nsfw, stickied, archived, - locked, saved, isCrosspost); + post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, + authorFlairHTML, postTimeMillis, title, permalink, score, postType, voteType, + nComments, upvoteRatio, flair, awards, nAwards, hidden, spoiler, nsfw, stickied, + archived, locked, saved, isCrosspost); post.setPreviews(previews); post.setVideoUrl(videoUrl); post.setVideoDownloadUrl(videoDownloadUrl); @@ -274,10 +274,9 @@ public class ParsePost { int postType = Post.IMAGE_TYPE; post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, - authorFlair, authorFlairHTML, postTimeMillis, - title, url, permalink, score, postType, - voteType, nComments, flair, awards, nAwards, hidden, spoiler, nsfw, - stickied, archived, locked, saved, isCrosspost); + authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, + postType, voteType, nComments, upvoteRatio, flair, awards, nAwards, + hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost); if (previews.isEmpty()) { previews.add(new Post.Preview(url, 0, 0)); @@ -287,10 +286,9 @@ public class ParsePost { //Gif post int postType = Post.GIF_TYPE; post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, - authorFlair, authorFlairHTML, postTimeMillis, - title, url, permalink, score, - postType, voteType, nComments, flair, awards, nAwards, hidden, spoiler, - nsfw, stickied, archived, locked, saved, isCrosspost); + authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, + postType, voteType, nComments, upvoteRatio, flair, awards, nAwards, + hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost); post.setPreviews(previews); post.setVideoUrl(url); @@ -299,9 +297,9 @@ public class ParsePost { int postType = Post.VIDEO_TYPE; post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, - authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, postType, - voteType, nComments, flair, awards, nAwards, hidden, spoiler, nsfw, stickied, - archived, locked, saved, isCrosspost); + authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, + postType, voteType, nComments, upvoteRatio, flair, awards, nAwards, + hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost); post.setPreviews(previews); post.setVideoUrl(url); post.setVideoDownloadUrl(url); @@ -311,10 +309,9 @@ public class ParsePost { int postType = Post.TEXT_TYPE; post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, - authorFlair, authorFlairHTML, postTimeMillis, - title, permalink, score, postType, voteType, nComments, flair, - awards, nAwards, hidden, spoiler, nsfw, stickied, archived, locked, - saved, isCrosspost); + authorFlair, authorFlairHTML, postTimeMillis, title, permalink, score, + postType, voteType, nComments, upvoteRatio, flair, awards, nAwards, + hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost); //Need attention post.setPreviews(previews); @@ -340,10 +337,9 @@ public class ParsePost { int postType = Post.LINK_TYPE; post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, - authorFlair, authorFlairHTML, postTimeMillis, - title, url, permalink, score, - postType, voteType, nComments, flair, awards, nAwards, hidden, spoiler, - nsfw, stickied, archived, locked, saved, isCrosspost); + authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, + postType, voteType, nComments, upvoteRatio, flair, awards, nAwards, + hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost); if (data.isNull(JSONUtils.SELFTEXT_KEY)) { post.setSelfText(""); } else { @@ -360,9 +356,9 @@ public class ParsePost { int postType = Post.IMAGE_TYPE; post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, - authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, postType, - voteType, nComments, flair, awards, nAwards, hidden, spoiler, nsfw, stickied, - archived, locked, saved, isCrosspost); + authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, + postType, voteType, nComments, upvoteRatio, flair, awards, nAwards, hidden, + spoiler, nsfw, stickied, archived, locked, saved, isCrosspost); if (previews.isEmpty()) { previews.add(new Post.Preview(url, 0, 0)); @@ -373,9 +369,9 @@ public class ParsePost { int postType = Post.VIDEO_TYPE; post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, - authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, postType, - voteType, nComments, flair, awards, nAwards, hidden, spoiler, nsfw, stickied, - archived, locked, saved, isCrosspost); + authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, + postType, voteType, nComments, upvoteRatio, flair, awards, nAwards, hidden, + spoiler, nsfw, stickied, archived, locked, saved, isCrosspost); post.setPreviews(previews); post.setVideoUrl(url); post.setVideoDownloadUrl(url); @@ -384,9 +380,9 @@ public class ParsePost { int postType = Post.NO_PREVIEW_LINK_TYPE; post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, - authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, postType, voteType, - nComments, flair, awards, nAwards, hidden, spoiler, nsfw, stickied, archived, - locked, saved, isCrosspost); + authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, + postType, voteType, nComments, upvoteRatio, flair, awards, nAwards, hidden, + spoiler, nsfw, stickied, archived, locked, saved, isCrosspost); //Need attention } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java b/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java index c55d3840..d814fb86 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java @@ -63,6 +63,7 @@ public class Post implements Parcelable { private int postType; private int voteType; private int nComments; + private int upvoteRatio; private boolean hidden; private boolean spoiler; private boolean nsfw; @@ -79,11 +80,11 @@ public class Post implements Parcelable { private ArrayList<Gallery> gallery = new ArrayList<>(); public Post(String id, String fullName, String subredditName, String subredditNamePrefixed, - String author, String authorFlair, String authorFlairHTML, - long postTimeMillis, String title, - String permalink, int score, int postType, int voteType, int nComments, String flair, - String awards, int nAwards, boolean hidden, boolean spoiler, boolean nsfw, boolean stickied, - boolean archived, boolean locked, boolean saved, boolean isCrosspost) { + String author, String authorFlair, String authorFlairHTML, long postTimeMillis, + String title, String permalink, int score, int postType, int voteType, int nComments, + int upvoteRatio, String flair, String awards, int nAwards, boolean hidden, boolean spoiler, + boolean nsfw, boolean stickied, boolean archived, boolean locked, boolean saved, + boolean isCrosspost) { this.id = id; this.fullName = fullName; this.subredditName = subredditName; @@ -99,6 +100,7 @@ public class Post implements Parcelable { this.postType = postType; this.voteType = voteType; this.nComments = nComments; + this.upvoteRatio = upvoteRatio; this.flair = flair; this.awards = awards; this.nAwards = nAwards; @@ -114,11 +116,11 @@ public class Post implements Parcelable { } public Post(String id, String fullName, String subredditName, String subredditNamePrefixed, - String author, String authorFlair, String authorFlairHTML, - long postTimeMillis, String title, + String author, String authorFlair, String authorFlairHTML, long postTimeMillis, String title, String url, String permalink, int score, int postType, int voteType, int nComments, - String flair, String awards, int nAwards, boolean hidden, boolean spoiler, boolean nsfw, - boolean stickied, boolean archived, boolean locked, boolean saved, boolean isCrosspost) { + int upvoteRatio, String flair, String awards, int nAwards, boolean hidden, boolean spoiler, + boolean nsfw, boolean stickied, boolean archived, boolean locked, boolean saved, + boolean isCrosspost) { this.id = id; this.fullName = fullName; this.subredditName = subredditName; @@ -135,6 +137,7 @@ public class Post implements Parcelable { this.postType = postType; this.voteType = voteType; this.nComments = nComments; + this.upvoteRatio = upvoteRatio; this.flair = flair; this.awards = awards; this.nAwards = nAwards; @@ -180,6 +183,7 @@ public class Post implements Parcelable { postType = in.readInt(); voteType = in.readInt(); nComments = in.readInt(); + upvoteRatio = in.readInt(); hidden = in.readByte() != 0; spoiler = in.readByte() != 0; nsfw = in.readByte() != 0; @@ -401,6 +405,14 @@ public class Post implements Parcelable { this.nComments = nComments; } + public int getUpvoteRatio() { + return upvoteRatio; + } + + public void setUpvoteRatio(int upvoteRatio) { + this.upvoteRatio = upvoteRatio; + } + public boolean isHidden() { return hidden; } @@ -531,6 +543,7 @@ public class Post implements Parcelable { parcel.writeInt(postType); parcel.writeInt(voteType); parcel.writeInt(nComments); + parcel.writeInt(upvoteRatio); parcel.writeByte((byte) (hidden ? 1 : 0)); parcel.writeByte((byte) (spoiler ? 1 : 0)); parcel.writeByte((byte) (nsfw ? 1 : 0)); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/CustomThemeSharedPreferencesUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/CustomThemeSharedPreferencesUtils.java index db7520d7..6feab8b4 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/CustomThemeSharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/CustomThemeSharedPreferencesUtils.java @@ -60,6 +60,7 @@ public class CustomThemeSharedPreferencesUtils { public static final String ARCHIVED_ICON_TINT = "archivedIconTint"; public static final String LOCKED_ICON_TINT = "lockedIconTint"; public static final String CROSSPOST_ICON_TINT = "crosspostIconTint"; + public static final String UPVOTE_RATIO_ICON_TINT = "upvoteRatioIconTint"; public static final String STICKIED_POST_ICON_TINT = "stickiedPost"; public static final String NO_PREVIEW_POST_TYPE_ICON_TINT = "noPreviewPostTypeIconTint"; public static final String SUBSCRIBED = "subscribed"; @@ -69,6 +70,7 @@ public class CustomThemeSharedPreferencesUtils { public static final String AUTHOR_FLAIR_TEXT_COLOR = "authorFlairTextColor"; public static final String SUBMITTER = "submitter"; public static final String MODERATOR = "moderator"; + public static final String CURRENT_USER = "currentUser"; public static final String SINGLE_COMMENT_THREAD_BACKGROUND_COLOR = "singleCommentThreadBackgroundColor"; public static final String UNREAD_MESSAGE_BACKGROUND_COLOR = "unreadMessageBackgroundColor"; public static final String DIVIDER_COLOR = "dividerColor"; @@ -140,6 +142,7 @@ public class CustomThemeSharedPreferencesUtils { editor.putInt(ARCHIVED_ICON_TINT, customTheme.archivedTint); editor.putInt(LOCKED_ICON_TINT, customTheme.lockedIconTint); editor.putInt(CROSSPOST_ICON_TINT, customTheme.crosspostIconTint); + editor.putInt(UPVOTE_RATIO_ICON_TINT, customTheme.upvoteRatioIconTint); editor.putInt(STICKIED_POST_ICON_TINT, customTheme.stickiedPostIconTint); editor.putInt(NO_PREVIEW_POST_TYPE_ICON_TINT, customTheme.noPreviewPostTypeIconTint); editor.putInt(SUBSCRIBED, customTheme.subscribed); @@ -149,6 +152,7 @@ public class CustomThemeSharedPreferencesUtils { editor.putInt(AUTHOR_FLAIR_TEXT_COLOR, customTheme.authorFlairTextColor); editor.putInt(SUBMITTER, customTheme.submitter); editor.putInt(MODERATOR, customTheme.moderator); + editor.putInt(CURRENT_USER, customTheme.currentUser); editor.putInt(SINGLE_COMMENT_THREAD_BACKGROUND_COLOR, customTheme.singleCommentThreadBackgroundColor); editor.putInt(UNREAD_MESSAGE_BACKGROUND_COLOR, customTheme.unreadMessageBackgroundColor); editor.putInt(DIVIDER_COLOR, customTheme.dividerColor); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/JSONUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/JSONUtils.java index 085ee905..5add8830 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/JSONUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/JSONUtils.java @@ -132,4 +132,5 @@ public class JSONUtils { public static final String CONTENT_URLS_KEY = "content_urls";; public static final String WEBM_KEY = "webm"; public static final String WEBM_URL_KEY = "webmUrl"; + public static final String UPVOTE_RATIO = "upvote_ratio"; } |