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..05b0c1f6dbf7f4c2ff6dab223cc278991a3c17c0 100644
--- a/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java
@@ -581,7 +581,14 @@ 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_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..e844f07ba59744249bc08e0a04cf058660d4fe6b 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);
diff --git a/src/main/res/xml/preferences.xml b/src/main/res/xml/preferences.xml
index 41fa01d0f2e626c8e5462a05bfb700136da9ffcc..260cca0b19931ea19161fe530fde121716f4dd3b 100644
--- a/src/main/res/xml/preferences.xml
+++ b/src/main/res/xml/preferences.xml
@@ -211,6 +211,16 @@
android:defaultValue="false"
android:key="custom_theme_dark"
android:title="Custom Theme is Dark?" />
+
+