Fix missing focus in new player UI (#5513)

* Fix missing focus in new player UI

* Update app/src/main/java/org/jellyfin/androidtv/ui/base/BaseScreen.kt

Co-authored-by: Bill Thornton <thornbill@users.noreply.github.com>

---------

Co-authored-by: Bill Thornton <thornbill@users.noreply.github.com>
This commit is contained in:
Niels van Velzen
2026-04-06 14:44:37 +02:00
committed by GitHub
parent 25dd7515cb
commit eaf2411a99
3 changed files with 37 additions and 2 deletions

View File

@@ -0,0 +1,29 @@
package org.jellyfin.androidtv.ui.base
import androidx.compose.foundation.focusGroup
import androidx.compose.foundation.layout.Box
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.Stable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
@Composable
@Stable
fun BaseScreen(
content: @Composable () -> Unit,
) {
// Work around a focus issue with our current fragment based navigation approach
// by always focusing the screen contents whenever the screen is created
val focusRequester = remember { FocusRequester() }
Box(
modifier = Modifier
.focusRequester(focusRequester)
.focusGroup()
) {
content()
}
LaunchedEffect(focusRequester) { focusRequester.requestFocus() }
}

View File

@@ -7,6 +7,7 @@ import androidx.fragment.app.Fragment
import androidx.fragment.compose.content
import androidx.lifecycle.lifecycleScope
import kotlinx.coroutines.launch
import org.jellyfin.androidtv.ui.base.BaseScreen
import org.jellyfin.sdk.model.api.ItemSortBy
import org.jellyfin.sdk.model.api.SortOrder
import org.jellyfin.sdk.model.serializer.toUUIDOrNull
@@ -46,6 +47,8 @@ class PhotoPlayerFragment : Fragment() {
container: ViewGroup?,
savedInstanceState: Bundle?
) = content {
PhotoPlayerScreen()
BaseScreen {
PhotoPlayerScreen()
}
}
}

View File

@@ -7,6 +7,7 @@ import androidx.fragment.app.Fragment
import androidx.fragment.compose.content
import androidx.lifecycle.lifecycleScope
import kotlinx.coroutines.launch
import org.jellyfin.androidtv.ui.base.BaseScreen
import org.jellyfin.androidtv.ui.playback.VideoQueueManager
import org.jellyfin.androidtv.ui.playback.rewrite.RewriteMediaManager
import org.jellyfin.playback.core.PlaybackManager
@@ -50,7 +51,9 @@ class VideoPlayerFragment : Fragment() {
container: ViewGroup?,
savedInstanceState: Bundle?
) = content {
VideoPlayerScreen()
BaseScreen {
VideoPlayerScreen()
}
}
override fun onPause() {