From e39d862ef3c3e1f1d0b201fc9a358da43a5f380e Mon Sep 17 00:00:00 2001 From: Koen J Date: Mon, 9 Sep 2024 12:41:16 +0200 Subject: [PATCH] Added rotation zone setting allowing you to specify the rotation to be less sensitive (default 45 degrees). Added reverse portrait setting allowing you to allow reverse portrait (default off). Added setting to hide recommendations. --- .../java/com/futo/platformplayer/Settings.kt | 15 ++++++++++++--- .../platformplayer/SimpleOrientationListener.kt | 16 ++++++++++++---- .../mainactivity/main/VideoDetailFragment.kt | 15 +++++++-------- .../mainactivity/main/VideoDetailView.kt | 5 ++++- app/src/main/res/values/strings.xml | 11 +++++++++++ 5 files changed, 46 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/com/futo/platformplayer/Settings.kt b/app/src/main/java/com/futo/platformplayer/Settings.kt index eec279de..c39b792e 100644 --- a/app/src/main/java/com/futo/platformplayer/Settings.kt +++ b/app/src/main/java/com/futo/platformplayer/Settings.kt @@ -471,13 +471,19 @@ class Settings : FragmentedStorageFileJson() { @FormField(R.string.full_screen_portrait, FieldForm.TOGGLE, R.string.allow_full_screen_portrait, 13) var fullscreenPortrait: Boolean = false; + @FormField(R.string.reverse_portrait, FieldForm.TOGGLE, R.string.reverse_portrait_description, 14) + var reversePortrait: Boolean = false; - @FormField(R.string.prefer_webm, FieldForm.TOGGLE, R.string.prefer_webm_description, 14) + @FormField(R.string.rotation_zone, FieldForm.DROPDOWN, R.string.rotation_zone_description, 15) + @DropdownFieldOptionsId(R.array.rotation_zone) + var rotationZone: Int = 2; + + @FormField(R.string.prefer_webm, FieldForm.TOGGLE, R.string.prefer_webm_description, 16) var preferWebmVideo: Boolean = false; - @FormField(R.string.prefer_webm_audio, FieldForm.TOGGLE, R.string.prefer_webm_audio_description, 15) + @FormField(R.string.prefer_webm_audio, FieldForm.TOGGLE, R.string.prefer_webm_audio_description, 17) var preferWebmAudio: Boolean = false; - @FormField(R.string.allow_under_cutout, FieldForm.TOGGLE, R.string.allow_under_cutout_description, 16) + @FormField(R.string.allow_under_cutout, FieldForm.TOGGLE, R.string.allow_under_cutout_description, 18) var allowVideoToGoUnderCutout: Boolean = true; } @@ -494,6 +500,9 @@ class Settings : FragmentedStorageFileJson() { @FormField(R.string.default_recommendations, FieldForm.TOGGLE, R.string.default_recommendations_description, 0) var recommendationsDefault: Boolean = false; + @FormField(R.string.hide_recommendations, FieldForm.TOGGLE, R.string.hide_recommendations_description, 0) + var hideRecommendations: Boolean = false; + @FormField(R.string.bad_reputation_comments_fading, FieldForm.TOGGLE, R.string.bad_reputation_comments_fading_description, 0) var badReputationCommentsFading: Boolean = true; diff --git a/app/src/main/java/com/futo/platformplayer/SimpleOrientationListener.kt b/app/src/main/java/com/futo/platformplayer/SimpleOrientationListener.kt index 6d231f9d..a289f02b 100644 --- a/app/src/main/java/com/futo/platformplayer/SimpleOrientationListener.kt +++ b/app/src/main/java/com/futo/platformplayer/SimpleOrientationListener.kt @@ -23,11 +23,19 @@ class SimpleOrientationListener( private val orientationListener = object : OrientationEventListener(activity, SensorManager.SENSOR_DELAY_UI) { override fun onOrientationChanged(orientation: Int) { + //val rotationZone = 45 + val rotationZone = when (Settings.instance.playback.rotationZone) { + 0 -> 15 + 1 -> 30 + 2 -> 45 + else -> 45 + } + val newOrientation = when { - orientation in 45..134 -> ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE - orientation in 135..224 -> ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT - orientation in 225..314 -> ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE - orientation in 315..360 || orientation in 0..44 -> ActivityInfo.SCREEN_ORIENTATION_PORTRAIT + orientation in (90 - rotationZone)..(90 + rotationZone - 1) -> ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE + orientation in (180 - rotationZone)..(180 + rotationZone - 1) -> ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT + orientation in (270 - rotationZone)..(270 + rotationZone - 1) -> ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE + orientation in (360 - rotationZone)..(360 + rotationZone - 1) || orientation in 0..(rotationZone - 1) -> ActivityInfo.SCREEN_ORIENTATION_PORTRAIT else -> lastOrientation } 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 95a4c47b..b1a498f5 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 @@ -98,7 +98,10 @@ class VideoDetailFragment : MainFragment { val isFullScreenPortraitAllowed = Settings.instance.playback.fullscreenPortrait; val bypassRotationPrevention = Settings.instance.other.bypassRotationPrevention; val currentRequestedOrientation = a.requestedOrientation - val currentOrientation = if (_currentOrientation == -1) currentRequestedOrientation else _currentOrientation + var currentOrientation = if (_currentOrientation == -1) currentRequestedOrientation else _currentOrientation + if (currentOrientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT && !Settings.instance.playback.reversePortrait) + currentOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT + val isAutoRotate = Settings.instance.playback.isAutoRotate() val isFs = isFullscreen @@ -108,20 +111,16 @@ class VideoDetailFragment : MainFragment { a.requestedOrientation = currentOrientation } } else if (currentOrientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE || currentOrientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE) { - if (isAutoRotate) { + if (isAutoRotate || currentOrientation != currentRequestedOrientation && (currentRequestedOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT || currentRequestedOrientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT)) { a.requestedOrientation = currentOrientation } } else { a.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE } } else if (bypassRotationPrevention) { - if (isAutoRotate) { - a.requestedOrientation = currentOrientation - } + a.requestedOrientation = currentOrientation } else if (currentOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT || currentOrientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT) { - if (isAutoRotate) { - a.requestedOrientation = currentOrientation - } + a.requestedOrientation = currentOrientation } else { a.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT } diff --git a/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/VideoDetailView.kt b/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/VideoDetailView.kt index 20a2a4a8..cd7d7952 100644 --- a/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/VideoDetailView.kt +++ b/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/VideoDetailView.kt @@ -1297,7 +1297,7 @@ class VideoDetailView : ConstraintLayout { if (video is TutorialFragment.TutorialVideo) { setTabIndex(0, true) } else { - if (Settings.instance.comments.recommendationsDefault) { + if (Settings.instance.comments.recommendationsDefault && !Settings.instance.comments.hideRecommendations) { setTabIndex(2, true) } else { when(Settings.instance.comments.defaultCommentSection) { @@ -2303,6 +2303,9 @@ class VideoDetailView : ConstraintLayout { return } + val recommendationsHidden = Settings.instance.comments.hideRecommendations + _buttonRecommended.visibility = if (recommendationsHidden) View.GONE else View.VISIBLE + _taskLoadRecommendations.cancel() _tabIndex = index _buttonRecommended.setTextColor(resources.getColor(if (index == 2) R.color.white else R.color.gray_ac)) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e802e9a6..bc78aa01 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -373,6 +373,10 @@ Gesture controls adjust system volume Live Chat Webview Fullscreen portrait + Allow reverse portrait + Allow app to flip into reverse portrait + Rotation zone + Specify the sensitivity of rotation zones (decrease to make less sensitive) Prefer Webm Video Codecs If player should prefer Webm codecs (vp9/opus) over mp4 codecs (h264/AAC), may result in worse compatibility. Prefer Webm Audio Codecs @@ -412,6 +416,8 @@ Default quality while previewing a video in a feed Primary Language Default Comment Section + Hide Recommendations + Fully hide the recommendations tab. Recommendations as Default Show recommendations as default, instead of comments. Bad Reputation Comment Fading @@ -953,4 +959,9 @@ Within 30 seconds of loss Always + + 15 + 30 + 45 + \ No newline at end of file