From ba364c69323de66a3950cd988b9c2e38bac20c87 Mon Sep 17 00:00:00 2001 From: ashnohe Date: Thu, 16 Oct 2025 16:33:18 -0700 Subject: [PATCH 1/8] fix screens to draw edge-to-edge --- Jetcaster/gradle/libs.versions.toml | 2 +- .../com/example/jetcaster/ui/MainActivity.kt | 4 +-- .../com/example/jetcaster/ui/home/Home.kt | 25 +++++++++++++++++-- .../jetcaster/ui/player/PlayerScreen.kt | 23 +++++++---------- 4 files changed, 35 insertions(+), 19 deletions(-) diff --git a/Jetcaster/gradle/libs.versions.toml b/Jetcaster/gradle/libs.versions.toml index 4a02af961..c4c2a6612 100644 --- a/Jetcaster/gradle/libs.versions.toml +++ b/Jetcaster/gradle/libs.versions.toml @@ -11,7 +11,7 @@ androidx-appcompat = "1.7.1" androidx-compose-bom = "2025.09.00" androidx-constraintlayout = "1.1.1" androidx-core-splashscreen = "1.0.1" -androidx-corektx = "1.16.0" +androidx-corektx = "1.17.0" androidx-glance = "1.1.1" androidx-lifecycle = "2.8.2" androidx-lifecycle-compose = "2.9.1" diff --git a/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/MainActivity.kt b/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/MainActivity.kt index d7cfca1a7..e01cdab3d 100644 --- a/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/MainActivity.kt +++ b/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/MainActivity.kt @@ -19,7 +19,7 @@ package com.example.jetcaster.ui import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent -import androidx.activity.enableEdgeToEdge +import androidx.core.view.WindowCompat import com.example.jetcaster.glancewidget.updateWidgetPreview import com.example.jetcaster.ui.theme.JetcasterTheme import com.google.accompanist.adaptive.calculateDisplayFeatures @@ -30,7 +30,7 @@ class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - enableEdgeToEdge() + WindowCompat.enableEdgeToEdge(window) updateWidgetPreview(this) setContent { val displayFeatures = calculateDisplayFeatures(this) diff --git a/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/home/Home.kt b/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/home/Home.kt index 7b363bfce..965a7aaa3 100644 --- a/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/home/Home.kt +++ b/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/home/Home.kt @@ -28,6 +28,7 @@ import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.WindowInsets +import androidx.compose.foundation.layout.asPaddingValues import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height @@ -84,6 +85,7 @@ import androidx.compose.ui.draw.clip import androidx.compose.ui.geometry.Rect import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Color +import androidx.compose.ui.platform.LocalLayoutDirection import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextOverflow @@ -394,7 +396,7 @@ private fun HomeScreen( val coroutineScope = rememberCoroutineScope() val snackbarHostState = remember { SnackbarHostState() } HomeScreenBackground( - modifier = modifier.windowInsetsPadding(WindowInsets.navigationBars), +// modifier = modifier.windowInsetsPadding(WindowInsets.navigationBars), ) { Scaffold( topBar = { @@ -418,6 +420,7 @@ private fun HomeScreen( containerColor = Color.Transparent, ) { contentPadding -> // Main Content + val layoutDirection = LocalLayoutDirection.current val snackBarText = stringResource(id = R.string.episode_added_to_your_queue) val showHomeCategoryTabs = featuredPodcasts.isNotEmpty() && homeCategories.isNotEmpty() HomeContent( @@ -426,7 +429,19 @@ private fun HomeScreen( filterableCategoriesModel = filterableCategoriesModel, podcastCategoryFilterResult = podcastCategoryFilterResult, library = library, - modifier = Modifier.padding(contentPadding), + /** + * Edge-to-edge: + * Handles left, right and top insets allowing content to scroll behind the system navigation bar for an edge-to-edge look. + * Bottom insets are applied to the last list item in [HomeContentGrid]. + */ + modifier = modifier.windowInsetsPadding( + WindowInsets( + left = contentPadding.calculateLeftPadding(layoutDirection), + right = contentPadding.calculateRightPadding(layoutDirection), + top = contentPadding.calculateTopPadding(), + bottom = 0.dp, + ) + ), onHomeAction = { action -> if (action is HomeAction.QueueEpisode) { coroutineScope.launch { @@ -585,6 +600,12 @@ private fun HomeContentGrid( LazyVerticalGrid( columns = GridCells.Adaptive(362.dp), modifier = modifier.fillMaxSize(), + /** + * Edge-to-edge: + * Allows content to scroll behind the system navigation bar while ensuring the last list item is still accessible. + * Top, right and left insets are handled in [HomeScreen]. + */ + contentPadding = WindowInsets.navigationBars.asPaddingValues() ) { when (selectedHomeCategory) { HomeCategory.Library -> { diff --git a/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/player/PlayerScreen.kt b/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/player/PlayerScreen.kt index 77536537f..0627cfdf3 100644 --- a/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/player/PlayerScreen.kt +++ b/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/player/PlayerScreen.kt @@ -29,7 +29,6 @@ import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.BoxWithConstraints import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.WindowInsets @@ -40,10 +39,10 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.only import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.safeDrawing import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.sizeIn import androidx.compose.foundation.layout.systemBars -import androidx.compose.foundation.layout.systemBarsPadding import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.windowInsetsPadding import androidx.compose.foundation.layout.wrapContentSize @@ -167,7 +166,7 @@ private fun PlayerScreen( SnackbarHost(hostState = snackbarHostState) }, modifier = modifier, - ) { contentPadding -> + ) { _ -> if (uiState.episodePlayerState.currentEpisode != null) { PlayerContentWithBackground( uiState = uiState, @@ -180,8 +179,7 @@ private fun PlayerScreen( } onAddToQueue() }, - playerControlActions = playerControlActions, - contentPadding = contentPadding, + playerControlActions = playerControlActions ) } else { FullScreenLoading() @@ -207,14 +205,11 @@ fun PlayerContentWithBackground( onAddToQueue: () -> Unit, playerControlActions: PlayerControlActions, modifier: Modifier = Modifier, - contentPadding: PaddingValues = PaddingValues(0.dp), ) { Box(modifier = modifier, contentAlignment = Alignment.Center) { PlayerBackground( episode = uiState.episodePlayerState.currentEpisode, - modifier = Modifier - .fillMaxSize() - .padding(contentPadding), + modifier = modifier.fillMaxSize() ) PlayerContent( uiState = uiState, @@ -222,7 +217,7 @@ fun PlayerContentWithBackground( displayFeatures = displayFeatures, onBackPress = onBackPress, onAddToQueue = onAddToQueue, - playerControlActions = playerControlActions, + playerControlActions = playerControlActions ) } } @@ -300,8 +295,8 @@ fun PlayerContent( startYPercentage = 1f, endYPercentage = 0f, ) - .systemBarsPadding() - .padding(horizontal = 8.dp), + .windowInsetsPadding(WindowInsets.safeDrawing) + .padding(horizontal = 8.dp) ) { TopAppBar( onBackPress = onBackPress, @@ -360,8 +355,8 @@ private fun PlayerContentRegular( startYPercentage = 1f, endYPercentage = 0f, ) - .systemBarsPadding() - .padding(horizontal = 8.dp), + .windowInsetsPadding(WindowInsets.safeDrawing) + .padding(horizontal = 8.dp) ) { TopAppBar( onBackPress = onBackPress, From 2625ea2afcc57d5b9d369ce08f2cfebec59e4122 Mon Sep 17 00:00:00 2001 From: ashnohe Date: Thu, 16 Oct 2025 17:14:47 -0700 Subject: [PATCH 2/8] clean up uncommented code --- .../src/main/java/com/example/jetcaster/ui/home/Home.kt | 4 +--- .../java/com/example/jetcaster/ui/player/PlayerScreen.kt | 6 +++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/home/Home.kt b/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/home/Home.kt index 965a7aaa3..119c71c07 100644 --- a/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/home/Home.kt +++ b/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/home/Home.kt @@ -395,9 +395,7 @@ private fun HomeScreen( val coroutineScope = rememberCoroutineScope() val snackbarHostState = remember { SnackbarHostState() } - HomeScreenBackground( -// modifier = modifier.windowInsetsPadding(WindowInsets.navigationBars), - ) { + HomeScreenBackground { Scaffold( topBar = { Column { diff --git a/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/player/PlayerScreen.kt b/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/player/PlayerScreen.kt index 0627cfdf3..6bf226e28 100644 --- a/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/player/PlayerScreen.kt +++ b/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/player/PlayerScreen.kt @@ -217,7 +217,7 @@ fun PlayerContentWithBackground( displayFeatures = displayFeatures, onBackPress = onBackPress, onAddToQueue = onAddToQueue, - playerControlActions = playerControlActions + playerControlActions = playerControlActions, ) } } @@ -296,7 +296,7 @@ fun PlayerContent( endYPercentage = 0f, ) .windowInsetsPadding(WindowInsets.safeDrawing) - .padding(horizontal = 8.dp) + .padding(horizontal = 8.dp), ) { TopAppBar( onBackPress = onBackPress, @@ -356,7 +356,7 @@ private fun PlayerContentRegular( endYPercentage = 0f, ) .windowInsetsPadding(WindowInsets.safeDrawing) - .padding(horizontal = 8.dp) + .padding(horizontal = 8.dp), ) { TopAppBar( onBackPress = onBackPress, From caf8f8440cb8ab5bb30bc88ef5509a70e46a7e12 Mon Sep 17 00:00:00 2001 From: ashnohe Date: Thu, 16 Oct 2025 17:19:21 -0700 Subject: [PATCH 3/8] revert to using systemBarsPadding() which is also okay --- .../java/com/example/jetcaster/ui/player/PlayerScreen.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/player/PlayerScreen.kt b/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/player/PlayerScreen.kt index 6bf226e28..41e42e297 100644 --- a/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/player/PlayerScreen.kt +++ b/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/player/PlayerScreen.kt @@ -43,6 +43,7 @@ import androidx.compose.foundation.layout.safeDrawing import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.sizeIn import androidx.compose.foundation.layout.systemBars +import androidx.compose.foundation.layout.systemBarsPadding import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.windowInsetsPadding import androidx.compose.foundation.layout.wrapContentSize @@ -179,7 +180,7 @@ private fun PlayerScreen( } onAddToQueue() }, - playerControlActions = playerControlActions + playerControlActions = playerControlActions, ) } else { FullScreenLoading() @@ -295,7 +296,7 @@ fun PlayerContent( startYPercentage = 1f, endYPercentage = 0f, ) - .windowInsetsPadding(WindowInsets.safeDrawing) + .systemBarsPadding() .padding(horizontal = 8.dp), ) { TopAppBar( @@ -355,7 +356,7 @@ private fun PlayerContentRegular( startYPercentage = 1f, endYPercentage = 0f, ) - .windowInsetsPadding(WindowInsets.safeDrawing) + .systemBarsPadding() .padding(horizontal = 8.dp), ) { TopAppBar( From af2dca71e7f8c3b789928bdf9e30961b3fcfd87d Mon Sep 17 00:00:00 2001 From: ashnohe Date: Thu, 16 Oct 2025 17:20:27 -0700 Subject: [PATCH 4/8] remove unused import --- .../main/java/com/example/jetcaster/ui/player/PlayerScreen.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/player/PlayerScreen.kt b/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/player/PlayerScreen.kt index 41e42e297..551cc9fc1 100644 --- a/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/player/PlayerScreen.kt +++ b/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/player/PlayerScreen.kt @@ -39,7 +39,6 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.only import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.safeDrawing import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.sizeIn import androidx.compose.foundation.layout.systemBars From 2705729ede73920442e3ed9e719d10c1a534e55c Mon Sep 17 00:00:00 2001 From: ashnohe Date: Thu, 16 Oct 2025 17:46:56 -0700 Subject: [PATCH 5/8] fix PillToolbar padding --- .../mobile/src/main/java/com/example/jetcaster/ui/home/Home.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/home/Home.kt b/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/home/Home.kt index 119c71c07..0a4237ed0 100644 --- a/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/home/Home.kt +++ b/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/home/Home.kt @@ -33,6 +33,7 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.navigationBars +import androidx.compose.foundation.layout.navigationBarsPadding import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.windowInsetsPadding @@ -467,7 +468,7 @@ private fun HomeScreen( @Composable fun PillToolbar(selectedHomeCategory: HomeCategory, onHomeAction: (HomeAction) -> Unit, modifier: Modifier = Modifier) { HorizontalFloatingToolbar( - modifier = modifier, + modifier = modifier.navigationBarsPadding(), colors = FloatingToolbarColors( toolbarContainerColor = MaterialTheme.colorScheme.surfaceContainerHighest, toolbarContentColor = MaterialTheme.colorScheme.onSurfaceVariant, From 5e1e50940affc9571997c4ce68b242bf702137f5 Mon Sep 17 00:00:00 2001 From: ashnohe Date: Thu, 16 Oct 2025 17:53:43 -0700 Subject: [PATCH 6/8] use padding instead of windowInsetsPadding --- .../main/java/com/example/jetcaster/ui/home/Home.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/home/Home.kt b/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/home/Home.kt index 0a4237ed0..5dd9a5a57 100644 --- a/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/home/Home.kt +++ b/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/home/Home.kt @@ -430,13 +430,13 @@ private fun HomeScreen( library = library, /** * Edge-to-edge: - * Handles left, right and top insets allowing content to scroll behind the system navigation bar for an edge-to-edge look. + * Handles start, end and top insets allowing content to scroll behind the system navigation bar for an edge-to-edge look. * Bottom insets are applied to the last list item in [HomeContentGrid]. */ - modifier = modifier.windowInsetsPadding( - WindowInsets( - left = contentPadding.calculateLeftPadding(layoutDirection), - right = contentPadding.calculateRightPadding(layoutDirection), + modifier = modifier.padding( + PaddingValues( + start = contentPadding.calculateLeftPadding(layoutDirection), + end = contentPadding.calculateRightPadding(layoutDirection), top = contentPadding.calculateTopPadding(), bottom = 0.dp, ) @@ -602,7 +602,7 @@ private fun HomeContentGrid( /** * Edge-to-edge: * Allows content to scroll behind the system navigation bar while ensuring the last list item is still accessible. - * Top, right and left insets are handled in [HomeScreen]. + * Top, start and end insets are handled in [HomeScreen]. */ contentPadding = WindowInsets.navigationBars.asPaddingValues() ) { From 84f53de20c041f7cd3f66e464490b3d0986a5771 Mon Sep 17 00:00:00 2001 From: ashnohe Date: Thu, 16 Oct 2025 17:59:53 -0700 Subject: [PATCH 7/8] remove extra modifier --- .../main/java/com/example/jetcaster/ui/player/PlayerScreen.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/player/PlayerScreen.kt b/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/player/PlayerScreen.kt index 551cc9fc1..3dec33adf 100644 --- a/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/player/PlayerScreen.kt +++ b/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/player/PlayerScreen.kt @@ -206,7 +206,7 @@ fun PlayerContentWithBackground( playerControlActions: PlayerControlActions, modifier: Modifier = Modifier, ) { - Box(modifier = modifier, contentAlignment = Alignment.Center) { + Box(contentAlignment = Alignment.Center) { PlayerBackground( episode = uiState.episodePlayerState.currentEpisode, modifier = modifier.fillMaxSize() From 548bd3f08eb91a0b3d736be07a20881ef6fbc3d1 Mon Sep 17 00:00:00 2001 From: ashnohe Date: Fri, 17 Oct 2025 14:36:05 -0700 Subject: [PATCH 8/8] add back in the box modifier --- .../main/java/com/example/jetcaster/ui/player/PlayerScreen.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/player/PlayerScreen.kt b/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/player/PlayerScreen.kt index 3dec33adf..551cc9fc1 100644 --- a/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/player/PlayerScreen.kt +++ b/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/player/PlayerScreen.kt @@ -206,7 +206,7 @@ fun PlayerContentWithBackground( playerControlActions: PlayerControlActions, modifier: Modifier = Modifier, ) { - Box(contentAlignment = Alignment.Center) { + Box(modifier = modifier, contentAlignment = Alignment.Center) { PlayerBackground( episode = uiState.episodePlayerState.currentEpisode, modifier = modifier.fillMaxSize()