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