From 8768e71a910284a74824a26db3041c339a3af325 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Wed, 24 Feb 2021 12:54:45 +0800 Subject: New options: Hide subreddit and user prefix and hide the number of votes. --- .../adapters/PostRecyclerViewAdapter.java | 93 +++++++++++++++++----- .../PostLayoutBottomSheetFragment.java | 4 +- .../ChangeHideSubredditAndUserPrefixEvent.java | 9 +++ .../events/ChangeHideTheNumberOfVotesEvent.java | 9 +++ .../infinityforreddit/fragments/PostFragment.java | 18 +++++ .../settings/PostPreferenceFragment.java | 18 +++++ .../utils/SharedPreferencesUtils.java | 2 + 7 files changed, 133 insertions(+), 20 deletions(-) create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeHideSubredditAndUserPrefixEvent.java create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeHideTheNumberOfVotesEvent.java (limited to 'app/src/main/java/ml') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java index 87025e50..46f3f7d9 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java @@ -210,6 +210,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter { @@ -89,5 +93,19 @@ public class PostPreferenceFragment extends PreferenceFragmentCompat { return true; }); } + + if (hideSubredditAndUserPrefixSwitch != null) { + hideSubredditAndUserPrefixSwitch.setOnPreferenceChangeListener((preference, newValue) -> { + EventBus.getDefault().post(new ChangeHideSubredditAndUserPrefixEvent((Boolean) newValue)); + return true; + }); + } + + if (hideTheNumberOfVotesSwitch != null) { + hideTheNumberOfVotesSwitch.setOnPreferenceChangeListener((preference, newValue) -> { + EventBus.getDefault().post(new ChangeHideTheNumberOfVotesEvent((Boolean) newValue)); + return true; + }); + } } } \ No newline at end of file diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java index 965f8145..abef106a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java @@ -165,6 +165,8 @@ public class SharedPreferencesUtils { public static final String CLICK_TO_SHOW_MEDIA_IN_GALLERY_LAYOUT = "click_to_show_media_in_gallery_layout"; public static final String HIDE_POST_TYPE = "hide_post_type"; public static final String HIDE_THE_NUMBER_OF_AWARDS = "hide_the_number_of_awards"; + public static final String HIDE_SUBREDDIT_AND_USER_PREFIX = "hide_subreddit_and_user_prefix"; + public static final String HIDE_THE_NUMBER_OF_VOTES = "hide_the_number_of_votes"; public static final String MAIN_PAGE_TABS_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.main_page_tabs"; public static final String MAIN_PAGE_TAB_COUNT = "_main_page_tab_count"; -- cgit v1.2.3