Skip to content

Commit 5ae1f78

Browse files
authored
Clean up dependency imports for Compose snippets (#151)
* Removing dispatcher from Bitmap writing, to fix crash when picture is being written to at the same time as this. * Apply Spotless * Fix workflow to trigger on pushes of spotless changes too Need to add the PAT https://github.com/stefanzweifel/git-auto-commit-action#commits-made-by-this-action-do-not-trigger-new-workflow-runs --------- Co-authored-by: riggaroo <[email protected]>
1 parent c7b62c1 commit 5ae1f78

File tree

6 files changed

+25
-81
lines changed

6 files changed

+25
-81
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ jobs:
3030

3131
steps:
3232
- uses: actions/checkout@v3
33-
33+
with:
34+
token: ${{ secrets.PAT}}
3435
- name: set up Java 17
3536
uses: actions/setup-java@v2
3637
with:
@@ -47,6 +48,3 @@ jobs:
4748
run: ./gradlew :compose:recomposehighlighter:build
4849
- name: Build kotlin snippets
4950
run: ./gradlew :kotlin:build
50-
# TODO fix bluetoothle snippets (lint is failing) - name: Build bluetoothle snippets
51-
# run: ./gradlew :bluetoothle:build
52-

.github/workflows/update_deps.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ jobs:
2929
branch: bot-update-deps
3030
delete-branch: true
3131
title: '🤖 Update Dependencies'
32-
body: Updated depedencies
32+
body: Updated dependencies
3333
reviewers: ${{ github.actor }}

compose/snippets/src/main/java/com/example/compose/snippets/animations/AnimationQuickGuide.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ import androidx.compose.runtime.mutableStateOf
8787
import androidx.compose.runtime.remember
8888
import androidx.compose.runtime.setValue
8989
import androidx.compose.ui.Alignment
90+
import androidx.compose.ui.ExperimentalComposeUiApi
9091
import androidx.compose.ui.Modifier
9192
import androidx.compose.ui.draw.clip
9293
import androidx.compose.ui.draw.drawBehind
@@ -719,6 +720,7 @@ private fun LoadingScreen() {
719720
}
720721
}
721722

