mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-08-06 16:19:28 +00:00
Finetuning rotation.
This commit is contained in:
parent
44a6e5da38
commit
66f9824b68
1 changed files with 41 additions and 16 deletions
|
@ -93,22 +93,35 @@ class VideoDetailFragment : MainFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateOrientation() {
|
private fun updateOrientation() {
|
||||||
|
val a = activity ?: return
|
||||||
val isMaximized = state == State.MAXIMIZED
|
val isMaximized = state == State.MAXIMIZED
|
||||||
val isFullScreenPortraitAllowed = Settings.instance.playback.fullscreenPortrait;
|
val isFullScreenPortraitAllowed = Settings.instance.playback.fullscreenPortrait;
|
||||||
val currentOrientation = _currentOrientation
|
val currentRequestedOrientation = a.requestedOrientation
|
||||||
|
val currentOrientation = if (_currentOrientation == -1) currentRequestedOrientation else _currentOrientation
|
||||||
|
val isAutoRotate = Settings.instance.playback.isAutoRotate()
|
||||||
val isFs = isFullscreen
|
val isFs = isFullscreen
|
||||||
|
|
||||||
if (isFs && isMaximized) {
|
if (isFs && isMaximized) {
|
||||||
if (isFullScreenPortraitAllowed) {
|
if (isFullScreenPortraitAllowed) {
|
||||||
activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR
|
if (isAutoRotate) {
|
||||||
|
a.requestedOrientation = currentOrientation
|
||||||
|
}
|
||||||
|
} else if (currentOrientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE || currentOrientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE) {
|
||||||
|
if (isAutoRotate) {
|
||||||
|
a.requestedOrientation = currentOrientation
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
|
a.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
|
||||||
|
}
|
||||||
|
} else if (currentOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT || currentOrientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT) {
|
||||||
|
if (isAutoRotate) {
|
||||||
|
a.requestedOrientation = currentOrientation
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT
|
a.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.i(TAG, "updateOrientation (isFs = ${isFs}, currentOrientation = ${currentOrientation}, isMaximized = ${isMaximized}, isFullScreenPortraitAllowed = ${isFullScreenPortraitAllowed}) resulted in requested orientation ${activity?.requestedOrientation}");
|
Log.i(TAG, "updateOrientation (isFs = ${isFs}, currentOrientation = ${currentOrientation}, currentRequestedOrientation = ${currentRequestedOrientation}, isMaximized = ${isMaximized}, isAutoRotate = ${isAutoRotate}, isFullScreenPortraitAllowed = ${isFullScreenPortraitAllowed}) resulted in requested orientation ${activity?.requestedOrientation}");
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onShownWithView(parameter: Any?, isBack: Boolean) {
|
override fun onShownWithView(parameter: Any?, isBack: Boolean) {
|
||||||
|
@ -269,6 +282,9 @@ class VideoDetailFragment : MainFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
_autoRotateChangeListener = AutoRotateChangeListener(requireContext(), Handler()) { _ ->
|
_autoRotateChangeListener = AutoRotateChangeListener(requireContext(), Handler()) { _ ->
|
||||||
|
if (updateAutoFullscreen()) {
|
||||||
|
return@AutoRotateChangeListener
|
||||||
|
}
|
||||||
updateOrientation()
|
updateOrientation()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,6 +296,9 @@ class VideoDetailFragment : MainFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
StatePlayer.instance.onRotationLockChanged.subscribe(this) {
|
StatePlayer.instance.onRotationLockChanged.subscribe(this) {
|
||||||
|
if (updateAutoFullscreen()) {
|
||||||
|
return@subscribe
|
||||||
|
}
|
||||||
updateOrientation()
|
updateOrientation()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,23 +307,29 @@ class VideoDetailFragment : MainFragment {
|
||||||
_currentOrientation = it
|
_currentOrientation = it
|
||||||
Logger.i(TAG, "Current orientation changed (_currentOrientation = ${_currentOrientation})")
|
Logger.i(TAG, "Current orientation changed (_currentOrientation = ${_currentOrientation})")
|
||||||
|
|
||||||
if (Settings.instance.playback.isAutoRotate()) {
|
if (updateAutoFullscreen()) {
|
||||||
if (state == State.MAXIMIZED && !isFullscreen && (it == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE || it == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE)) {
|
return@subscribe
|
||||||
_viewDetail?.setFullscreen(true)
|
|
||||||
return@subscribe
|
|
||||||
}
|
|
||||||
|
|
||||||
if (state == State.MAXIMIZED && isFullscreen && !Settings.instance.playback.fullscreenPortrait && (it == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT || it == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT)) {
|
|
||||||
_viewDetail?.setFullscreen(false)
|
|
||||||
return@subscribe
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateOrientation()
|
updateOrientation()
|
||||||
}
|
}
|
||||||
return _view!!;
|
return _view!!;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun updateAutoFullscreen(): Boolean {
|
||||||
|
if (Settings.instance.playback.isAutoRotate()) {
|
||||||
|
if (state == State.MAXIMIZED && !isFullscreen && (_currentOrientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE || _currentOrientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE)) {
|
||||||
|
_viewDetail?.setFullscreen(true)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == State.MAXIMIZED && isFullscreen && !Settings.instance.playback.fullscreenPortrait && (_currentOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT || _currentOrientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT)) {
|
||||||
|
_viewDetail?.setFullscreen(false)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
fun onUserLeaveHint() {
|
fun onUserLeaveHint() {
|
||||||
val viewDetail = _viewDetail;
|
val viewDetail = _viewDetail;
|
||||||
Logger.i(TAG, "onUserLeaveHint preventPictureInPicture=${viewDetail?.preventPictureInPicture} isCasting=${StateCasting.instance.isCasting} isBackgroundPictureInPicture=${Settings.instance.playback.isBackgroundPictureInPicture()} allowBackground=${viewDetail?.allowBackground}");
|
Logger.i(TAG, "onUserLeaveHint preventPictureInPicture=${viewDetail?.preventPictureInPicture} isCasting=${StateCasting.instance.isCasting} isBackgroundPictureInPicture=${Settings.instance.playback.isBackgroundPictureInPicture()} allowBackground=${viewDetail?.allowBackground}");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue