Fixed
Status Update
Comments
lp...@google.com <lp...@google.com> #2
Possibly related to / duplicate of:
ad...@google.com <ad...@google.com> #3
Yes, definitely related.
ap...@google.com <ap...@google.com> #4
Project: platform/frameworks/support
Branch: androidx-main
commit 36faab79e432504b1274aeb5c4375cc664f6d98d
Author: Mihai Popa <popam@google.com>
Date: Mon Jul 05 17:40:45 2021
Default true usePlatformDefaultWidth for dialogs
Relnote: "Dialogs now follow the platform sizing behaviour. Set usePlatformDefaultWidth to false to override this behaviour."
Fixes: 192682388
Test: AlertDialogTest
Change-Id: Iffaedb8890f59627a58fb4f33d06044ac120fd7d
M compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/AlertDialogTest.kt
M compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/DialogTest.kt
M compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/window/AndroidDialog.android.kt
https://android-review.googlesource.com/1756490
Branch: androidx-main
commit 36faab79e432504b1274aeb5c4375cc664f6d98d
Author: Mihai Popa <popam@google.com>
Date: Mon Jul 05 17:40:45 2021
Default true usePlatformDefaultWidth for dialogs
Relnote: "Dialogs now follow the platform sizing behaviour. Set usePlatformDefaultWidth to false to override this behaviour."
Fixes: 192682388
Test: AlertDialogTest
Change-Id: Iffaedb8890f59627a58fb4f33d06044ac120fd7d
M compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/AlertDialogTest.kt
M compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/DialogTest.kt
M compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/window/AndroidDialog.android.kt
ha...@gmail.com <ha...@gmail.com> #5
In reply to last comment,
This commit still has issue, as you are passing the default value of usePlatformDefaultWidth true.
But in the inner constructor its not being used it is still hardcoded.
So if we pass usePlatformDefaultWidth = false, its not reflected in the object and thus issue is still there.
@Immutable
class DialogProperties @ExperimentalComposeUiApi constructor( //This constructor is used by app
val dismissOnBackPress: Boolean = true,
val dismissOnClickOutside: Boolean = true,
val securePolicy: SecureFlagPolicy = SecureFlagPolicy.Inherit,
val usePlatformDefaultWidth: Boolean = true,
decorFitsSystemWindows: Boolean = true
) {
@Suppress("OPT_IN_MARKER_ON_WRONG_TARGET", "CanBePrimaryConstructorProperty")
@get:ExperimentalComposeUiApi
@ExperimentalComposeUiApi
val decorFitsSystemWindows: Boolean = decorFitsSystemWindows
@OptIn(ExperimentalComposeUiApi::class)
constructor( // This is the inner constructor thus setting the value usePlatformDefaultWidth = true and not reflecting in the SDK code.
dismissOnBackPress: Boolean = true,
dismissOnClickOutside: Boolean = true,
securePolicy: SecureFlagPolicy = SecureFlagPolicy.Inherit,
) : this(
dismissOnBackPress = dismissOnBackPress,
dismissOnClickOutside = dismissOnClickOutside,
securePolicy = securePolicy,
usePlatformDefaultWidth = true,
decorFitsSystemWindows = true
)
This commit still has issue, as you are passing the default value of usePlatformDefaultWidth true.
But in the inner constructor its not being used it is still hardcoded.
So if we pass usePlatformDefaultWidth = false, its not reflected in the object and thus issue is still there.
@Immutable
class DialogProperties @ExperimentalComposeUiApi constructor( //This constructor is used by app
val dismissOnBackPress: Boolean = true,
val dismissOnClickOutside: Boolean = true,
val securePolicy: SecureFlagPolicy = SecureFlagPolicy.Inherit,
val usePlatformDefaultWidth: Boolean = true,
decorFitsSystemWindows: Boolean = true
) {
@Suppress("OPT_IN_MARKER_ON_WRONG_TARGET", "CanBePrimaryConstructorProperty")
@get:ExperimentalComposeUiApi
@ExperimentalComposeUiApi
val decorFitsSystemWindows: Boolean = decorFitsSystemWindows
@OptIn(ExperimentalComposeUiApi::class)
constructor( // This is the inner constructor thus setting the value usePlatformDefaultWidth = true and not reflecting in the SDK code.
dismissOnBackPress: Boolean = true,
dismissOnClickOutside: Boolean = true,
securePolicy: SecureFlagPolicy = SecureFlagPolicy.Inherit,
) : this(
dismissOnBackPress = dismissOnBackPress,
dismissOnClickOutside = dismissOnClickOutside,
securePolicy = securePolicy,
usePlatformDefaultWidth = true,
decorFitsSystemWindows = true
)
Description
Using the AlertDialog API as shown in the sample code here:https://cs.android.com/androidx/platform/tools/dokka-devsite-plugin/+/master:testData/compose/samples/material/samples/AlertDialogSample.kt;l=36 yields a dialog that extends all the way to the device screen edges as shown in the attached screenshot.
AlertDialogs should leave space near the edges as
android.app.AlertDialog
does.We should address this prior to 1.0 if we can; as-is it's seemingly mandatory to add a
Modifier.padding(24.dp)
to AlertDialog usages to avoid the edges of the screen.Other adaptive behavior for larger screens is out of scope for this change.