Fixed
Status Update
Comments
il...@google.com <il...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-main
commit f0dc0968ae703e34aba39b2c6c836077c340d2a5
Author: Jeremy Woods <jbwoods@google.com>
Date: Wed Sep 01 15:34:41 2021
Make argument default params last
When generating an argument in kotlin from safe args, default parameters
should always come after none defaults in the argument's constructor.
RelNote: "When generating arguments, safe args now puts parameters
without default values before those with default values."
Test: ./gradlew --rerun-tasks
navigation:navigation-safe-args-generator:test
Bug: 198493585
Change-Id: I8970968c48deb3a1437437df9a3db696ed497372
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/kotlin_nav_writer_test/MainFragmentArgs.kt
https://android-review.googlesource.com/1816980
Branch: androidx-main
commit f0dc0968ae703e34aba39b2c6c836077c340d2a5
Author: Jeremy Woods <jbwoods@google.com>
Date: Wed Sep 01 15:34:41 2021
Make argument default params last
When generating an argument in kotlin from safe args, default parameters
should always come after none defaults in the argument's constructor.
RelNote: "When generating arguments, safe args now puts parameters
without default values before those with default values."
Test: ./gradlew --rerun-tasks
navigation:navigation-safe-args-generator:test
Bug: 198493585
Change-Id: I8970968c48deb3a1437437df9a3db696ed497372
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/kotlin_nav_writer_test/MainFragmentArgs.kt
ja...@gmail.com <ja...@gmail.com> #3
This has been fixed internally and will be available in the Navigation 2.4.0-alpha09
release.
ub...@gmail.com <ub...@gmail.com> #4
Problem as a result of this in alpha09, it will now generate broken code when nullable parameters are before non-nullable parameters in the navigation resource file.
ja...@gmail.com <ja...@gmail.com> #5
Re
In the future, please always file regressions as new bugs with a sample project that reproduces your issue rather than commenting on issues already marked as fixed - that way we can properly track those fixes for the next release.
ub...@gmail.com <ub...@gmail.com> #6
From my perspective a more forward-looking solution would be to conceive a way to make resource IDs final again. In a modularized world, having them be non-final leads to nothing but problems. It was a lesser problem back when they were made non-final originally (somewhere in Jelly Bean I believe).
ja...@gmail.com <ja...@gmail.com> #7
I'd rather eliminate the need to have anyone use an R.layout or R.id reference. You don't care about final IDs when you never touch them directly. Layout XMLs are a schema and we should treat them as such by generating interaction types that abstract the underlying mechanics.
il...@google.com <il...@google.com>
al...@google.com <al...@google.com> #8
Given that a) we intended to lock down annotation APIs about two weeks ago so that we could finalize betas and b) this API surface seems to need further discussion, I'm with #5. Please remove this API and re-add for further discussion in the next feature cycle (about four weeks from now).
se...@google.com <se...@google.com> #9
There is aosp/931676 inflight, that doesn't have this issue, but need to check if tools team can create integration with it, it looks good.
ap...@google.com <ap...@google.com> #10
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 2f634eec2143acd6a4ea19a375a6e3877cdcc2ed
Author: Ian Lake <ilake@google.com>
Date: Tue Mar 19 10:14:07 2019
Convert @ContentView to constructor annotation
As layout IDs are non-final in library modules
(and in the future, app modules), change
@ContentView to only be a marker annotation for
a constructor which developers can call with
a specific layout ID.
Fixes: 128352521
Fixes: 127531658
Test: updated tests
Change-Id: I15e2edee8cbd68180991f89fbc3b04e12c961ede
M activity/api/1.0.0-alpha06.txt
M activity/api/current.txt
M activity/src/androidTest/java/androidx/activity/ContentViewTest.kt
M activity/src/main/java/androidx/activity/ComponentActivity.java
M annotations/api/1.1.0-beta01.txt
M annotations/api/current.txt
M annotations/src/main/java/androidx/annotation/ContentView.java
M appcompat/api/1.1.0-alpha04.txt
M appcompat/api/current.txt
M appcompat/src/main/java/androidx/appcompat/app/AppCompatActivity.java
M fragment/api/1.1.0-alpha06.txt
M fragment/api/current.txt
M fragment/src/androidTest/java/androidx/fragment/app/FragmentFactoryTest.kt
M fragment/src/androidTest/java/androidx/fragment/app/FragmentLifecycleTest.kt
M fragment/src/androidTest/java/androidx/fragment/app/FragmentTest.kt
M fragment/src/androidTest/java/androidx/fragment/app/FragmentTransactionTest.kt
M fragment/src/androidTest/java/androidx/fragment/app/FragmentViewTest.kt
M fragment/src/androidTest/java/androidx/fragment/app/NestedInflatedFragmentTest.kt
M fragment/src/androidTest/java/androidx/fragment/app/StrictFragment.kt
M fragment/src/androidTest/java/androidx/fragment/app/StrictViewFragment.kt
M fragment/src/androidTest/java/androidx/fragment/app/test/FragmentTestActivity.kt
M fragment/src/androidTest/java/androidx/fragment/app/test/LoaderActivity.kt
M fragment/src/main/java/androidx/fragment/app/Fragment.java
M fragment/src/main/java/androidx/fragment/app/FragmentActivity.java
M testutils/src/main/java/androidx/testutils/RecreatedActivity.kt
https://android-review.googlesource.com/931676
https://goto.google.com/android-sha1/2f634eec2143acd6a4ea19a375a6e3877cdcc2ed
Branch: androidx-master-dev
commit 2f634eec2143acd6a4ea19a375a6e3877cdcc2ed
Author: Ian Lake <ilake@google.com>
Date: Tue Mar 19 10:14:07 2019
Convert @ContentView to constructor annotation
As layout IDs are non-final in library modules
(and in the future, app modules), change
@ContentView to only be a marker annotation for
a constructor which developers can call with
a specific layout ID.
Fixes: 128352521
Fixes: 127531658
Test: updated tests
Change-Id: I15e2edee8cbd68180991f89fbc3b04e12c961ede
M activity/api/1.0.0-alpha06.txt
M activity/api/current.txt
M activity/src/androidTest/java/androidx/activity/ContentViewTest.kt
M activity/src/main/java/androidx/activity/ComponentActivity.java
M annotations/api/1.1.0-beta01.txt
M annotations/api/current.txt
M annotations/src/main/java/androidx/annotation/ContentView.java
M appcompat/api/1.1.0-alpha04.txt
M appcompat/api/current.txt
M appcompat/src/main/java/androidx/appcompat/app/AppCompatActivity.java
M fragment/api/1.1.0-alpha06.txt
M fragment/api/current.txt
M fragment/src/androidTest/java/androidx/fragment/app/FragmentFactoryTest.kt
M fragment/src/androidTest/java/androidx/fragment/app/FragmentLifecycleTest.kt
M fragment/src/androidTest/java/androidx/fragment/app/FragmentTest.kt
M fragment/src/androidTest/java/androidx/fragment/app/FragmentTransactionTest.kt
M fragment/src/androidTest/java/androidx/fragment/app/FragmentViewTest.kt
M fragment/src/androidTest/java/androidx/fragment/app/NestedInflatedFragmentTest.kt
M fragment/src/androidTest/java/androidx/fragment/app/StrictFragment.kt
M fragment/src/androidTest/java/androidx/fragment/app/StrictViewFragment.kt
M fragment/src/androidTest/java/androidx/fragment/app/test/FragmentTestActivity.kt
M fragment/src/androidTest/java/androidx/fragment/app/test/LoaderActivity.kt
M fragment/src/main/java/androidx/fragment/app/Fragment.java
M fragment/src/main/java/androidx/fragment/app/FragmentActivity.java
M testutils/src/main/java/androidx/testutils/RecreatedActivity.kt
il...@google.com <il...@google.com> #11
We've changed how @ContentView functions. The previous form of:
@ContentView(R.layout.main)
class MainFragment : Fragment() {
}
becomes
class MainFragment : Fragment(R.layout.main) {
}
While the default FragmentFactory (and AppComponentFactory for Activities on API 28+) still require a no-argument constructor, Fragment and ComponentActivity/FragmentActivity/AppCompatActivity allow your no-argument constructor or custom constructor to call up to a second constructor which takes a @LayoutRes int of the layout you want to inflate. That second constructor is annotated with @ContentView and will be used for future Tools integrations.
@ContentView(R.layout.main)
class MainFragment : Fragment() {
}
becomes
class MainFragment : Fragment(R.layout.main) {
}
While the default FragmentFactory (and AppComponentFactory for Activities on API 28+) still require a no-argument constructor, Fragment and ComponentActivity/FragmentActivity/AppCompatActivity allow your no-argument constructor or custom constructor to call up to a second constructor which takes a @LayoutRes int of the layout you want to inflate. That second constructor is annotated with @ContentView and will be used for future Tools integrations.
zh...@gmail.com <zh...@gmail.com> #12
Layout IDs will become non-usable in annotations, in application modules?
------
Is it to deliberately kill code such as:
https://github.com/square/mortar/blob/d7bb8e5b5dd773376d940319a49bce9bf7c1058c/mortar-sample/src/main/java/com/example/mortar/screen/ChatListScreen.java#L33
and
https://github.com/lyft/scoop/blob/8d8e499bf3e6399676d314a18094a99a57b99a46/scoop-basics/src/main/java/com/example/scoop/basics/ui/layoutsample/screen/LayoutScreen.java#L10
?
------
Is it to deliberately kill code such as:
and
?
il...@google.com <il...@google.com> #13
For discussion on non-final IDs in app modules and why the Tools team is considering it, see the section on resource namespacing part of the "What's New With the Android Gradle Plugin" talk from AndroidDevSummit: https://www.youtube.com/watch?v=GlwvVJNWlWg&t=1318
ta...@gmail.com <ta...@gmail.com> #14
I've seen in recent changelog that giving layout in constructors is also supported in AppCompatActivity. Is this something supported in older API levels?
il...@google.com <il...@google.com> #15
Re #14 as per the Javadoc: https://developer.android.com/reference/androidx/appcompat/app/AppCompatActivity?hl=en#AppCompatActivity(int)
"This should generally be called from your constructor that takes no parameters, as is required for API 27 and lower or when using the default AppComponentFactory."
"This should generally be called from your constructor that takes no parameters, as is required for API 27 and lower or when using the default AppComponentFactory."
Description
Version used: Version 1.0.0-alpha04
Since `R.layout` is non-final in library projects, we can't use the `@ContentView` annotation.