New option: Settings->Video->Easier to Watch in Full Screen.

This commit is contained in:
Docile-Alligator 2022-06-11 19:56:55 +08:00
parent 5d07ad2d3b
commit 92cb309bf6
8 changed files with 43 additions and 2 deletions

View File

@ -174,6 +174,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
private boolean mHideTheNumberOfComments;
private boolean mSeparatePostAndComments;
private boolean mLegacyAutoplayVideoControllerUI;
private boolean mEasierToWatchInFullScreen;
private PostDetailRecyclerViewAdapterCallback mPostDetailRecyclerViewAdapterCallback;
private int mColorAccent;
@ -313,6 +314,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
.build();
mSeparatePostAndComments = separatePostAndComments;
mLegacyAutoplayVideoControllerUI = sharedPreferences.getBoolean(SharedPreferencesUtils.LEGACY_AUTOPLAY_VIDEO_CONTROLLER_UI, false);
mEasierToWatchInFullScreen = sharedPreferences.getBoolean(SharedPreferencesUtils.EASIER_TO_WATCH_IN_FULL_SCREEN, false);
mAccessToken = accessToken;
mAccountName = accountName;
mPost = post;
@ -1727,7 +1729,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
previewImageView.setOnClickListener(view -> fullscreenButton.performClick());
playerView.setOnClickListener(view -> {
if (playerView.isControllerVisible()) {
if (mEasierToWatchInFullScreen && playerView.isControllerVisible()) {
fullscreenButton.performClick();
}
});

View File

@ -211,6 +211,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
private boolean mLegacyAutoplayVideoControllerUI;
private boolean mFixedHeightPreviewInCard;
private boolean mHideTextPostContent;
private boolean mEasierToWatchInFullScreen;
private Drawable mCommentIcon;
private ExoCreator mExoCreator;
private Callback mCallback;
@ -289,6 +290,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
mLegacyAutoplayVideoControllerUI = sharedPreferences.getBoolean(SharedPreferencesUtils.LEGACY_AUTOPLAY_VIDEO_CONTROLLER_UI, false);
mFixedHeightPreviewInCard = sharedPreferences.getBoolean(SharedPreferencesUtils.FIXED_HEIGHT_PREVIEW_IN_CARD, false);
mHideTextPostContent = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_TEXT_POST_CONTENT, false);
mEasierToWatchInFullScreen = sharedPreferences.getBoolean(SharedPreferencesUtils.EASIER_TO_WATCH_IN_FULL_SCREEN, false);
mPostLayout = postLayout;
mDefaultLinkPostLayout = Integer.parseInt(sharedPreferences.getString(SharedPreferencesUtils.DEFAULT_LINK_POST_LAYOUT_KEY, "-1"));
@ -1812,6 +1814,10 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
}
}
public void setEasierToWatchInFullScreen(boolean easierToWatchInFullScreen) {
this.mEasierToWatchInFullScreen = easierToWatchInFullScreen;
}
@Override
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
if (holder instanceof PostBaseViewHolder) {
@ -2808,7 +2814,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
previewImageView.setOnClickListener(view -> fullscreenButton.performClick());
videoPlayer.setOnClickListener(view -> {
if (videoPlayer.isControllerVisible()) {
if (mEasierToWatchInFullScreen && videoPlayer.isControllerVisible()) {
fullscreenButton.performClick();
}
});

View File

@ -0,0 +1,9 @@
package ml.docilealligator.infinityforreddit.events;
public class ChangeEasierToWatchInFullScreenEvent {
public boolean easierToWatchInFullScreen;
public ChangeEasierToWatchInFullScreenEvent(boolean easierToWatchInFullScreen) {
this.easierToWatchInFullScreen = easierToWatchInFullScreen;
}
}

View File

@ -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) {

View File

@ -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));

View File

@ -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";

View File

@ -641,6 +641,7 @@
<string name="settings_post_feed_max_resolution_warning_title">Increase the value to show previews in higher resolution, but the app may crash unexpectedly.</string>
<string name="settings_post_feed_max_resolution_title">Post Feed Preview Max Resolution (Width * Height)</string>
<string name="settings_reddit_video_default_resolution">Reddit Video Default Resolution</string>
<string name="settings_easier_to_watch_in_full_screen_title">Easier to Watch in Full Screen</string>
<string name="no_link_available">Cannot get the link</string>

View File

@ -77,6 +77,11 @@
app:key="autoplay_nsfw_videos"
app:title="@string/settings_autoplay_nsfw_videos_title" />
<ml.docilealligator.infinityforreddit.customviews.CustomFontSwitchPreference
app:defaultValue="false"
app:key="easier_to_watch_in_full_screen"
app:title="@string/settings_easier_to_watch_in_full_screen_title" />
<ml.docilealligator.infinityforreddit.customviews.CustomFontSeekBarPreference
app:defaultValue="75"
android:max="100"