Posted by Alicja Heisig, Developer Relations Program Manager
Welcome to #IamaGDE - a series of spotlights presenting Google Developer Experts (GDEs) from across the globe. Discover their stories, passions, and highlights of their community work.
Gaston Saillen started coding for fun, making apps for his friends. About seven years ago, he began working full-time as an Android developer for startups. He built a bunch of apps—and then someone gave him an idea for an app that has had a broad social impact in his local community. Now, he is a senior Android developer at Distillery.
After seven years of building apps for startups, Gaston visited a local food delivery truck to pick up dinner, and the server asked him, “Why don’t you do a food delivery app for the town, since you are an Android developer? We don’t have any food delivery apps here, but in the big city, there are tons of them.”
The food truck proprietor added that he was new in town and needed a tool to boost his sales. Gaston was up for the challenge and created a straightforward delivery app for local Cordoba restaurants he named Uh-Lala! Restaurants configure the app themselves, and there’s no app fee. “My plan was to deliver this service to this community and start making some progress on the technology that they use for delivery,” says Gaston. “And after that, a lot of other food delivery services started using the app.”
The base app is built similarly to food delivery apps for bigger companies. Gaston built it for Cordoba restaurants first, after several months of development, and it’s still the only food delivery app in town. When he released the app, it immediately got traction, with people placing orders. His friends joined, and the app expanded. “I’ve made a lot of apps as an Android engineer, but this is the first time I’ve made one that had such an impact on my community.”
He had to figure out how to deliver real-time notifications that food was ready for delivery. “That was a little tough at first, but then I got to know more about all the backend functions and everything, and that opened up a lot of new features.”
He also had to educate two groups of users: Restaurant owners need to know how to input their data into the app, and customers had to change their habit of using their phones for calls instead of apps.
Gaston says seeing people using the app is rewarding because he feels like he’s helping his community. “All of a sudden, nearby towns started using Uh-LaLa!, and I didn't expect it to grow that big, and it helped those communities.”
During the COVID-19 pandemic, many restaurants struggled to maintain their sales numbers. A local pub owner ran a promotion through Instagram to use the Uh-Lala! App for ten percent off, and their sales returned to pre-COVID levels. “That is a success story. They were really happy about the app.”
Gaston has been a GDE for seven years. When he was working on his last startup, he found himself regularly answering questions about Android development and Firebase on StackOverflow and creating developer content in the form of blog posts and YouTube videos. When he learned about the GDE program, it seemed like a perfect way to continue to contribute his Android development knowledge to an even broader developer community. Once he was selected, he continued writing blog posts and making videos—and now, they reach a broader audience.
“I created a course on Udemy that I keep updated, and I’m still writing the blog posts,” he says. “We also started the GDG here in Cordoba, and we try to have a new talk every month.”
Gaston enjoys the GDE community and sharing his ideas about Firebase and Android with other developers. He and several fellow Firebase developers started a WhatsApp group to chat about Firebase. “I enjoy being a Google Developer Expert because I can meet members of the community that do the same things that I do. It’s a really nice way to keep improving my skills and meet other people who also contribute and make videos and blogs about what I love: Android.”
The Android platform provides developers with state-of-the art tools to build apps for user. Firebase allows developers to accelerate and scale app development without managing infrastructure; release apps and monitor their performance and stability; and boost engagement with analytics, A/B testing, and messaging campaigns.
Gaston looks forward to developing Uh-La-La further and building more apps, like a coworking space reservation app that would show users the hours and locations of nearby coworking spaces and allow them to reserve a space at a certain time. He is also busy as an Android developer with Distillery.
“Keep moving forward. Any adversity that you will be having in your career will be part of your learning, so the more that you find problems and solve them, the more that you will learn and progress in your career.”
Learn more about the Experts Program → developers.google.com/community/experts
Watch more on YouTube → https://goo.gle/GDE
Follow us on Twitter and LinkedIn
Posted by Murat Yener, Android Developer Advocate
That’s a wrap! We’ve just finished a new MAD skills series on Gradle and Android Gradle plugin build APIs. In this series we shifted gears and took a look at how you can extend your build by using Gradle and brand new Android Gradle plugin APIs.
We covered how Gradle works, how you can configure the Android Gradle plugin, and learned which APIs to use to help customize your builds and keep your builds fast and efficient. If you missed this series or some of the episodes, here is a quick recap of what to expect.
Gradle is a general purpose build tool which can build specific project types by using plugins. Plugins introduce a way to configure the build and decide which tasks are needed to build that project. Gradle configures and executes these tasks in different phases. Understanding how the build phases work and how to configure the Android Gradle plugin can help you customize your build according to your project’s needs and keep build times efficient.
You can check out the following video or if you prefer, read the article.
Extending your build by writing your own plugin gives you a way to customize your build even further! Starting with version 7.0, Android Gradle Plugin now offers stable extension points for manipulating variant configuration and the produced build artifacts. In this episode we started with writing a custom task and used the new Variant API to initialize and modify properties of Variants.
You can find the same content in article form.
As we saw in previous episodes, keeping your config phase fast and resolving values lazily can help keep your builds efficient. Providers and Properties let you pass inputs and receive outputs from Gradle tasks lazily. In this episode we also take a look at the new Artifacts API to access and modify the app manifest.
Check out the article or the following video.
In the last episode in the series, we feature Alex Saveau, who maintains the Gradle Play Publisher and Version Orchestrator plugins. Alex shares a tip on using modern AGP and Gradle APIs to manipulate Android build artifacts.
To learn more, check out the following video.
Finally, we wrapped up this series with a live Q&A session where we answered your questions. If you missed the Q&A, make sure to check out the following recording.
If you are interested to learn more, make sure to check out the resources and the Gradle recipes repo linked below! See you in the next MAD Skills series.
Recipes repo: https://github.com/android/gradle-recipes
Extend the Android Gradle plugin: https://developer.android.com/studio/build/extend-agp
AGP Roadmap: https://goo.gle/3EuNYXz
Posted by Marcel PintĂł Biescas, Developer Relations Engineer, @marxallski
Android 12 revamps a key feature for many Android users, App Widgets, making them more useful, beautiful, and discoverable (84% use at least 1 widget). Today, we’re making it even easier to build them by releasing the first alpha of Jetpack Glance, a new framework built on top of the Jetpack Compose runtime designed to make it faster and easier to build app widgets for the home screen and other surfaces.
We’d love you to give it a try and share your feedback!
Glance offers similar modern, declarative Kotlin APIs that you are used to with Jetpack Compose, helping you build beautiful, responsive app widgets with way less code.
Glance “Hello World” widget sample
class GreetingsWidget(private val name: String): GlanceAppWidget() { @Composable override fun Content() { Text(text = "Hello $name") } } class GreetingsWidgetReceiver : GlanceAppWidgetReceiver() { override val glanceAppWidget = GreetingsWidget("Glance") }
Glance provides a base-set of Composables to help build “glanceable” experiences. Starting today with app widget components but with more coming. Using the Jetpack Compose runtime, Glance can translate Composables into actual RemoteViews, and display them in an app widget.
Diagram: Glance structure
This means that Glance requires Compose to be enabled and depends on Runtime, Graphics, and Unit UI Compose layers, but it’s not directly interoperable with other existing Jetpack Compose UI elements. However, state or any other logic within your app can be shared to create a glanceable UI.
This initial release introduces the main APIs to enable you to build app widgets in addition to providing interoperability with existing RemoteViews.
Here’s an overview of what the library offers, at a glance:
GlanceAppWidget
GlanceAppWidgetReceiver
Box
Row
Column
Text
Button
LazyColumn
Image
Spacer
GlanceModifier
Action
actionStartActivity
actionRunCallback
actionStartService
actionStartBroadcastReceiver
ActionParameters
SizeMode.Single
SizeMode.Exact
SizeMode.Responsive
GlanceAppWidget state
GlanceStateDefinition
LocalContext
LocalState
LocalGlanceId
LocalSize
RemoteViews
AndroidRemoteViews
We are working on bringing even more functionality with default theming, further Android Studio support, and more. Stay tuned for new releases.
Note: while the minSDK is 21, we are currently only supporting compatibility till SDK v23.
Check out the sample on GitHub for a quick start. Glance works with the latest stable Android Studio, although since Glance relies on Compose Runtime, follow the steps on the Jetpack Compose docs to set it up first.
In addition, for a more advanced showcase, checkout the demos in the AndroidX repository.
ResponsiveAppWidget.kt demo
The Alpha version is your opportunity to influence the APIs, so please share your feedback and let us know your experience!
Happy Composing with Glance!
Posted by Manuel Vicente Vivo, Developer Relations Engineer, @manuelvicnt
As Android apps grow in size, it's important to design the code with an architecture in place to allow the app to scale, improve quality and robustness, and make it easier to test.
An app architecture defines the boundaries between parts of the app and the responsibilities each part should have. This favors the separation of concerns principle that enables the aforementioned benefits.
In response to community demand for up-to-date guidance on app architecture, we're launching a revamped guide to app architecture. This includes best practices and recommended architecture for building robust, high-quality apps. It also provides a page for each layer of the recommended architecture: UI, domain, and data layers. Within them, you'll find deep dives into more complex topics, such as how to handle UI events.
Each Android app should have at least two layers:
You can add an additional layer called the domain layer to simplify and reuse the interactions between the UI and data layers.
General diagram of a typical app architecture. The UI layer gets the application data from the optional domain layer, or the data layer, that exposes application data.
We have created a learning pathway to help you consume this content in order and in a trackable way. Don't miss the chance to learn all of this and get a badge as recognition!
If you’re a beginner, you should begin by understanding the benefits of having an app architecture and then follow these recommendations as a first approach to the topic. Intermediate and advanced developers can follow these recommendations and customize them to their needs. In fact, our research suggests that most professional developers are already using these best practices.
You might be wondering if you should update your existing architecture to follow this recommendation, and the answer is no… or wait… it's up to you. If your current architecture works for your team, you might want to stick with it. But you might also find patterns in our guides you can benefit from and incorporate into your app.
This is the first batch of documents we're releasing, with more to come in 2022. Help us make the guidance better! If you have any feedback on the current recommendations or if you want to see other architecture-related topics in them, let us know in our docs issue tracker.
Posted by Purnima Kochikar, Vice President, Google Play Partnerships
Hello there,
Today we are kicking off Notes from Google Play, a new series where several times a year we celebrate your creativity and impact, and share key insights and best practices, to inspire you to be bolder, go further, and build even more innovative apps and games.
Purnima Kochikar addresses our goals behind the 'Notes from Google Play' series.
2021 continued to be a year of challenges and uncertainty, and you inspired us by your ability to turn obstacles into useful and joyful apps and services. Your apps helped over 2.5 billion people using Android devices learn, connect, relax, exercise, laugh, have fun, and so much more. As a result, developers making over 1M USD per month with Google Play’s billing or having 10 million monthly active users grew by 30% this year.
In this inaugural edition of Notes from Google Play we celebrate your creativity and resilience. A developer who exemplified these traits and deeply moved and inspired me and my team is Mohammed Kamara. Thank you, Mo for channeling deep personal loss to create a better world for women of color, providing affordable and customized healthcare through the app. We are humbled to play a small part in making your vision for InovCares a reality.
Mohamed Kamara, CEO and Founder of InovCares, tells the story behind his groundbreaking healthcare app.
A special shout out also goes to the winners of the Best of Google Play Awards and the Indie Games Festival. All of you inspire us to continue to work hard to evolve Play and Android to enable you to build great apps and successful businesses.
This focus on you and your success resulted in many impactful developments in 2021, including the evolution of our business model and new product features and tools. At Google Play we are focused on two key goals - helping you build and grow sustainable global businesses and investing in Android and Play platform features, tools, and ecosystems to enable you to build innovative apps and games.
As the mobile industry has matured, you have created app businesses that have varying needs, so we’ve designed multiple programs to support you. For example, we created the Play Media Experience Program to encourage Video, Audio, and Books developers to build great cross-device experiences, while enabling apps that support authors & musicians by discounting the service fee as low as 10%. A few months ago we announced a new fee structure to support the evolution of the subscriptions business model, allowing all subscription app developers to benefit from lower fees. Due to the innovative changes we announced this year, I’m thrilled to share that 99% of developers globally now qualify for a service fee of 15% or less. Thank you for your thoughtful feedback while we were designing these programs and your vocal support since the launch of the new fee structure.
We have also continued to invest in programs to help you reach, retain, and re-engage your users.
We are committed to empowering you to turn your creative ideas into excellent apps and have created tools and guidelines to help ensure your apps are of high quality. I invite you to pay attention to three key features/guidelines:
Trust and safety are the cornerstones of sustainable business success and key to user loyalty. This year, we continued to invest in platform features and policies that help you build safer apps and strengthen user trust. We also heard your feedback and have invested in educational tools and resources to help you anticipate and understand the new features and policies. The key highlights this year -
Nothing excites me more than finding and nurturing the next generation of talented developers and building local ecosystems around the world that address local needs. Earlier this year we announced a reduced service fee tier of 15% on the first $1M in annual earnings for all developers, helping us continue to foster innovation on Android/Play.
It has been truly humbling to see key influencers, stakeholders, and industry and government leaders co-invest with us in this effort. Our most successful developers invested personal time and energy to mentor, coach, and grow Indies through the Indie Games Accelerator. Government leaders partnered with us to support startup ecosystems in countries like Korea and India - the ChangGoo program in Korea has been created in partnership with Ministry of SMEs and Startups (MSS) and the Korea Institute of Startup & Entrepreneurship Development (KISED), whereas the Appscale Academy in India was established in partnership with the MeitY Startup Hub, an initiative of the Ministry of Electronics and Information Technology (MeitY). Thank you all for your commitment to innovation and the app ecosystem.
Get a snapshot view of Appscale Academy: our growth and development program for startups across India.
I have missed seeing you in person over the last two years. The challenges imposed by COVID-19 helped us find new ways to stay connected. Many of you participated in virtual sessions to learn about new market opportunities and engaged in thoughtful online discussions on topics as diverse as Future of Work, Diversity, Equity, and Inclusion, and Growth and Global expansion strategies. Some of you also told us that you are feeling some online event fatigue, so this year we also invested in content that you can consume at your own pace including thought leadership and best practices, and e-learning courses on Play Academy. We even launched our first certificate to help you get the most out of our store listing tools and features.
Until the next edition, from my team to yours, best wishes for the upcoming year. We hope you will always see Google Play as a partner to help you delight your users, expand your audience, and grow your business.
Happy Holidays.
Purnima Kochikar,
Vice President, Google Play Partnerships
Make sure you don’t miss future editions by following me / us on Twitter or signing up to our monthly newsletter.
Posted by Maru Ahues Bouza, Director, Android Developer Relations
Apps are essential to making Android a platform people love - whether it’s on their phones, cars, TVs, or watches. As a popular mobile platform, Android is thriving with 1 in 4 developers - worldwide - building for Android according to Stack Overflow’s 2020 developer survey.
In Android Developer Relations (or Android DevRel for short), our mission is to help developers be successful on Android by helping them build great apps with the latest Android and Play features, empower anyone to get a great career as an Android developer, and advocate for developers as Android and Play evolve. It’s truly rewarding because we get to see the future of apps - every day - and help our fellow developers achieve great things. With such a big mission, we’re hiring engineers, technical writers, and program managers - and if this gets you inspired, we’d love to talk! Check out the links at the end of this blog and apply to join our team.
But first, what does Android DevRel actually do? Our team works with external developers, writes code, creates content, launches careers, grows communities, runs conferences - and more. Read on to learn more!
We work with product and engineering teams in Android and Play to define go-to-market strategies for new developer products and run Early Access Programs (EAPs) with the goal of building better products for all developers. Through these EAPs, we do deep technical engineering work with the most influential developers to help them integrate and deliver feedback to validate that the products we’re building are ready to work at scale.
We work with these developers to build high quality apps across multiple screens, to ensure better user experiences on Android and we share their success stories to show how integrating with these products will help developers be more successful in the Android ecosystem, and to help inspire other developers to adopt.
A big part of how we help developers is through code — be it tutorials, videos, blogs, or entire multi-unit educational courses. We produce everything from simple code snippets that explain how to perform a specific function, to sample apps like Jet* or the Google I/O app that demonstrates how everything comes together. In the process of creating sample code, you may be the first developer to ever build something with a new API! We call this being the “zeroth customer” and it’s an important role where you can directly influence the direction of a product through feedback (and yes, some trial and error!)
In helping developers, we end up learning best practices and producing a ton of content - documentation, tutorials, screencasts, talks, blog posts, podcasts, and more. There is an art to breaking down complex subjects into a learning path - to help both beginner and advanced developers alike - and it is something we do every day. From introducing new concepts, to distilling best practices, to thoroughly documenting the functionality of a new API - our role is to help developers understand and thrive on Android. While our output is the content itself, it’s important to note that engineering is at the heart of this. In order to teach developers how to use these technologies, we first have to understand them deeply ourselves.
Teach millions of developers through learning materials
Many of us were Android developers before we joined DevRel, and one of the most gratifying aspects of our role is meeting and connecting with developers around the world. We engage with Google Developer Experts for Android (GDEs), Google Developer Groups, and of course individual community members on a regular basis through events, social media, and Slack. We love to hear what people are working on, lend a hand where we can, and create connections across the community so people can learn from each other.
One of the places the community comes together is at conferences - and Android has a lot of them! While you can pick up a skill or learn about the latest software design pattern, people always say the most valuable thing they get from conferences is connecting with fellow developers. Meeting people in person (side note: can’t wait until we can do that again!) is such an important part of building a network of people you can count on for help - whether you get stuck in your next project, or are looking for career advice. While many of these conferences are run by the community themselves, we participate in these events around the world and look forward to engaging with this community wherever they are. We also organize the Android Developer Summit and the Android track at Google I/O.
Apps connect you to the people in your life, help you do things more easily, or even help you learn new skills. In the past year many of us have had to find new ways of doing things, and this has seen us reach for apps more often than ever before, while growing the demand for app developers. In fact, developer jobs are growing 5.5x faster than other professions (U.S. Bureau of Labor Statistics). In Android DevRel, it is our privilege to build curriculum and work with universities and student groups around the world to skill-up the next generation of developers.
Training the next generation of Android developers
Want to join Android DevRel? Take a look at some of the roles below. Google often uses a single listing to make it easier for people to apply - so if it doesn’t say Android DevRel in the title of the role just tell them you’re interested in joining our team in your cover letter.
Android DevRel works with developers everywhere in the world, we want our team to represent all the developers we work with and we believe that diverse teams build better products that work for everyone. If you’re from an underrepresented group in tech, please apply even if you don’t think you match all the requirements and read what we’re doing to build a more diverse and inclusive Google.
Read on to see the roles that are available today:
At Android Dev Summit in October we highlighted the growth we’re seeing in large screen devices like tablets, foldables, and Chromebooks. We talked about how we’re making it easier to build great app experiences for these devices through new Jetpack APIs, tools, and guidance. We also introduced a developer preview of 12L, a feature drop for Android 12 that’s purpose-built for large screens.
With 12L, we’ve optimized and polished the system UI for large screens, made multitasking more powerful and intuitive, and improved compatibility support so apps look better right out of the box. 12L also includes a handful of new APIs for developers, such as for spatial audio and improved drag-and-drop for accessibility.
Today we’re releasing the first Beta of 12L for your testing and feedback as you get your apps ready for the feature drop coming early next year. You can try the new large screens features by setting up an Android emulator in Android Studio. 12L is for phones, too, and you can now enroll here to get 12L Beta 1 on supported Pixel devices. If you are still enrolled in the Android 12 Beta program, you’ll get the 12L update automatically. Through a partnership with Lenovo, you can also try 12L on the Lenovo Tab P12 Pro tablet, see the Lenovo site for details on available builds and support.
Today’s Beta 1 build includes improvements to functionality and user experience as well as the latest bug fixes, optimizations, and the December 2021 security patches. For developers, we’ve finalized the APIs early, so Beta 1 also includes the official 12L APIs (API level 32), updated build tools, and system images for testing. These give you everything you need to test your apps with the 12L features.
With 12L, we’ve focused on refining the UI on large screen devices, across notifications, quick settings, lockscreen, overview, home screen, and more. For example, on screens above 600dp, the notification shade, lockscreen, and other system surfaces use a new two-column layout to take advantage of the screen area.
Two-column layouts show more and are easier to use
Multitasking is also more powerful and intuitive - 12L includes a new taskbar on large screens that lets users instantly switch to favorite apps on the fly or drag-and-drop apps into split-screen mode. Remember, on Android 12 and later, users can launch any app into split screen mode, regardless whether the app is resizable. Make sure to test your apps in split screen mode!
Drag and drop apps into split-screen mode
Last, we’ve improved compatibility mode with visual and stability improvements to offer a better letterboxing experience for users and help apps look better by default. If your app is not yet optimized for large screens, make sure to test your app with the new letterboxing.
As you optimize your apps for large screens, here are some of our latest APIs and tools that can make it easier to build a great experience for users.
Make sure to check out all of our large screens developer resources for details on these and other APIs and tools.
With the 12L feature drop coming to devices early next year, now is a great time to optimize your apps for large screens. For developers, we highly recommend checking out how your apps work in split screen mode with windows of various sizes. If you haven’t optimized your app yet, see how it looks in different orientations and try the new compatibility mode changes if they apply.
The easiest way to get started with the large screen features is using the Android Emulator in a foldable or tablet configuration - see the complete setup instructions here.
Now you can also flash 12L onto a large screen device. Through a partnership with Lenovo, you can try 12L preview builds on the Lenovo Tab P12 Pro. Currently Lenovo is offering a Developer Preview 1 build, with updates coming in the weeks ahead. Visit Lenovo's 12L preview site for complete information on available builds and support.
12L is coming to phones, too, and although you won’t see the large screen features on smaller screens, we welcome you to try out the latest improvements in this feature drop. Just enroll your supported Pixel device here to get the latest 12L Beta update over-the-air. If you are still enrolled in the Android 12 Beta program, you’ll automatically receive the update 12L.
For details on 12L and the release timeline, visit the 12L developer site. You can report issues and requests here, and as always, we appreciate your feedback!
Posted by Alex Vanyo, Developer Relations Engineer
Watch faces are one of the most visible ways that people express themselves on their smartwatches, and they’re one of the best ways to display your brand to your users.
Watch Face Studio from Samsung is a great tool for creating watch faces without writing any code. For developers who want more fine-tuned control, we've recently launched the Jetpack Watch Face library written from the ground up in Kotlin.
The stable release of the Jetpack Watch Face library includes all functionality from the Wearable Support Library and many new features that make it easier to support customization on the smartwatch and on the system companion app on mobile, including:
If you are still using the Wearable Support Library, we strongly encourage migrating to the new Jetpack libraries to take advantage of the new APIs and upcoming features and bug fixes.
Below is an example of configuring a watch face from the phone with no code written on or for the phone.
Editing a watch face using the Galaxy Wearable mobile companion app
If you use the Jetpack Watch Face library to save your watch face configuration options, the values are synced with the mobile companion app. That is, all the cross-device communication is handled for you.
The mobile app will automatically present those options to the user in a simple, intuitive user interface where they change them to whatever works best for their style. It also includes previews that update in real time.
Let’s dive into the API with an overview of the most important components for creating a custom watch face!
A subclass of WatchFaceService forms the entry point of any Jetpack watch face. Implementing a WatchFaceService requires creating 3 objects: A UserStyleSchema, a ComplicationSlotsManager, and a WatchFace:
WatchFaceService
UserStyleSchema
ComplicationSlotsManager
WatchFace
Diagram showing the 3 main parts of a WatchFaceService
These 3 objects are specified by overriding 3 abstract methods from WatchFaceService:
class CustomWatchFaceService : WatchFaceService() { /** * The specification of settings the watch face supports. * This is similar to a database schema. */ override fun createUserStyleSchema(): UserStyleSchema = // ... /** * The complication slot configuration for the watchface. */ override fun createComplicationSlotsManager( currentUserStyleRepository: CurrentUserStyleRepository ): ComplicationSlotsManager = // ... /** * The watch face itself, which includes the renderer for drawing. */ override suspend fun createWatchFace( surfaceHolder: SurfaceHolder, watchState: WatchState, complicationSlotsManager: ComplicationSlotsManager, currentUserStyleRepository: CurrentUserStyleRepository ): WatchFace = // ... }
Let’s take a more detailed look at each one of these in turn, and some of the other classes that the library creates on your behalf.
The UserStyleSchema defines the primary information source for a Jetpack watch face. The UserStyleSchema should contain a list of all customization settings available to the user, as well as information about what those options do and what the default option is. These settings can be boolean flags, lists, ranges, and more.
By providing this schema, the library will automatically keep track of changes to settings by the user, either through the mobile companion app on a connected phone or via changes made on the smartwatch in a custom editor activity.
override fun createUserStyleSchema(): UserStyleSchema = UserStyleSchema( listOf( // Allows user to change the color styles of the watch face UserStyleSetting.ListUserStyleSetting( UserStyleSetting.Id(COLOR_STYLE_SETTING), // ... ), // Allows user to toggle on/off the hour pips (dashes around the outer edge of the watch UserStyleSetting.BooleanUserStyleSetting( UserStyleSetting.Id(DRAW_HOUR_PIPS_STYLE_SETTING), // ... ), // Allows user to change the length of the minute hand UserStyleSetting.DoubleRangeUserStyleSetting( UserStyleSetting.Id(WATCH_HAND_LENGTH_STYLE_SETTING), // ... ) ) )
The current user style can be observed via the CurrentUserStyleRepository, which is created by the library based on the UserStyleSchema.
CurrentUserStyleRepository
It gives you a UserStyle which is just a Map with keys based on the settings defined in the schema:
UserStyle
Map
Map<UserStyleSetting, UserStyleSetting.Option>
As the user’s preferences change, a MutableStateFlow of UserStyle will emit the latest selected options for all of the settings defined in the UserStyleSchema.
MutableStateFlow
currentUserStyleRepository.userStyle.collect { newUserStyle -> // Update configuration based on user style }
Complications allow a watch face to display additional information from other apps on the watch, such as events, health data, or the day.
The ComplicationSlotsManager defines how many complications a watch face supports, and where they are positioned on the screen. To support changing the location or number of complications, the ComplicationSlotsManager also uses the CurrentUserStyleRepository.
override fun createComplicationSlotsManager( currentUserStyleRepository: CurrentUserStyleRepository ): ComplicationSlotsManager { val defaultCanvasComplicationFactory = CanvasComplicationFactory { watchState, listener -> // ... } val leftComplicationSlot = ComplicationSlot.createRoundRectComplicationSlotBuilder( id = 100, canvasComplicationFactory = defaultCanvasComplicationFactory, // ... ) .setDefaultDataSourceType(ComplicationType.SHORT_TEXT) .build() val rightComplicationSlot = ComplicationSlot.createRoundRectComplicationSlotBuilder( id = 101, canvasComplicationFactory = defaultCanvasComplicationFactory, // ... ) .setDefaultDataSourceType(ComplicationType.SHORT_TEXT) .build() return ComplicationSlotsManager( listOf(leftComplicationSlot, rightComplicationSlot), currentUserStyleRepository ) }
The WatchFace describes the type of watch face and how to draw it.
A WatchFace can be specified as digital or analog and can optionally have a tap listener for when the user taps on the watch face.
Most importantly, a WatchFace specifies a Renderer, which actually renders the watch face:
Renderer
override suspend fun createWatchFace( surfaceHolder: SurfaceHolder, watchState: WatchState, complicationSlotsManager: ComplicationSlotsManager, currentUserStyleRepository: CurrentUserStyleRepository ): WatchFace = WatchFace( watchFaceType = WatchFaceType.ANALOG, renderer = // ... )
The prettiest part of a watch face! Every watch face will create a custom subclass of a renderer that implements everything needed to actually draw the watch face to a canvas.
The renderer is in charge of combining the UserStyle (the map from CurrentUserStyleRepository), the complication information from ComplicationSlotsManager, the current time, and other state information to render the watch face.
CurrentUserStyleRepository)
class CustomCanvasRenderer( private val context: Context, surfaceHolder: SurfaceHolder, watchState: WatchState, private val complicationSlotsManager: ComplicationSlotsManager, currentUserStyleRepository: CurrentUserStyleRepository, canvasType: Int ) : Renderer.CanvasRenderer( surfaceHolder = surfaceHolder, currentUserStyleRepository = currentUserStyleRepository, watchState = watchState, canvasType = canvasType, interactiveDrawModeUpdateDelayMillis = 16L ) { override fun render(canvas: Canvas, bounds: Rect, zonedDateTime: ZonedDateTime) { // Draw into the canvas! } override fun renderHighlightLayer(canvas: Canvas, bounds: Rect, zonedDateTime: ZonedDateTime) { // Draw into the canvas! } }
In addition to the system WYSIWYG editor on the phone, we strongly encourage supporting configuration on the smartwatch to allow the user to customize their watch face without requiring a companion device.
To support this, a watch face can provide a configuration Activity and allow the user to change settings using an EditorSession returned from EditorSession.createOnWatchEditorSession. As the user makes changes, calling EditorSession.renderWatchFaceToBitmap provides a live preview of the watch face in the editor Activity.
Activity
EditorSession
EditorSession.createOnWatchEditorSession
EditorSession.renderWatchFaceToBitmap
To see how the whole puzzle fits together to tell the time, check out the watchface sample on GitHub. To learn more about developing for Wear OS, check out the developer website.