diff --git a/app/src/main/java/com/futo/platformplayer/Settings.kt b/app/src/main/java/com/futo/platformplayer/Settings.kt
index ea4e8384..c818a8ab 100644
--- a/app/src/main/java/com/futo/platformplayer/Settings.kt
+++ b/app/src/main/java/com/futo/platformplayer/Settings.kt
@@ -213,19 +213,27 @@ class Settings : FragmentedStorageFileJson() {
fun isAutoRotate() = autoRotate == 1 || (autoRotate == 2 && StateApp.instance.getCurrentSystemAutoRotate());
- @FormField("Background Behavior", FieldForm.DROPDOWN, "", 5)
+ @FormField("Auto-Rotate Dead Zone", FieldForm.DROPDOWN, "Auto-rotate deadzone in degrees", 5)
+ @DropdownFieldOptionsId(R.array.auto_rotate_dead_zone)
+ var autoRotateDeadZone: Int = 0;
+
+ fun getAutoRotateDeadZoneDegrees(): Int {
+ return autoRotateDeadZone * 5;
+ }
+
+ @FormField("Background Behavior", FieldForm.DROPDOWN, "", 6)
@DropdownFieldOptionsId(R.array.player_background_behavior)
var backgroundPlay: Int = 2;
fun isBackgroundContinue() = backgroundPlay == 1;
fun isBackgroundPictureInPicture() = backgroundPlay == 2;
- @FormField("Resume After Preview", FieldForm.DROPDOWN, "When watching a video in preview mode, resume at the position when opening the video", 4)
+ @FormField("Resume After Preview", FieldForm.DROPDOWN, "When watching a video in preview mode, resume at the position when opening the video", 7)
@DropdownFieldOptionsId(R.array.resume_after_preview)
var resumeAfterPreview: Int = 1;
- @FormField("Live Chat Webview", FieldForm.TOGGLE, "Use the live chat web window when available over native implementation.", 5)
+ @FormField("Live Chat Webview", FieldForm.TOGGLE, "Use the live chat web window when available over native implementation.", 8)
var useLiveChatWindow: Boolean = true;
fun shouldResumePreview(previewedPosition: Long): Boolean{
diff --git a/app/src/main/java/com/futo/platformplayer/listeners/OrientationManager.kt b/app/src/main/java/com/futo/platformplayer/listeners/OrientationManager.kt
index f78b4652..ae6640a9 100644
--- a/app/src/main/java/com/futo/platformplayer/listeners/OrientationManager.kt
+++ b/app/src/main/java/com/futo/platformplayer/listeners/OrientationManager.kt
@@ -2,7 +2,9 @@ package com.futo.platformplayer.listeners
import android.content.Context
import android.view.OrientationEventListener
+import com.futo.platformplayer.Settings
import com.futo.platformplayer.constructs.Event1
+import com.futo.platformplayer.logging.Logger
class OrientationManager : OrientationEventListener {
@@ -11,32 +13,37 @@ class OrientationManager : OrientationEventListener {
var orientation : Orientation = Orientation.PORTRAIT;
constructor(context: Context) : super(context) { }
- constructor(context: Context, rate: Int) : super(context, rate) { }
- init {
-
- }
override fun onOrientationChanged(orientationAnglep: Int) {
- if(orientationAnglep == -1)
+ if (orientationAnglep == -1) return
+
+ val deadZone = Settings.instance.playback.getAutoRotateDeadZoneDegrees()
+ val isInDeadZone = when (orientation) {
+ Orientation.PORTRAIT -> orientationAnglep in 0 until (60 - deadZone) || orientationAnglep in (300 + deadZone) .. 360
+ Orientation.REVERSED_LANDSCAPE -> orientationAnglep in (60 + deadZone) until (140 - deadZone)
+ Orientation.REVERSED_PORTRAIT -> orientationAnglep in (140 + deadZone) until (220 - deadZone)
+ Orientation.LANDSCAPE -> orientationAnglep in (220 + deadZone) until (300 - deadZone)
+ }
+
+ if (isInDeadZone) {
return;
+ }
- var newOrientation = Orientation.PORTRAIT;
- if(orientationAnglep > 60 && orientationAnglep < 140)
- newOrientation = Orientation.REVERSED_LANDSCAPE;
- else if(orientationAnglep >= 140 && orientationAnglep <= 220)
- newOrientation = Orientation.REVERSED_PORTRAIT;
- else if(orientationAnglep >= 220 && orientationAnglep <= 300)
- newOrientation = Orientation.LANDSCAPE;
- else
- newOrientation = Orientation.PORTRAIT;
+ val newOrientation = when (orientationAnglep) {
+ in 60 until 140 -> Orientation.REVERSED_LANDSCAPE
+ in 140 until 220 -> Orientation.REVERSED_PORTRAIT
+ in 220 until 300 -> Orientation.LANDSCAPE
+ else -> Orientation.PORTRAIT
+ }
- if(newOrientation != orientation) {
- orientation = newOrientation;
- onOrientationChanged.emit(newOrientation);
+ Logger.i("OrientationManager", "Orientation=$newOrientation orientationAnglep=$orientationAnglep");
+
+ if (newOrientation != orientation) {
+ orientation = newOrientation
+ onOrientationChanged.emit(newOrientation)
}
}
-
//TODO: Perhaps just use ActivityInfo orientations instead..
enum class Orientation {
PORTRAIT,
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 2bf47b60..977cc525 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -99,6 +99,12 @@
- Enabled
- Same as System
+
+ - 0
+ - 5
+ - 10
+ - 20
+
- Disabled
- Enabled