diff options
author | Alex Ning <chineseperson5@gmail.com> | 2021-05-15 00:52:23 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2021-05-15 00:52:23 +0000 |
commit | 49ffafdfd492ea8e6190e36457813f05311b008d (patch) | |
tree | 0f2fc53596bc01d93c8ea651682c155976106b0b /app/src/main/java/ml | |
parent | b9a2a1adead1f741d43d79f35cda44330c391580 (diff) | |
download | infinity-for-reddit-49ffafdfd492ea8e6190e36457813f05311b008d.tar infinity-for-reddit-49ffafdfd492ea8e6190e36457813f05311b008d.tar.gz infinity-for-reddit-49ffafdfd492ea8e6190e36457813f05311b008d.tar.bz2 infinity-for-reddit-49ffafdfd492ea8e6190e36457813f05311b008d.tar.lz infinity-for-reddit-49ffafdfd492ea8e6190e36457813f05311b008d.tar.xz infinity-for-reddit-49ffafdfd492ea8e6190e36457813f05311b008d.tar.zst infinity-for-reddit-49ffafdfd492ea8e6190e36457813f05311b008d.zip |
Hiding post fliar in PostFragment is now available.
Diffstat (limited to 'app/src/main/java/ml')
5 files changed, 46 insertions, 4 deletions
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<Post, RecyclerView private boolean mMarkPostsAsReadOnScroll; private boolean mHideReadPostsAutomatically; private boolean mHidePostType; + private boolean mHidePostFlair; private boolean mHideTheNumberOfAwards; private boolean mHideSubredditAndUserPrefix; private boolean mHideTheNumberOfVotes; @@ -287,6 +288,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView mHideReadPostsAutomatically = postHistorySharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.HIDE_READ_POSTS_AUTOMATICALLY_BASE, false); mHidePostType = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_POST_TYPE, false); + mHidePostFlair = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_POST_FLAIR, false); mHideTheNumberOfAwards = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_AWARDS, false); mHideSubredditAndUserPrefix = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_SUBREDDIT_AND_USER_PREFIX, false); mHideTheNumberOfVotes = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_VOTES, false); @@ -622,8 +624,12 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView } if (flair != null && !flair.equals("")) { - ((PostBaseViewHolder) holder).flairTextView.setVisibility(View.VISIBLE); - Utils.setHTMLWithImageToTextView(((PostBaseViewHolder) holder).flairTextView, flair, false); + if (mHidePostFlair) { + ((PostBaseViewHolder) holder).flairTextView.setVisibility(View.GONE); + } else { + ((PostBaseViewHolder) holder).flairTextView.setVisibility(View.VISIBLE); + Utils.setHTMLWithImageToTextView(((PostBaseViewHolder) holder).flairTextView, flair, false); + } } if (nAwards > 0 && !mHideTheNumberOfAwards) { @@ -1123,8 +1129,12 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView } if (flair != null && !flair.equals("")) { - ((PostCompactBaseViewHolder) holder).flairTextView.setVisibility(View.VISIBLE); - Utils.setHTMLWithImageToTextView(((PostCompactBaseViewHolder) holder).flairTextView, flair, false); + if (mHidePostFlair) { + ((PostCompactBaseViewHolder) holder).flairTextView.setVisibility(View.GONE); + } else { + ((PostCompactBaseViewHolder) holder).flairTextView.setVisibility(View.VISIBLE); + Utils.setHTMLWithImageToTextView(((PostCompactBaseViewHolder) holder).flairTextView, flair, false); + } } if (nAwards > 0 && !mHideTheNumberOfAwards) { @@ -1801,6 +1811,10 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView mHidePostType = hidePostType; } + public void setHidePostFlair(boolean hidePostFlair) { + mHidePostFlair = hidePostFlair; + } + public void setHideTheNumberOfAwards(boolean hideTheNumberOfAwards) { mHideTheNumberOfAwards = hideTheNumberOfAwards; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeHidePostFlairEvent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeHidePostFlairEvent.java new file mode 100644 index 00000000..f3a9a7a4 --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeHidePostFlairEvent.java @@ -0,0 +1,9 @@ +package ml.docilealligator.infinityforreddit.events; + +public class ChangeHidePostFlairEvent { + public boolean hidePostFlair; + + public ChangeHidePostFlairEvent(boolean hidePostFlair) { + this.hidePostFlair = hidePostFlair; + } +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java index 7110e057..19bfaeb5 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java @@ -85,6 +85,7 @@ import ml.docilealligator.infinityforreddit.events.ChangeDataSavingModeEvent; import ml.docilealligator.infinityforreddit.events.ChangeDefaultPostLayoutEvent; import ml.docilealligator.infinityforreddit.events.ChangeDisableImagePreviewEvent; import ml.docilealligator.infinityforreddit.events.ChangeEnableSwipeActionSwitchEvent; +import ml.docilealligator.infinityforreddit.events.ChangeHidePostFlairEvent; import ml.docilealligator.infinityforreddit.events.ChangeHidePostTypeEvent; import ml.docilealligator.infinityforreddit.events.ChangeHideSubredditAndUserPrefixEvent; import ml.docilealligator.infinityforreddit.events.ChangeHideTheNumberOfAwardsEvent; @@ -1826,6 +1827,14 @@ public class PostFragment extends Fragment implements FragmentCommunicator { } @Subscribe + public void onChangeHidePostFlairEvent(ChangeHidePostFlairEvent event) { + if (mAdapter != null) { + mAdapter.setHidePostFlair(event.hidePostFlair); + refreshAdapter(); + } + } + + @Subscribe public void onChangeHideTheNumberOfAwardsEvent(ChangeHideTheNumberOfAwardsEvent event) { if (mAdapter != null) { mAdapter.setHideTheNumberOfAwards(event.hideTheNumberOfAwards); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostPreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostPreferenceFragment.java index c45a2c1a..f3a4f30c 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostPreferenceFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostPreferenceFragment.java @@ -12,6 +12,7 @@ import org.greenrobot.eventbus.EventBus; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.events.ChangeCompactLayoutToolbarHiddenByDefaultEvent; import ml.docilealligator.infinityforreddit.events.ChangeDefaultPostLayoutEvent; +import ml.docilealligator.infinityforreddit.events.ChangeHidePostFlairEvent; import ml.docilealligator.infinityforreddit.events.ChangeHidePostTypeEvent; import ml.docilealligator.infinityforreddit.events.ChangeHideSubredditAndUserPrefixEvent; import ml.docilealligator.infinityforreddit.events.ChangeHideTheNumberOfAwardsEvent; @@ -36,6 +37,7 @@ public class PostPreferenceFragment extends PreferenceFragmentCompat { SwitchPreference longPressToHideToolbarInCompactLayoutSwitch = findPreference(SharedPreferencesUtils.LONG_PRESS_TO_HIDE_TOOLBAR_IN_COMPACT_LAYOUT); SwitchPreference postCompactLayoutToolbarHiddenByDefaultSwitch = findPreference(SharedPreferencesUtils.POST_COMPACT_LAYOUT_TOOLBAR_HIDDEN_BY_DEFAULT); SwitchPreference hidePostTypeSwitch = findPreference(SharedPreferencesUtils.HIDE_POST_TYPE); + SwitchPreference hidePostFlairSwitch = findPreference(SharedPreferencesUtils.HIDE_POST_FLAIR); SwitchPreference hideTheNumberOfAwardsSwitch = findPreference(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_AWARDS); SwitchPreference hideSubredditAndUserPrefixSwitch = findPreference(SharedPreferencesUtils.HIDE_SUBREDDIT_AND_USER_PREFIX); SwitchPreference hideTheNumberOfVotesSwitch = findPreference(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_VOTES); @@ -90,6 +92,13 @@ public class PostPreferenceFragment extends PreferenceFragmentCompat { }); } + if (hidePostFlairSwitch != null) { + hidePostFlairSwitch.setOnPreferenceChangeListener((preference, newValue) -> { + 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"; |