-
-
Notifications
You must be signed in to change notification settings - Fork 673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
theming: respect user current color scheme #1592
Conversation
Test apk: https://anonymfile.com/4Bxa/playground-6-armeabi-v7a-debug.apk from kivy.lang import Builder
from kivy.metrics import dp
from kivy.clock import Clock
from kivymd.uix.boxlayout import MDBoxLayout
from kivymd.app import MDApp
KV = """
<ColorView>:
text:""
color:app.theme_cls.surfaceContainerLowColor
padding:dp(15)
MDLabel:
text:root.text
padding:dp(10)
MDBoxLayout:
md_bg_color:root.color
radius:[dp(10)] * 4
ScrollView:
MDBoxLayout:
adaptive_height:True
orientation:"vertical"
MDLabel:
text:"Dynamic Colors"
halign:"center"
size_hint_y:None
height:dp(100)
"""
class ColorView(MDBoxLayout):
pass
class MainApp(MDApp):
def build(self):
self.theme_cls.theme_style = "Dark"
self.theme_cls.dynamic_color = True
return Builder.load_string(KV)
def on_start(self):
super().on_start()
Clock.schedule_once(self.add_colors)
def add_colors(self, instance):
for color in dir(self.theme_cls):
if color.endswith("Color"):
_widget = ColorView( size_hint_y=None, height=dp(70))
_widget.text = color
_widget.color = getattr(self.theme_cls, color)
self.root.children[0].add_widget(_widget)
MainApp().run() |
Great! Good job! |
@kulothunganug Thanks for testing! And yes I am aware of that, I was digging into android's src I and found that color's need to be scored first based on their proportions and then index is selected. But the problem is /**
* Filters and ranks colors from WallpaperColors.
*
* @param wallpaperColors Colors extracted from an image via quantization.
* @param filter If false, allow colors that have low chroma, creating grayscale themes.
* @return List of ARGB ints, ordered from highest scoring to lowest.
*/
@JvmStatic
@JvmOverloads
fun getSeedColors(wallpaperColors: WallpaperColors, filter: Boolean = true): List<Int> {
val totalPopulation =
wallpaperColors.allColors.values.reduce { a, b -> a + b }.toDouble()
When I get |
@kulothunganug Can you post the logcat output also? |
|
@kulothunganug I sent you apk in discord DM. |
Merge this PR? |
@HeaTTheatR not yet. Needs some more testing. I will inform when to merge. |
Ok |
@kulothunganug Actually it's a internal color, not listed in https://kivymd.readthedocs.io/en/latest/components/dynamic-color. (Also for some reason the color which cotains "fixed" matches with android UI. For example colors in android QS panel excatly matches with fixed primary color) |
Thanks for the info! |
https://discord.com/channels/566880874789076992/566880874789076994/1209062326133587968 |
Description of the problem
Current color scheme generation gets top color from wallpaper. But in Android there are multiple options for wallpaper colors which leads to theme mismatch.
Click to view image
Multiple color options
Solution
This PR implements getting color scheme from android api.
Also this PR skips color quantization if Android already had done it. So this means we don't need color generation if Android is
8.1
or8.1
+.test.mp4
Remaning things
Changes done to
theming.py
are minimal, it may require more changes (you can do it yourself in your own way).Note: Please wait some time before merging so that testing can be done.