Skip to content

Commit 4d21fa4

Browse files
chrisbanesJolandaVerhoefnickbutcherflorina-muntenescuJoseAlcerreca
authoredOct 28, 2020
[All] Update to Compose 1.0.0-alpha06 (android#261)
* [Jetsnack] Cart implementation * [Jetsnack] Reuse Quantity Selector * [Jetsnack] Reuse Destination Bar * [Jetsnack] Add Inspired By Section to Cart * [Jetsnack] Add Checkout Bar to cart * [Jetsnack] Fix Spotless issues * [Jetsnack] Fix review comments * [Jetsnack] Fix review comments * Update to snapshot 6922857. * [Jetsurvey] Bump to alpha06 * [Owl] Update to snapshot 6922857. * [JetChat] Update to snapshot 6922857 * [Rally] Update to snapshot 6922857 * [Jetcaster] Update to snapshot 6922857. * Removes unncessary elevation param * [Crane] Update to 6922857 snapshot (android#246) * [Owl] Replace elevation overlay workaround with AmbientElevationOverlay. * [Jetchat] Replace elevation overlay workaround with AmbientElevationOverlay * [Jetsurvey] Redesigned next/prev buttons * [Jetsurvey] Redesigned progress indicator * [Jetsurvey] Adding elevation to the action bar * [Jetsurvey] Capitalising strings * [Jetsurvey] Question title redesigned * [Jetsurvey] Removing unused composable * [Jetsurvey] Removing the column usage in progress indicator * [Crane] Adds Hilt to the project (android#237) * [JetNews] bump to alpha06 (android#258) * [JetNews] bump to alpha06 * Fix unused modifier on BookmarkButton * Update all samples to AGP 4.2.0-alpha15 * Turn on allWarningsAsErrors in Jetsurvey * Tidy up gradle.properties We now have parallel compilation, caching and on-demand configuration enabled on all projects * Disable Jetifier where possible Only Crane requires Jetifier becuase it uses the Google Maps SDK. * Update all projects to ktlint 0.39.0 * Update snapshot URL * Update to Compose 1.0.0-alpha06 Co-authored-by: Jolanda Verhoef <jolandaverhoef@google.com> Co-authored-by: Nick Butcher <nickbutcher@users.noreply.github.com> Co-authored-by: Nick Butcher <nickbutcher@google.com> Co-authored-by: Florina Muntenescu <florinam@google.com> Co-authored-by: Jose Alcerreca <jalc@google.com> Co-authored-by: Jolanda Verhoef <JolandaVerhoef@users.noreply.github.com> Co-authored-by: Jose Alcérreca <JoseAlcerreca@users.noreply.github.com> Co-authored-by: Florina Muntenescu <2998890+florina-muntenescu@users.noreply.github.com> Co-authored-by: Manuel Vivo <manuelvicnt@gmail.com> Co-authored-by: Sean McQuillan <seanmcq@google.com>
1 parent 4ffcd3b commit 4d21fa4

File tree

124 files changed

+1910
-830
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+1910
-830
lines changed
 

‎.github/ci-gradle.properties

+21-21
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
/*
2-
* Copyright 2019 Google, Inc.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
1+
#
2+
# Copyright 2020 The Android Open Source Project
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
1616

17-
org.gradle.daemon=false
18-
org.gradle.parallel=true
19-
org.gradle.jvmargs=-Xmx5120m
20-
org.gradle.workers.max=2
17+
org.gradle.daemon=false
18+
org.gradle.parallel=true
19+
org.gradle.jvmargs=-Xmx5120m
20+
org.gradle.workers.max=2
2121

22-
kotlin.incremental=false
23-
kotlin.compiler.execution.strategy=in-process
22+
kotlin.incremental=false
23+
kotlin.compiler.execution.strategy=in-process

‎Crane/README.md

+34
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,38 @@ implemented using a different Activity will be displayed. In there, you can see
3232
embedded in Compose and Compose buttons updating the Android View. Notice how you can also
3333
interact with the `MapView` seamlessly.
3434

35+
## Hilt
36+
37+
Crane uses [Hilt][hilt] to manage its dependencies. The Hilt's ViewModel extension (with the
38+
`@ViewModelInject` annotation) works perfectly with Compose's ViewModel integration (`viewModel()`
39+
composable function) as you can see in the following snippet of code. `viewModel()` will
40+
automatically use the factory that Hilt creates for the ViewModel:
41+
42+
```
43+
class MainViewModel @ViewModelInject constructor(
44+
private val destinationsRepository: DestinationsRepository,
45+
@DefaultDispatcher private val defaultDispatcher: CoroutineDispatcher,
46+
datesRepository: DatesRepository
47+
) : ViewModel() { ... }
48+
49+
@Composable
50+
fun CraneHomeContent(...) {
51+
val viewModel: MainViewModel = viewModel()
52+
...
53+
}
54+
```
55+
56+
Disclaimer: Passing dependencies to a ViewModel which are not available at compile time (which is
57+
sometimes called _assisted injection_) doesn't work as you might expect using `viewModel()`.
58+
Compose's ViewModel integration cannot currently scope a ViewModel to a given composable. Instead
59+
it is always scoped to the host Activity or Fragment. This means that calling `viewModel()` with
60+
different factories in the same host Activity/Fragment don't have the desired effect; the _first_
61+
factory will be always used.
62+
63+
This is the case of the [DetailsViewModel](detailsViewModel), which takes the name of
64+
a `City` as a parameter to load the required information for the screen. However, the above isn't a
65+
problem in this sample, since `DetailsScreen` is always used in it's own newly launched Activity.
66+
3567
## Google Maps SDK
3668

3769
To get the MapView working, you need to get an API key as
@@ -79,6 +111,8 @@ limitations under the License.
79111
[details]: app/src/main/java/androidx/compose/samples/crane/details/DetailsActivity.kt
80112
[data]: app/src/main/java/androidx/compose/samples/crane/data/CraneData.kt
81113
[mainViewModel]: app/src/main/java/androidx/compose/samples/crane/home/MainViewModel.kt
114+
[detailsViewModel]: app/src/main/java/androidx/compose/samples/crane/details/DetailsViewModel.kt
82115
[homeTest]: app/src/androidTest/java/androidx/compose/samples/crane/home/HomeTest.kt
83116
[detailsTest]: app/src/androidTest/java/androidx/compose/samples/crane/details/DetailsActivityTest.kt
84117
[coil-accompanist]: https://github.com/chrisbanes/accompanist
118+
[hilt]: https://d.android.com/hilt

0 commit comments

Comments
 (0)
Please sign in to comment.