Skip to content

Commit f33efaa

Browse files
authored
Merge branch 'main' into unused-code-cleanup
2 parents fd2470b + e4396f6 commit f33efaa

File tree

26 files changed

+912
-13
lines changed

26 files changed

+912
-13
lines changed

.github/workflows/build-ios.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
name: Build snippets
15+
16+
on:
17+
push:
18+
branches: [ '*' ]
19+
paths:
20+
- 'kmp/**'
21+
- '.github/workflows/build-ios.yml'
22+
pull_request:
23+
branches: [ '*' ]
24+
paths:
25+
- 'kmp/**'
26+
- '.github/workflows/build-ios.yml'
27+
workflow_dispatch:
28+
concurrency:
29+
group: ${{ github.workflow }}-${{ github.ref }}-build-ios
30+
cancel-in-progress: true
31+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
32+
jobs:
33+
build_ios:
34+
name: Build iOS app
35+
runs-on: macos-latest
36+
steps:
37+
- uses: maxim-lobanov/setup-xcode@v1
38+
with:
39+
xcode-version: latest-stable
40+
41+
- name: Checkout
42+
uses: actions/checkout@v5
43+
44+
- name: Build iOS app
45+
uses: mxcl/xcodebuild@v3
46+
with:
47+
xcode: ^16
48+
scheme: iosApp
49+
platform: iOS
50+
action: build
51+
working-directory: kmp/iosApp

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,17 @@ build
1111
.externalNativeBuild
1212
.idea/*
1313
/.idea/*
14+
.kotlin
15+
16+
### Xcode ###
17+
## User settings
18+
xcuserdata/
19+
20+
### Xcode Patch ###
21+
*.xcodeproj/*
22+
!*.xcodeproj/project.pbxproj
23+
!*.xcodeproj/xcshareddata/
24+
!*.xcodeproj/project.xcworkspace/
25+
!*.xcworkspace/contents.xcworkspacedata
26+
/*.gcno
27+
**/xcshareddata/WorkspaceSettings.xcsettings

build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ plugins {
1010
alias(libs.plugins.kotlin.parcelize) apply false
1111
alias(libs.plugins.compose.compiler) apply false
1212
alias(libs.plugins.kotlin.serialization) apply false
13+
alias(libs.plugins.kotlin.multiplatform) apply false
14+
alias(libs.plugins.android.kotlin.multiplatform.library) apply false
15+
alias(libs.plugins.android.lint) apply false
1316
}
1417

1518
apply("${project.rootDir}/buildscripts/toml-updater-config.gradle")

compose/snippets/src/main/java/com/example/compose/snippets/interop/InteroperabilityAPIsSnippets.kt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import androidx.activity.ComponentActivity
3232
import androidx.activity.compose.setContent
3333
import androidx.compose.foundation.layout.Column
3434
import androidx.compose.foundation.layout.fillMaxSize
35+
import androidx.compose.foundation.lazy.LazyColumn
3536
import androidx.compose.material3.Button
3637
import androidx.compose.material3.MaterialTheme
3738
import androidx.compose.material3.Text
@@ -191,6 +192,28 @@ class ExampleFragmentMultipleComposeView : Fragment() {
191192
}
192193
// [END android_compose_interop_apis_compose_in_fragment_multiple]
193194

