Fixed
Status Update
Comments
il...@google.com <il...@google.com>
mi...@gmail.com <mi...@gmail.com> #2
we've initially planned this for 1.0.0 but didn't make the cut.
au...@gmail.com <au...@gmail.com> #3
I would add my +1 to this, if only that Room would recognize views (creation being secondary as it can be accomplished with raw queries).
be...@gmail.com <be...@gmail.com> #4
+1 For this. View support would be very helpful.
md...@gmail.com <md...@gmail.com> #5
+1 For this
il...@google.com <il...@google.com>
ap...@google.com <ap...@google.com> #6
+1 For this
ap...@google.com <ap...@google.com> #7
+10 for view support :)
il...@google.com <il...@google.com> #8
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 86ccd847759ea146464aaaf9ed128342d704b3ac
Author: Yuichi Araki <yaraki@google.com>
Date: Mon Aug 06 12:15:14 2018
Database View
Use @DatabaseView to create a view.
Bug: 67033276
Test: DatabaseViewTest, DatabaseViewProcessorTest, DatabaseVerifierTest,
Test: DatabaseWriterTest, SQLiteOpenHelperWriterTest,
Test: DatabaseViewSyncTest, InvalidationTrackerTest
Change-Id: I4a909add53f82fc6816b8d944278a3c9abef735d
M room/common/api/current.txt
M room/common/src/main/java/androidx/room/Database.java
A room/common/src/main/java/androidx/room/DatabaseView.java
M room/common/src/main/java/androidx/room/SkipQueryVerification.java
M room/compiler/src/main/kotlin/androidx/room/ext/javapoet_ext.kt
M room/compiler/src/main/kotlin/androidx/room/parser/ParserErrors.kt
M room/compiler/src/main/kotlin/androidx/room/processor/DatabaseProcessor.kt
A room/compiler/src/main/kotlin/androidx/room/processor/DatabaseViewProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/processor/ProcessorErrors.kt
M room/compiler/src/main/kotlin/androidx/room/verifier/DatabaseVerifier.kt
M room/compiler/src/main/kotlin/androidx/room/vo/Database.kt
A room/compiler/src/main/kotlin/androidx/room/vo/DatabaseView.kt
M room/compiler/src/main/kotlin/androidx/room/writer/DatabaseWriter.kt
M room/compiler/src/main/kotlin/androidx/room/writer/SQLiteOpenHelperWriter.kt
A room/compiler/src/main/kotlin/androidx/room/writer/ViewInfoValidationWriter.kt
A room/compiler/src/test/data/common/input/UserSummary.java
M room/compiler/src/test/data/databasewriter/input/ComplexDatabase.java
M room/compiler/src/test/data/databasewriter/output/ComplexDatabase.java
M room/compiler/src/test/kotlin/androidx/room/processor/DaoProcessorTest.kt
M room/compiler/src/test/kotlin/androidx/room/processor/DatabaseProcessorTest.kt
A room/compiler/src/test/kotlin/androidx/room/processor/DatabaseViewProcessorTest.kt
M room/compiler/src/test/kotlin/androidx/room/processor/QueryMethodProcessorTest.kt
M room/compiler/src/test/kotlin/androidx/room/testing/test_util.kt
M room/compiler/src/test/kotlin/androidx/room/verifier/DatabaseVerifierTest.kt
M room/compiler/src/test/kotlin/androidx/room/writer/DaoWriterTest.kt
M room/compiler/src/test/kotlin/androidx/room/writer/DatabaseWriterTest.kt
M room/compiler/src/test/kotlin/androidx/room/writer/SQLiteOpenHelperWriterTest.kt
M room/integration-tests/autovaluetestapp/src/androidTest/java/androidx/room/integration/autovaluetestapp/TestDatabase.java
M room/integration-tests/autovaluetestapp/src/androidTest/java/androidx/room/integration/autovaluetestapp/dao/PetDao.java
M room/integration-tests/autovaluetestapp/src/androidTest/java/androidx/room/integration/autovaluetestapp/test/PetDaoTest.java
A room/integration-tests/autovaluetestapp/src/androidTest/java/androidx/room/integration/autovaluetestapp/vo/DogWithOwner.java
A room/integration-tests/testapp/schemas/androidx.room.integration.testapp.migration.MigrationDb/8.json
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/TestDatabase.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/dao/PetDao.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/migration/MigrationDb.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/migration/MigrationTest.java
A room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/DatabaseViewTest.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/InvalidationTest.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/LiveDataQueryTest.java
A room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/vo/PetWithUser.java
M room/migration/src/main/java/androidx/room/migration/bundle/BundleUtil.java
M room/migration/src/main/java/androidx/room/migration/bundle/DatabaseBundle.java
A room/migration/src/main/java/androidx/room/migration/bundle/DatabaseViewBundle.java
M room/migration/src/test/java/androidx/room/migration/bundle/DatabaseBundleTest.java
A room/migration/src/test/java/androidx/room/migration/bundle/DatabaseViewBundleTest.java
A room/runtime/src/androidTest/java/androidx/room/migration/ViewInfoTest.java
M room/runtime/src/main/java/androidx/room/InvalidationTracker.java
A room/runtime/src/main/java/androidx/room/util/ViewInfo.java
M room/runtime/src/test/java/androidx/room/InvalidationTrackerTest.java
M room/testing/src/main/java/androidx/room/testing/MigrationTestHelper.java
https://android-review.googlesource.com/731045
https://goto.google.com/android-sha1/86ccd847759ea146464aaaf9ed128342d704b3ac
Branch: androidx-master-dev
commit 86ccd847759ea146464aaaf9ed128342d704b3ac
Author: Yuichi Araki <yaraki@google.com>
Date: Mon Aug 06 12:15:14 2018
Database View
Use @DatabaseView to create a view.
Bug: 67033276
Test: DatabaseViewTest, DatabaseViewProcessorTest, DatabaseVerifierTest,
Test: DatabaseWriterTest, SQLiteOpenHelperWriterTest,
Test: DatabaseViewSyncTest, InvalidationTrackerTest
Change-Id: I4a909add53f82fc6816b8d944278a3c9abef735d
M room/common/api/current.txt
M room/common/src/main/java/androidx/room/Database.java
A room/common/src/main/java/androidx/room/DatabaseView.java
M room/common/src/main/java/androidx/room/SkipQueryVerification.java
M room/compiler/src/main/kotlin/androidx/room/ext/javapoet_ext.kt
M room/compiler/src/main/kotlin/androidx/room/parser/ParserErrors.kt
M room/compiler/src/main/kotlin/androidx/room/processor/DatabaseProcessor.kt
A room/compiler/src/main/kotlin/androidx/room/processor/DatabaseViewProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/processor/ProcessorErrors.kt
M room/compiler/src/main/kotlin/androidx/room/verifier/DatabaseVerifier.kt
M room/compiler/src/main/kotlin/androidx/room/vo/Database.kt
A room/compiler/src/main/kotlin/androidx/room/vo/DatabaseView.kt
M room/compiler/src/main/kotlin/androidx/room/writer/DatabaseWriter.kt
M room/compiler/src/main/kotlin/androidx/room/writer/SQLiteOpenHelperWriter.kt
A room/compiler/src/main/kotlin/androidx/room/writer/ViewInfoValidationWriter.kt
A room/compiler/src/test/data/common/input/UserSummary.java
M room/compiler/src/test/data/databasewriter/input/ComplexDatabase.java
M room/compiler/src/test/data/databasewriter/output/ComplexDatabase.java
M room/compiler/src/test/kotlin/androidx/room/processor/DaoProcessorTest.kt
M room/compiler/src/test/kotlin/androidx/room/processor/DatabaseProcessorTest.kt
A room/compiler/src/test/kotlin/androidx/room/processor/DatabaseViewProcessorTest.kt
M room/compiler/src/test/kotlin/androidx/room/processor/QueryMethodProcessorTest.kt
M room/compiler/src/test/kotlin/androidx/room/testing/test_util.kt
M room/compiler/src/test/kotlin/androidx/room/verifier/DatabaseVerifierTest.kt
M room/compiler/src/test/kotlin/androidx/room/writer/DaoWriterTest.kt
M room/compiler/src/test/kotlin/androidx/room/writer/DatabaseWriterTest.kt
M room/compiler/src/test/kotlin/androidx/room/writer/SQLiteOpenHelperWriterTest.kt
M room/integration-tests/autovaluetestapp/src/androidTest/java/androidx/room/integration/autovaluetestapp/TestDatabase.java
M room/integration-tests/autovaluetestapp/src/androidTest/java/androidx/room/integration/autovaluetestapp/dao/PetDao.java
M room/integration-tests/autovaluetestapp/src/androidTest/java/androidx/room/integration/autovaluetestapp/test/PetDaoTest.java
A room/integration-tests/autovaluetestapp/src/androidTest/java/androidx/room/integration/autovaluetestapp/vo/DogWithOwner.java
A room/integration-tests/testapp/schemas/androidx.room.integration.testapp.migration.MigrationDb/8.json
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/TestDatabase.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/dao/PetDao.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/migration/MigrationDb.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/migration/MigrationTest.java
A room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/DatabaseViewTest.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/InvalidationTest.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/LiveDataQueryTest.java
A room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/vo/PetWithUser.java
M room/migration/src/main/java/androidx/room/migration/bundle/BundleUtil.java
M room/migration/src/main/java/androidx/room/migration/bundle/DatabaseBundle.java
A room/migration/src/main/java/androidx/room/migration/bundle/DatabaseViewBundle.java
M room/migration/src/test/java/androidx/room/migration/bundle/DatabaseBundleTest.java
A room/migration/src/test/java/androidx/room/migration/bundle/DatabaseViewBundleTest.java
A room/runtime/src/androidTest/java/androidx/room/migration/ViewInfoTest.java
M room/runtime/src/main/java/androidx/room/InvalidationTracker.java
A room/runtime/src/main/java/androidx/room/util/ViewInfo.java
M room/runtime/src/test/java/androidx/room/InvalidationTrackerTest.java
M room/testing/src/main/java/androidx/room/testing/MigrationTestHelper.java
an...@gmail.com <an...@gmail.com> #9
I don't remember when I was this excited about a feature. Great work, can't wait to see it land in an official release.
il...@google.com <il...@google.com> #10
"Thanks" seems so inadequate, but thanks :-)
an...@gmail.com <an...@gmail.com> #11
Am I right in determining from that, that the starting fragment can only have it's title passed during initial creation[$1] or direct navigation[$2]?
Assuming I have a starting fragment labelled "A", and a second fragment somewhere in the graph labelled "B".
If I wish to change the title for the starting fragment "A" due to some action taken (e.g button press) on that ("A") fragment then I will need to find some other means of setting it, is this correct?
Same if I want the title on fragment "A" to change based on a choice made on fragment "B", but navigation back to "A" (from "B") occurs via the back/up button or popping from the nav stack?
At the moment I'm setting the title for my starting fragment through a navigation listener (addOnNavigatedListener), and observing a LiveData change from my view model, as doing only one or the other results in situations where the title is not set. This means that for the majority of the time the title is set at least twice [$3].
$1) Presumably any one of these is only called once during the app's active lifetime, likely in `[Main]Activity.onCreate`, is that correct? As I understand it, using this feature would also require some alteration to how navigation is set up in the layout (.xml) files, right?
* `NavHostFragment.create(R.navigation.graph, args)`, or
* `navController.setGraph(R.navigation.graph, args)`, or
* `navController.setGraph(navGraph, args)`
$2) `navController.navigate(action)`
$3) The title is set by
1. the navigation component to whatever is in the label, and
2. the onNavigated listener, and
3. the observer on the LiveData.
While it's light work this repetition in setting the title seems wasteful.
I cannot quite put my finger on it but it seems strange to me that the navigation source gets to set the title as opposed to the destination setting the title based on some internal state.To make this work for me I would have to ensure that every source a fragment can be navigated from knows how to correctly determine the expected title, as opposed to that determination only being made in one place (the destination fragment).
il...@google.com <il...@google.com> #12
Parameterized labels only pull from the arguments of the destination, yes.
If you need dynamic titles or more complicated logic, you should not use android:label in your graph and instead set the title yourself - NavigationUI only sets a title if the android:label exists.
If you need dynamic titles or more complicated logic, you should not use android:label in your graph and instead set the title yourself - NavigationUI only sets a title if the android:label exists.
an...@gmail.com <an...@gmail.com> #13
Thanks, I've removed the label from the fragment in the nav graph resource file. It was used as the default/fallback title until the title was set through the user's action.
se...@google.com <se...@google.com> #14
This API was reviewed as part of "mass-review" of Navigation APIs at Donut Pod on December 4th.
jo...@gmail.com <jo...@gmail.com> #15
Sorry to come up and notify you all but this is marked as fixed even though I found an issue with this approach:
<fragment
android:id="@+id/exampleFragment"
android:name="com.example.ExampleFragment"
android:label="{title}"
tools:layout="@layout/fragment_examplel">
<argument
android:name="title"
app:argType="string"/>
</fragment>
This works fine, but as soon as the activity/view gets destroyed (e.g. rotating the device) the title gets cleared. let me know if I'm missing something but I'm using the safe args direction and passing the text as getString(R.string.example_title).
<fragment
android:id="@+id/exampleFragment"
android:name="com.example.ExampleFragment"
android:label="{title}"
tools:layout="@layout/fragment_examplel">
<argument
android:name="title"
app:argType="string"/>
</fragment>
This works fine, but as soon as the activity/view gets destroyed (e.g. rotating the device) the title gets cleared. let me know if I'm missing something but I'm using the safe args direction and passing the text as getString(R.string.example_title).
il...@google.com <il...@google.com> #16
Re #15 - please file a new bug with a sample that reproduces your issue.
st...@gmail.com <st...@gmail.com> #17
can i use argument from a parcelable type for the label ?
something like this ?
<fragment
android:id="@+id/displayFragment"
android:name="com.commonsware.jetpack.sampler.nav.DisplayFragment"
android:label="{User.userName}" >
<argument
android:name="User"
app:argType="com.example.app.User"/>
</fragment>
something like this ?
<fragment
android:id="@+id/displayFragment"
android:name="com.commonsware.jetpack.sampler.nav.DisplayFragment"
android:label="{User.userName}" >
<argument
android:name="User"
app:argType="com.example.app.User"/>
</fragment>
il...@google.com <il...@google.com> #18
Re #17 - no, that's not supported, the only supported format is {argName}
which calls toString()
on the argument. You'd want to file a new feature request.
Description
The navigation components use the value in `android:label` to set the [toolbar] title depending on where in the navigation graph the use has navigated to. This works fine except I want to have the title reflect the category of things the screen is referring to, but the specific thing that the user is about to edit.
Normally I would have piece of code like `updateTitle` below on the activity and then call it from the fragment (onResume) with:
``` kotlin
updateTitle(getString(R.string.book_title, bookNumber))
```
but this does not work unless I also remove the `android:label` attribute from the nav_graph.xml.
Component used:
'android.arch.navigation:navigation-fragment-ktx:1.0.0-alpha01'
'android.arch.navigation:navigation-ui-ktx:1.0.0-alpha01'
Version used:
as above
Devices/Android versions reproduced on:
All
- Sample project to trigger the issue.
``` xml
// snippet from nav_graph.xml
<fragment
android:id="@+id/bookFragment"
android:name="com.example.bookFragment"
android:label="@string/book_title" >
<argument
android:name="bookId"
app:type="integer" />
</fragment>
// snippet from sttrings.xml
<string name="book_title">book %1$d</string>
```
Some snippets from the way I would otherwise do it.
``` kotlin
// actrivity, implements updateTitle( from an interface (Foo)
override fun updateTitle(title: String) {
toolbar?.title = title
}
// fragment
override fun onResume() {
super.onResume()
// foo is the activity cast to Foo
foo?.updateTitle(getString(R.string.reading_title, 1))
}
```
- A screenrecord or screenshots showing the issue (if UI related).
Actual title vs expected