Merge pull request #800 from Bnyro/master

small cleanup
This commit is contained in:
Bnyro 2022-07-16 20:59:15 +02:00 committed by GitHub
commit a50bf8d00b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 11 deletions

View File

@ -8,9 +8,6 @@ object Globals {
var isFullScreen = false var isFullScreen = false
var isMiniPlayerVisible = false var isMiniPlayerVisible = false
// for the settings
var isCurrentViewMainSettings = true
// for the data saver mode // for the data saver mode
var dataSaverModeEnabled = false var dataSaverModeEnabled = false
} }

View File

@ -176,7 +176,7 @@ class PlayerFragment : Fragment() {
val mainActivity = activity as MainActivity val mainActivity = activity as MainActivity
if (autoRotationEnabled) { if (autoRotationEnabled) {
// enable auto rotation // enable auto rotation
mainActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER mainActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR
onConfigurationChanged(resources.configuration) onConfigurationChanged(resources.configuration)
} else { } else {
// go to portrait mode // go to portrait mode
@ -376,6 +376,7 @@ class PlayerFragment : Fragment() {
binding.linLayout.visibility = View.GONE binding.linLayout.visibility = View.GONE
playerBinding.fullscreen.setImageResource(R.drawable.ic_fullscreen_exit) playerBinding.fullscreen.setImageResource(R.drawable.ic_fullscreen_exit)
playerBinding.exoTitle.visibility = View.VISIBLE playerBinding.exoTitle.visibility = View.VISIBLE
playerBinding.closeImageButton.visibility = View.GONE
val mainActivity = activity as MainActivity val mainActivity = activity as MainActivity
val fullscreenOrientationPref = PreferenceHelper val fullscreenOrientationPref = PreferenceHelper
@ -393,7 +394,7 @@ class PlayerFragment : Fragment() {
// a video with normal aspect ratio // a video with normal aspect ratio
else ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE else ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE
} }
"auto" -> ActivityInfo.SCREEN_ORIENTATION_USER "auto" -> ActivityInfo.SCREEN_ORIENTATION_SENSOR
"landscape" -> ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE "landscape" -> ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE
"portrait" -> ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT "portrait" -> ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT
else -> ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE else -> ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE
@ -415,6 +416,7 @@ class PlayerFragment : Fragment() {
binding.linLayout.visibility = View.VISIBLE binding.linLayout.visibility = View.VISIBLE
playerBinding.fullscreen.setImageResource(R.drawable.ic_fullscreen) playerBinding.fullscreen.setImageResource(R.drawable.ic_fullscreen)
playerBinding.exoTitle.visibility = View.INVISIBLE playerBinding.exoTitle.visibility = View.INVISIBLE
playerBinding.closeImageButton.visibility = View.VISIBLE
scaleControls(1F) scaleControls(1F)
@ -1320,7 +1322,16 @@ class PlayerFragment : Fragment() {
playerBinding.exoBottomBar.visibility = visibility playerBinding.exoBottomBar.visibility = visibility
playerBinding.closeImageButton.visibility = visibility playerBinding.closeImageButton.visibility = visibility
playerBinding.exoTitle.visibility = playerBinding.exoTitle.visibility =
if (isLocked && Globals.isFullScreen) View.VISIBLE else View.INVISIBLE if (isLocked &&
Globals.isFullScreen
) View.VISIBLE else View.INVISIBLE
// hide the close image button
playerBinding.closeImageButton.visibility =
if (isLocked &&
!Globals.isFullScreen &&
autoRotationEnabled
) View.VISIBLE else View.GONE
// disable double tap to seek when the player is locked // disable double tap to seek when the player is locked
if (isLocked) enableDoubleTapToSeek() else disableDoubleTapToSeek() if (isLocked) enableDoubleTapToSeek() else disableDoubleTapToSeek()
@ -1481,15 +1492,13 @@ class PlayerFragment : Fragment() {
exoPlayerView.hideController() exoPlayerView.hideController()
exoPlayerView.useController = false exoPlayerView.useController = false
// set portrait mode
unsetFullscreen() unsetFullscreen()
Globals.isFullScreen = false Globals.isFullScreen = false
} else { } else {
// enable exoPlayer controls again // enable exoPlayer controls again
exoPlayerView.useController = true exoPlayerView.useController = true
// switch back to portrait mode
unsetFullscreen()
} }
} }

View File

@ -7,7 +7,6 @@ import androidx.preference.ListPreference
import androidx.preference.Preference import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceFragmentCompat
import com.github.libretube.BuildConfig import com.github.libretube.BuildConfig
import com.github.libretube.Globals
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.dialogs.RequireRestartDialog import com.github.libretube.dialogs.RequireRestartDialog
import com.github.libretube.util.ThemeHelper import com.github.libretube.util.ThemeHelper
@ -94,7 +93,6 @@ class MainSettings : PreferenceFragmentCompat() {
} }
private fun navigateToSettingsFragment(newFragment: Fragment) { private fun navigateToSettingsFragment(newFragment: Fragment) {
Globals.isCurrentViewMainSettings = false
parentFragmentManager.beginTransaction() parentFragmentManager.beginTransaction()
.replace(R.id.settings, newFragment) .replace(R.id.settings, newFragment)
.commitNow() .commitNow()