mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-13 22:00: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)
|
||||
|
||||
lateinit var searchView: SearchView
|
||||
lateinit var searchItem: MenuItem
|
||||
private lateinit var searchItem: MenuItem
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
@ -131,9 +131,20 @@ class MainActivity : BaseActivity() {
|
||||
|
||||
setupSubscriptionsBadge()
|
||||
|
||||
val playerViewModel = ViewModelProvider(this)[PlayerViewModel::class.java]
|
||||
|
||||
// new way of handling back presses
|
||||
onBackPressedDispatcher.addCallback(object : OnBackPressedCallback(true) {
|
||||
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) {
|
||||
try {
|
||||
minimizePlayer()
|
||||
|
@ -432,7 +432,7 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
||||
}
|
||||
|
||||
@SuppressLint("SourceLockedOrientationActivity")
|
||||
private fun unsetFullscreen() {
|
||||
fun unsetFullscreen() {
|
||||
// leave fullscreen mode
|
||||
with(binding.playerMotionLayout) {
|
||||
getConstraintSet(R.id.start).constrainHeight(R.id.player, 0)
|
||||
|
Loading…
Reference in New Issue
Block a user