Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,15 @@ protolayout = "1.3.0"
reactive-streams = "1.0.4"
recyclerview = "1.4.0"
registryDigitalCredentials = "1.0.0-alpha04"
room = "2.6.1"
robolectric = "4.16.1"
roborazzi = "1.59.0"
spotless = "8.3.0"
targetSdk = "37"
tiles = "1.5.0"
tracing = "1.3.0"
truth = "1.4.4"
turbine = "1.1.0"
tvComposeMaterial3 = "1.1.0-beta01"
validatorPush = "1.0.0-alpha09"
version-catalog-update = "1.1.0"
Expand Down Expand Up @@ -206,6 +208,7 @@ androidx-protolayout-expression = { module = "androidx.wear.protolayout:protolay
androidx-protolayout-material = { module = "androidx.wear.protolayout:protolayout-material", version.ref = "protolayout" }
androidx-protolayout-material3 = { module = "androidx.wear.protolayout:protolayout-material3", version.ref = "protolayout" }
androidx-recyclerview = { module = "androidx.recyclerview:recyclerview", version.ref = "recyclerview" }
androidx-room-common = { module = "androidx.room:room-common", version.ref = "room" }
androidx-registry-digitalcredentials-openid = { module = "androidx.credentials.registry:registry-digitalcredentials-openid", version.ref = "registryDigitalCredentials" }
androidx-registry-digitalcredentials-mdoc = { module = "androidx.credentials.registry:registry-digitalcredentials-mdoc", version.ref = "registryDigitalCredentials" }
androidx-registry-digitalcredentials-sdjwtvc = { module = "androidx.credentials.registry:registry-digitalcredentials-sdjwtvc", version.ref = "registryDigitalCredentials" }
Expand Down Expand Up @@ -252,6 +255,7 @@ androidx-test-core-ktx = { module = "androidx.test:core-ktx", version.ref = "and
crossdeviceprompt = { module = "com.google.android.play:crossdeviceprompt", version.ref = "crossdeviceprompt" }
firebase-ai = { module = "com.google.firebase:firebase-ai" }
firebase-bom = { module = "com.google.firebase:firebase-bom", version.ref = "firebase-bom" }
firebase-firestore = { module = "com.google.firebase:firebase-firestore" }
glide-compose = { module = "com.github.bumptech.glide:compose", version.ref = "glide" }
google-android-material = { module = "com.google.android.material:material", version.ref = "material" }
google-ar-core = { module = "com.google.ar:core", version.ref = "google-ar-core" }
Expand Down Expand Up @@ -287,6 +291,7 @@ roborazzi-compose = { module = "io.github.takahirom.roborazzi:roborazzi-compose"
roborazzi-rule = { module = "io.github.takahirom.roborazzi:roborazzi-junit-rule", version.ref = "roborazzi" }
tv-compose-material = { module = "androidx.tv:tv-material", version.ref = "tvComposeMaterial3" }
truth = { module = "com.google.truth:truth", version.ref = "truth" }
turbine = { module = "app.cash.turbine:turbine", version.ref = "turbine" }
validator-push = { module = "com.google.android.wearable.watchface.validator:validator-push", version.ref = "validatorPush" }
wear-compose-material = { module = "androidx.wear.compose:compose-material", version.ref = "wearComposeMaterial" }
wear-compose-material3 = { module = "androidx.wear.compose:compose-material3", version.ref = "wearComposeMaterial3" }
Expand Down
16 changes: 15 additions & 1 deletion kotlin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,22 @@ android {
}
}
dependencies {
// AndroidX
implementation(libs.androidx.activity.ktx)
implementation(libs.androidx.lifecycle.runtime)
implementation(libs.androidx.lifecycle.viewmodel.ktx)
implementation(libs.androidx.room.common)

// Firebase
implementation(platform(libs.firebase.bom))
implementation(libs.firebase.firestore)

// KotlinX
implementation(libs.kotlinx.coroutines.android)
testImplementation(libs.kotlinx.coroutines.test)

// Testing
testImplementation(libs.junit)
testImplementation(libs.kotlinx.coroutines.test)
testImplementation(libs.truth)
testImplementation(libs.turbine)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright 2026 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.example.android.basics

// [START android_kotlin_adopt_person]
data class Person(var firstName: String?, var lastName: String?)
// [END android_kotlin_adopt_person]

fun String.foo(): String = this

fun testExtensionFunction() {
// [START android_kotlin_adopt_foo]
// [START_EXCLUDE]
val placeholderBefore = ""
// [END_EXCLUDE]

val myString: String = "hello"
val fooString = myString.foo()

// [START_EXCLUDE]
val placeholderAfter = ""
// [END_EXCLUDE]
// [END android_kotlin_adopt_foo]
}

class Foo {
fun baz() {}
fun zap() {}
}

fun testLet() {
// [START android_kotlin_adopt_let]
val nullableFoo: Foo? = Foo()

// This lambda executes only if nullableFoo is not null
// and `foo` is of the non-nullable Foo type
nullableFoo?.let { foo ->
foo.baz()
foo.zap()
}
// [END android_kotlin_adopt_let]
}

fun testSmartCast() {
// [START android_kotlin_adopt_smartcast]
val nullableFoo: Foo? = null
if (nullableFoo != null) {
nullableFoo.baz() // Using !! or ?. isn't required; the Kotlin compiler infers non-nullability
nullableFoo.zap() // from guard condition; smart casts nullableFoo to Foo inside this block
}
// [END android_kotlin_adopt_smartcast]
}
Loading
Loading