diff --git a/src/cheogram/res/values/colors.xml b/src/cheogram/res/values/colors.xml index 54eadd7c3e089e029f8c72f4c27ecfa3bc1b4406..a391bea697fb54535bbefdaaaad87133cd0fc4ce 100644 --- a/src/cheogram/res/values/colors.xml +++ b/src/cheogram/res/values/colors.xml @@ -9,6 +9,14 @@ #FFC700 @color/perpy + @color/grey50 + @color/grey200 + @color/grey300 + + @color/grey800 + @color/grey700 + @color/grey900 @color/black_perpy + @color/black_perpy diff --git a/src/cheogram/res/values/themes.xml b/src/cheogram/res/values/themes.xml index 27c5ace57fa2446e90d5fdef959bbb51e84bd5f8..bcd7c9097674283543c1fbd83f6db9417ae1c8cf 100644 --- a/src/cheogram/res/values/themes.xml +++ b/src/cheogram/res/values/themes.xml @@ -361,6 +361,9 @@ diff --git a/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java b/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java index 92953da6f66a468d23f4041803fab56298e12231..de24c026fc47b379a896191edb20be6a73d3c3f8 100644 --- a/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java @@ -581,7 +581,15 @@ public class SettingsActivity extends XmppActivity implements OnSharedPreference xmppConnectionService.reinitializeMuclumbusService(); } else if (name.equals(AUTOMATIC_MESSAGE_DELETION)) { xmppConnectionService.expireOldMessages(true); - } else if (name.equals(THEME) || name.equals("custom_theme_primary") || name.equals("custom_theme_primary_dark") || name.equals("custom_theme_accent") || name.equals("custom_theme_dark")) { + } else if ( name.equals(THEME) || + name.equals("custom_theme_automatic") || + name.equals("custom_theme_primary") || + name.equals("custom_theme_primary_dark") || + name.equals("custom_theme_accent") || + name.equals("custom_theme_dark") || + name.equals("custom_theme_background_primary") || + name.equals("custom_theme_background_primary_dark")) + { final int theme = findTheme(); xmppConnectionService.setTheme(theme); ThemeHelper.applyCustomColors(xmppConnectionService); diff --git a/src/main/java/eu/siacs/conversations/utils/ThemeHelper.java b/src/main/java/eu/siacs/conversations/utils/ThemeHelper.java index 3ce5f16de1ac2aa397b83502436738dbb5522901..2f6fd2e1dcb2887dfb6f7dcaf41aa84bc27c5be7 100644 --- a/src/main/java/eu/siacs/conversations/utils/ThemeHelper.java +++ b/src/main/java/eu/siacs/conversations/utils/ThemeHelper.java @@ -64,6 +64,26 @@ public class ThemeHelper { if (sharedPreferences.contains("custom_theme_primary")) colors.put(R.color.custom_theme_primary, sharedPreferences.getInt("custom_theme_primary", 0)); if (sharedPreferences.contains("custom_theme_primary_dark")) colors.put(R.color.custom_theme_primary_dark, sharedPreferences.getInt("custom_theme_primary_dark", 0)); if (sharedPreferences.contains("custom_theme_accent")) colors.put(R.color.custom_theme_accent, sharedPreferences.getInt("custom_theme_accent", 0)); + if (sharedPreferences.contains("custom_theme_background_primary")) { + int background_primary = sharedPreferences.getInt("custom_theme_background_primary", 0); + int alpha = (background_primary >> 24) & 0xFF; + int red = (background_primary >> 16) & 0xFF; + int green = (background_primary >> 8) & 0xFF; + int blue = background_primary & 0xFF; + colors.put(R.color.custom_theme_background_primary, background_primary); + colors.put(R.color.custom_theme_background_secondary, (int)((alpha << 24) | ((int)(red*.9) << 16) | ((int)(green*.9) << 8) | (int)(blue*.9))); + colors.put(R.color.custom_theme_background_tertiary, (int)((alpha << 24) | ((int)(red*.85) << 16) | ((int)(green*.85) << 8) | (int)(blue*.85))); + } + if (sharedPreferences.contains("custom_theme_background_primary_dark")) { + int background_primary = sharedPreferences.getInt("custom_theme_background_primary_dark", 0); + int alpha = (background_primary >> 24) & 0xFF; + int red = (background_primary >> 16) & 0xFF; + int green = (background_primary >> 8) & 0xFF; + int blue = background_primary & 0xFF; + colors.put(R.color.custom_theme_background_primary_dark, background_primary); + colors.put(R.color.custom_theme_background_secondary_dark, (int)((alpha << 24) | ((int)(40 + red*.84) << 16) | ((int)(40 + green*.84) << 8) | (int)(40 + blue*.84))); + colors.put(R.color.custom_theme_background_tertiary_dark, (int)((alpha << 24) | ((int)(red*.5) << 16) | ((int)(green*.5) << 8) | (int)(blue*.5))); + } if (colors.isEmpty()) return colors; ResourcesLoader loader = ColorResourcesLoaderCreator.create(context, colors); @@ -117,7 +137,9 @@ public class ThemeHelper { private static boolean isDark(final SharedPreferences sharedPreferences, final Resources resources) { final String setting = sharedPreferences.getString(SettingsActivity.THEME, resources.getString(R.string.theme)); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && "automatic".equals(setting)) { + if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && "automatic".equals(setting)) || + ("custom".equals(setting) && sharedPreferences.getBoolean("custom_theme_automatic", false)) + ) { return (resources.getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES; } else { if ("custom".equals(setting)) return sharedPreferences.getBoolean("custom_theme_dark", false); diff --git a/src/main/res/xml/preferences.xml b/src/main/res/xml/preferences.xml index 41fa01d0f2e626c8e5462a05bfb700136da9ffcc..7d5c526c6af8cf95407acb6726e86ffd2615fb7e 100644 --- a/src/main/res/xml/preferences.xml +++ b/src/main/res/xml/preferences.xml @@ -209,8 +209,24 @@ + + +