diff --git a/WearWidget/app/src/main/java/com/google/example/wear_widget/WeatherActivity.kt b/WearWidget/app/src/main/java/com/google/example/wear_widget/WeatherActivity.kt index 227319995..9f6878e23 100644 --- a/WearWidget/app/src/main/java/com/google/example/wear_widget/WeatherActivity.kt +++ b/WearWidget/app/src/main/java/com/google/example/wear_widget/WeatherActivity.kt @@ -15,7 +15,6 @@ */ package com.google.example.wear_widget -import android.annotation.SuppressLint import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent @@ -30,7 +29,6 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp -import androidx.glance.wear.GlanceWearWidgetManager import androidx.wear.compose.foundation.lazy.TransformingLazyColumn import androidx.wear.compose.foundation.lazy.rememberTransformingLazyColumnState import androidx.wear.compose.material3.Button @@ -41,8 +39,6 @@ import androidx.wear.compose.material3.Text import kotlinx.coroutines.launch class WeatherActivity : ComponentActivity() { - // Suppressed because triggerUpdate is restricted to LIBRARY_GROUP. - @SuppressLint("RestrictedApi") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { @@ -56,12 +52,7 @@ class WeatherActivity : ComponentActivity() { onUpdate = { temp, cond -> scope.launch { setWeatherState(WeatherState(temp, cond)) - val manager = GlanceWearWidgetManager(this@WeatherActivity) - val widget = WeatherWidget() - val activeWidgets = manager.fetchActiveWidgets(widget::class) - activeWidgets.forEach { handle -> - widget.triggerUpdate(this@WeatherActivity, handle.instanceId) - } + WeatherWidget().triggerUpdateAll(this@WeatherActivity) } }, ) diff --git a/WearWidget/app/src/main/java/com/google/example/wear_widget/WeatherUpdateReceiver.kt b/WearWidget/app/src/main/java/com/google/example/wear_widget/WeatherUpdateReceiver.kt index 83fa38d95..48835c46a 100644 --- a/WearWidget/app/src/main/java/com/google/example/wear_widget/WeatherUpdateReceiver.kt +++ b/WearWidget/app/src/main/java/com/google/example/wear_widget/WeatherUpdateReceiver.kt @@ -15,12 +15,10 @@ */ package com.google.example.wear_widget -import android.annotation.SuppressLint import android.content.BroadcastReceiver import android.content.Context import android.content.Intent import android.util.Log -import androidx.glance.wear.GlanceWearWidgetManager import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.SupervisorJob @@ -37,8 +35,6 @@ class WeatherUpdateReceiver : BroadcastReceiver() { private val scope = CoroutineScope(Dispatchers.IO + SupervisorJob()) } - // Suppressed because triggerUpdate is restricted to LIBRARY_GROUP. - @SuppressLint("RestrictedApi") override fun onReceive(context: Context, intent: Intent) { if (intent.action == ACTION_UPDATE_WEATHER) { val temp = intent.getIntExtra(EXTRA_TEMP, 72) @@ -53,12 +49,7 @@ class WeatherUpdateReceiver : BroadcastReceiver() { context.setWeatherState( WeatherState(temp, WeatherCondition.fromEmoji(condition)) ) - val manager = GlanceWearWidgetManager(context) - val widget = WeatherWidget() - val activeWidgets = manager.fetchActiveWidgets(widget::class) - activeWidgets.forEach { handle -> - widget.triggerUpdate(context.applicationContext, handle.instanceId) - } + WeatherWidget().triggerUpdateAll(context) Log.d("WeatherReceiver", "Pushed weather update: $temp, $condition") } catch (e: Exception) { Log.e("WeatherReceiver", "Error updating weather", e) diff --git a/WearWidget/gradle/libs.versions.toml b/WearWidget/gradle/libs.versions.toml index a8b8b5736..5c86aec53 100644 --- a/WearWidget/gradle/libs.versions.toml +++ b/WearWidget/gradle/libs.versions.toml @@ -4,17 +4,17 @@ desugar_jdk_libs = "2.1.5" playServicesWearable = "20.0.1" kotlin = "2.3.21" composeBom = "2026.05.00" -remoteMaterialAlpha = "1.0.0-alpha07" -remoteComposeAlpha = "1.0.0-alpha15" +remoteMaterialAlpha = "1.0.0-alpha12" +remoteComposeAlpha = "1.0.0-alpha20" runtime = "1.11.1" uiTooling = "1.11.1" -wear = "1.0.0-alpha14" -wearCore = "1.0.0-alpha14" +wear = "1.0.0-alpha19" +wearCore = "1.0.0-alpha19" wearToolingPreview = "1.0.0" -composeMaterial = "1.6.1" +composeMaterial = "1.7.0" activityCompose = "1.13.0" datastore = "1.2.1" -tiles = "1.6.0" +tiles = "1.6.2" robolectric = "4.17-SNAPSHOT" roborazzi = "1.60.0" junit = "4.13.2"