Wednesday, June 23, 2021

Android 12’s Material You theming system has been recreated by a developer

Material You’s wallpaper-based theming system, codenamed “monet,” finally went live in Android 12 Beta 2. The theming system creates color palettes based on the dominant color scheme of your wallpaper and applies them to Quick Settings tiles, lockscreen, Settings, pop-ups, and apps. However, in its current implementation, it only themes part of the system UI and select system apps. Most third-party apps don’t support this dynamic theming as Google hasn’t published the documentation on Material You yet. While we don’t know when Google will publish resources and libraries on Material You, Danny Lin (kdrag0n), the developer of ProtonAOSP ROM, has come forth with his own theme engine based on “monet”.

kdrag0n’s theming engine works just like “monet” and opens up the Pixel-exclusive dynamic theming to all devices running Android 12 and Android 11. kdrag0n was the developer that first got “monet” working in early Android 12 developer preview builds. Since then, he has reverse-engineered Google’s implementation and has been giving feedback to members of Google’s SystemUI team, notably James O’Leary (who seems to be part of the team that developed “monet” at Google).

kdrag0n's theming engine based on monet

According to kdrag0n, his implementation doesn’t use any code or APIs from Google or Android 12, so there’s no dependency on devices running Android 12 for his model to be used. kdrag0n’s theme engine follows Material You color targets. These targets are then “recolored by adjusting colorfulness and hue in @bjornornorn’s Oklab perceptual color space. The resulting colors are gamut-mapped to sRGB using gamut intersection in Oklab space.” Users can also change colorfulness and make it prioritize colorfulness over accurate shades.

Appearance menu in Kdrag0n's theming engine Android 12's Quick Settings tiles and notification shade themed by kdrag0n's theming engine

kdrag0n’s theme engine is open-source under the MIT license, meaning custom ROM developers (and even OEMs) can implement it if they wish to. In fact, the developer’s own ProtonAOSP ROM will be one of the first to implement it when Android 12 goes public. If you’re a custom ROM developer, you can cherry-pick these commits and merge them into your fork.

The developer is also working on Jetpack Compose and Flutter libraries, which will allow even apps built for Android 11 to support dynamic colors. Apps targeting Android 11 can register a listener to get notified when wallpaper colors change. kdrag0n’s code is meant for generating themes based on the new wallpaper color.

As an example of his model working for apps targeting Android 11, the developer shared a video with us demonstrating an app changing its theme every frame at 90fps. Do note that this demo is just an example of what can be done and is not recommended to be recreated exactly as shown.

This one can have a big hit on performance and battery, though the developer’s Pixel 4 can render theme changes at 90fps for simpler views. According to the developer, Jetpack Compose hasn’t been optimized for performance that much, and the Flutter library might be better. In any case, it only takes 0.05 ms for his engine to generate a theme, but changing the UI theme every frame is taxing on performance nonetheless.


Mishaal Rahman contributed to this article. 

The post Android 12’s Material You theming system has been recreated by a developer appeared first on xda-developers.



from xda-developers https://ift.tt/2Ulzua8
via IFTTT

No comments:

Post a Comment