Skip to content

Commit bea3661

Browse files
committed
Merge branch 'main' into feature-settings
# Conflicts: # feature/settings/src/main/java/com/google/samples/apps/nowinandroid/feature/settings/SettingsDialog.kt
2 parents 7dadf03 + caaa82b commit bea3661

File tree

153 files changed

+4308
-1831
lines changed

Some content is hidden

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

153 files changed

+4308
-1831
lines changed

.github/workflows/AndroidCIWithGmd.yaml

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,40 @@ jobs:
1010

1111
android-ci:
1212
runs-on: macos-12
13-
strategy:
14-
matrix:
15-
device-config: [ "pixel4api30aospatd", "pixelcapi30aospatd" ]
1613

1714
steps:
18-
- uses: actions/setup-java@v3
15+
- name: Checkout
16+
uses: actions/checkout@v3
17+
18+
- name: Validate Gradle Wrapper
19+
uses: gradle/wrapper-validation-action@v1
20+
21+
- name: Copy CI gradle.properties
22+
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties
23+
24+
- name: Set up JDK 17
25+
uses: actions/setup-java@v3
1926
with:
2027
distribution: 'zulu'
21-
java-version: '11'
22-
- uses: actions/checkout@v3
28+
java-version: 17
29+
30+
- name: Setup Gradle
31+
uses: gradle/gradle-build-action@v2
2332

2433
- name: Setup Android SDK
2534
uses: android-actions/setup-android@v2
2635

36+
- name: Build AndroidTest apps
37+
run: ./gradlew packageDemoDebug packageDemoDebugAndroidTest
38+
2739
- name: Run instrumented tests with GMD
2840
run: ./gradlew cleanManagedDevices --unused-only &&
29-
./gradlew ${{ matrix.device-config }}DemoDebugAndroidTest -Dorg.gradle.workers.max=1
41+
./gradlew ciDemoDebugAndroidTest -Dorg.gradle.workers.max=1
3042
-Pandroid.testoptions.manageddevices.emulator.gpu="swiftshader_indirect" -Pandroid.experimental.testOptions.managedDevices.emulator.showKernelLogging=true
3143

3244
- name: Upload test reports
3345
if: success() || failure()
3446
uses: actions/upload-artifact@v3
3547
with:
3648
name: test-reports
37-
path: |
38-
'**/*/build/reports/androidTests/'
49+
path: '**/build/reports/androidTests'

.github/workflows/Build.yaml

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ jobs:
2424
- name: Copy CI gradle.properties
2525
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties
2626

27-
- name: Set up JDK 11
27+
- name: Set up JDK 17
2828
uses: actions/setup-java@v3
2929
with:
3030
distribution: 'zulu'
31-
java-version: 11
31+
java-version: 17
3232

3333
- name: Setup Gradle
3434
uses: gradle/gradle-build-action@v2
@@ -48,15 +48,22 @@ jobs:
4848
- name: Upload build outputs (APKs)
4949
uses: actions/upload-artifact@v3
5050
with:
51-
name: build-outputs
52-
path: app/build/outputs
51+
name: APKs
52+
path: '**/build/outputs/apk/**/*.apk'
5353

54-
- name: Upload build reports
54+
- name: Upload lint reports (HTML)
5555
if: always()
5656
uses: actions/upload-artifact@v3
5757
with:
58-
name: build-reports
59-
path: app/build/reports
58+
name: lint-reports
59+
path: '**/build/reports/lint-results-*.html'
60+
61+
- name: Upload test results (XML)
62+
if: always()
63+
uses: actions/upload-artifact@v3
64+
with:
65+
name: test-results
66+
path: '**/build/test-results/test*UnitTest/**.xml'
6067

6168
androidTest:
6269
needs: build
@@ -73,15 +80,18 @@ jobs:
7380
- name: Copy CI gradle.properties
7481
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties
7582

76-
- name: Set up JDK 11
83+
- name: Set up JDK 17
7784
uses: actions/setup-java@v3
7885
with:
7986
distribution: 'zulu'
80-
java-version: 11
87+
java-version: 17
8188

8289
- name: Setup Gradle
8390
uses: gradle/gradle-build-action@v2
8491

