Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 {
Expand All @@ -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)
}
},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions WearWidget/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading