diff options
| author | Ali B <abittin@gmail.com> | 2020-12-03 16:02:53 +0300 |
|---|---|---|
| committer | Ali B <abittin@gmail.com> | 2020-12-04 16:49:21 +0300 |
| commit | ed348bd07783599ddecf61317c4e63a944feb12a (patch) | |
| tree | 86e9bdbacab4b548c82e82b49559e390ea0f01a8 | |
| parent | 4f641f672185f5951252488f47bbdbb336d8390c (diff) | |
PartsBin: add Adobe RGB panel mode
Change-Id: I16f2f27e04a97e4fb280f5cafe311d77dee32ed0
| -rw-r--r-- | README.md | 5 | ||||
| -rw-r--r-- | res/layout/panel_modes.xml | 9 | ||||
| -rw-r--r-- | res/values/config.xml | 3 | ||||
| -rw-r--r-- | src/com/aicp/device/AdobeRGBModeSwitch.java | 42 | ||||
| -rw-r--r-- | src/com/aicp/device/DeviceSettings.java | 1 | ||||
| -rw-r--r-- | src/com/aicp/device/PanelSettings.java | 28 | ||||
| -rw-r--r-- | src/com/aicp/device/Startup.java | 6 |
7 files changed, 93 insertions, 1 deletions
@@ -45,7 +45,7 @@ _Note that defining paths needs support in the kernel! Thus the features might n DCDSwitch: DC-Dimming toggle with additional QS tile - Displaypanel Color Modes: sRGB, DCI-P3, WideColor, OnePlus, Nightmode. With additional QS tile + Displaypanel Color Modes: sRGB, Adobe RGB, DCI-P3, WideColor, OnePlus, Nightmode. With additional QS tile Display Refreshrate: Automatic, Manual (60Hz, 90Hz) with additional QS tile [Note: Requires setting the kernel node for "dynamic_fps" and a few other bools.] @@ -129,6 +129,9 @@ _Note that defining paths needs support in the kernel! Thus the features might n `<!-- Path to devices SRGBMode toggle file -->`<br /> `<string name="pathSRGBModeToggle"> </string>`<br /> +`<!-- Path to devices AdobeRGBMode toggle file -->`<br /> +`<string name="pathAdobeRGBModeToggle"> </string>`<br /> + `<!-- Path to devices DCI-P3 Mode toggle file -->`<br /> `<string name="pathDCIModeToggle"> </string>`<br /> diff --git a/res/layout/panel_modes.xml b/res/layout/panel_modes.xml index 99ddf00..df405a4 100644 --- a/res/layout/panel_modes.xml +++ b/res/layout/panel_modes.xml @@ -66,6 +66,15 @@ limitations under the License android:textAppearance="?android:attr/textAppearanceMedium" /> <RadioButton + android:id="@+id/adobergb_mode" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:minHeight="?android:attr/listPreferredItemHeight" + android:gravity="center_vertical" + android:text="@string/adobergb_mode_title" + android:textAppearance="?android:attr/textAppearanceMedium" /> + + <RadioButton android:id="@+id/dci_mode" android:layout_width="wrap_content" android:layout_height="wrap_content" diff --git a/res/values/config.xml b/res/values/config.xml index 690ff46..1805ff6 100644 --- a/res/values/config.xml +++ b/res/values/config.xml @@ -56,6 +56,9 @@ <!-- Path to devices SRGBMode toggle file --> <string name="pathSRGBModeToggle"></string> + <!-- Path to devices AdobeRGBMode toggle file --> + <string name="pathAdobeRGBModeToggle"></string> + <!-- Path to devices DCIMode toggle file --> <string name="pathDCIModeToggle"></string> diff --git a/src/com/aicp/device/AdobeRGBModeSwitch.java b/src/com/aicp/device/AdobeRGBModeSwitch.java new file mode 100644 index 0000000..8549537 --- /dev/null +++ b/src/com/aicp/device/AdobeRGBModeSwitch.java @@ -0,0 +1,42 @@ +/* +* Copyright (C) 2016 The OmniROM Project +* Copyright (C) 2020 The Android Ice Cold Project +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see <http://www.gnu.org/licenses/>. +* +*/ +package com.aicp.device; + +import android.content.Context; + +public class AdobeRGBModeSwitch { + + public static final String SETTINGS_KEY = DeviceSettings.KEY_SETTINGS_PREFIX + DeviceSettings.KEY_ADOBERGB_SWITCH; + + public static String getFile(Context context) { + String fileName = context.getResources().getString(R.string.pathAdobeRGBModeToggle); + if (fileName != null && !fileName.isEmpty() && Utils.fileWritable(fileName)) { + return fileName; + } + return null; + } + + public static boolean isSupported(Context context) { + return getFile(context) != null; + } + + public static boolean isCurrentlyEnabled(Context context) { + return Utils.getFileValueAsBoolean(getFile(context), false); + } +} diff --git a/src/com/aicp/device/DeviceSettings.java b/src/com/aicp/device/DeviceSettings.java index bfd62e4..9f0abad 100644 --- a/src/com/aicp/device/DeviceSettings.java +++ b/src/com/aicp/device/DeviceSettings.java @@ -74,6 +74,7 @@ public class DeviceSettings extends PreferenceFragment implements public static final String KEY_SPEAKER_GAIN = "speaker_gain"; public static final String KEY_SRGB_SWITCH = "srgb"; + public static final String KEY_ADOBERGB_SWITCH = "adobe_rgb"; public static final String KEY_HBM_SWITCH = "hbm"; public static final String KEY_PROXI_SWITCH = "proxi"; public static final String KEY_DCD_SWITCH = "dcd"; diff --git a/src/com/aicp/device/PanelSettings.java b/src/com/aicp/device/PanelSettings.java index 3fbd0c1..613d65e 100644 --- a/src/com/aicp/device/PanelSettings.java +++ b/src/com/aicp/device/PanelSettings.java @@ -55,6 +55,7 @@ public class PanelSettings extends PreferenceFragment implements RadioGroup.OnCh mRadioGroup = (RadioGroup) view.findViewById(R.id.radio_group); updateRadioButtonState(view.findViewById(R.id.dci_mode), DCIModeSwitch.isSupported(mContext)); updateRadioButtonState(view.findViewById(R.id.srgb_mode), SRGBModeSwitch.isSupported(mContext)); + updateRadioButtonState(view.findViewById(R.id.adobergb_mode), AdobeRGBModeSwitch.isSupported(mContext)); updateRadioButtonState(view.findViewById(R.id.wide_mode), WideModeSwitch.isSupported(mContext)); updateRadioButtonState(view.findViewById(R.id.oneplus_mode), OnePlusModeSwitch.isSupported(mContext)); updateRadioButtonState(view.findViewById(R.id.night_mode), NightModeSwitch.isSupported(mContext)); @@ -66,6 +67,8 @@ public class PanelSettings extends PreferenceFragment implements RadioGroup.OnCh checkedButtonId = R.id.dci_mode; } else if (SRGBModeSwitch.isCurrentlyEnabled(mContext)) { checkedButtonId = R.id.srgb_mode; + } else if (AdobeRGBModeSwitch.isCurrentlyEnabled(mContext)) { + checkedButtonId = R.id.adobergb_mode; } else if (OnePlusModeSwitch.isCurrentlyEnabled(mContext)) { checkedButtonId = R.id.oneplus_mode; } else if (NightModeSwitch.isCurrentlyEnabled(mContext)) { @@ -96,6 +99,8 @@ public class PanelSettings extends PreferenceFragment implements RadioGroup.OnCh Settings.System.putInt(getContext().getContentResolver(), WideModeSwitch.SETTINGS_KEY, 0); Utils.writeValue(OnePlusModeSwitch.getFile(mContext), "0"); Settings.System.putInt(getContext().getContentResolver(), OnePlusModeSwitch.SETTINGS_KEY, 0); + Utils.writeValue(AdobeRGBModeSwitch.getFile(mContext), "0"); + Settings.System.putInt(getContext().getContentResolver(), AdobeRGBModeSwitch.SETTINGS_KEY, 0); Utils.writeValue(SRGBModeSwitch.getFile(mContext), "1"); Settings.System.putInt(getContext().getContentResolver(), SRGBModeSwitch.SETTINGS_KEY, 1); } else if (checkedId == R.id.dci_mode) { @@ -107,6 +112,8 @@ public class PanelSettings extends PreferenceFragment implements RadioGroup.OnCh Settings.System.putInt(getContext().getContentResolver(), WideModeSwitch.SETTINGS_KEY, 0); Utils.writeValue(OnePlusModeSwitch.getFile(mContext), "0"); Settings.System.putInt(getContext().getContentResolver(), OnePlusModeSwitch.SETTINGS_KEY, 0); + Utils.writeValue(AdobeRGBModeSwitch.getFile(mContext), "0"); + Settings.System.putInt(getContext().getContentResolver(), AdobeRGBModeSwitch.SETTINGS_KEY, 0); Utils.writeValue(SRGBModeSwitch.getFile(mContext), "0"); Settings.System.putInt(getContext().getContentResolver(), SRGBModeSwitch.SETTINGS_KEY, 0); } else if (checkedId == R.id.wide_mode) { @@ -118,6 +125,8 @@ public class PanelSettings extends PreferenceFragment implements RadioGroup.OnCh Settings.System.putInt(getContext().getContentResolver(), WideModeSwitch.SETTINGS_KEY, 1); Utils.writeValue(OnePlusModeSwitch.getFile(mContext), "0"); Settings.System.putInt(getContext().getContentResolver(), OnePlusModeSwitch.SETTINGS_KEY, 0); + Utils.writeValue(AdobeRGBModeSwitch.getFile(mContext), "0"); + Settings.System.putInt(getContext().getContentResolver(), AdobeRGBModeSwitch.SETTINGS_KEY, 0); Utils.writeValue(SRGBModeSwitch.getFile(mContext), "0"); Settings.System.putInt(getContext().getContentResolver(), SRGBModeSwitch.SETTINGS_KEY, 0); } else if (checkedId == R.id.night_mode) { @@ -129,6 +138,8 @@ public class PanelSettings extends PreferenceFragment implements RadioGroup.OnCh Settings.System.putInt(getContext().getContentResolver(), WideModeSwitch.SETTINGS_KEY, 0); Utils.writeValue(OnePlusModeSwitch.getFile(mContext), "0"); Settings.System.putInt(getContext().getContentResolver(), OnePlusModeSwitch.SETTINGS_KEY, 0); + Utils.writeValue(AdobeRGBModeSwitch.getFile(mContext), "0"); + Settings.System.putInt(getContext().getContentResolver(), AdobeRGBModeSwitch.SETTINGS_KEY, 0); Utils.writeValue(SRGBModeSwitch.getFile(mContext), "0"); Settings.System.putInt(getContext().getContentResolver(), SRGBModeSwitch.SETTINGS_KEY, 0); } else if (checkedId == R.id.oneplus_mode) { @@ -140,6 +151,8 @@ public class PanelSettings extends PreferenceFragment implements RadioGroup.OnCh Settings.System.putInt(getContext().getContentResolver(), WideModeSwitch.SETTINGS_KEY, 0); Utils.writeValue(OnePlusModeSwitch.getFile(mContext), "1"); Settings.System.putInt(getContext().getContentResolver(), OnePlusModeSwitch.SETTINGS_KEY, 1); + Utils.writeValue(AdobeRGBModeSwitch.getFile(mContext), "0"); + Settings.System.putInt(getContext().getContentResolver(), AdobeRGBModeSwitch.SETTINGS_KEY, 0); Utils.writeValue(SRGBModeSwitch.getFile(mContext), "0"); Settings.System.putInt(getContext().getContentResolver(), SRGBModeSwitch.SETTINGS_KEY, 0); } else if (checkedId == R.id.off_mode) { @@ -151,6 +164,21 @@ public class PanelSettings extends PreferenceFragment implements RadioGroup.OnCh Settings.System.putInt(getContext().getContentResolver(), WideModeSwitch.SETTINGS_KEY, 0); Utils.writeValue(OnePlusModeSwitch.getFile(mContext), "0"); Settings.System.putInt(getContext().getContentResolver(), OnePlusModeSwitch.SETTINGS_KEY, 0); + Utils.writeValue(AdobeRGBModeSwitch.getFile(mContext), "0"); + Settings.System.putInt(getContext().getContentResolver(), AdobeRGBModeSwitch.SETTINGS_KEY, 0); + Utils.writeValue(SRGBModeSwitch.getFile(mContext), "0"); + Settings.System.putInt(getContext().getContentResolver(), SRGBModeSwitch.SETTINGS_KEY, 0); + } else if (checkedId == R.id.adobergb_mode) { + Utils.writeValue(NightModeSwitch.getFile(mContext), "0"); + Settings.System.putInt(getContext().getContentResolver(), NightModeSwitch.SETTINGS_KEY, 0); + Utils.writeValue(DCIModeSwitch.getFile(mContext), "0"); + Settings.System.putInt(getContext().getContentResolver(), DCIModeSwitch.SETTINGS_KEY, 0); + Utils.writeValue(WideModeSwitch.getFile(mContext), "0"); + Settings.System.putInt(getContext().getContentResolver(), WideModeSwitch.SETTINGS_KEY, 0); + Utils.writeValue(OnePlusModeSwitch.getFile(mContext), "0"); + Settings.System.putInt(getContext().getContentResolver(), OnePlusModeSwitch.SETTINGS_KEY, 0); + Utils.writeValue(AdobeRGBModeSwitch.getFile(mContext), "1"); + Settings.System.putInt(getContext().getContentResolver(), AdobeRGBModeSwitch.SETTINGS_KEY, 1); Utils.writeValue(SRGBModeSwitch.getFile(mContext), "0"); Settings.System.putInt(getContext().getContentResolver(), SRGBModeSwitch.SETTINGS_KEY, 0); } diff --git a/src/com/aicp/device/Startup.java b/src/com/aicp/device/Startup.java index 09057bb..99e3e23 100644 --- a/src/com/aicp/device/Startup.java +++ b/src/com/aicp/device/Startup.java @@ -61,6 +61,9 @@ public class Startup extends BroadcastReceiver { boolean enabled = sharedPrefs.getBoolean(DeviceSettings.KEY_SRGB_SWITCH, false); Settings.System.putInt(resolver, SRGBModeSwitch.SETTINGS_KEY, enabled ? 1 : 0); + enabled = sharedPrefs.getBoolean(DeviceSettings.KEY_ADOBERGB_SWITCH, false); + Settings.System.putInt(resolver, AdobeRGBModeSwitch.SETTINGS_KEY, enabled ? 1 : 0); + enabled = sharedPrefs.getBoolean(DeviceSettings.KEY_HBM_SWITCH, false); Settings.System.putInt(resolver, HBMModeSwitch.SETTINGS_KEY, enabled ? 1 : 0); @@ -194,6 +197,9 @@ public class Startup extends BroadcastReceiver { enabled = Settings.System.getInt(resolver, SRGBModeSwitch.SETTINGS_KEY, 0) != 0; restore(SRGBModeSwitch.getFile(context), enabled); + enabled = Settings.System.getInt(resolver, AdobeRGBModeSwitch.SETTINGS_KEY, 0) != 0; + restore(AdobeRGBModeSwitch.getFile(context), enabled); + enabled = Settings.System.getInt(resolver, DCDModeSwitch.SETTINGS_KEY, 0) != 0; restore(DCDModeSwitch.getFile(context), enabled); |