92+
- name: Build AndroidTest apps
93+
run: ./gradlew packageDemoDebug packageDemoDebugAndroidTest --daemon
94+
8595
- name: Run instrumentation tests
8696
uses: reactivecircus/android-emulator-runner@v2
8797
with:
@@ -90,11 +100,11 @@ jobs:
90100
disable-animations: true
91101
disk-size: 6000M
92102
heap-size: 600M
93-
script: ./gradlew connectedDemoDebugAndroidTest -x :benchmark:connectedDemoBenchmarkAndroidTest
103+
script: ./gradlew connectedDemoDebugAndroidTest --daemon
94104

95105
- name: Upload test reports
96106
if: always()
97107
uses: actions/upload-artifact@v3
98108
with:
99109
name: test-reports-${{ matrix.api-level }}
100-
path: '*/build/reports/androidTests'
110+
path: '**/build/reports/androidTests'

.github/workflows/Release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ jobs:
2020
- name: Copy CI gradle.properties
2121
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties
2222

23-
- name: Set up JDK 11
23+
- name: Set up JDK 17
2424
uses: actions/setup-java@v3
2525
with:
2626
distribution: 'zulu'
27-
java-version: 11
27+
java-version: 17
2828

2929
- name: Build app
3030
run: ./gradlew :app:assembleDemoRelease

README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,14 @@ The app uses adaptive layouts to
132132

