diff --git a/app/src/main/java/com/futo/platformplayer/Settings.kt b/app/src/main/java/com/futo/platformplayer/Settings.kt
index 05512eea..270158fd 100644
--- a/app/src/main/java/com/futo/platformplayer/Settings.kt
+++ b/app/src/main/java/com/futo/platformplayer/Settings.kt
@@ -415,8 +415,8 @@ class Settings : FragmentedStorageFileJson() {
@FormField(R.string.simplify_sources, FieldForm.TOGGLE, R.string.simplify_sources_description, 4)
var simplifySources: Boolean = true;
- @FormField(R.string.force_enable_auto_rotate_in_full_screen, FieldForm.TOGGLE, R.string.force_enable_auto_rotate_in_full_screen_description, 5)
- var forceAllowFullScreenRotation: Boolean = true
+ @FormField(R.string.always_allow_reverse_landscape_auto_rotate, FieldForm.TOGGLE, R.string.always_allow_reverse_landscape_auto_rotate_description, 5)
+ var alwaysAllowReverseLandscapeAutoRotate: Boolean = true
@FormField(R.string.background_behavior, FieldForm.DROPDOWN, -1, 6)
@DropdownFieldOptionsId(R.array.player_background_behavior)
diff --git a/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/VideoDetailFragment.kt b/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/VideoDetailFragment.kt
index 9709d3c8..e27acb48 100644
--- a/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/VideoDetailFragment.kt
+++ b/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/VideoDetailFragment.kt
@@ -4,8 +4,11 @@ import android.annotation.SuppressLint
import android.content.Context
import android.content.pm.ActivityInfo
import android.content.res.Configuration
+import android.database.ContentObserver
import android.os.Build
import android.os.Bundle
+import android.os.Handler
+import android.os.Looper
import android.view.LayoutInflater
import android.view.OrientationEventListener
import android.view.View
@@ -85,6 +88,7 @@ class VideoDetailFragment() : MainFragment() {
private var _landscapeOrientationListener: LandscapeOrientationListener? = null
private var _portraitOrientationListener: PortraitOrientationListener? = null
+ private var _autoRotateObserver: AutoRotateObserver? = null
fun nextVideo() {
_viewDetail?.nextVideo(true, true, true);
@@ -161,6 +165,7 @@ class VideoDetailFragment() : MainFragment() {
val isFullScreenPortraitAllowed = Settings.instance.playback.fullscreenPortrait
val isReversePortraitAllowed = Settings.instance.playback.reversePortrait
val rotationLock = StatePlayer.instance.rotationLock
+ val alwaysAllowReverseLandscapeAutoRotate = Settings.instance.playback.alwaysAllowReverseLandscapeAutoRotate
val isLandscapeVideo: Boolean = _viewDetail?.isLandscapeVideo() ?: false
@@ -169,11 +174,7 @@ class VideoDetailFragment() : MainFragment() {
// For small windows if the device isn't landscape right now and full screen portrait isn't allowed then we should force landscape
if (isSmallWindow && isFullscreen && !isFullScreenPortraitAllowed && resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT && !rotationLock && isLandscapeVideo) {
- if (Settings.instance.playback.forceAllowFullScreenRotation) {
- a.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
- } else {
- a.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE
- }
+ a.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE
if (autoRotateEnabled
) {
// start listening for the device to rotate to landscape
@@ -181,6 +182,11 @@ class VideoDetailFragment() : MainFragment() {
_landscapeOrientationListener?.enableListener()
}
}
+ // For small windows if always all reverse landscape then we'll lock the orientation to landscape when system auto-rotate is off to make sure that locking
+ // and unlockiung in the player settings keep orientation in landscape
+ else if (isSmallWindow && isFullscreen && !isFullScreenPortraitAllowed && alwaysAllowReverseLandscapeAutoRotate && !rotationLock && isLandscapeVideo && !autoRotateEnabled) {
+ a.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
+ }
// For small windows if the device isn't in a portrait orientation and we're in the maximized state then we should force portrait
// only do this if auto-rotate is on portrait is forced when leaving full screen for autorotate off
else if (isSmallWindow && !isMinimizingFromFullScreen && !isFullscreen && state == State.MAXIMIZED && resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) {
@@ -392,6 +398,10 @@ class VideoDetailFragment() : MainFragment() {
updateOrientation()
}
}
+ _autoRotateObserver = AutoRotateObserver(requireContext(), Handler(Looper.getMainLooper())) {
+ updateOrientation()
+ }
+ _autoRotateObserver?.startObserving()
return _view!!;
}
@@ -496,6 +506,7 @@ class VideoDetailFragment() : MainFragment() {
_landscapeOrientationListener?.disableListener()
_portraitOrientationListener?.disableListener()
+ _autoRotateObserver?.stopObserving()
_viewDetail?.let {
_viewDetail = null;
@@ -657,3 +668,25 @@ class PortraitOrientationListener(
}
}
}
+
+class AutoRotateObserver(context: Context, handler: Handler, private val onAutoRotateChanged: () -> Unit) : ContentObserver(handler) {
+ private val contentResolver = context.contentResolver
+
+ override fun onChange(selfChange: Boolean) {
+ super.onChange(selfChange)
+
+ onAutoRotateChanged()
+ }
+
+ fun startObserving() {
+ contentResolver.registerContentObserver(
+ android.provider.Settings.System.getUriFor(android.provider.Settings.System.ACCELEROMETER_ROTATION),
+ false,
+ this
+ )
+ }
+
+ fun stopObserving() {
+ contentResolver.unregisterContentObserver(this)
+ }
+}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 87d9bdb5..3b55bfcd 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -287,8 +287,8 @@
Schedules discovered planned content as notifications, resulting in more accurate notifications for this content.
Attempt to utilize byte ranges
Auto Update
- Force Enable Auto-Rotate In Full-Screen Mode
- Force enable auto-rotation between the two landscape orientations in full-screen mode, even when you disable auto-rotate at the system level.
+ Always allow reverse landscape auto-rotate
+ There will always be auto-rotation between the two landscape orientations in full-screen mode, even when you disable auto-rotate in system settings.
Simplify sources
Deduplicate sources by resolution so that only more relevant sources are visible.
Automatic Backup