mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-05-01 23:24:34 +02:00
Added dead zone to auto rotate.
This commit is contained in:
parent
5b4d142f07
commit
3527d8bac6
@ -213,19 +213,27 @@ class Settings : FragmentedStorageFileJson() {
|
|||||||
|
|
||||||
fun isAutoRotate() = autoRotate == 1 || (autoRotate == 2 && StateApp.instance.getCurrentSystemAutoRotate());
|
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)
|
@DropdownFieldOptionsId(R.array.player_background_behavior)
|
||||||
var backgroundPlay: Int = 2;
|
var backgroundPlay: Int = 2;
|
||||||
|
|
||||||
fun isBackgroundContinue() = backgroundPlay == 1;
|
fun isBackgroundContinue() = backgroundPlay == 1;
|
||||||
fun isBackgroundPictureInPicture() = backgroundPlay == 2;
|
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)
|
@DropdownFieldOptionsId(R.array.resume_after_preview)
|
||||||
var resumeAfterPreview: Int = 1;
|
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;
|
var useLiveChatWindow: Boolean = true;
|
||||||
|
|
||||||
fun shouldResumePreview(previewedPosition: Long): Boolean{
|
fun shouldResumePreview(previewedPosition: Long): Boolean{
|
||||||
|
@ -2,7 +2,9 @@ package com.futo.platformplayer.listeners
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.view.OrientationEventListener
|
import android.view.OrientationEventListener
|
||||||
|
import com.futo.platformplayer.Settings
|
||||||
import com.futo.platformplayer.constructs.Event1
|
import com.futo.platformplayer.constructs.Event1
|
||||||
|
import com.futo.platformplayer.logging.Logger
|
||||||
|
|
||||||
class OrientationManager : OrientationEventListener {
|
class OrientationManager : OrientationEventListener {
|
||||||
|
|
||||||
@ -11,32 +13,37 @@ class OrientationManager : OrientationEventListener {
|
|||||||
var orientation : Orientation = Orientation.PORTRAIT;
|
var orientation : Orientation = Orientation.PORTRAIT;
|
||||||
|
|
||||||
constructor(context: Context) : super(context) { }
|
constructor(context: Context) : super(context) { }
|
||||||
constructor(context: Context, rate: Int) : super(context, rate) { }
|
|
||||||
init {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onOrientationChanged(orientationAnglep: Int) {
|
override fun onOrientationChanged(orientationAnglep: Int) {
|
||||||
if(orientationAnglep == -1)
|
if (orientationAnglep == -1) return
|
||||||
return;
|
|
||||||
|
|
||||||
var newOrientation = Orientation.PORTRAIT;
|
val deadZone = Settings.instance.playback.getAutoRotateDeadZoneDegrees()
|
||||||
if(orientationAnglep > 60 && orientationAnglep < 140)
|
val isInDeadZone = when (orientation) {
|
||||||
newOrientation = Orientation.REVERSED_LANDSCAPE;
|
Orientation.PORTRAIT -> orientationAnglep in 0 until (60 - deadZone) || orientationAnglep in (300 + deadZone) .. 360
|
||||||
else if(orientationAnglep >= 140 && orientationAnglep <= 220)
|
Orientation.REVERSED_LANDSCAPE -> orientationAnglep in (60 + deadZone) until (140 - deadZone)
|
||||||
newOrientation = Orientation.REVERSED_PORTRAIT;
|
Orientation.REVERSED_PORTRAIT -> orientationAnglep in (140 + deadZone) until (220 - deadZone)
|
||||||
else if(orientationAnglep >= 220 && orientationAnglep <= 300)
|
Orientation.LANDSCAPE -> orientationAnglep in (220 + deadZone) until (300 - deadZone)
|
||||||
newOrientation = Orientation.LANDSCAPE;
|
}
|
||||||
else
|
|
||||||
newOrientation = Orientation.PORTRAIT;
|
if (isInDeadZone) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger.i("OrientationManager", "Orientation=$newOrientation orientationAnglep=$orientationAnglep");
|
||||||
|
|
||||||
if (newOrientation != orientation) {
|
if (newOrientation != orientation) {
|
||||||
orientation = newOrientation;
|
orientation = newOrientation
|
||||||
onOrientationChanged.emit(newOrientation);
|
onOrientationChanged.emit(newOrientation)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//TODO: Perhaps just use ActivityInfo orientations instead..
|
//TODO: Perhaps just use ActivityInfo orientations instead..
|
||||||
enum class Orientation {
|
enum class Orientation {
|
||||||
PORTRAIT,
|
PORTRAIT,
|
||||||
|
@ -99,6 +99,12 @@
|
|||||||
<item>Enabled</item>
|
<item>Enabled</item>
|
||||||
<item>Same as System</item>
|
<item>Same as System</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
<string-array name="auto_rotate_dead_zone">
|
||||||
|
<item>0</item>
|
||||||
|
<item>5</item>
|
||||||
|
<item>10</item>
|
||||||
|
<item>20</item>
|
||||||
|
</string-array>
|
||||||
<string-array name="enabled_disabled_array">
|
<string-array name="enabled_disabled_array">
|
||||||
<item>Disabled</item>
|
<item>Disabled</item>
|
||||||
<item>Enabled</item>
|
<item>Enabled</item>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user