diff --git a/src/cheogram/res/values/colors.xml b/src/cheogram/res/values/colors.xml index 7bd3a36975dd610baf8e884c3322fb006e55c283..302ae981bffceee2139e441a0391ed7e0e427601 100644 --- a/src/cheogram/res/values/colors.xml +++ b/src/cheogram/res/values/colors.xml @@ -9,14 +9,16 @@ #FFC700 @color/perpy + @color/black_perpy + @color/black_perpy @color/grey50 @color/grey200 @color/grey300 - @color/grey800 - @color/grey900 - @color/grey700 - @color/black_perpy - - @color/black_perpy + @color/perpy + @color/black_perpy + @color/black_perpy + @color/grey800 + @color/grey900 + @color/grey700 diff --git a/src/cheogram/res/values/themes.xml b/src/cheogram/res/values/themes.xml index bcd7c9097674283543c1fbd83f6db9417ae1c8cf..f8f2690a5896136b903f513afb7c9fcc13c45ea1 100644 --- a/src/cheogram/res/values/themes.xml +++ b/src/cheogram/res/values/themes.xml @@ -370,12 +370,12 @@ diff --git a/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java b/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java index de24c026fc47b379a896191edb20be6a73d3c3f8..8d6a2b7d4fd461694e41a4bf7b7f453e969c1ba2 100644 --- a/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java @@ -428,6 +428,19 @@ public class SettingsActivity extends XmppActivity implements OnSharedPreference final Preference customTheme = mSettingsFragment.findPreference("custom_theme"); if (customTheme != null) uiCategory.removePreference(customTheme); } + + final boolean customAutomatic = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("custom_theme_automatic", false); + if (Build.VERSION.SDK_INT > 30 && theTheme.equals("custom") && !customAutomatic) { + final PreferenceScreen customTheme = (PreferenceScreen) mSettingsFragment.findPreference("custom_theme"); + final boolean isDark = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("custom_theme_dark", false); + if (isDark) { + final PreferenceCategory customThemeColors = (PreferenceCategory) mSettingsFragment.findPreference("custom_theme_colors"); + customTheme.removePreference(customThemeColors); + } else { + final PreferenceCategory customThemeColorsDark = (PreferenceCategory) mSettingsFragment.findPreference("custom_theme_colors_dark"); + customTheme.removePreference(customThemeColorsDark); + } + } } private void changeOmemoSettingSummary() { @@ -583,12 +596,15 @@ public class SettingsActivity extends XmppActivity implements OnSharedPreference xmppConnectionService.expireOldMessages(true); } else if ( name.equals(THEME) || name.equals("custom_theme_automatic") || + name.equals("custom_theme_dark") || 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")) + name.equals("custom_dark_theme_primary") || + name.equals("custom_dark_theme_primary_dark") || + name.equals("custom_dark_theme_accent") || + name.equals("custom_dark_theme_background_primary")) { final int theme = findTheme(); xmppConnectionService.setTheme(theme); diff --git a/src/main/java/eu/siacs/conversations/utils/ThemeHelper.java b/src/main/java/eu/siacs/conversations/utils/ThemeHelper.java index ae3ed02d5797e3568076ca8314009a12fa9a55ee..ad4a6f49d85a70953b2be35919abc025a8774964 100644 --- a/src/main/java/eu/siacs/conversations/utils/ThemeHelper.java +++ b/src/main/java/eu/siacs/conversations/utils/ThemeHelper.java @@ -74,15 +74,18 @@ public class ThemeHelper { 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); + if (sharedPreferences.contains("custom_dark_theme_primary")) colors.put(R.color.custom_dark_theme_primary, sharedPreferences.getInt("custom_dark_theme_primary", 0)); + if (sharedPreferences.contains("custom_dark_theme_primary_dark")) colors.put(R.color.custom_dark_theme_primary_dark, sharedPreferences.getInt("custom_dark_theme_primary_dark", 0)); + if (sharedPreferences.contains("custom_dark_theme_accent")) colors.put(R.color.custom_dark_theme_accent, sharedPreferences.getInt("custom_dark_theme_accent", 0)); + if (sharedPreferences.contains("custom_dark_theme_background_primary")) { + int background_primary = sharedPreferences.getInt("custom_dark_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_dark, background_primary); - colors.put(R.color.custom_theme_background_secondary_dark, (int)((alpha << 24) | ((int)(red*.5) << 16) | ((int)(green*.5) << 8) | (int)(blue*.5))); - colors.put(R.color.custom_theme_background_tertiary_dark, (int)((alpha << 24) | ((int)(40 + red*.84) << 16) | ((int)(40 + green*.84) << 8) | (int)(40 + blue*.84))); + colors.put(R.color.custom_dark_theme_background_primary, background_primary); + colors.put(R.color.custom_dark_theme_background_secondary, (int)((alpha << 24) | ((int)(red*.5) << 16) | ((int)(green*.5) << 8) | (int)(blue*.5))); + colors.put(R.color.custom_dark_theme_background_tertiary, (int)((alpha << 24) | ((int)(40 + red*.84) << 16) | ((int)(40 + green*.84) << 8) | (int)(40 + blue*.84))); } if (colors.isEmpty()) return colors; diff --git a/src/main/res/xml/preferences.xml b/src/main/res/xml/preferences.xml index 6a466a8e56d407e7c1a3c1e38be7a137c82e6460..d069cf9c032d23e12588a0adfc3938a8239ba4d5 100644 --- a/src/main/res/xml/preferences.xml +++ b/src/main/res/xml/preferences.xml @@ -202,21 +202,21 @@ android:selectable="false" android:persistent="false" android:summary="You may sometimes have to force quit the app to get changes applied."/> + + + android:title="Light"> - - + + + + + + -