From 6e8bd08828a04799a98859c10dad431fe697f2ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A7=81=F0=9D=93=9C=F0=9D=93=B8=F0=9D=93=B1=F0=9D=93=AA?= =?UTF-8?q?=F0=9D=93=B6=F0=9D=93=B6=F0=9D=93=AE=F0=9D=93=AD=20=F0=9D=93=9E?= =?UTF-8?q?=F0=9D=93=BD=F0=9D=93=AA=F0=9D=93=B4=F0=9D=93=BE=EA=A7=82?= <121404638+mohammed0taku@users.noreply.github.com> Date: Wed, 13 Mar 2024 15:56:33 +0300 Subject: [PATCH] Update ExoplayerView.kt (#237) * feat (player): added portrait mode Co-authored-by: MohammedOtaku <121404638+MohammedOtaku@users.noreply.github.com> --- .../ani/dantotsu/media/anime/ExoplayerView.kt | 47 +++++++++++-------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt b/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt index d25d7bb4..9e971005 100644 --- a/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt +++ b/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt @@ -392,30 +392,37 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL }, AUDIO_CONTENT_TYPE_MOVIE, AUDIOFOCUS_GAIN) if (System.getInt(contentResolver, System.ACCELEROMETER_ROTATION, 0) != 1) { - if (PrefManager.getVal(PrefName.RotationPlayer)) { - orientationListener = - object : OrientationEventListener(this, SensorManager.SENSOR_DELAY_UI) { - override fun onOrientationChanged(orientation: Int) { - if (orientation in 45..135) { - if (rotation != ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE) exoRotate.visibility = - View.VISIBLE - rotation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE - } else if (orientation in 225..315) { - if (rotation != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) exoRotate.visibility = - View.VISIBLE - rotation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE - } + if (PrefManager.getVal(PrefName.RotationPlayer)) { + orientationListener = + object : OrientationEventListener(this, SensorManager.SENSOR_DELAY_UI) { + override fun onOrientationChanged(orientation: Int) { + if (orientation in 45..135) { + if (rotation != ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE) { + exoRotate.visibility = View.VISIBLE } + rotation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE + } else if (orientation in 225..315) { + if (rotation != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) { + exoRotate.visibility = View.VISIBLE + } + rotation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE + } else if (orientation in 315..360 || orientation in 0..45) { + if (rotation != ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) { + exoRotate.visibility = View.VISIBLE + } + rotation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT } - orientationListener?.enable() + } } + orientationListener?.enable() + } - requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE - exoRotate.setOnClickListener { - requestedOrientation = rotation - it.visibility = View.GONE - } - } + requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE + exoRotate.setOnClickListener { + requestedOrientation = rotation + it.visibility = View.GONE + } +} setupSubFormatting(playerView)