195+
// [START android_compose_interop_apis_android_view_reuse]
196+
@Composable
197+
fun AndroidViewInLazyList() {
198+
LazyColumn {
199+
items(100) { index ->
200+
AndroidView(
201+
modifier = Modifier.fillMaxSize(), // Occupy the max size in the Compose UI tree
202+
factory = { context ->
203+
MyView(context)
204+
},
205+
update = { view ->
206+
view.selectedItem = index
207+
},
208+
onReset = { view ->
209+
view.clear()
210+
}
211+
)
212+
}
213+
}
214+
}
215+
// [END android_compose_interop_apis_android_view_reuse]
216+
194217
// [START android_compose_interop_apis_views_in_compose]
195218
@Composable
196219
fun CustomView() {
@@ -231,6 +254,8 @@ fun ContentExample() {
231254
// [START_EXCLUDE silent]
232255
class MyView(context: Context) : View(context) {
233256
var selectedItem: Int = 0
257+
258+
fun clear() { }
234259
}
235260
// [END_EXCLUDE silent]
236261
// [END android_compose_interop_apis_views_in_compose]

compose/snippets/src/main/java/com/example/compose/snippets/modifiers/CustomModifierSnippets.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ private class CircleNode(var color: Color) : DrawModifierNode, Modifier.Node() {
142142
}
143143
// [END android_compose_custom_modifiers_7]
144144

145+
// TODO: Create a new snippet that overrides InspectorInfo.inspectableProperties.
145146
// [START android_compose_custom_modifiers_8]
146147
// ModifierNodeElement
147148
private data class CircleElement(val color: Color) : ModifierNodeElement<CircleNode>() {
@@ -159,6 +160,7 @@ fun Modifier.circle(color: Color) = this then CircleElement(color)
159160
// [END android_compose_custom_modifiers_9]
160161

161162
private object CustomModifierSnippets10 {
163+
// TODO: Create a new snippet that overrides InspectorInfo.inspectableProperties.
162164
// [START android_compose_custom_modifiers_10]
163165
// Modifier factory
164166
fun Modifier.circle(color: Color) = this then CircleElement(color)
@@ -181,6 +183,7 @@ private object CustomModifierSnippets10 {
181183
// [END android_compose_custom_modifiers_10]
182184
}
183185

186+
// TODO: Create a new snippet that overrides InspectorInfo.inspectableProperties.
184187
// [START android_compose_custom_modifiers_11]
185188
fun Modifier.fixedPadding() = this then FixedPaddingElement
186189

compose/snippets/src/main/java/com/example/compose/snippets/pictureinpicture/PictureInPictureSnippets.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ fun PipListenerPreAPI12(shouldEnterPipMode: Boolean) {
356356
) {
357357
val context = LocalContext.current
358358
DisposableEffect(context) {
359-
val onUserLeaveBehavior: () -> Unit = {
359+
val onUserLeaveBehavior = Runnable {
360360
context.findActivity()
361361
.enterPictureInPictureMode(PictureInPictureParams.Builder().build())
362362
}
@@ -384,7 +384,7 @@ fun EnterPiPPre12(shouldEnterPipMode: Boolean) {
384384
) {
385385
val context = LocalContext.current
386386
DisposableEffect(context) {
387-
val onUserLeaveBehavior: () -> Unit = {
387+
val onUserLeaveBehavior = Runnable {
388388
if (currentShouldEnterPipMode) {
389389
context.findActivity()
390390
.enterPictureInPictureMode(PictureInPictureParams.Builder().build())

gradle/libs.versions.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ androidx-lifecycle-runtime = { module = "androidx.lifecycle:lifecycle-runtime-kt
130130
androidx-lifecycle-runtime-compose = { module = "androidx.lifecycle:lifecycle-runtime-compose", version.ref = "androidx-lifecycle-runtime-compose" }
131131
androidx-lifecycle-service = { module = "androidx.lifecycle:lifecycle-service", version.ref = "lifecycleService" }
132132
androidx-lifecycle-viewModelCompose = { module = "androidx.lifecycle:lifecycle-viewmodel-compose", version.ref = "androidx-lifecycle-compose" }
133+
androidx-lifecycle-viewmodel = { module = "androidx.lifecycle:lifecycle-viewmodel", version.ref = "androidx-lifecycle-compose" }
133134
androidx-lifecycle-viewmodel-ktx = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "androidx-lifecycle-compose" }
134135
androidx-material-icons-core = { module = "androidx.compose.material:material-icons-core" }
135136
androidx-media3-common = { module = "androidx.media3:media3-common", version.ref = "media3" }
@@ -179,7 +180,7 @@ horologist-compose-layout = { module = "com.google.android.horologist:horologist
179180
horologist-compose-material = { module = "com.google.android.horologist:horologist-compose-material", version.ref = "horologist" }
180181
junit = { module = "junit:junit", version.ref = "junit" }
181182
kotlin-coroutines-okhttp = { module = "ru.gildor.coroutines:kotlin-coroutines-okhttp", version.ref = "kotlinCoroutinesOkhttp" }
182-
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" }
183+
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
183184
kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "coroutines" }
184185
kotlinx-coroutines-guava = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-guava", version.ref = "kotlinxCoroutinesGuava" }
185186
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" }
@@ -189,6 +190,8 @@ play-services-wearable = { module = "com.google.android.gms:play-services-wearab
189190
validator-push = { module = "com.google.android.wearable.watchface.validator:validator-push", version.ref = "validatorPush" }
190191
wear-compose-material = { module = "androidx.wear.compose:compose-material", version.ref = "wearComposeMaterial" }
191192
wear-compose-material3 = { module = "androidx.wear.compose:compose-material3", version.ref = "wearComposeMaterial3" }
193+
jetbrains-kotlin-stdlib = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib", version.ref = "kotlin" }
194+
kotlin-test = { group = "org.jetbrains.kotlin", name = "kotlin-test", version.ref = "kotlin" }
192195

193196
[plugins]
194197
android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" }
@@ -197,7 +200,10 @@ compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "
197200
gradle-versions = { id = "com.github.ben-manes.versions", version.ref = "gradle-versions" }
198201
hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }
199202
kotlin-android = "org.jetbrains.kotlin.android:2.2.10"
203+
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
204+
android-kotlin-multiplatform-library = { id = "com.android.kotlin.multiplatform.library", version.ref = "androidGradlePlugin" }
200205
kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" }
201206
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
202207
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
203208
version-catalog-update = { id = "nl.littlerobots.version-catalog-update", version.ref = "version-catalog-update" }
209+
android-lint = { id = "com.android.lint", version.ref = "androidGradlePlugin" }
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
TEAM_ID=
2+
3+
PRODUCT_NAME=KotlinProject
4+
PRODUCT_BUNDLE_IDENTIFIER=org.example.project.KotlinProject$(TEAM_ID)
5+
6+
CURRENT_PROJECT_VERSION=1
7+
MARKETING_VERSION=1.0

0 commit comments

Comments
 (0)