Skip to content

Commit 2f6441c

Browse files
committed
Adds Wear voice input
1 parent b883fb9 commit 2f6441c

File tree

21 files changed

+449
-0
lines changed

21 files changed

+449
-0
lines changed

.github/workflows/apply_spotless.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,6 @@ jobs:
4747
uses: stefanzweifel/git-auto-commit-action@v5
4848
with:
4949
commit_message: Apply Spotless
50+
51+
- name: Run spotlessApply for Wear
52+
run: ./gradlew :wear:spotlessApply --init-script gradle/init.gradle.kts --no-configuration-cache --stacktrace

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,5 @@ jobs:
4343
run: ./gradlew :compose:recomposehighlighter:build
4444
- name: Build kotlin snippets
4545
run: ./gradlew :kotlin:build
46+
- name: Build Wear snippets
47+
run: ./gradlew :wear:build

gradle/libs.versions.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ recyclerview = "1.3.2"
4343
# @keep
4444
targetSdk = "34"
4545
version-catalog-update = "0.8.3"
46+
playServicesWearable = "18.1.0"
47+
wearComposeMaterial = "1.2.1"
48+
wearComposeFoundation = "1.2.1"
49+
coreSplashscreen = "1.0.1"
50+
horologist = "0.5.24"
4651

4752
[libraries]
4853
accompanist-adaptive = { module = "com.google.accompanist:accompanist-adaptive", version.ref = "accompanist" }
@@ -110,6 +115,12 @@ junit = { module = "junit:junit", version.ref = "junit" }
110115
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" }
111116
kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "coroutines" }
112117
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" }
118+
play-services-wearable = { group = "com.google.android.gms", name = "play-services-wearable", version.ref = "playServicesWearable" }
119+
compose-material = { group = "androidx.wear.compose", name = "compose-material", version.ref = "wearComposeMaterial" }
120+
compose-foundation = { group = "androidx.wear.compose", name = "compose-foundation", version.ref = "wearComposeFoundation" }
121+
androidx-core-splashscreen = { group = "androidx.core", name = "core-splashscreen", version.ref = "coreSplashscreen" }
122+
horologist-compose-layout = { module = "com.google.android.horologist:horologist-compose-layout", version.ref = "horologist" }
123+
horologist-compose-material = { module = "com.google.android.horologist:horologist-compose-material", version.ref = "horologist" }
113124

114125
[plugins]
115126
android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" }

settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ include(
2626
":compose:recomposehighlighter",
2727
":kotlin",
2828
":compose:snippets",
29+
":wear",
2930
)

wear/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

