Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
03e2b27
Refactor swipe-to-dismiss examples (#486)
JolandaVerhoef Apr 29, 2025
da3ebb8
Update accessibility snippets (#508)
simona-anomis May 1, 2025
432ff04
Migrate XR snippets to alpha04 (#509)
devbridie May 8, 2025
222fd4f
🤖 Update Dependencies (#511)
compose-devrel-github-bot May 8, 2025
187d70f
Adding snippet for MV-HEVC video playback (#513)
vad710 May 8, 2025
3f4d4ad
Update to 1.5.0-beta01 (#514)
kul3r4 May 12, 2025
21896a6
Fix package name (#515)
kul3r4 May 12, 2025
70285ac
Fix scrollState for List and expand the snippet to show more code for…
kul3r4 May 13, 2025
903fcbc
Properly handle recycling of RecomposeHighlighterModifier (#510)
mlykotom May 14, 2025
f6e899c
State based TF snippets (#520)
MagicalMeghan May 15, 2025
9d62789
Icon button snippets (#512)
wardlauren May 15, 2025
cd2e0c1
Updates to ResizableComponent (#516)
vad710 May 16, 2025
4c55c0d
Update migration snippet (#524)
MagicalMeghan May 16, 2025
a9a6a55
Add state based Autofill snippets (#525)
MagicalMeghan May 16, 2025
ce81ef6
Update StateBasedText snippets (#526)
MagicalMeghan May 19, 2025
8f703cc
Add snippets for XR alpha04 hands (#530)
devbridie May 22, 2025
7f4c676
Change XR SceneViewer intent setup (#531)
devbridie May 23, 2025
7230f05
Fix for #533 animated CircleNode modifier (#534)
IanGClifton Jun 12, 2025
f34038d
updating setSubspaceContent snippet (#543)
amyZepp Jun 12, 2025
b198bf0
Update android_system_bar_protection_kotlin to change alpha (#544)
ashnohe Jun 17, 2025
d0ef8d0
Fix Drag&Drop code to also support external apps (#546)
tiwiz Jun 18, 2025
3fbcdcb
Add tile interaction snippets (#547)
ithinkihaveacat Jun 18, 2025
a37e651
Add comment to clarify that both callbacks can be used (#548)
tiwiz Jun 18, 2025
88d1bd6
Add snippets for Android Wear's Always On doc (#549)
ithinkihaveacat Jun 20, 2025
592ac88
Add android_wear_m3_interaction_loadaction_request tag (#551)
ithinkihaveacat Jun 20, 2025
5723c5a
🤖 Update Dependencies (#552)
compose-devrel-github-bot Jun 23, 2025
81b5d86
Move END tag to correct location (#553)
ithinkihaveacat Jun 24, 2025
cafc3dd
Snippets for some Wear OS Tile pages (#554)
ithinkihaveacat Jun 25, 2025
c9e37f8
Adds Watch Face Push validation library snippet (#555)
garanj Jun 27, 2025
a9464f2
Update build.yml to add Watch Face Push validation (#556)
garanj Jun 27, 2025
327c0ac
Typo fix - one import per line (#557)
asolovay Jun 30, 2025
ef79bd2
Update webview url (#559)
cy245 Jul 2, 2025
0c23312
Add additional credman webview snippet and autofill snippets (#561)
cy245 Jul 8, 2025
80802cb
Add remaining autofill snippet with edittext (#562)
cy245 Jul 9, 2025
33c4bc2
Fix rethrowing cancellation exceptions (#563)
mlykotom Jul 11, 2025
341dbd4
Add profiling manager snippets for how-to-capture DAC docs (#568)
edgararriagag Jul 16, 2025
b78993d
Update XR snippets to be compatible with alpha05 versions of the libr…
devbridie Jul 31, 2025
1b043a4
Add example of Lottie animation (#572)
ithinkihaveacat Aug 1, 2025
c703008
Fixing compile error in DeviceCompatibilityModeTestJavaSnippets (#575)
asolovay Aug 5, 2025
f8abcf7
Add Glance in-app widget pinning snippet (#580)
ashnohe Aug 6, 2025
f643874
Revised snippets for consistency. (#579)
JonEckenrode Aug 8, 2025
a87b076
Resolve build failures so repository will build with `./gradlew clean…
cartland Aug 11, 2025
79a26f9
Adding code snippets for wake locks doc (#582)
asolovay Aug 12, 2025
910e372
Breaking long line in code snippet (#586)
asolovay Aug 13, 2025
d1b418e
Add PreloadManager snippets, and update media3 to 1.8.0 (#574)
asolovay Aug 13, 2025
39218cc
Enable spotless on all modules (#587)
cartland Aug 18, 2025
f11b3bc
Build: Increase Gradle JVM heap size to 4g (#595)
cartland Aug 21, 2025
982ea5e
🤖 Update Dependencies (#596)
compose-devrel-github-bot Aug 21, 2025
97d93a1
Adds complications snippets (#597)
garanj Aug 22, 2025
dd30aee
Wear complications (#598)
garanj Aug 22, 2025
41d2e50
Update comments in MyComplicationDataSourceService.kt, visible in And…
khufdev Aug 26, 2025
32e681d
Fix typo for Activity constant (CANCELLED -> CANCELED) (#606)
khufdev Aug 26, 2025
5673ffc
Add lottie animation fallback example (#608)
ithinkihaveacat Aug 26, 2025
7a0ebbe
Update comments in complication part of AndroidManifest.xml (#605)
khufdev Aug 27, 2025
fcea14b
Add padding to avoid overwriting TimeText (#529)
ithinkihaveacat Aug 28, 2025
3c8b283
Refactor(SearchBar): Reorder modifier parameter to follow convention …
cartland Aug 29, 2025
a73d3b4
Refactor(text): Use KTX extension for isDigitsOnly check (#593)
cartland Aug 29, 2025
d6d74ed
Refactor: Rename Composable functions to follow naming conventions (#…
cartland Aug 29, 2025
959474f
Lint: Use specialized state holders to avoid autoboxing (#591)
cartland Aug 29, 2025
e2de07a
Fix(gestures): Handle pointer events inside awaitPointerEventScope (#…
cartland Aug 29, 2025
f95ab59
Fix: Prevent memory leak from implicit SAM conversion (#588)
cartland Aug 29, 2025
6301d76
docs(modifiers): Add TODOs for inspectableProperties lint warnings (#…
cartland Aug 30, 2025
fb85817
Add KMP ViewModel snippets (#611)
mlykotom Sep 1, 2025
e4396f6
Fix missing snippet (#612)
mlykotom Sep 1, 2025
7a69216
Add viewmodel screen for KMP (#613)
mlykotom Sep 3, 2025
a75378c
Add android_wear_tile_version_fallback (#614)
ithinkihaveacat Sep 3, 2025
3d5181b
Disabling some "unused" warnings (#610)
asolovay Sep 3, 2025
30ed522
Resolve warnings in the Wakelock code snippets (#615)
asolovay Sep 5, 2025
89ecf71
Migrate snippets from dac/training/wearables/tiles/screen-size (#617)
ithinkihaveacat Sep 10, 2025
9efabdd
add WindowInsetsRulers snippet (#616)
ashnohe Sep 10, 2025
9436a8d
Update state based (#619)
MagicalMeghan Sep 11, 2025
292ef1d
Update the wear preview code
ithinkihaveacat Sep 11, 2025
73e600d
Adding shadows code snippets (#620)
wardlauren Sep 11, 2025
1da1d9d
Add basic WindowInsetsRulers cases (#621)
ashnohe Sep 16, 2025
89507d5
Add navigation3 snippets
dturner May 20, 2025
c9405a1
Apply Spotless
dturner May 20, 2025
9105e56
Remove long package name
dturner May 20, 2025
e799446
Update Nav3 snippets to match alpha09 API
dturner Sep 23, 2025
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
11 changes: 1 addition & 10 deletions .github/workflows/apply_spotless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,7 @@ jobs:
java-version: '17'

- name: Run spotlessApply
run: ./gradlew :compose:spotlessApply --init-script gradle/init.gradle.kts --no-configuration-cache --stacktrace

- name: Run spotlessApply for Wear
run: ./gradlew :wear:spotlessApply --init-script gradle/init.gradle.kts --no-configuration-cache --stacktrace

- name: Run spotlessApply for Misc
run: ./gradlew :misc:spotlessApply --init-script gradle/init.gradle.kts --no-configuration-cache --stacktrace

- name: Run spotlessApply for XR
run: ./gradlew :xr:spotlessApply --init-script gradle/init.gradle.kts --no-configuration-cache --stacktrace
run: ./gradlew spotlessApply --init-script gradle/init.gradle.kts --no-configuration-cache --stacktrace

- name: Auto-commit if spotlessApply has changes
uses: stefanzweifel/git-auto-commit-action@v5
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/build-ios.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Copyright 2025 Google LLC
#
# 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
#
# http://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.
name: Build snippets

on:
push:
branches: [ '*' ]
paths:
- 'kmp/**'
- '.github/workflows/build-ios.yml'
pull_request:
branches: [ '*' ]
paths:
- 'kmp/**'
- '.github/workflows/build-ios.yml'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-build-ios
cancel-in-progress: true
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build_ios:
name: Build iOS app
runs-on: macos-latest
steps:
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable

- name: Checkout
uses: actions/checkout@v5

- name: Build iOS app
uses: mxcl/xcodebuild@v3
with:
xcode: ^16
scheme: iosApp
platform: iOS
action: build
working-directory: kmp/iosApp
16 changes: 4 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,7 @@ jobs:
with:
distribution: 'zulu'
java-version: '17'
- name: Build Compose
run: ./gradlew :compose:snippets:build
- name: Build recompose snippets
run: ./gradlew :compose:recomposehighlighter:build
- name: Build kotlin snippets
run: ./gradlew :kotlin:build
- name: Build Wear snippets
run: ./gradlew :wear:build
- name: Build misc snippets
run: ./gradlew :misc:build
- name: Build XR snippets
run: ./gradlew :xr:build
- name: Build All
run: ./gradlew build --stacktrace
- name: Build Watch Face Push validation snippets
run: ./gradlew :watchfacepush:validator:run --stacktrace
16 changes: 15 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,22 @@
/.idea/modules.xml
/.idea/workspace.xml
.DS_Store
/build
build
/captures
.externalNativeBuild
.idea/*
/.idea/*
.kotlin

### Xcode ###
## User settings
xcuserdata/

### Xcode Patch ###
*.xcodeproj/*
!*.xcodeproj/project.pbxproj
!*.xcodeproj/xcshareddata/
!*.xcodeproj/project.xcworkspace/
!*.xcworkspace/contents.xcworkspacedata
/*.gcno
**/xcshareddata/WorkspaceSettings.xcsettings
5 changes: 2 additions & 3 deletions bluetoothle/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sample.android.bluetoothle">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
Expand All @@ -23,6 +22,6 @@
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

</manifest>
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package com.sample.android.bluetoothle.java;

import androidx.appcompat.app.AppCompatActivity;

import android.Manifest;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothManager;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import androidx.annotation.RequiresPermission;
import androidx.appcompat.app.AppCompatActivity;

import com.sample.android.bluetoothle.R;

public class MainActivity extends AppCompatActivity {
Expand All @@ -19,6 +21,7 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_main);
}

@RequiresPermission(Manifest.permission.BLUETOOTH_CONNECT)
private void setUpBLE() {
// [START get_bluetooth_adapter]
// Initializes Bluetooth adapter.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@

package com.sample.android.bluetoothle.kotlin

import android.Manifest
import android.app.ListActivity
import android.bluetooth.BluetoothAdapter
import android.bluetooth.le.ScanCallback
import android.bluetooth.le.ScanResult
import android.os.Handler
import androidx.annotation.RequiresPermission
import com.sample.android.bluetoothle.java.LeDeviceListAdapter

/**
Expand All @@ -47,6 +49,7 @@ class DeviceScanActivity : ListActivity() {
// Stops scanning after 10 seconds.
private val SCAN_PERIOD: Long = 10000

@RequiresPermission(Manifest.permission.BLUETOOTH_SCAN)
private fun scanLeDevice() {
if (!mScanning) { // Stops scanning after a pre-defined scan period.
handler.postDelayed({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@

package com.sample.android.bluetoothle.kotlin

import android.Manifest
import android.bluetooth.BluetoothAdapter
import android.bluetooth.BluetoothManager
import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.annotation.RequiresPermission
import androidx.appcompat.app.AppCompatActivity

class MainActivity : AppCompatActivity() {
Expand All @@ -31,6 +33,7 @@ class MainActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
}

@RequiresPermission(Manifest.permission.BLUETOOTH_CONNECT)
private fun setUpBLE() {
// [START get_bluetooth_adapter]
// Initializes Bluetooth adapter.
Expand Down
3 changes: 3 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ plugins {
alias(libs.plugins.kotlin.parcelize) apply false
alias(libs.plugins.compose.compiler) apply false
alias(libs.plugins.kotlin.serialization) apply false
alias(libs.plugins.kotlin.multiplatform) apply false
alias(libs.plugins.android.kotlin.multiplatform.library) apply false
alias(libs.plugins.android.lint) apply false
}

apply("${project.rootDir}/buildscripts/toml-updater-config.gradle")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ private class RecomposeHighlighterModifier : Modifier.Node(), DrawModifierNode {

override val shouldAutoInvalidate: Boolean = false

override fun onReset() {
totalCompositions = 0
timerJob?.cancel()
}

override fun onDetach() {
timerJob?.cancel()
}
Expand Down
8 changes: 8 additions & 0 deletions compose/snippets/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ dependencies {
implementation(libs.androidx.compose.material3.adaptive.layout)
implementation(libs.androidx.compose.material3.adaptive.navigation)
implementation(libs.androidx.compose.material3.adaptive.navigation.suite)
implementation(libs.androidx.compose.material3.windowsizeclass)
implementation(libs.androidx.compose.material)

implementation(libs.androidx.compose.runtime)
Expand Down Expand Up @@ -136,7 +137,13 @@ dependencies {
implementation(libs.androidx.navigation.compose)
implementation(libs.hilt.android)
implementation(libs.androidx.hilt.navigation.compose)

implementation(libs.kotlinx.serialization.core)
implementation(libs.kotlinx.serialization.json)
implementation(libs.androidx.compose.material3.adaptive.navigation3)
implementation(libs.androidx.navigation3.runtime)
implementation(libs.androidx.navigation3.ui)
implementation(libs.androidx.lifecycle.viewmodel.navigation3)

implementation(libs.androidx.recyclerview)

Expand All @@ -160,6 +167,7 @@ dependencies {
debugImplementation(libs.androidx.compose.ui.tooling)

androidTestImplementation(libs.androidx.compose.ui.test.junit4)
androidTestImplementation(libs.androidx.compose.ui.test.junit4.accessibility)
debugImplementation(libs.androidx.compose.ui.test.manifest)

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,109 @@

package com.example.compose.snippets.accessibility

import androidx.activity.ComponentActivity
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.size
import androidx.compose.material3.Text
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.semantics.SemanticsActions
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.getOrNull
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.test.SemanticsMatcher
import androidx.compose.ui.test.assert
import androidx.compose.ui.test.junit4.accessibility.enableAccessibilityChecks
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import com.example.compose.snippets.MyActivity
import androidx.compose.ui.test.onRoot
import androidx.compose.ui.test.tryPerformAccessibilityChecks
import androidx.compose.ui.unit.dp
import com.google.android.apps.common.testing.accessibility.framework.AccessibilityCheckResult
import com.google.android.apps.common.testing.accessibility.framework.integrations.espresso.AccessibilityValidator
import org.junit.Ignore
import org.junit.Rule
import org.junit.Test

class AccessibilitySnippetsTest {
class AccessibilityTest {

// [START android_compose_accessibility_testing_label]
@Rule
@JvmField
val composeTestRule = createAndroidComposeRule<MyActivity>()
val composeTestRule = createAndroidComposeRule<ComponentActivity>()

@Test
fun noAccessibilityLabel() {
composeTestRule.setContent {
Box(
modifier = Modifier
.size(50.dp, 50.dp)
.background(color = Color.Gray)
.clickable { }
.semantics {
contentDescription = ""
}
)
}

private val nodeMatcher = SemanticsMatcher("DUMMY") { it.isRoot }
composeTestRule.enableAccessibilityChecks()

@Ignore("Dummy test")
// Any action (such as performClick) will perform accessibility checks too:
composeTestRule.onRoot().tryPerformAccessibilityChecks()
}
// [END android_compose_accessibility_testing_label]

// [START android_compose_accessibility_testing_click]
@Test
fun smallClickTarget() {
composeTestRule.setContent {
Box(
modifier = Modifier
.size(20.dp, 20.dp)
.background(color = Color(0xFFFAFBFC))
.clickable { }
)
}

composeTestRule.enableAccessibilityChecks()

// Any action (such as performClick) will perform accessibility checks too:
composeTestRule.onRoot().tryPerformAccessibilityChecks()
}
// [END android_compose_accessibility_testing_click]

// [START android_compose_accessibility_testing_validator]
@Test
fun lowContrastScreen() {
composeTestRule.setContent {
Box(
modifier = Modifier
.fillMaxSize()
.background(color = Color(0xFFFAFBFC)),
contentAlignment = Alignment.Center
) {
Text(text = "Hello", color = Color(0xFFB0B1B2))
}
}

// Optionally, set AccessibilityValidator manually
val accessibilityValidator = AccessibilityValidator()
.setThrowExceptionFor(
AccessibilityCheckResult.AccessibilityCheckResultType.WARNING
)

composeTestRule.enableAccessibilityChecks(accessibilityValidator)

composeTestRule.onRoot().tryPerformAccessibilityChecks()
}
// [END android_compose_accessibility_testing_validator]

private val nodeMatcher = SemanticsMatcher(description = "DUMMY") { it.isRoot }

@Ignore("Dummy test")
// [START android_compose_accessibility_testing]
@Test
fun test() {
Expand Down
Loading