Merge pull request #5698 from Bnyro/master

fix: miniplayer minimized when opening video via link
This commit is contained in:
Bnyro 2024-03-05 19:23:52 +01:00 committed by GitHub
commit 17f12ede65
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -8,11 +8,11 @@ import android.view.KeyEvent
import android.view.Menu import android.view.Menu
import android.view.MenuItem import android.view.MenuItem
import android.view.View import android.view.View
import android.view.ViewTreeObserver
import android.widget.ScrollView import android.widget.ScrollView
import androidx.activity.addCallback import androidx.activity.addCallback
import androidx.activity.viewModels import androidx.activity.viewModels
import androidx.appcompat.widget.SearchView import androidx.appcompat.widget.SearchView
import androidx.constraintlayout.widget.ConstraintSet
import androidx.core.content.pm.ShortcutManagerCompat import androidx.core.content.pm.ShortcutManagerCompat
import androidx.core.os.bundleOf import androidx.core.os.bundleOf
import androidx.core.view.allViews import androidx.core.view.allViews
@ -417,11 +417,20 @@ class MainActivity : BaseActivity() {
navController.navigate(NavDirections.openPlaylist(playlistId = it)) navController.navigate(NavDirections.openPlaylist(playlistId = it))
} }
intent?.getStringExtra(IntentData.videoId)?.let { intent?.getStringExtra(IntentData.videoId)?.let {
// the bottom navigation bar has to be created before opening the video
// otherwise the player layout measures aren't calculated properly
// and the miniplayer is opened at a closed state and overlapsing the navigationb ar
binding.bottomNav.viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener {
override fun onGlobalLayout() {
NavigationHelper.navigateVideo( NavigationHelper.navigateVideo(
context = this, context = this@MainActivity,
videoUrlOrId = it, videoUrlOrId = it,
timestamp = intent.getLongExtra(IntentData.timeStamp, 0L) timestamp = intent.getLongExtra(IntentData.timeStamp, 0L)
) )
binding.bottomNav.viewTreeObserver.removeOnGlobalLayoutListener(this)
}
})
} }
intent?.getStringExtra(IntentData.query)?.let { intent?.getStringExtra(IntentData.query)?.let {
savedSearchQuery = it savedSearchQuery = it
@ -456,8 +465,6 @@ class MainActivity : BaseActivity() {
linLayout.isVisible = true linLayout.isVisible = true
playerMotionLayout.setTransitionDuration(250) playerMotionLayout.setTransitionDuration(250)
playerMotionLayout.transitionToEnd() playerMotionLayout.transitionToEnd()
playerMotionLayout.getConstraintSet(R.id.start)
.constrainHeight(R.id.player, ConstraintSet.WRAP_CONTENT)
playerMotionLayout.enableTransition(R.id.yt_transition, true) playerMotionLayout.enableTransition(R.id.yt_transition, true)
} }
(fragment as? AudioPlayerFragment)?.binding?.apply { (fragment as? AudioPlayerFragment)?.binding?.apply {