From 49ffafdfd492ea8e6190e36457813f05311b008d Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Sat, 15 May 2021 08:52:23 +0800 Subject: Hiding post fliar in PostFragment is now available. --- .../adapters/PostRecyclerViewAdapter.java | 22 ++++++++++++++++++---- .../events/ChangeHidePostFlairEvent.java | 9 +++++++++ .../infinityforreddit/fragments/PostFragment.java | 9 +++++++++ .../settings/PostPreferenceFragment.java | 9 +++++++++ .../utils/SharedPreferencesUtils.java | 1 + app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml/post_preferences.xml | 5 +++++ 7 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeHidePostFlairEvent.java (limited to 'app/src') 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 95be0ca5..4565a71c 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,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter 0 && !mHideTheNumberOfAwards) { @@ -1123,8 +1129,12 @@ public class PostRecyclerViewAdapter extends PagedListAdapter 0 && !mHideTheNumberOfAwards) { @@ -1801,6 +1811,10 @@ public class PostRecyclerViewAdapter extends PagedListAdapter { + EventBus.getDefault().post(new ChangeHidePostFlairEvent((Boolean) newValue)); + return true; + }); + } + if (hideTheNumberOfAwardsSwitch != null) { hideTheNumberOfAwardsSwitch.setOnPreferenceChangeListener((preference, newValue) -> { EventBus.getDefault().post(new ChangeHideTheNumberOfAwardsEvent((Boolean) newValue)); 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 1125d71a..3242c63c 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,7 @@ public class SharedPreferencesUtils { public static final String USER_DEFAULT_SORT_TIME = "user_default_sort_time"; 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_POST_FLAIR = "hide_post_flair"; 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"; diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c3456e0e..6dd4979f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -541,6 +541,7 @@ User Default Sort Time Click to Show Media in Gallery Layout Hide Post Type + Hide Post Flair Hide the Number of Awards Hide Subreddit and User Prefix Hide the Number of Votes diff --git a/app/src/main/res/xml/post_preferences.xml b/app/src/main/res/xml/post_preferences.xml index 7e47f86c..7ea526a5 100644 --- a/app/src/main/res/xml/post_preferences.xml +++ b/app/src/main/res/xml/post_preferences.xml @@ -19,6 +19,11 @@ app:key="hide_post_type" app:title="@string/settings_hide_post_type" /> + +