When the idea arose to make the dials for watches on Android Wear, the case started without fear. The development experience under the “big” android was, and on the watch a tiny screen and just one button is easier than light.
As always, the instructions from the developers at
developer.android.com/training/building-wearables.html were ignored - it was necessary to create, not read manuals. Therefore, many things that can be gleaned from there, became insights and their own "breakthroughs".
The application consists of two parts:
mobile and
wear , which Android Studio kindly generates when creating a new project. The revelation was that wear is compiled, packaged and embedded in raw resources mobile. Mobile, on the other hand, is a standard application for a phone, which, when installed, unfolds and sends wear from its set to the clock. Android Wear, a bridge application that connects wearable gadgets with the “big brother” (swings from Google to reveal the full potential of the watch), is engaged in sending and downloading. By the way, Motorola also offers to install its application, which is like Android Wear, only Moto Connect :) Of the buns, there is its own, Motorola advertising application, which looked to them personally, and of course its fitness gadgets.
')
It was decided not to cut the bike, but to use the latest engineering achievements by building an application on the SDK from professionals who had a hand in the origins of the platform (quote from the site):
github.com/ustwo/clockwise
Subsequently, when the platform became more familiar, it turned out that the guys wrote a not very thick layer over the native WatchFaceService, thereby leaving complete freedom for creativity and saving a day or two to write the same basic service. In any case, thank you: the platform allows you to configure the elements of the style of future hours, the frequency of updates, pulls on itself the functionality of working with dates and delegates the onDraw and onLayout methods. In addition, it reports the shape of the clock, though only in two versions - round / square. Motorola with its "beard" (it is "chin" or "flat tire") is defined as round, but with a width greater than the height, so we calculate it.
Podkuzmil noble built-in method on24HourFormatChanged, which we did not call when changing the format when the dial was active. The only call occurred at the time of launch. I had to monitor the format with each screen update.
Since the designer was present in the team, a volitional decision was immediately made - the dials would be rendered with images. No logic, drawing on canvas, only PNG, only hardcore. Libraries of images were created, which are responsible for numbers and positional ImageView, where the necessary numbers were substituted by HH: mm in 24 or 12-hour format, depending on the user's locale.
Further, following the tastes and preferences of users, there was a need to display the date. For it appeared 6 ImageView dd.MM.yy or MM.dd, if the owner of the watch is originally from the USA.
The most frequent reproach that was put forward to us at that time on Google Play was the lack of an
ambient mode . We deliberately did not implement it, because its existence was mentioned in the instructions, and almost without pictures and far from the beginning.
According to the good idea of the creators of the platform, the watch after a few seconds of inactivity goes into battery saving mode, sending a notification service to the service that renders the dial. The dial should respond to the new state by completely simplifying the interface. Instead of a colorful picture with a lot of whistles, the screen must be filled with 95% black, leaving only dim tsiferki. Further, the image quality depends on the manufacturer of the clock: someone displays shades of gray in ambient mode, and someone displays a picture in b / w. Also in this mode it is prescribed to disable all the energy-intensive functions of your application - no geolocation and youtube viewing.
The last step was the functionality of displaying information about the battery level of the phone and the clock. Communication with the phone takes place through the Google message layer, so this seemingly insignificant amount of information required the implementation of an additional service, which has become a cornerstone in the messaging infrastructure between the phone and the clock.
PS And life hacking for those who do not know. To get rid of the annoying “Ok Google” hint on the clock screen, you need to say this “spell” 2-3 times. Voila, no more eyes to callous!