wear/build.gradle.kts

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
plugins {
2+
alias(libs.plugins.android.application)
3+
alias(libs.plugins.kotlin.android)
4+
}
5+
6+
android {
7+
namespace = "com.example.wear"
8+
compileSdk = 34
9+
10+
defaultConfig {
11+
applicationId = "com.example.wear"
12+
minSdk = 26
13+
targetSdk = 33
14+
versionCode = 1
15+
versionName = "1.0"
16+
vectorDrawables {
17+
useSupportLibrary = true
18+
}
19+
20+
}
21+
22+
buildTypes {
23+
release {
24+
isMinifyEnabled = false
25+
proguardFiles(
26+
getDefaultProguardFile("proguard-android-optimize.txt"),
27+
"proguard-rules.pro"
28+
)
29+
}
30+
}
31+
compileOptions {
32+
sourceCompatibility = JavaVersion.VERSION_17
33+
targetCompatibility = JavaVersion.VERSION_17
34+
}
35+
kotlin {
36+
jvmToolchain(17)
37+
}
38+
39+
buildFeatures {
40+
compose = true
41+
}
42+
composeOptions {
43+
kotlinCompilerExtensionVersion = libs.versions.compose.compiler.get()
44+
}
45+
packaging {
46+
resources {
47+
excludes += "/META-INF/{AL2.0,LGPL2.1}"
48+
}
49+
}
50+
}
51+
52+
dependencies {
53+
val composeBom = platform(libs.androidx.compose.bom)
54+
implementation(composeBom)
55+
androidTestImplementation(composeBom)
56+
57+
implementation(libs.play.services.wearable)
58+
implementation(platform(libs.androidx.compose.bom))
59+
implementation(libs.androidx.compose.ui)
60+
implementation(libs.androidx.compose.ui.tooling.preview)
61+
implementation(libs.compose.material)
62+
implementation(libs.compose.foundation)
63+
implementation(libs.androidx.activity.compose)
64+
implementation(libs.androidx.core.splashscreen)
65+
implementation(libs.horologist.compose.layout)
66+
implementation(libs.horologist.compose.material)
67+
androidTestImplementation(libs.androidx.compose.ui.test.junit4)
68+
debugImplementation(libs.androidx.compose.ui.tooling)
69+
debugImplementation(libs.androidx.compose.ui.test.manifest)
70+
testImplementation(libs.junit)
71+
72+
androidTestImplementation(libs.junit)
73+
androidTestImplementation(libs.androidx.test.core)
74+
androidTestImplementation(libs.androidx.test.runner)
75+
androidTestImplementation(libs.androidx.test.espresso.core)
76+
androidTestImplementation(libs.androidx.compose.ui.test)
77+
debugImplementation(libs.androidx.compose.ui.tooling)
78+
}

wear/lint.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<lint>
3+
<!-- Ignore the IconLocation for the Tile preview images -->
4+
<issue id="IconLocation">
5+
<ignore path="res/drawable/tile_preview.png" />
6+
<ignore path="res/drawable-round/tile_preview.png" />
7+
</issue>
8+
</lint>

wear/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile

wear/src/main/AndroidManifest.xml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
<uses-permission android:name="android.permission.WAKE_LOCK" />
5+
6+
<uses-feature android:name="android.hardware.type.watch" />
7+
8+
<application
9+
android:allowBackup="true"
10+
android:icon="@mipmap/ic_launcher"
11+
android:label="@string/app_name"
12+
android:supportsRtl="true"
13+
android:theme="@android:style/Theme.DeviceDefault">
14+
<uses-library
15+
android:name="com.google.android.wearable"
16+
android:required="true" />
17+
18+
<!--
19+
Set to true if your app is Standalone, that is, it does not require the handheld
20+
app to run.
21+
-->
22+
<meta-data
23+
android:name="com.google.android.wearable.standalone"
24+
android:value="true" />
25+
26+
<activity
27+
android:name=".snippets.MainActivity"
28+
android:exported="true"
29+
android:taskAffinity=""
30+
android:theme="@android:style/Theme.DeviceDefault">
31+
<intent-filter>
32+
<action android:name="android.intent.action.MAIN" />
33+
34+
<category android:name="android.intent.category.LAUNCHER" />
35+
</intent-filter>
36+
</activity>
37+
</application>
38+
39+
</manifest>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright 2021 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.example.wear.snippets
18+
19+
import android.os.Bundle
20+
import androidx.activity.ComponentActivity
21+
import androidx.activity.compose.setContent
22+
import androidx.compose.runtime.Composable
23+
import com.example.wear.snippets.voiceinput.VoiceInputScreen
24+
import com.google.android.horologist.annotations.ExperimentalHorologistApi
25+
26+
class MainActivity : ComponentActivity() {
27+
override fun onCreate(savedInstanceState: Bundle?) {
28+
29+
super.onCreate(savedInstanceState)
30+
31+
setTheme(android.R.style.Theme_DeviceDefault)
32+
33+
setContent {
34+
WearApp()
35+
}
36+
}
37+
}
38+
39+
@OptIn(ExperimentalHorologistApi::class)
40+
@Composable
41+
fun WearApp() {
42+
VoiceInputScreen()
43+
}

0 commit comments

Comments
 (0)