From 92cb309bf603a69a143412900bfb5c45349b92a9 Mon Sep 17 00:00:00 2001 From: Docile-Alligator Date: Sat, 11 Jun 2022 19:56:55 +0800 Subject: New option: Settings->Video->Easier to Watch in Full Screen. --- .../adapters/PostDetailRecyclerViewAdapter.java | 4 +++- .../infinityforreddit/adapters/PostRecyclerViewAdapter.java | 8 +++++++- .../events/ChangeEasierToWatchInFullScreenEvent.java | 9 +++++++++ .../infinityforreddit/fragments/PostFragment.java | 8 ++++++++ .../infinityforreddit/settings/VideoPreferenceFragment.java | 9 +++++++++ .../infinityforreddit/utils/SharedPreferencesUtils.java | 1 + 6 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeEasierToWatchInFullScreenEvent.java (limited to 'app/src/main/java') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java index 1afbf635..bf6fabe9 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java @@ -174,6 +174,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter fullscreenButton.performClick()); playerView.setOnClickListener(view -> { - if (playerView.isControllerVisible()) { + if (mEasierToWatchInFullScreen && playerView.isControllerVisible()) { fullscreenButton.performClick(); } }); 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 b17b800a..41d09e99 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java @@ -211,6 +211,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter fullscreenButton.performClick()); videoPlayer.setOnClickListener(view -> { - if (videoPlayer.isControllerVisible()) { + if (mEasierToWatchInFullScreen && videoPlayer.isControllerVisible()) { fullscreenButton.performClick(); } }); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeEasierToWatchInFullScreenEvent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeEasierToWatchInFullScreenEvent.java new file mode 100644 index 00000000..30a3cef8 --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeEasierToWatchInFullScreenEvent.java @@ -0,0 +1,9 @@ +package ml.docilealligator.infinityforreddit.events; + +public class ChangeEasierToWatchInFullScreenEvent { + public boolean easierToWatchInFullScreen; + + public ChangeEasierToWatchInFullScreenEvent(boolean easierToWatchInFullScreen) { + this.easierToWatchInFullScreen = easierToWatchInFullScreen; + } +} 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 48f1dbd5..de518519 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java @@ -94,6 +94,7 @@ import ml.docilealligator.infinityforreddit.events.ChangeDataSavingModeEvent; import ml.docilealligator.infinityforreddit.events.ChangeDefaultLinkPostLayoutEvent; import ml.docilealligator.infinityforreddit.events.ChangeDefaultPostLayoutEvent; import ml.docilealligator.infinityforreddit.events.ChangeDisableImagePreviewEvent; +import ml.docilealligator.infinityforreddit.events.ChangeEasierToWatchInFullScreenEvent; import ml.docilealligator.infinityforreddit.events.ChangeEnableSwipeActionSwitchEvent; import ml.docilealligator.infinityforreddit.events.ChangeFixedHeightPreviewInCardEvent; import ml.docilealligator.infinityforreddit.events.ChangeHidePostFlairEvent; @@ -2106,6 +2107,13 @@ public class PostFragment extends Fragment implements FragmentCommunicator { } } + @Subscribe + public void onChangeEasierToWatchInFullScreenEvent(ChangeEasierToWatchInFullScreenEvent event) { + if (mAdapter != null) { + mAdapter.setEasierToWatchInFullScreen(event.easierToWatchInFullScreen); + } + } + private void refreshAdapter() { int previousPosition = -1; if (mLinearLayoutManager != null) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/VideoPreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/VideoPreferenceFragment.java index 2eb3f6e7..9802e3cb 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/VideoPreferenceFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/VideoPreferenceFragment.java @@ -18,6 +18,7 @@ import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.customviews.CustomFontPreferenceFragmentCompat; import ml.docilealligator.infinityforreddit.events.ChangeAutoplayNsfwVideosEvent; +import ml.docilealligator.infinityforreddit.events.ChangeEasierToWatchInFullScreenEvent; import ml.docilealligator.infinityforreddit.events.ChangeMuteAutoplayingVideosEvent; import ml.docilealligator.infinityforreddit.events.ChangeMuteNSFWVideoEvent; import ml.docilealligator.infinityforreddit.events.ChangeRememberMutingOptionInPostFeedEvent; @@ -46,6 +47,7 @@ public class VideoPreferenceFragment extends CustomFontPreferenceFragmentCompat SwitchPreference rememberMutingOptionInPostFeedSwitchPreference = findPreference(SharedPreferencesUtils.REMEMBER_MUTING_OPTION_IN_POST_FEED); SwitchPreference muteNSFWVideosSwitchPreference = findPreference(SharedPreferencesUtils.MUTE_NSFW_VIDEO); SwitchPreference autoplayNsfwVideosSwitchPreference = findPreference(SharedPreferencesUtils.AUTOPLAY_NSFW_VIDEOS); + SwitchPreference easierToWatchInFullScreenSwitchPreference = findPreference(SharedPreferencesUtils.EASIER_TO_WATCH_IN_FULL_SCREEN); SeekBarPreference startAutoplayVisibleAreaOffsetPortrait = findPreference(SharedPreferencesUtils.START_AUTOPLAY_VISIBLE_AREA_OFFSET_PORTRAIT); SeekBarPreference startAutoplayVisibleAreaOffsetLandscape = findPreference(SharedPreferencesUtils.START_AUTOPLAY_VISIBLE_AREA_OFFSET_LANDSCAPE); @@ -61,6 +63,13 @@ public class VideoPreferenceFragment extends CustomFontPreferenceFragmentCompat }); } + if (easierToWatchInFullScreenSwitchPreference != null) { + easierToWatchInFullScreenSwitchPreference.setOnPreferenceChangeListener((preference, newValue) -> { + EventBus.getDefault().post(new ChangeEasierToWatchInFullScreenEvent((Boolean) newValue)); + return true; + }); + } + if (muteNSFWVideosSwitchPreference != null) { muteNSFWVideosSwitchPreference.setOnPreferenceChangeListener((preference, newValue) -> { EventBus.getDefault().post(new ChangeMuteNSFWVideoEvent((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 37c0924b..a6d27c62 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java @@ -210,6 +210,7 @@ public class SharedPreferencesUtils { public static final String HIDE_UPVOTE_RATIO = "hide_upvote_ratio"; public static final String POST_FEED_MAX_RESOLUTION = "post_feed_max_resolution"; public static final String REDDIT_VIDEO_DEFAULT_RESOLUTION = "reddit_video_default_resolution"; + public static final String EASIER_TO_WATCH_IN_FULL_SCREEN = "easier_to_watch_in_full_screen"; 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"; -- cgit v1.2.3