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