From d8395c1abea34db05513ef9d51c47d3bc8e34792 Mon Sep 17 00:00:00 2001 From: Ido Ben-Hur Date: Thu, 8 Dec 2022 03:15:17 +0200 Subject: [PATCH] Cherish: Allow choosing a custom background color seed [2/2] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Hưng Phan --- res/values/cherish_strings.xml | 4 ++ res/xml/monet_settings.xml | 11 +++++ .../settings/fragments/MonetSettings.java | 43 +++++++++++++++++++ 3 files changed, 58 insertions(+) diff --git a/res/values/cherish_strings.xml b/res/values/cherish_strings.xml index fcf3ed6..212214e 100644 --- a/res/values/cherish_strings.xml +++ b/res/values/cherish_strings.xml @@ -896,6 +896,10 @@ Preset Accent Color Override default accent color + Accent background + Choose a different accent color for background + Background Color + Override default background accent color Luminance Higher values produce brighter colors Chroma diff --git a/res/xml/monet_settings.xml b/res/xml/monet_settings.xml index 5d0c260..d6ca4ff 100644 --- a/res/xml/monet_settings.xml +++ b/res/xml/monet_settings.xml @@ -37,6 +37,17 @@ android:title="@string/accent_color_title" android:summary="@string/accent_color_summary" /> + + + + 1d) luminV = Math.round((lumin - 1f) * 100f); @@ -179,6 +198,15 @@ public class MonetSettings extends SettingsPreferenceFragment implements int value = (Integer) newValue; setColorValue(value); return true; + } else if (preference == mAccentBackgroundPref) { + boolean value = (Boolean) newValue; + if (!value) setBgColorValue(0); + mBgColorPref.setEnabled(value); + return true; + } else if (preference == mBgColorPref) { + int value = (Integer) newValue; + setBgColorValue(value); + return true; } else if (preference == mLuminancePref) { int value = (Integer) newValue; setLuminanceValue(value); @@ -208,6 +236,12 @@ public class MonetSettings extends SettingsPreferenceFragment implements private boolean updateAccentEnablement(String source) { final boolean shouldEnable = source != null && source.equals(COLOR_SOURCE_PRESET); mAccentColorPref.setEnabled(shouldEnable); + mAccentBackgroundPref.setEnabled(shouldEnable); + if (!shouldEnable) { + mBgColorPref.setEnabled(false); + mAccentBackgroundPref.setEnabled(false); + mAccentBackgroundPref.setChecked(false); + } return shouldEnable; } @@ -266,6 +300,15 @@ public class MonetSettings extends SettingsPreferenceFragment implements } catch (JSONException | IllegalArgumentException ignored) {} } + private void setBgColorValue(int color) { + try { + JSONObject object = getSettingsJson(); + if (color != 0) object.putOpt(OVERLAY_CATEGORY_BG_COLOR, color); + else object.remove(OVERLAY_CATEGORY_BG_COLOR); + putSettingsJson(object); + } catch (JSONException | IllegalArgumentException ignored) {} + } + private void setLuminanceValue(int lumin) { try { JSONObject object = getSettingsJson();