Skip to content
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

Add support for Android 12+ dynamic colors #647

Merged
merged 5 commits into from
Jul 6, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
<item>@string/pref_theme_e_epaper</item>
<item>@string/pref_theme_e_desert</item>
<item>@string/pref_theme_e_jungle</item>
<item>@string/pref_theme_e_monet</item>
<item>@string/pref_theme_e_monetlight</item>
<item>@string/pref_theme_e_monetdark</item>
</string-array>
<string-array name="pref_theme_values">
<item>system</item>
Expand All @@ -39,6 +42,9 @@
<item>epaper</item>
<item>desert</item>
<item>jungle</item>
<item>monet</item>
<item>monetlight</item>
<item>monetdark</item>
</string-array>
<string-array name="pref_swipe_dist_entries">
<item>@string/pref_swipe_dist_e_very_short</item>
Expand Down
3 changes: 3 additions & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ This application contains no ads, doesn't make any network requests and is Open
<string name="pref_theme_e_epaper">ePaper</string>
<string name="pref_theme_e_desert">Desert</string>
<string name="pref_theme_e_jungle">Jungle</string>
<string name="pref_theme_e_monet">System Monet</string>
<string name="pref_theme_e_monetlight">Monet (Light)</string>
<string name="pref_theme_e_monetdark">Monet (Dark)</string>
<string name="pref_swipe_dist_e_very_short">Very short</string>
<string name="pref_swipe_dist_e_short">Short</string>
<string name="pref_swipe_dist_e_default">Normal</string>
Expand Down
24 changes: 24 additions & 0 deletions res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,28 @@
<item name="emoji_button_bg">?colorKeyActivated</item>
<item name="emoji_color">#000000</item>
</style>
<style name="MonetLight" parent="@style/BaseTheme">
<item name="android:isLightTheme">true</item>
<item name="colorKeyboard">@android:color/system_accent1_100</item>
<item name="colorKey">@android:color/system_accent1_0</item>
<item name="colorKeyActivated">@android:color/system_accent1_300</item>
<item name="colorLabel">@android:color/system_accent1_1000</item>
<item name="colorLabelActivated">@android:color/system_accent1_1000</item>
<item name="colorLabelLocked">@android:color/system_accent1_500</item>
<item name="colorSubLabel">@android:color/system_accent1_900</item>
<item name="emoji_button_bg">?colorKeyActivated</item>
<item name="emoji_color">@android:color/system_accent1_1000</item>
</style>
<style name="MonetDark" parent="@style/BaseTheme">
<item name="android:isLightTheme">false</item>
<item name="colorKeyboard">@android:color/system_neutral1_900</item>
<item name="colorKey">@android:color/system_neutral1_800</item>
<item name="colorKeyActivated">@android:color/system_accent1_100</item>
<item name="colorLabel">@android:color/system_neutral1_0</item>
<item name="colorLabelActivated">@android:color/system_accent1_900</item>
<item name="colorLabelLocked">@android:color/system_accent1_500</item>
<item name="colorSubLabel">@android:color/system_accent1_500</item>
<item name="emoji_button_bg">?colorKeyActivated</item>
<item name="emoji_color">@android:color/system_accent1_0</item>
</style>
</resources>
8 changes: 7 additions & 1 deletion srcs/juloo.keyboard2/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ float get_dip_pref_oriented(DisplayMetrics dm, String pref_base_name, float def_

private int getThemeId(Resources res, String theme_name)
{
int night_mode = res.getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
switch (theme_name)
{
case "light": return R.style.Light;
Expand All @@ -409,9 +410,14 @@ private int getThemeId(Resources res, String theme_name)
case "epaper": return R.style.ePaper;
case "desert": return R.style.Desert;
case "jungle": return R.style.Jungle;
case "monetlight": return R.style.MonetLight;
case "monetdark": return R.style.MonetDark;
case "monet":
if ((night_mode & Configuration.UI_MODE_NIGHT_NO) != 0)
return R.style.MonetLight;
return R.style.MonetDark;
default:
case "system":
int night_mode = res.getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
if ((night_mode & Configuration.UI_MODE_NIGHT_NO) != 0)
return R.style.Light;
return R.style.Dark;
Expand Down
Loading