Skip to content

Commit

Permalink
fix: video links dont open on android 10 and below
Browse files Browse the repository at this point in the history
  • Loading branch information
Bnyro committed May 1, 2024
1 parent d40e4eb commit 6b82d95
Showing 1 changed file with 24 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.github.libretube.ui.activities
import android.annotation.SuppressLint
import android.content.Intent
import android.content.res.Configuration
import android.os.Build
import android.os.Bundle
import android.view.KeyEvent
import android.view.Menu
Expand Down Expand Up @@ -438,20 +439,29 @@ class MainActivity : BaseActivity() {
.show(supportFragmentManager, null)
}
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 overlapping the navigation bar
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)
}
})
// the below explained work around only seems to work on Android 11 and above
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
// 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 overlapping the navigation bar
binding.bottomNav.viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener {

Check failure on line 447 in app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt

View workflow job for this annotation

GitHub Actions / Check Code Quality

[ktlint] reported by reviewdog 🐶 A multiline expression should start on a new line Raw Output: app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt:447:78: error: A multiline expression should start on a new line (standard:multiline-expression-wrapping)
override fun onGlobalLayout() {
NavigationHelper.navigateVideo(
context = this@MainActivity,
videoUrlOrId = it,
timestamp = intent.getLongExtra(IntentData.timeStamp, 0L)

Check failure on line 452 in app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt

View workflow job for this annotation

GitHub Actions / Check Code Quality

[ktlint] reported by reviewdog 🐶 Missing trailing comma before ")" Raw Output: app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt:452:86: error: Missing trailing comma before ")" (standard:trailing-comma-on-call-site)
)

binding.bottomNav.viewTreeObserver.removeOnGlobalLayoutListener(this)
}
})
} else {
NavigationHelper.navigateVideo(
context = this@MainActivity,
videoUrlOrId = it,
timestamp = intent.getLongExtra(IntentData.timeStamp, 0L)

Check failure on line 462 in app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt

View workflow job for this annotation

GitHub Actions / Check Code Quality

[ktlint] reported by reviewdog 🐶 Missing trailing comma before ")" Raw Output: app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt:462:78: error: Missing trailing comma before ")" (standard:trailing-comma-on-call-site)
)
}
}
intent?.getStringExtra(IntentData.query)?.let {
savedSearchQuery = it
Expand Down

0 comments on commit 6b82d95

Please sign in to comment.