mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 22:30:30 +05:30
basic landscape implementation
This commit is contained in:
parent
3f98f7d54a
commit
3c432aa49f
@ -37,7 +37,7 @@
|
||||
android:exported="true"
|
||||
android:hardwareAccelerated="true"
|
||||
android:launchMode="singleTop"
|
||||
android:screenOrientation="userPortrait"
|
||||
android:screenOrientation="user"
|
||||
android:supportsPictureInPicture="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
@ -84,8 +84,6 @@ class MainActivity : AppCompatActivity() {
|
||||
binding = ActivityMainBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT
|
||||
|
||||
navController = findNavController(R.id.fragment)
|
||||
binding.bottomNav.setupWithNavController(navController)
|
||||
|
||||
@ -290,7 +288,6 @@ class MainActivity : AppCompatActivity() {
|
||||
// set the animation duration
|
||||
motionLayout.setTransitionDuration(250)
|
||||
motionLayout.transitionToEnd()
|
||||
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT
|
||||
with(motionLayout) {
|
||||
getConstraintSet(R.id.start).constrainHeight(R.id.player, 0)
|
||||
enableTransition(R.id.yt_transition, true)
|
||||
|
@ -6,6 +6,7 @@ import android.app.PictureInPictureParams
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.pm.ActivityInfo
|
||||
import android.content.res.Configuration
|
||||
import android.graphics.Color
|
||||
import android.graphics.Rect
|
||||
import android.net.Uri
|
||||
@ -163,6 +164,9 @@ class PlayerFragment : Fragment() {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
hideKeyboard()
|
||||
|
||||
val mainActivity = activity as MainActivity
|
||||
mainActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER
|
||||
onConfigurationChanged(resources.configuration)
|
||||
setSponsorBlockPrefs()
|
||||
createExoPlayer(view)
|
||||
initializeTransitionLayout(view)
|
||||
@ -232,7 +236,6 @@ class PlayerFragment : Fragment() {
|
||||
Globals.isMiniPlayerVisible = false
|
||||
binding.playerMotionLayout.transitionToEnd()
|
||||
val mainActivity = activity as MainActivity
|
||||
mainActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT
|
||||
mainActivity.supportFragmentManager.beginTransaction()
|
||||
.remove(this)
|
||||
.commit()
|
||||
@ -241,7 +244,6 @@ class PlayerFragment : Fragment() {
|
||||
Globals.isMiniPlayerVisible = false
|
||||
binding.playerMotionLayout.transitionToEnd()
|
||||
val mainActivity = activity as MainActivity
|
||||
mainActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT
|
||||
mainActivity.supportFragmentManager.beginTransaction()
|
||||
.remove(this)
|
||||
.commit()
|
||||
@ -374,7 +376,7 @@ class PlayerFragment : Fragment() {
|
||||
scaleControls(1F)
|
||||
|
||||
val mainActivity = activity as MainActivity
|
||||
mainActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT
|
||||
mainActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER
|
||||
|
||||
Globals.isFullScreen = false
|
||||
}
|
||||
@ -1435,9 +1437,6 @@ class PlayerFragment : Fragment() {
|
||||
enableTransition(R.id.yt_transition, false)
|
||||
}
|
||||
|
||||
val mainActivity = activity as MainActivity
|
||||
mainActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT
|
||||
|
||||
Globals.isFullScreen = false
|
||||
} else {
|
||||
// enable exoPlayer controls again
|
||||
@ -1462,4 +1461,22 @@ class PlayerFragment : Fragment() {
|
||||
private fun updatePipParams() = PictureInPictureParams.Builder()
|
||||
.setActions(emptyList())
|
||||
.build()
|
||||
|
||||
override fun onConfigurationChanged(newConfig: Configuration) {
|
||||
super.onConfigurationChanged(newConfig)
|
||||
val orientation = newConfig.orientation
|
||||
|
||||
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
// go to fullscreen mode
|
||||
setFullscreen()
|
||||
} else {
|
||||
// leave fullscreen mode
|
||||
val rotationPref = PreferenceHelper.getString(
|
||||
requireContext(),
|
||||
"fullscreen_orientation",
|
||||
"ratio"
|
||||
)
|
||||
if (rotationPref!! != "portrait") unsetFullscreen()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user