@@ -71,25 +71,23 @@ import java.io.ObjectOutputStream
7171
7272/* * TODO:
7373 * Show spinner when no data available / loading from app
74- * Refresh UI when data updates
7574 * Move actions / triggers / gear to their own page with horizontal swipe
7675 * show all actions, not just favorites
7776 * Theme based on main app colors
78- * Watch to App communication
7977 */
8078class MainActivity : ComponentActivity (), DataClient.OnDataChangedListener,
8179 CapabilityClient .OnCapabilityChangedListener {
8280 private var wearData: MutableLiveData <WearData > = MutableLiveData <WearData >(WearData ())
8381
8482 override fun onResume () {
8583 super .onResume()
86- println (" onResume()" )
84+ // println("onResume()")
8785 Wearable .getDataClient(this ).addListener(this )
8886 }
8987
9088 override fun onPause () {
9189 super .onPause()
92- println (" onPause()" )
90+ // println("onPause()")
9391 Wearable .getDataClient(this ).removeListener(this )
9492 }
9593
@@ -127,9 +125,9 @@ class MainActivity : ComponentActivity(), DataClient.OnDataChangedListener,
127125 }
128126
129127 override fun onDataChanged (dataEvents : DataEventBuffer ) {
130- println (" onDataChanged()" )
128+ // println("onDataChanged()")
131129 dataEvents.forEach { event ->
132- println (" onDataChanged() ${event.type} " )
130+ // println("onDataChanged() ${event.type}")
133131 // DataItem changed
134132 if (event.type == DataEvent .TYPE_CHANGED ) {
135133 event.dataItem.also { item ->
@@ -141,7 +139,7 @@ class MainActivity : ComponentActivity(), DataClient.OnDataChangedListener,
141139
142140 private fun getWearDataItem (item : DataItem ) {
143141 try {
144- println (" Loading Actions" )
142+ // println("Loading Actions")
145143 val gson = Gson ()
146144 // asMap converts the bytes to the java object
147145 // The flutter library watch_connectivity was built for flutter to flutter, not flutter to compose
@@ -170,6 +168,7 @@ class MainActivity : ComponentActivity(), DataClient.OnDataChangedListener,
170168 val capabilityId = // Find a nearby node or pick one arbitrarily.
171169 result.nodes.firstOrNull { it.isNearby }?.id
172170 ? : result.nodes.firstOrNull()?.id
171+ // println("Capability ID: ${capabilityId}")
173172 if (capabilityId == null ) {
174173 return @addOnSuccessListener
175174 }
@@ -189,7 +188,7 @@ class MainActivity : ComponentActivity(), DataClient.OnDataChangedListener,
189188
190189
191190 override fun onCreate (savedInstanceState : Bundle ? ) {
192- println (" onCreate()" )
191+ // println("onCreate()")
193192 installSplashScreen()
194193
195194 super .onCreate(savedInstanceState)
@@ -204,7 +203,7 @@ class MainActivity : ComponentActivity(), DataClient.OnDataChangedListener,
204203 // TODO: When app is visible, send a message to update application context
205204 @Composable
206205 fun WearApp () {
207- println (" WearApp()" )
206+ // println("WearApp()")
208207 val context = LocalContext .current
209208 val state: State <WearData ?> = wearData.observeAsState()
210209
@@ -370,7 +369,7 @@ class MainActivity : ComponentActivity(), DataClient.OnDataChangedListener,
370369 GearButton (
371370 contentModifier,
372371 it.name,
373- it.batteryLevel.toInt() ,
372+ it.batteryLevel,
374373 it.color
375374 )
376375 }
@@ -464,7 +463,7 @@ class MainActivity : ComponentActivity(), DataClient.OnDataChangedListener,
464463 }
465464
466465 override fun onCapabilityChanged (p0 : CapabilityInfo ) {
467- println (" onCapabilityChanged() ${p0.name} ${p0.nodes} " )
466+ // println("onCapabilityChanged() ${p0.name} ${p0.nodes}")
468467 sendMessageToPhone(
469468 data = WearSendData (
470469 capability = " refresh" ,
0 commit comments