mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 22:30:30 +05:30
finish fullscreen on backpress
This commit is contained in:
parent
852a3311b3
commit
187f96bc49
@ -53,7 +53,7 @@ class MainActivity : BaseActivity() {
|
|||||||
val autoRotationEnabled = PreferenceHelper.getBoolean(PreferenceKeys.AUTO_ROTATION, false)
|
val autoRotationEnabled = PreferenceHelper.getBoolean(PreferenceKeys.AUTO_ROTATION, false)
|
||||||
|
|
||||||
lateinit var searchView: SearchView
|
lateinit var searchView: SearchView
|
||||||
lateinit var searchItem: MenuItem
|
private lateinit var searchItem: MenuItem
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
@ -131,9 +131,20 @@ class MainActivity : BaseActivity() {
|
|||||||
|
|
||||||
setupSubscriptionsBadge()
|
setupSubscriptionsBadge()
|
||||||
|
|
||||||
|
val playerViewModel = ViewModelProvider(this)[PlayerViewModel::class.java]
|
||||||
|
|
||||||
// new way of handling back presses
|
// new way of handling back presses
|
||||||
onBackPressedDispatcher.addCallback(object : OnBackPressedCallback(true) {
|
onBackPressedDispatcher.addCallback(object : OnBackPressedCallback(true) {
|
||||||
override fun handleOnBackPressed() {
|
override fun handleOnBackPressed() {
|
||||||
|
if (playerViewModel.isFullscreen.value == true) {
|
||||||
|
for (fragment in supportFragmentManager.fragments) {
|
||||||
|
if (fragment is PlayerFragment) {
|
||||||
|
fragment.unsetFullscreen()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (binding.mainMotionLayout.progress == 0F) {
|
if (binding.mainMotionLayout.progress == 0F) {
|
||||||
try {
|
try {
|
||||||
minimizePlayer()
|
minimizePlayer()
|
||||||
|
@ -432,7 +432,7 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("SourceLockedOrientationActivity")
|
@SuppressLint("SourceLockedOrientationActivity")
|
||||||
private fun unsetFullscreen() {
|
fun unsetFullscreen() {
|
||||||
// leave fullscreen mode
|
// leave fullscreen mode
|
||||||
with(binding.playerMotionLayout) {
|
with(binding.playerMotionLayout) {
|
||||||
getConstraintSet(R.id.start).constrainHeight(R.id.player, 0)
|
getConstraintSet(R.id.start).constrainHeight(R.id.player, 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user