android / wear-os-samples

Multiple samples showing best practices in app and watch face development on Wear OS.
https://developer.android.com/wear
Apache License 2.0
1.12k stars 573 forks source link

Update to more modern approach #32

Closed IgorGanapolsky closed 2 years ago

IgorGanapolsky commented 4 years ago

Hello, thank you so much for these samples. I am learning how to build Android Wear apps thanks to these. However, can you please update your code to Kotlin and use Coroutines + Architecture Components instead of Handlers and Alarms? All these samples seem extremely outdated practices compared to IoSched and Sunflower samples which Google advocates.

Igor

codingjeremy commented 4 years ago

Thanks for the suggestion.

I'll remaking some of these in Kotlin over the rest of the year, and I will update these when they are ready.

LouisCAD commented 4 years ago

Great news @codingjeremy!

If that can fit in your priorities, it'd be nice to have at least one sample using Jetpack Compose (that might imply making a new Jetpack Compose based UI library for wearables/WearOS/watches/small-screens-scope/whatever).

Another thing that would be great is coroutines and/or Flow based communication between the associated device and the watch, with retry strategy when connection is unstable/cut.

IgorGanapolsky commented 4 years ago

@codingjeremy Could we create a sample of a Timer App? We could utilize JetPack Compose, like @LouisCAD suggested. The reason I like Timer Apps is because they showcase animations (countdown circular progress or linear progress), and RecyclerViews (having a list of timers, deleting or adding a new timer to the list). Furthermore, we can showcase Jetpack DataStore to persist the timers in memory.

codingjeremy commented 3 years ago

@LouisCAD - I'm adding in some coroutine stuff to the watch faces now (already rewritten Analog + settings stuff in Kotlin), so yes, anywhere I can add coroutines and/or Flow where it makes sense I definitely will. :)

As for Compose, we will work on some samples for a Wear sample soon. Compose is definitely something the Wear team is interested in.

@IgorGanapolsky - We have some ideas for a full Wear sample app to produce. I will definitely pass the Timer idea along to them. Thanks for the suggestion!

LouisCAD commented 3 years ago

@codingjeremy I'm so happy to see WearOS getting MAD (Modern Android Development) love!

BTW, I've been wondering if Jetpack Compose could be used to make efficient Watch Faces… currently, I think you need a View/ViewGroup, but I guess there's a way to draw against a plain Canvas as is required by Wallpaper and Watch Face services?

Some animations and art the community has already been doing with Compose could look really good on some wrists and might eventually raise the appeal of smartwatches along with more ease to get started making modern WearOS companion or standalone apps!

IgorGanapolsky commented 3 years ago

I converted this library to Kotlin: https://jitpack.io/#IgorGanapolsky/SeekArc. It provides something like this animation for timers. Perhaps it can be utilized. arc_sweeps

codingjeremy commented 3 years ago

@LouisCAD - I'm working on integrating the kotlin watch face with some new stuff but I will pass that along and follow up here. We are working on making watch face dev easier.

@IgorGanapolsky Thanks for send that to me! I will pass it along.

alexvanyo commented 2 years ago

Almost all of the samples have now been updated to use Kotlin, coroutines/flow, and for some Compose as well! (I will close this issue as some of the final PRs get merged in)

If you haven't taken a look already, hopefully the updated samples are useful!