From 25fff4064c6cfa395e3618a8ce89a7bfc287b146 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Thu, 20 Jan 2022 15:00:26 +0800 Subject: New option: Hide Text Post Content. --- .../adapters/PostRecyclerViewAdapter.java | 10 ++++++++-- .../events/ChangeHideTextPostContent.java | 9 +++++++++ .../infinityforreddit/fragments/PostFragment.java | 10 ++++++++++ .../fragments/ViewPostDetailFragment.java | 2 ++ .../settings/PostPreferenceFragment.java | 19 ++++++++++++------- .../utils/SharedPreferencesUtils.java | 1 + app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml/post_preferences.xml | 5 +++++ 8 files changed, 48 insertions(+), 9 deletions(-) create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeHideTextPostContent.java (limited to 'app/src/main') 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 82ccc212..df842ad4 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java @@ -207,6 +207,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter { + EventBus.getDefault().post(new ChangeHideTheNumberOfCommentsEvent((Boolean) newValue)); + return true; + }); + } + + if (hideTextPostContentSwitch != null) { + hideTextPostContentSwitch.setOnPreferenceChangeListener((preference, newValue) -> { + EventBus.getDefault().post(new ChangeHideTextPostContent((Boolean) newValue)); + return true; }); } 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 e5713e4f..74dc9a7f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java @@ -201,6 +201,7 @@ public class SharedPreferencesUtils { public static final String LEGACY_AUTOPLAY_VIDEO_CONTROLLER_UI = "legacy_autoplay_video_controller_ui"; public static final String PINCH_TO_ZOOM_VIDEO = "pinch_to_zoom_video"; public static final String FIXED_HEIGHT_PREVIEW_IN_CARD = "fixed_height_preview_in_card"; + public static final String HIDE_TEXT_POST_CONTENT = "hide_text_post_content"; public static final String DEFAULT_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit_preferences"; public static final String MAIN_PAGE_TABS_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.main_page_tabs"; diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 733343bf..8751ce69 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -625,6 +625,7 @@ Custom Title Font Family Custom Content Font Family Fixed Height in Card + Hide Text Post Content Cannot get the link diff --git a/app/src/main/res/xml/post_preferences.xml b/app/src/main/res/xml/post_preferences.xml index 3bc09d0f..d07b5edd 100644 --- a/app/src/main/res/xml/post_preferences.xml +++ b/app/src/main/res/xml/post_preferences.xml @@ -52,6 +52,11 @@ app:key="hide_the_number_of_comments" app:title="@string/settings_hide_the_number_of_comments" /> + +