723+
@OptIn(ExperimentalComposeUiApi::class)
722724
@Preview
723725
@Composable
724726
fun AnimationLayout() {

compose/snippets/src/main/java/com/example/compose/snippets/graphics/AdvancedGraphicsSnippets.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import android.content.Context
2121
import android.content.Intent
2222
import android.content.Intent.createChooser
2323
import android.graphics.Bitmap
24-
import android.graphics.Canvas
2524
import android.graphics.Picture
2625
import android.media.MediaScannerConnection
2726
import android.net.Uri
@@ -45,8 +44,10 @@ import androidx.compose.material3.SnackbarHostState
4544
import androidx.compose.material3.SnackbarResult
4645
import androidx.compose.material3.Text
4746
import androidx.compose.runtime.Composable
47+
import androidx.compose.runtime.getValue
4848
import androidx.compose.runtime.remember
4949
import androidx.compose.runtime.rememberCoroutineScope
50+
import androidx.compose.runtime.setValue
5051
import androidx.compose.ui.Alignment
5152
import androidx.compose.ui.Modifier
5253
import androidx.compose.ui.draw.drawWithCache
@@ -67,7 +68,6 @@ import com.google.accompanist.permissions.ExperimentalPermissionsApi
6768
import com.google.accompanist.permissions.rememberMultiplePermissionsState
6869
import java.io.File
6970
import kotlin.coroutines.resume
70-
import kotlinx.coroutines.Dispatchers
7171
import kotlinx.coroutines.launch
7272
import kotlinx.coroutines.suspendCancellableCoroutine
7373

@@ -86,6 +86,7 @@ import kotlinx.coroutines.suspendCancellableCoroutine
8686
* See the License for the specific language governing permissions and
8787
* limitations under the License.
8888
*/
89+
8990
@OptIn(ExperimentalPermissionsApi::class)
9091
@Preview
9192
@Composable
@@ -108,7 +109,7 @@ fun BitmapFromComposableSnippet() {
108109
// and shares it with the default share sheet.
109110
fun shareBitmapFromComposable() {
110111
if (writeStorageAccessState.allPermissionsGranted) {
111-
coroutineScope.launch(Dispatchers.IO) {
112+
coroutineScope.launch {
112113
val bitmap = createBitmapFromPicture(picture)
113114
val uri = bitmap.saveToDisk(context)
114115
shareBitmap(context, uri)
@@ -158,6 +159,7 @@ fun BitmapFromComposableSnippet() {
158159
height
159160
)
160161
)
162+
// requires at least 1.6.0-alpha01+
161163
draw(this, this.layoutDirection, pictureCanvas, this.size) {
162164
this@onDrawWithContent.drawContent()
163165
}

compose/snippets/src/main/java/com/example/compose/snippets/tooling/AndroidStudioComposeSnippets.kt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
package com.example.compose.snippets.tooling
1818

19-
import androidx.annotation.FloatRange
20-
import androidx.annotation.IntRange
2119
import androidx.compose.foundation.background
2220
import androidx.compose.foundation.layout.Box
2321
import androidx.compose.material3.MaterialTheme
@@ -28,14 +26,9 @@ import androidx.compose.ui.Modifier
2826
import androidx.compose.ui.graphics.Color
2927
import androidx.compose.ui.platform.LocalInspectionMode
3028
import androidx.compose.ui.res.stringResource
31-
import androidx.compose.ui.tooling.preview.Device
32-
import androidx.compose.ui.tooling.preview.Devices
3329
import androidx.compose.ui.tooling.preview.Preview
3430
import androidx.compose.ui.tooling.preview.PreviewParameter
3531
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
36-
import androidx.compose.ui.tooling.preview.UiMode
37-
import androidx.compose.ui.tooling.preview.Wallpaper
38-
import androidx.compose.ui.tooling.preview.Wallpapers
3932
import com.example.compose.snippets.R
4033
import com.example.compose.snippets.interop.User
4134

@@ -174,7 +167,7 @@ fun UserProfilePreview2(
174167
UserProfile(user)
175168
}
176169
// [END android_compose_tooling_preview_parameter_provider_composable2]
177-
170+
/*
178171
private object PreviewAnnotationEx {
179172
// [START android_compose_tooling_preview_annotation]
180173
annotation class Preview(
@@ -194,3 +187,4 @@ private object PreviewAnnotationEx {
194187
)
195188
// [END android_compose_tooling_preview_annotation]
196189
}
190+
*/

gradle/libs.versions.toml

Lines changed: 13 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,23 @@
1-
#####
2-
# This file is duplicated to individual samples from the global scripts/libs.versions.toml
3-
# Do not add a dependency to an individual sample, edit the global version instead.
4-
#####
51
[versions]
62
accompanist = "0.30.1"
73
androidGradlePlugin = "8.1.1"
8-
androidx-activity-compose = "1.8.0-alpha06"
4+
androidx-activity-compose = "1.8.0-beta01"
95
androidx-appcompat = "1.6.1"
10-
androidx-benchmark = "1.1.1"
11-
androidx-benchmark-junit4 = "1.1.0-beta04"
12-
androidx-cardview = "1.0.0"
13-
androidx-compose-bom = "2023.08.00"
6+
androidx-compose-bom = "2023.09.00"
147
androidx-constraintlayout = "2.1.4"
15-
androidx-constraintlayout-compose = "1.1.0-alpha12"
8+
androidx-constraintlayout-compose = "1.0.1"
169
androidx-coordinator-layout = "1.2.0"
17-
androidx-corektx = "1.9.0"
18-
androidx-emoji2-views = "1.4.0-beta05"
10+
androidx-corektx = "1.12.0"
11+
androidx-emoji2-views = "1.4.0"
1912
androidx-fragment-ktx = "1.6.1"
2013
androidx-glance-appwidget = "1.0.0"
21-
androidx-lifecycle-compose = "2.6.1"
22-
androidx-lifecycle-runtime-compose = "2.6.1"
23-
androidx-navigation = "2.7.0"
24-
androidx-paging = "3.2.0-rc01"
25-
androidx-paging-common = "3.1.1"
26-
androidx-palette = "1.0.0"
14+
androidx-lifecycle-compose = "2.6.2"
15+
androidx-lifecycle-runtime-compose = "2.6.2"
16+
androidx-navigation = "2.7.2"
17+
androidx-paging = "3.2.1"
2718
androidx-test = "1.5.0"
2819
androidx-test-espresso = "3.5.1"
29-
androidx-test-ext-junit = "1.1.5"
30-
androidx-test-ext-truth = "1.5.0"
31-
androidx-window = "1.2.0-alpha02"
3220
androidxHiltNavigationCompose = "1.0.0"
33-
androix-test-uiautomator = "2.2.0"
3421
coil = "2.4.0"
3522
# @keep
3623
compileSdk = "34"
@@ -39,42 +26,28 @@ coroutines = "1.7.3"
3926
google-maps = "18.1.0"
4027
gradle-versions = "0.47.0"
4128
hilt = "2.47"
42-
hiltExt = "1.0.0"
43-
# @pin When updating to AGP 7.4.0-alpha10 and up we can update this https://developer.android.com/studio/write/java8-support#library-desugaring-versions
44-
jdkDesugar = "1.2.2"
4529
junit = "4.13.2"
4630
# @pin Update in conjuction with Compose Compiler
4731
kotlin = "1.8.21"
4832
ksp = "1.8.0-1.0.9"
4933
maps-compose = "2.13.0"
50-
material = "1.11.0-alpha01"
34+
material = "1.11.0-alpha02"
5135
# @keep
5236
minSdk = "21"
53-
okhttp = "4.11.0"
5437
recyclerview = "1.3.1"
55-
robolectric = "4.9.2"
56-
rome = "1.18.0"
57-
room = "2.5.1"
58-
secrets = "2.0.1"
5938
# @keep
6039
targetSdk = "34"
6140
version-catalog-update = "0.8.1"
6241

6342
[libraries]
6443
accompanist-adaptive = { module = "com.google.accompanist:accompanist-adaptive", version.ref = "accompanist" }
6544
accompanist-permissions = { module = "com.google.accompanist:accompanist-permissions", version.ref = "accompanist" }
66-
accompanist-swiperefresh = { module = "com.google.accompanist:accompanist-swiperefresh", version.ref = "accompanist" }
67-
accompanist-systemuicontroller = { module = "com.google.accompanist:accompanist-systemuicontroller", version.ref = "accompanist" }
6845
accompanist-theme-adapter-appcompat = { module = "com.google.accompanist:accompanist-themeadapter-appcompat", version.ref = "accompanist" }
6946
accompanist-theme-adapter-material = { module = "com.google.accompanist:accompanist-themeadapter-material", version.ref = "accompanist" }
7047
accompanist-theme-adapter-material3 = { module = "com.google.accompanist:accompanist-themeadapter-material3", version.ref = "accompanist" }
7148
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activity-compose" }
72-
androidx-activity-ktx = "androidx.activity:activity-ktx:1.8.0-alpha05"
49+
7350
androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx-appcompat" }
74-
androidx-benchmark-macrobenchmark = { module = "androidx.benchmark:benchmark-macro", version.ref = "androidx-benchmark" }
75-
androidx-benchmark-macrobenchmark-junit4 = { module = "androidx.benchmark:benchmark-macro-junit4", version.ref = "androidx-benchmark-junit4" }
76-
androidx-cardview = { module = "androidx.cardview:cardview", version.ref = "androidx-cardview" }
77-
androidx-compose-animation = { module = "androidx.compose.animation:animation" }
7851
androidx-compose-animation-graphics = { module = "androidx.compose.animation:animation-graphics" }
7952
androidx-compose-bom = { module = "androidx.compose:compose-bom", version.ref = "androidx-compose-bom" }
8053
androidx-compose-foundation = { module = "androidx.compose.foundation:foundation" }
@@ -87,7 +60,8 @@ androidx-compose-runtime = { module = "androidx.compose.runtime:runtime" }
8760
androidx-compose-runtime-livedata = { module = "androidx.compose.runtime:runtime-livedata" }
8861
androidx-compose-ui = { module = "androidx.compose.ui:ui" }
8962
androidx-compose-ui-googlefonts = { module = "androidx.compose.ui:ui-text-google-fonts" }
90-
androidx-compose-ui-graphics = { module = "androidx.compose.ui:ui-graphics" }
63+
# TODO remove usage of this when `draw` method is in stable.
64+
androidx-compose-ui-graphics = "androidx.compose.ui:ui-graphics:1.6.0-alpha05"
9165
androidx-compose-ui-test = { module = "androidx.compose.ui:ui-test" }
9266
androidx-compose-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4" }
9367
androidx-compose-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest" }
@@ -104,59 +78,33 @@ androidx-fragment-ktx = { module = "androidx.fragment:fragment-ktx", version.ref
10478
androidx-glance-appwidget = { module = "androidx.glance:glance-appwidget", version.ref = "androidx-glance-appwidget" }
10579
androidx-glance-material3 = { module = "androidx.glance:glance-material3", version.ref = "androidx-glance-appwidget" }
10680
androidx-hilt-navigation-compose = { module = "androidx.hilt:hilt-navigation-compose", version.ref = "androidxHiltNavigationCompose" }
107-
androidx-lifecycle-livedata-ktx = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "androidx-lifecycle-compose" }
10881
androidx-lifecycle-runtime = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "androidx-lifecycle-compose" }
10982
androidx-lifecycle-runtime-compose = { module = "androidx.lifecycle:lifecycle-runtime-compose", version.ref = "androidx-lifecycle-runtime-compose" }
11083
androidx-lifecycle-viewModelCompose = { module = "androidx.lifecycle:lifecycle-viewmodel-compose", version.ref = "androidx-lifecycle-compose" }
11184
androidx-lifecycle-viewmodel-ktx = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "androidx-lifecycle-compose" }
112-
androidx-lifecycle-viewmodel-savedstate = { module = "androidx.lifecycle:lifecycle-viewmodel-savedstate", version.ref = "androidx-lifecycle-compose" }
11385
androidx-navigation-compose = { module = "androidx.navigation:navigation-compose", version.ref = "androidx-navigation" }
114-
androidx-navigation-fragment = { module = "androidx.navigation:navigation-fragment-ktx", version.ref = "androidx-navigation" }
115-
androidx-navigation-ui-ktx = { module = "androidx.navigation:navigation-ui-ktx", version.ref = "androidx-navigation" }
116-
androidx-paging-common-ktx = { module = "androidx.paging:paging-common-ktx", version.ref = "androidx-paging-common" }
11786
androidx-paging-compose = { module = "androidx.paging:paging-compose", version.ref = "androidx-paging" }
118-
androidx-palette = { module = "androidx.palette:palette", version.ref = "androidx-palette" }
11987
androidx-recyclerview = { module = "androidx.recyclerview:recyclerview", version.ref = "recyclerview" }
120-
androidx-room-compiler = { module = "androidx.room:room-compiler", version.ref = "room" }
121-
androidx-room-ktx = { module = "androidx.room:room-ktx", version.ref = "room" }
122-
androidx-room-runtime = { module = "androidx.room:room-runtime", version.ref = "room" }
12388
androidx-test-core = { module = "androidx.test:core", version.ref = "androidx-test" }
12489
androidx-test-espresso-core = { module = "androidx.test.espresso:espresso-core", version.ref = "androidx-test-espresso" }
125-
androidx-test-ext-junit = { module = "androidx.test.ext:junit", version.ref = "androidx-test-ext-junit" }
126-
androidx-test-ext-truth = { module = "androidx.test.ext:truth", version.ref = "androidx-test-ext-truth" }
127-
androidx-test-rules = { module = "androidx.test:rules", version.ref = "androidx-test" }
12890
androidx-test-runner = "androidx.test:runner:1.5.2"
129-
androidx-test-uiautomator = { module = "androidx.test.uiautomator:uiautomator", version.ref = "androix-test-uiautomator" }
130-
androidx-window = { module = "androidx.window:window", version.ref = "androidx-window" }
13191
androidx-work-runtime-ktx = "androidx.work:work-runtime-ktx:2.8.1"
13292
coil-kt-compose = { module = "io.coil-kt:coil-compose", version.ref = "coil" }
133-
core-jdk-desugaring = { module = "com.android.tools:desugar_jdk_libs", version.ref = "jdkDesugar" }
13493
google-android-material = { module = "com.google.android.material:material", version.ref = "material" }
13594
googlemaps-compose = { module = "com.google.maps.android:maps-compose", version.ref = "maps-compose" }
13695
googlemaps-maps = { module = "com.google.android.gms:play-services-maps", version.ref = "google-maps" }
13796
hilt-android = { module = "com.google.dagger:hilt-android", version.ref = "hilt" }
138-
hilt-android-testing = { module = "com.google.dagger:hilt-android-testing", version.ref = "hilt" }
13997
hilt-compiler = { module = "com.google.dagger:hilt-android-compiler", version.ref = "hilt" }
140-
hilt-ext-compiler = { module = "androidx.hilt:hilt-compiler", version.ref = "hiltExt" }
14198
junit = { module = "junit:junit", version.ref = "junit" }
14299
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" }
143100
kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "coroutines" }
144101
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" }
145-
okhttp-logging = { module = "com.squareup.okhttp3:logging-interceptor", version.ref = "okhttp" }
146-
okhttp3 = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" }
147-
robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectric" }
148-
rometools-modules = { module = "com.rometools:rome-modules", version.ref = "rome" }
149-
rometools-rome = { module = "com.rometools:rome", version.ref = "rome" }
150102

151103
[plugins]
152104
android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" }
153105
android-library = { id = "com.android.library", version.ref = "androidGradlePlugin" }
154-
android-test = { id = "com.android.test", version.ref = "androidGradlePlugin" }
155106
gradle-versions = { id = "com.github.ben-manes.versions", version.ref = "gradle-versions" }
156107
hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }
157108
kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" }
158109
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
159-
kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" }
160-
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
161-
secrets = { id = "com.google.android.libraries.mapsplatform.secrets-gradle-plugin", version.ref = "secrets" }
162110
version-catalog-update = { id = "nl.littlerobots.version-catalog-update", version.ref = "version-catalog-update" }

0 commit comments

Comments
 (0)