133133
Find out more about the [UI architecture here](docs/ArchitectureLearningJourney.md#ui-layer).
134134

135-
# Baseline profiles
135+
# Performance
136+
137+
## Benchmarks
138+
139+
Find all tests written using [`Macrobenchmark`](https://developer.android.com/topic/performance/benchmarking/macrobenchmark-overview)
140+
in the `benchmarks` module. This module also contains the test to generate the Baseline profile.
141+
142+
## Baseline profiles
136143

137144
The baseline profile for this app is located at [`app/src/main/baseline-prof.txt`](app/src/main/baseline-prof.txt).
138145
It contains rules that enable AOT compilation of the critical user path taken during app launch.
@@ -144,6 +151,19 @@ To generate the baseline profile, select the `benchmark` build variant and run t
144151
`BaselineProfileGenerator` benchmark test on an AOSP Android Emulator.
145152
Then copy the resulting baseline profile from the emulator to [`app/src/main/baseline-prof.txt`](app/src/main/baseline-prof.txt).
146153

154+
## Compose compiler metrics
155+
156+
Run the following command to get and analyse compose compiler metrics:
157+
158+
```
159+
./gradlew assembleRelease -PenableComposeCompilerMetrics=true -PenableComposeCompilerReports=true
160+
```
161+
162+
The reports files will be added to build/compose-reports in each module. The metrics files will be
163+
added to build/compose-metrics in each module.
164+
165+
For more information on Compose compiler metrics, see [this blog post](https://medium.com/androiddevelopers/jetpack-compose-stability-explained-79c10db270c8).
166+
147167
# License
148168

149169
**Now in Android** is distributed under the terms of the Apache License (Version 2.0). See the

app-nia-catalog/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ android {
4747
missingDimensionStrategy(FlavorDimension.contentType.name, NiaFlavor.demo.name)
4848
}
4949

50-
packagingOptions {
50+
packaging {
5151
resources {
5252
excludes.add("/META-INF/{AL2.0,LGPL2.1}")
5353
}
5454
}
5555
namespace = "com.google.samples.apps.niacatalog"
5656

5757
buildTypes {
58-
val release by getting {
58+
release {
5959
// To publish on the Play store a private signing key is required, but to allow anyone
6060
// who clones the code to sign and run the release variant, use the debug signing key.
6161
// TODO: Abstract the signing configuration to a separate file to avoid hardcoding this.

app-nia-catalog/src/main/java/com/google/samples/apps/niacatalog/ui/Catalog.kt

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import androidx.compose.runtime.mutableStateOf
3636
import androidx.compose.runtime.remember
3737
import androidx.compose.runtime.setValue
3838
import androidx.compose.ui.Modifier
39-
import androidx.compose.ui.res.painterResource
4039
import androidx.compose.ui.unit.dp
4140
import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaButton
4241
import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaFilterChip
@@ -206,13 +205,13 @@ fun NiaCatalog() {
206205
onCheckedChange = { checked -> firstChecked = checked },
207206
icon = {
208207
Icon(
209-
painter = painterResource(id = NiaIcons.BookmarkBorder),
208+
imageVector = NiaIcons.BookmarkBorder,
210209
contentDescription = null,
211210
)
212211
},
213212
checkedIcon = {
214213
Icon(
215-
painter = painterResource(id = NiaIcons.Bookmark),
214+
imageVector = NiaIcons.Bookmark,
216215
contentDescription = null,
217216
)
218217
},
@@ -223,13 +222,13 @@ fun NiaCatalog() {
223222
onCheckedChange = { checked -> secondChecked = checked },
224223
icon = {
225224
Icon(
226-
painter = painterResource(id = NiaIcons.BookmarkBorder),
225+
imageVector = NiaIcons.BookmarkBorder,
227226
contentDescription = null,
228227
)
229228
},
230229
checkedIcon = {
231230
Icon(
232-
painter = painterResource(id = NiaIcons.Bookmark),
231+
imageVector = NiaIcons.Bookmark,
233232
contentDescription = null,
234233
)
235234
},
@@ -239,13 +238,13 @@ fun NiaCatalog() {
239238
onCheckedChange = {},
240239
icon = {
241240
Icon(
242-
painter = painterResource(id = NiaIcons.BookmarkBorder),
241+
imageVector = NiaIcons.BookmarkBorder,
243242
contentDescription = null,
244243
)
245244
},
246245
checkedIcon = {
247246
Icon(
248-
painter = painterResource(id = NiaIcons.Bookmark),
247+
imageVector = NiaIcons.Bookmark,
249248
contentDescription = null,
250249
)
251250
},
@@ -256,13 +255,13 @@ fun NiaCatalog() {
256255
onCheckedChange = {},
257256
icon = {
258257
Icon(
259-
painter = painterResource(id = NiaIcons.BookmarkBorder),
258+
imageVector = NiaIcons.BookmarkBorder,
260259
contentDescription = null,
261260
)
262261
},
263262
checkedIcon = {
264263
Icon(
265-
painter = painterResource(id = NiaIcons.Bookmark),
264+
imageVector = NiaIcons.Bookmark,
266265
contentDescription = null,
267266
)
268267
},
@@ -334,40 +333,31 @@ fun NiaCatalog() {
334333
item { Text("Navigation", Modifier.padding(top = 16.dp)) }
335334
item {
336335
var selectedItem by remember { mutableStateOf(0) }
337-
val items = listOf("For you", "Episodes", "Saved", "Interests")
336+
val items = listOf("For you", "Saved", "Interests")
338337
val icons = listOf(
339338
NiaIcons.UpcomingBorder,
340-
NiaIcons.MenuBookBorder,
341339
NiaIcons.BookmarksBorder,
340+
NiaIcons.Grid3x3,
342341
)
343342
val selectedIcons = listOf(
344343
NiaIcons.Upcoming,
345-
NiaIcons.MenuBook,
346344
NiaIcons.Bookmarks,
345+
NiaIcons.Grid3x3,
347346
)
348-
val tagIcon = NiaIcons.Tag
349347
NiaNavigationBar {
350348
items.forEachIndexed { index, item ->
351349
NiaNavigationBarItem(
352350
icon = {
353-
if (index == 3) {
354-
Icon(imageVector = tagIcon, contentDescription = null)
355-
} else {
356-
Icon(
357-
painter = painterResource(id = icons[index]),
358-
contentDescription = item,
359-
)
360-
}
351+
Icon(
352+
imageVector = icons[index],
353+
contentDescription = item,
354+
)
361355
},
362356
selectedIcon = {
363-
if (index == 3) {
364-
Icon(imageVector = tagIcon, contentDescription = null)
365-
} else {
366-
Icon(
367-
painter = painterResource(id = selectedIcons[index]),
368-
contentDescription = item,
369-
)
370-
}
357+
Icon(
358+
imageVector = selectedIcons[index],
359+
contentDescription = item,
360+
)
371361
},
372362
label = { Text(item) },
373363
selected = selectedItem == index,

0 commit comments

Comments
 (0)