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
17 changes: 12 additions & 5 deletions WearOS/Wearable/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,15 @@ android {
sarifOutput = layout.buildDirectory.file("reports/lint-results-debug.sarif").get().asFile
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

kotlin {
jvmToolchain(21)
compilerOptions {
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17)
}
}
}

Expand Down Expand Up @@ -90,11 +97,11 @@ dependencies {
// compileOnly("com.google.android.wearable:wearable:2.9.0")
// implementation("com.google.android.support:wearable:2.9.0")
// implementation("com.google.android.gms:play-services-maps:20.0.0")
// implementation("androidx.wear:wear:1.3.0")
// androidTestImplementation("androidx.test.ext:junit:1.1.5")
// androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
// implementation("androidx.wear:wear:1.4.0")
// androidTestImplementation("androidx.test.ext:junit:1.3.0")
// androidTestImplementation("androidx.test.espresso:espresso-core:3.7.0")
// androidTestImplementation("androidx.test.uiautomator:uiautomator:2.3.0")
// androidTestImplementation("com.google.truth:truth:1.4.2")
// androidTestImplementation("com.google.truth:truth:1.4.5")
// androidTestImplementation("junit:junit:4.13.2")
}
// [END maps_wear_os_dependencies]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015 Google Inc. All Rights Reserved.
* Copyright 2026 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -48,8 +48,12 @@ public void onCreate(Bundle savedState) {
// Enable ambient support, so the map remains visible in simplified, low-color display
// when the user is no longer actively using the app but the app is still visible on the
// watch face.
AmbientModeSupport.AmbientController controller = AmbientModeSupport.attach(this);
Log.d(AmbientActivity.class.getSimpleName(), "Is ambient enabled: " + controller.isAmbient());
try {
AmbientModeSupport.AmbientController controller = AmbientModeSupport.attach(this);
Log.d(AmbientActivity.class.getSimpleName(), "Is ambient enabled: " + controller.isAmbient());
} catch (Exception e) {
Log.w(AmbientActivity.class.getSimpleName(), "Ambient mode unavailable on this device: " + e.getMessage());
}

// Obtain the MapFragment and set the async listener to be notified when the map is ready.
mapFragment = (SupportMapFragment) getSupportFragmentManager()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015 Google Inc. All Rights Reserved.
* Copyright 2026 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -54,9 +54,13 @@ public void onCreate(Bundle savedState) {
// when the user is no longer actively using the app but the app is still visible on the
// watch face.
// [START maps_wear_os_ambient_mode_support]
AmbientModeSupport.AmbientController controller = AmbientModeSupport.attach(this);
try {
AmbientModeSupport.AmbientController controller = AmbientModeSupport.attach(this);
Log.d(MainActivity.class.getSimpleName(), "Is ambient enabled: " + controller.isAmbient());
} catch (Exception e) {
Log.w(MainActivity.class.getSimpleName(), "Ambient mode unavailable on this device: " + e.getMessage());
}
// [END maps_wear_os_ambient_mode_support]
Log.d(MainActivity.class.getSimpleName(), "Is ambient enabled: " + controller.isAmbient());

// Retrieve the containers for the root of the layout and the map. Margins will need to be
// set on them to account for the system window insets.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015 Google Inc. All Rights Reserved.
* Copyright 2026 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -39,8 +39,12 @@ class AmbientActivity : AppCompatActivity(), AmbientModeSupport.AmbientCallbackP
// Enable ambient support, so the map remains visible in simplified, low-color display
// when the user is no longer actively using the app but the app is still visible on the
// watch face.
val controller = AmbientModeSupport.attach(this)
Log.d(AmbientActivity::class.java.simpleName, "Is ambient enabled: " + controller.isAmbient)
try {
val controller = AmbientModeSupport.attach(this)
Log.d(AmbientActivity::class.java.simpleName, "Is ambient enabled: " + controller.isAmbient)
} catch (e: Exception) {
Log.w(AmbientActivity::class.java.simpleName, "Ambient mode unavailable on this device: ${e.message}")
}

// Obtain the MapFragment and set the async listener to be notified when the map is ready.
mapFragment = supportFragmentManager
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015 Google Inc. All Rights Reserved.
* Copyright 2026 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -49,9 +49,13 @@ class MainActivity : AppCompatActivity(), OnMapReadyCallback,
// when the user is no longer actively using the app but the app is still visible on the
// watch face.
// [START maps_wear_os_ambient_mode_support]
val controller = AmbientModeSupport.attach(this)
try {
val controller = AmbientModeSupport.attach(this)
Log.d(MainActivity::class.java.simpleName, "Is ambient enabled: " + controller.isAmbient)
} catch (e: Exception) {
Log.w(MainActivity::class.java.simpleName, "Ambient mode unavailable on this device: ${e.message}")
}
// [END maps_wear_os_ambient_mode_support]
Log.d(MainActivity::class.java.simpleName, "Is ambient enabled: " + controller.isAmbient)

// Retrieve the containers for the root of the layout and the map. Margins will need to be
// set on them to account for the system window insets.
Expand Down