mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 14:20:30 +05:30
commit
7bc6215cb0
@ -59,11 +59,7 @@ class MainActivity : BaseActivity() {
|
||||
autoRotationEnabled = PreferenceHelper.getBoolean(PreferenceKeys.AUTO_ROTATION, false)
|
||||
|
||||
// enable auto rotation if turned on
|
||||
requestedOrientation = if (autoRotationEnabled) {
|
||||
ActivityInfo.SCREEN_ORIENTATION_USER
|
||||
} else {
|
||||
ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT
|
||||
}
|
||||
requestOrientationChange()
|
||||
|
||||
// start service that gets called on closure
|
||||
try {
|
||||
@ -160,6 +156,17 @@ class MainActivity : BaseActivity() {
|
||||
loadIntentData()
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotate according to the preference
|
||||
*/
|
||||
fun requestOrientationChange() {
|
||||
requestedOrientation = if (autoRotationEnabled) {
|
||||
ActivityInfo.SCREEN_ORIENTATION_USER
|
||||
} else {
|
||||
ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a break reminder when watched too long
|
||||
*/
|
||||
|
@ -154,7 +154,7 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
||||
/**
|
||||
* user preferences
|
||||
*/
|
||||
private var token = PreferenceHelper.getToken()
|
||||
private val token = PreferenceHelper.getToken()
|
||||
private var videoShownInExternalPlayer = false
|
||||
|
||||
/**
|
||||
@ -186,7 +186,6 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
||||
return binding.root
|
||||
}
|
||||
|
||||
@SuppressLint("SourceLockedOrientationActivity")
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
context?.hideKeyboard(view)
|
||||
@ -194,17 +193,7 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
||||
// clear the playing queue
|
||||
PlayingQueue.clear()
|
||||
|
||||
setUserPrefs()
|
||||
|
||||
val mainActivity = activity as MainActivity
|
||||
if (PlayerHelper.autoRotationEnabled) {
|
||||
// enable auto rotation
|
||||
mainActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR
|
||||
onConfigurationChanged(resources.configuration)
|
||||
} else {
|
||||
// go to portrait mode
|
||||
mainActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT
|
||||
}
|
||||
changeOrientationMode()
|
||||
|
||||
createExoPlayer()
|
||||
initializeTransitionLayout()
|
||||
@ -224,14 +213,6 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
||||
Handler(Looper.getMainLooper()).postDelayed(this::showBottomBar, 100)
|
||||
}
|
||||
|
||||
private fun setUserPrefs() {
|
||||
token = PreferenceHelper.getToken()
|
||||
|
||||
// save whether auto rotation is enabled
|
||||
|
||||
// save whether related streams are enabled
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
private fun initializeTransitionLayout() {
|
||||
val mainActivity = activity as MainActivity
|
||||
@ -268,10 +249,12 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
||||
viewModel.isMiniPlayerVisible.value = true
|
||||
exoPlayerView.useController = false
|
||||
mainMotionLayout.progress = 1F
|
||||
(activity as MainActivity).requestOrientationChange()
|
||||
} else if (currentId == sId) {
|
||||
viewModel.isMiniPlayerVisible.value = false
|
||||
exoPlayerView.useController = true
|
||||
mainMotionLayout.progress = 0F
|
||||
changeOrientationMode()
|
||||
}
|
||||
}
|
||||
|
||||
@ -1303,6 +1286,22 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the sensor mode if auto fullscreen is enabled
|
||||
*/
|
||||
@SuppressLint("SourceLockedOrientationActivity")
|
||||
private fun changeOrientationMode() {
|
||||
val mainActivity = activity as MainActivity
|
||||
if (PlayerHelper.autoRotationEnabled) {
|
||||
// enable auto rotation
|
||||
mainActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR
|
||||
onConfigurationChanged(resources.configuration)
|
||||
} else {
|
||||
// go to portrait mode
|
||||
mainActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCaptionsClicked() {
|
||||
if (!this@PlayerFragment::streams.isInitialized ||
|
||||
streams.subtitles == null ||
|
||||
|
Loading…
Reference in New Issue
Block a user