Status Update
Comments
ma...@google.com <ma...@google.com>
mo...@google.com <mo...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-main
Author: Jeremy Woods <
Link:
Add @CheckResult annotation to generated Action functions
Expand for full commit details
Add @CheckResult annotation to generated Action functions
Adding the check result annotation to the Action functions and methods
generated by safeargs to ensure that developers actually use the
functions.
RelNote: "Navigation Safe Args actions are now generated with the
`@CheckResult` annotation to ensure they are used."
Test: modified all tests
Bug: 356323084
Change-Id: I14d4c00fe8fc0e994b962776e1f10b4a8a63ece4
Files:
- M
navigation/navigation-safe-args-generator/build.gradle
- M
navigation/navigation-safe-args-generator/src/main/kotlin/androidx/navigation/safe/args/generator/java/JavaNavWriter.kt
- M
navigation/navigation-safe-args-generator/src/main/kotlin/androidx/navigation/safe/args/generator/java/JavaTypes.kt
- M
navigation/navigation-safe-args-generator/src/main/kotlin/androidx/navigation/safe/args/generator/kotlin/KotlinNavWriter.kt
- M
navigation/navigation-safe-args-generator/src/test/test-data/expected/java_nav_writer_test/LongPackageFragmentDirections.java
- M
navigation/navigation-safe-args-generator/src/test/test-data/expected/java_nav_writer_test/MainFragmentDirections.java
- M
navigation/navigation-safe-args-generator/src/test/test-data/expected/java_nav_writer_test/SanitizedMainFragmentDirections.java
- M
navigation/navigation-safe-args-generator/src/test/test-data/expected/kotlin_nav_writer_test/FunFragmentDirections.kt
- M
navigation/navigation-safe-args-generator/src/test/test-data/expected/kotlin_nav_writer_test/LongPackageFragmentDirections.kt
- M
navigation/navigation-safe-args-generator/src/test/test-data/expected/kotlin_nav_writer_test/MainFragmentDefaultParamDirections.kt
- M
navigation/navigation-safe-args-generator/src/test/test-data/expected/kotlin_nav_writer_test/MainFragmentDirections.kt
- M
navigation/navigation-safe-args-generator/src/test/test-data/expected/nav_generator_test/java/nested/LoginDirections.java
- M
navigation/navigation-safe-args-generator/src/test/test-data/expected/nav_generator_test/java/nested/LoginFragmentDirections.java
- M
navigation/navigation-safe-args-generator/src/test/test-data/expected/nav_generator_test/java/nested/MainFragmentDirections.java
- M
navigation/navigation-safe-args-generator/src/test/test-data/expected/nav_generator_test/java/nested/RegisterFragmentDirections.java
- M
navigation/navigation-safe-args-generator/src/test/test-data/expected/nav_generator_test/java/nested_overridden_action/InnerSettingsDirections.java
- M
navigation/navigation-safe-args-generator/src/test/test-data/expected/nav_generator_test/java/nested_overridden_action/InnerSettingsFragmentDirections.java
- M
navigation/navigation-safe-args-generator/src/test/test-data/expected/nav_generator_test/java/nested_overridden_action/MainFragmentDirections.java
- M
navigation/navigation-safe-args-generator/src/test/test-data/expected/nav_generator_test/java/nested_overridden_action/SettingsDirections.java
- M
navigation/navigation-safe-args-generator/src/test/test-data/expected/nav_generator_test/java/nested_overridden_action/SettingsFragmentDirections.java
- M
navigation/navigation-safe-args-generator/src/test/test-data/expected/nav_generator_test/java/nested_same_action/MainFragmentDirections.java
- M
navigation/navigation-safe-args-generator/src/test/test-data/expected/nav_generator_test/java/nested_same_action/SettingsDirections.java
- M
navigation/navigation-safe-args-generator/src/test/test-data/expected/nav_generator_test/java/nested_same_action/SettingsFragmentDirections.java
- M
navigation/navigation-safe-args-generator/src/test/test-data/expected/nav_generator_test/kotlin/nested/LoginDirections.kt
- M
navigation/navigation-safe-args-generator/src/test/test-data/expected/nav_generator_test/kotlin/nested/LoginFragmentDirections.kt
- M
navigation/navigation-safe-args-generator/src/test/test-data/expected/nav_generator_test/kotlin/nested/MainFragmentDirections.kt
- M
navigation/navigation-safe-args-generator/src/test/test-data/expected/nav_generator_test/kotlin/nested/RegisterFragmentDirections.kt
- M
navigation/navigation-safe-args-generator/src/test/test-data/expected/nav_generator_test/kotlin/nested_overridden_action/InnerSettingsDirections.kt
- M
navigation/navigation-safe-args-generator/src/test/test-data/expected/nav_generator_test/kotlin/nested_overridden_action/InnerSettingsFragmentDirections.kt
- M
navigation/navigation-safe-args-generator/src/test/test-data/expected/nav_generator_test/kotlin/nested_overridden_action/MainFragmentDirections.kt
- M
navigation/navigation-safe-args-generator/src/test/test-data/expected/nav_generator_test/kotlin/nested_overridden_action/SettingsDirections.kt
- M
navigation/navigation-safe-args-generator/src/test/test-data/expected/nav_generator_test/kotlin/nested_overridden_action/SettingsFragmentDirections.kt
- M
navigation/navigation-safe-args-generator/src/test/test-data/expected/nav_generator_test/kotlin/nested_same_action/MainFragmentDirections.kt
- M
navigation/navigation-safe-args-generator/src/test/test-data/expected/nav_generator_test/kotlin/nested_same_action/SettingsDirections.kt
- M
navigation/navigation-safe-args-generator/src/test/test-data/expected/nav_generator_test/kotlin/nested_same_action/SettingsFragmentDirections.kt
Hash: f3d29e5d85c7911cb2909239c6f2b68e974b8804
Date: Wed Feb 05 22:18:16 2025
sa...@gmail.com <sa...@gmail.com> #3
This has been fixed internally and will be available in the Navigation 2.8.7
release.
mo...@google.com <mo...@google.com> #4
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.navigation:navigation-safe-args-generator:2.9.0-alpha06
va...@google.com <va...@google.com> #5
One potential workaround is applying a windowInsetsPadding
or windowInsets*Height
to an item inside the LazyColumn
, as opposed to using contentPadding
(since that allows using the ModifierLocal
normally. But that may not always be an option (or that has other non-desirable effects).
mo...@google.com <mo...@google.com> #6
Any solution that involves composition means that layout will be delayed by 1 frame.
For the above problem, I think we need something like this:
val consumedNavigationBars by remember { MutableWindowInsets() }
Box(
modifier = Modifier
.consumedWindowInsets(WindowInsets.navigationBars)
.withConsumedWindowInsets {
consumedNavigationBars.insets = WindowInsets.navigationBars.exclude(it)
}
) {
// will have non-zero insets
val insets = consumedNavigationBars.asPaddingValues()
}
class MutableWindowInsets : WindowInsets {
var insets by mutableStateOf(WindowInsets(0, 0, 0, 0))
fun getLeft(density: Density, layoutDirection: LayoutDirection): Int = insets.getLeft(density, layoutDirection)
fun getTop(density: Density): Int = insets.getTop(density)
fun getRight(density: Density, layoutDirection: LayoutDirection): Int = insets.getRight(density, layoutDirection)
fun getBottom(density: Density): Int = insets.getBottom(density)
}
ap...@google.com <ap...@google.com> #7
Branch: androidx-main
commit f6c646af9c5d6eed33998affaccdba72dcc9b825
Author: George Mount <mount@google.com>
Date: Mon Aug 29 15:55:07 2022
Allow access to consumed WindowInsets
Fixes: 237019262
Fixes: 243119659
Relnote: "Added Modifier.withConsumedWindowInsets() to
to get consumed WindowInsets for use outside windowInsetsPadding.
Added MutableWindowInsets to allow easily changing WindowInsets
without recomposition."
Test: new tests
Change-Id: I7fd28c29953ca10b4182d07996f16b66263548b1
M compose/foundation/foundation-layout/src/test/kotlin/androidx/compose/foundation/layout/WindowInsetsTest.kt
M compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/WindowInsetsPaddingSample.kt
M compose/foundation/foundation-layout/api/public_plus_experimental_1.3.0-beta02.txt
M compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/WindowInsetsPaddingTest.kt
M compose/foundation/foundation-layout/api/public_plus_experimental_current.txt
M compose/foundation/foundation-layout/src/commonMain/kotlin/androidx/compose/foundation/layout/WindowInsets.kt
M compose/foundation/foundation-layout/src/commonMain/kotlin/androidx/compose/foundation/layout/WindowInsetsPadding.kt
na...@google.com <na...@google.com> #8
This bug was linked in a change in the following release(s):
androidx.compose.foundation:foundation-layout:1.3.0-beta03
Description
Jetpack Compose version: 1.2.0-rc02
Jetpack Compose component(s) used: Foundation
Android Studio Build: #AI-221.4165.146.2211.8713749
Kotlin version: 1.6.21
When accessing the window insets via
asPaddingValues()
it does not account for the already consumed insets further in the hierarchy. E.g.The
PaddingValues
could be added to aLazyColumn
or similar layout that need extra padding, but only when a parent has not already consumed them. As far as I can tell it is not possible to access the amount of consumed insets, which makes it difficult to achieve this kind of layout.My feature request is either having
asPaddingValues
already account for the consumed insets (just likeModifier.navigationBarPadding()
) or at least provide read-only access to the amount of consumed insets.