From f8915f3c2c6d4ef9405152de9ba4cc46d281191f Mon Sep 17 00:00:00 2001 From: Bnyro Date: Tue, 5 Mar 2024 19:21:13 +0100 Subject: [PATCH] fix: miniplayer minimized when opening video via link --- .../libretube/ui/activities/MainActivity.kt | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt b/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt index dd5cb68ee..afbbf28ae 100644 --- a/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt +++ b/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt @@ -8,11 +8,11 @@ import android.view.KeyEvent import android.view.Menu import android.view.MenuItem import android.view.View +import android.view.ViewTreeObserver import android.widget.ScrollView import androidx.activity.addCallback import androidx.activity.viewModels import androidx.appcompat.widget.SearchView -import androidx.constraintlayout.widget.ConstraintSet import androidx.core.content.pm.ShortcutManagerCompat import androidx.core.os.bundleOf import androidx.core.view.allViews @@ -417,11 +417,20 @@ class MainActivity : BaseActivity() { navController.navigate(NavDirections.openPlaylist(playlistId = it)) } intent?.getStringExtra(IntentData.videoId)?.let { - NavigationHelper.navigateVideo( - context = this, - videoUrlOrId = it, - timestamp = intent.getLongExtra(IntentData.timeStamp, 0L) - ) + // 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( + context = this@MainActivity, + videoUrlOrId = it, + timestamp = intent.getLongExtra(IntentData.timeStamp, 0L) + ) + + binding.bottomNav.viewTreeObserver.removeOnGlobalLayoutListener(this) + } + }) } intent?.getStringExtra(IntentData.query)?.let { savedSearchQuery = it @@ -456,8 +465,6 @@ class MainActivity : BaseActivity() { linLayout.isVisible = true playerMotionLayout.setTransitionDuration(250) playerMotionLayout.transitionToEnd() - playerMotionLayout.getConstraintSet(R.id.start) - .constrainHeight(R.id.player, ConstraintSet.WRAP_CONTENT) playerMotionLayout.enableTransition(R.id.yt_transition, true) } (fragment as? AudioPlayerFragment)?.binding?.apply {