Skip to content

Commit a1f5dd3

Browse files
Axelen123oSumAtrIX
authored andcommitted
fix: handle edge-to-edge properly in fullscreen dialogs
1 parent 2b07848 commit a1f5dd3

File tree

8 files changed

+70
-57
lines changed

8 files changed

+70
-57
lines changed

app/src/main/java/app/revanced/manager/ui/component/ExceptionViewerDialog.kt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ import androidx.compose.runtime.Composable
1616
import androidx.compose.ui.Modifier
1717
import androidx.compose.ui.platform.LocalContext
1818
import androidx.compose.ui.res.stringResource
19-
import androidx.compose.ui.window.Dialog
20-
import androidx.compose.ui.window.DialogProperties
2119
import app.revanced.manager.R
2220
import app.revanced.manager.ui.component.bundle.BundleTopBar
2321

@@ -26,12 +24,8 @@ import app.revanced.manager.ui.component.bundle.BundleTopBar
2624
fun ExceptionViewerDialog(text: String, onDismiss: () -> Unit) {
2725
val context = LocalContext.current
2826

29-
Dialog(
27+
FullscreenDialog(
3028
onDismissRequest = onDismiss,
31-
properties = DialogProperties(
32-
usePlatformDefaultWidth = false,
33-
dismissOnBackPress = true
34-
)
3529
) {
3630
Scaffold(
3731
topBar = {
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package app.revanced.manager.ui.component
2+
3+
import android.view.WindowManager
4+
import androidx.compose.runtime.Composable
5+
import androidx.compose.runtime.LaunchedEffect
6+
import androidx.compose.ui.graphics.Color
7+
import androidx.compose.ui.graphics.toArgb
8+
import androidx.compose.ui.platform.LocalView
9+
import androidx.compose.ui.window.Dialog
10+
import androidx.compose.ui.window.DialogProperties
11+
import androidx.compose.ui.window.DialogWindowProvider
12+
13+
private val properties = DialogProperties(
14+
usePlatformDefaultWidth = false,
15+
dismissOnBackPress = true,
16+
decorFitsSystemWindows = false,
17+
)
18+
19+
@Composable
20+
fun FullscreenDialog(onDismissRequest: () -> Unit, content: @Composable () -> Unit) {
21+
Dialog(
22+
onDismissRequest = onDismissRequest,
23+
properties = properties
24+
) {
25+
val window = (LocalView.current.parent as DialogWindowProvider).window
26+
LaunchedEffect(Unit) {
27+
window.statusBarColor = Color.Transparent.toArgb()
28+
window.navigationBarColor = Color.Transparent.toArgb()
29+
window.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS)
30+
}
31+
32+
content()
33+
}
34+
}

app/src/main/java/app/revanced/manager/ui/component/bundle/BundleInformationDialog.kt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ import androidx.compose.runtime.*
1212
import androidx.compose.runtime.saveable.rememberSaveable
1313
import androidx.compose.ui.Modifier
1414
import androidx.compose.ui.res.stringResource
15-
import androidx.compose.ui.window.Dialog
16-
import androidx.compose.ui.window.DialogProperties
1715
import androidx.lifecycle.compose.collectAsStateWithLifecycle
1816
import app.revanced.manager.R
1917
import app.revanced.manager.data.platform.NetworkInfo
@@ -23,6 +21,7 @@ import app.revanced.manager.domain.bundles.PatchBundleSource.Extensions.asRemote
2321
import app.revanced.manager.domain.bundles.PatchBundleSource.Extensions.isDefault
2422
import app.revanced.manager.domain.bundles.PatchBundleSource.Extensions.nameState
2523
import app.revanced.manager.ui.component.ExceptionViewerDialog
24+
import app.revanced.manager.ui.component.FullscreenDialog
2625
import kotlinx.coroutines.launch
2726
import org.koin.compose.koinInject
2827

@@ -56,12 +55,8 @@ fun BundleInformationDialog(
5655
)
5756
}
5857

59-
Dialog(
58+
FullscreenDialog(
6059
onDismissRequest = onDismissRequest,
61-
properties = DialogProperties(
62-
usePlatformDefaultWidth = false,
63-
dismissOnBackPress = true
64-
)
6560
) {
6661
val bundleName by bundle.nameState
6762

app/src/main/java/app/revanced/manager/ui/component/bundle/BundlePatchesDialog.kt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,12 @@ import androidx.compose.ui.res.stringResource
2222
import androidx.compose.ui.text.font.FontWeight
2323
import androidx.compose.ui.text.style.TextOverflow
2424
import androidx.compose.ui.unit.dp
25-
import androidx.compose.ui.window.Dialog
26-
import androidx.compose.ui.window.DialogProperties
2725
import androidx.lifecycle.compose.collectAsStateWithLifecycle
2826
import app.revanced.manager.R
2927
import app.revanced.manager.domain.bundles.PatchBundleSource
3028
import app.revanced.manager.patcher.patch.PatchInfo
3129
import app.revanced.manager.ui.component.ArrowButton
30+
import app.revanced.manager.ui.component.FullscreenDialog
3231
import app.revanced.manager.ui.component.LazyColumnWithScrollbar
3332

3433
@OptIn(ExperimentalMaterial3Api::class)
@@ -41,12 +40,8 @@ fun BundlePatchesDialog(
4140
var showOptions by rememberSaveable { mutableStateOf(false) }
4241
val state by bundle.state.collectAsStateWithLifecycle()
4342

44-
Dialog(
43+
FullscreenDialog(
4544
onDismissRequest = onDismissRequest,
46-
properties = DialogProperties(
47-
usePlatformDefaultWidth = false,
48-
dismissOnBackPress = true
49-
)
5045
) {
5146
Scaffold(
5247
topBar = {

app/src/main/java/app/revanced/manager/ui/component/patches/OptionFields.kt

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import androidx.compose.foundation.layout.fillMaxHeight
1414
import androidx.compose.foundation.layout.fillMaxWidth
1515
import androidx.compose.foundation.layout.padding
1616
import androidx.compose.foundation.lazy.LazyColumn
17+
import androidx.compose.foundation.lazy.LazyListItemInfo
1718
import androidx.compose.foundation.lazy.items
1819
import androidx.compose.foundation.lazy.itemsIndexed
1920
import androidx.compose.foundation.lazy.rememberLazyListState
@@ -55,13 +56,13 @@ import androidx.compose.ui.res.pluralStringResource
5556
import androidx.compose.ui.res.stringResource
5657
import androidx.compose.ui.text.font.FontStyle
5758
import androidx.compose.ui.unit.dp
58-
import androidx.compose.ui.window.DialogProperties
5959
import app.revanced.manager.R
6060
import app.revanced.manager.data.platform.Filesystem
6161
import app.revanced.manager.patcher.patch.Option
6262
import app.revanced.manager.ui.component.AlertDialogExtended
6363
import app.revanced.manager.ui.component.AppTopBar
6464
import app.revanced.manager.ui.component.FloatInputDialog
65+
import app.revanced.manager.ui.component.FullscreenDialog
6566
import app.revanced.manager.ui.component.IntInputDialog
6667
import app.revanced.manager.ui.component.LongInputDialog
6768
import app.revanced.manager.ui.component.haptics.HapticExtendedFloatingActionButton
@@ -73,16 +74,17 @@ import app.revanced.manager.util.saver.snapshotStateListSaver
7374
import app.revanced.manager.util.saver.snapshotStateSetSaver
7475
import app.revanced.manager.util.toast
7576
import app.revanced.manager.util.transparentListItemColors
77+
import kotlinx.coroutines.CoroutineScope
7678
import kotlinx.parcelize.Parcelize
7779
import org.koin.compose.koinInject
7880
import org.koin.core.component.KoinComponent
7981
import org.koin.core.component.get
8082
import sh.calvin.reorderable.ReorderableItem
8183
import sh.calvin.reorderable.rememberReorderableLazyColumnState
84+
import sh.calvin.reorderable.rememberReorderableLazyListState
8285
import java.io.Serializable
8386
import kotlin.random.Random
8487
import kotlin.reflect.typeOf
85-
import androidx.compose.ui.window.Dialog as ComposeDialog
8688

8789
private class OptionEditorScope<T : Any>(
8890
private val editor: OptionEditor<T>,
@@ -497,7 +499,8 @@ private class ListOptionEditor<T : Serializable>(private val elementEditor: Opti
497499

498500
val lazyListState = rememberLazyListState()
499501
val reorderableLazyColumnState =
500-
rememberReorderableLazyColumnState(lazyListState) { from, to ->
502+
// Update the list
503+
rememberReorderableLazyListState(lazyListState) { from, to ->
501504
// Update the list
502505
items.add(to.index, items.removeAt(from.index))
503506
}
@@ -524,12 +527,8 @@ private class ListOptionEditor<T : Serializable>(private val elementEditor: Opti
524527
scope.submitDialog(items.mapNotNull { it.value })
525528
}
526529

527-
ComposeDialog(
530+
FullscreenDialog(
528531
onDismissRequest = back,
529-
properties = DialogProperties(
530-
usePlatformDefaultWidth = false,
531-
dismissOnBackPress = true
532-
),
533532
) {
534533
Scaffold(
535534
topBar = {

app/src/main/java/app/revanced/manager/ui/component/patches/PathSelectorDialog.kt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@ import androidx.compose.runtime.setValue
2323
import androidx.compose.ui.Modifier
2424
import androidx.compose.ui.graphics.vector.ImageVector
2525
import androidx.compose.ui.res.stringResource
26-
import androidx.compose.ui.window.Dialog
27-
import androidx.compose.ui.window.DialogProperties
2826
import app.revanced.manager.R
2927
import app.revanced.manager.ui.component.AppTopBar
28+
import app.revanced.manager.ui.component.FullscreenDialog
3029
import app.revanced.manager.ui.component.GroupHeader
3130
import app.revanced.manager.ui.component.LazyColumnWithScrollbar
3231
import app.revanced.manager.util.saver.PathSaver
@@ -48,12 +47,8 @@ fun PathSelectorDialog(root: Path, onSelect: (Path?) -> Unit) {
4847
currentDirectory.listDirectoryEntries().filter(Path::isReadable).partition(Path::isDirectory)
4948
}
5049

51-
Dialog(
50+
FullscreenDialog(
5251
onDismissRequest = { onSelect(null) },
53-
properties = DialogProperties(
54-
usePlatformDefaultWidth = false,
55-
dismissOnBackPress = true
56-
)
5752
) {
5853
Scaffold(
5954
topBar = {

app/src/main/java/app/revanced/manager/ui/screen/PatchesSelectorScreen.kt

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,13 @@ import androidx.compose.ui.draw.rotate
6060
import androidx.compose.ui.res.stringResource
6161
import androidx.compose.ui.text.style.TextAlign
6262
import androidx.compose.ui.unit.dp
63-
import androidx.compose.ui.window.Dialog
64-
import androidx.compose.ui.window.DialogProperties
6563
import androidx.lifecycle.compose.collectAsStateWithLifecycle
6664
import app.revanced.manager.R
6765
import app.revanced.manager.patcher.patch.Option
6866
import app.revanced.manager.patcher.patch.PatchInfo
6967
import app.revanced.manager.ui.component.AppTopBar
7068
import app.revanced.manager.ui.component.CheckedFilterChip
69+
import app.revanced.manager.ui.component.FullscreenDialog
7170
import app.revanced.manager.ui.component.LazyColumnWithScrollbar
7271
import app.revanced.manager.ui.component.SafeguardDialog
7372
import app.revanced.manager.ui.component.SearchBar
@@ -369,14 +368,22 @@ fun PatchesSelectorScreen(
369368
Icon(Icons.Outlined.Restore, stringResource(R.string.reset))
370369
}
371370
HapticExtendedFloatingActionButton(
372-
text = { Text(stringResource(R.string.save_with_count, selectedPatchCount)) },
371+
text = {
372+
Text(
373+
stringResource(
374+
R.string.save_with_count,
375+
selectedPatchCount
376+
)
377+
)
378+
},
373379
icon = {
374380
Icon(
375381
imageVector = Icons.Outlined.Save,
376382
contentDescription = stringResource(R.string.save)
377383
)
378384
},
379-
expanded = patchLazyListStates.getOrNull(pagerState.currentPage)?.isScrollingUp ?: true,
385+
expanded = patchLazyListStates.getOrNull(pagerState.currentPage)?.isScrollingUp
386+
?: true,
380387
onClick = {
381388
onSave(vm.getCustomSelection(), vm.getOptions())
382389
}
@@ -630,13 +637,7 @@ private fun OptionsDialog(
630637
reset: () -> Unit,
631638
set: (String, Any?) -> Unit,
632639
onDismissRequest: () -> Unit,
633-
) = Dialog(
634-
onDismissRequest = onDismissRequest,
635-
properties = DialogProperties(
636-
usePlatformDefaultWidth = false,
637-
dismissOnBackPress = true
638-
)
639-
) {
640+
) = FullscreenDialog(onDismissRequest = onDismissRequest) {
640641
Scaffold(
641642
topBar = {
642643
AppTopBar(

gradle/libs.versions.toml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
[versions]
2-
ktx = "1.15.0"
3-
material3 = "1.3.1"
4-
ui-tooling = "1.7.7"
5-
viewmodel-lifecycle = "2.8.7"
2+
ktx = "1.16.0"
3+
material3 = "1.3.2"
4+
ui-tooling = "1.8.1"
5+
viewmodel-lifecycle = "2.9.0"
66
splash-screen = "1.0.1"
7-
activity = "1.10.0"
7+
activity = "1.10.1"
88
appcompat = "1.7.0"
99
preferences-datastore = "1.1.2"
10-
work-runtime = "2.10.0"
11-
compose-bom = "2025.01.01"
12-
navigation = "2.8.6"
10+
work-runtime = "2.10.1"
11+
compose-bom = "2025.05.00"
12+
navigation = "2.9.0"
1313
accompanist = "0.37.0"
1414
placeholder = "1.1.2"
1515
reorderable = "2.4.3"
1616
serialization = "1.8.0"
1717
collection = "0.3.8"
1818
datetime = "0.6.1"
19-
room-version = "2.6.1"
19+
room-version = "2.7.1"
2020
revanced-patcher = "21.0.0"
2121
revanced-library = "3.0.2"
2222
plugin-api = "1.0.0"
@@ -25,7 +25,7 @@ ktor = "2.3.9"
2525
markdown-renderer = "0.30.0"
2626
fading-edges = "1.0.4"
2727
kotlin = "2.1.10"
28-
android-gradle-plugin = "8.8.0"
28+
android-gradle-plugin = "8.9.1"
2929
dev-tools-gradle-plugin = "2.1.10-1.0.29"
3030
about-libraries-gradle-plugin = "11.5.0"
3131
coil = "2.7.0"

0 commit comments

Comments
 (0)