summaryrefslogtreecommitdiffstats
path: root/DeviceSettings
diff options
context:
space:
mode:
authorDaniel Hillenbrand <codeworkx@cyanogenmod.org>2013-06-09 11:07:54 +0200
committerDaniel Hillenbrand <codeworkx@cyanogenmod.org>2013-06-09 11:11:02 +0200
commit01917c8934400b75dd4e1af6c9dd2a7632e9a51f (patch)
tree144745f514b48bb9cb90d9f6b17421dd7cdbc347 /DeviceSettings
parent036beb482d9e803dbc311b576dbd2850d29ddd16 (diff)
downloaddevice_samsung_galaxys2-common-01917c8934400b75dd4e1af6c9dd2a7632e9a51f.zip
device_samsung_galaxys2-common-01917c8934400b75dd4e1af6c9dd2a7632e9a51f.tar.gz
device_samsung_galaxys2-common-01917c8934400b75dd4e1af6c9dd2a7632e9a51f.tar.bz2
galaxys2: advanced settings: add content adaptive backlight control
Change-Id: I325d9663d7d1b82a7ebfb112e983a485689b063b
Diffstat (limited to 'DeviceSettings')
-rw-r--r--DeviceSettings/res/values/strings.xml12
-rw-r--r--DeviceSettings/res/xml/screen_preferences.xml106
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/CABC.java58
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java1
-rwxr-xr-xDeviceSettings/src/com/cyanogenmod/settings/device/ScreenFragmentActivity.java4
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java1
6 files changed, 132 insertions, 50 deletions
diff --git a/DeviceSettings/res/values/strings.xml b/DeviceSettings/res/values/strings.xml
index 5d0a427..6fd764d 100644
--- a/DeviceSettings/res/values/strings.xml
+++ b/DeviceSettings/res/values/strings.xml
@@ -4,8 +4,15 @@
<string name="defaults_button">Reset to default</string>
+ <!-- Screen Preference -->
<string name="category_screen_title">Screen</string>
<string name="screen_colors_title">Colors</string>
+
+ <!-- Content adaptive backlight control -->
+ <string name="cabc_title_head">CABC</string>
+ <string name="cabc_summary_head">Enable content adaptive backlight control</string>
+
+ <!-- mDNIe -->
<string name="mdnie_scenario_title_head">Scenario</string>
<string name="mdnie_scenario_summary_head">Set the mDNIe Scenario</string>
<string name="mdnie_mode_title_head">Mode</string>
@@ -17,16 +24,19 @@
<string name="panel_gamma_title_head">Screen Gamma</string>
<string name="panel_gamma_summary_head">Set screen gamma value</string>
+ <!-- Touchscreen tuning -->
<string name="touchscreen_subcat_title">Touchscreen</string>
<string name="touchscreen_sensitivity_title_head">Touch sensitivity</string>
<string name="touchscreen_sensitivity_summary_head">Set touch panel sensitivity</string>
+ <!-- Touchkey tuning -->
<string name="touchkey_subcat_title">Touchkeys</string>
<string name="touchkey_light_title_head">Enable keys backlight</string>
<string name="touchkey_light_summary_head">Light up touchkeys when screen is on</string>
<string name="touchkey_timeout_title_head">Backlight timeout</string>
<string name="touchkey_timeout_summary_head">Delay after a keypress before backlight turns off</string>
+ <!-- Sensors Preference -->
<string name="category_sensors_title">Sensors</string>
<string name="accelerometer_subcat_title">Accelerometer</string>
<string name="use_accelerometer_calibration_title_head">Use calibration data</string>
@@ -45,10 +55,12 @@
<string name="vibrator_tuning_summary_head">Adjust the strength of the vibration feedback</string>
<string name="vibrator_warning">Values higher than %1$d are not recommended</string>
+ <!-- Radio Preference -->
<string name="category_radio_title">Radio</string>
<string name="hspa_title_head">HSPA</string>
<string name="hspa_summary_head">Enable HSDPA/HSUPA</string>
+ <!-- Dock Preference -->
<string name="category_dock_title">Dock</string>
<string name="dockaudio_subcat_title">Audio</string>
<string name="use_dock_audio_title_head">Use Dock USB Audio</string>
diff --git a/DeviceSettings/res/xml/screen_preferences.xml b/DeviceSettings/res/xml/screen_preferences.xml
index d053bbd..0e05e3e 100644
--- a/DeviceSettings/res/xml/screen_preferences.xml
+++ b/DeviceSettings/res/xml/screen_preferences.xml
@@ -1,59 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- android:title="@string/app_name">
+ android:title="@string/app_name">
<PreferenceCategory
- android:title="@string/screen_colors_title">
-
- <!-- mDNIe Scenario modes -->
- <com.cyanogenmod.settings.device.mDNIeScenario
- android:key="mdnie_scenario"
- android:title="@string/mdnie_scenario_title_head"
- android:summary="@string/mdnie_scenario_summary_head"
- android:entries="@array/mdnie_scenario_entries"
- android:entryValues="@array/mdnie_scenario_entries_values"
- android:defaultValue="0" />
+ android:title="@string/screen_colors_title">
+ <!-- CABC -->
+ <com.cyanogenmod.settings.device.CABC
+ android:key="cabc"
+ android:title="@string/cabc_title_head"
+ android:summary="@string/cabc_summary_head"
+ android:defaultValue="true" />
- <!-- mDNIe Mode -->
- <com.cyanogenmod.settings.device.mDNIeMode
- android:key="mdnie_mode"
- android:title="@string/mdnie_mode_title_head"
- android:summary="@string/mdnie_mode_summary_head"
- android:entries="@array/mdnie_mode_entries"
- android:entryValues="@array/mdnie_mode_entries_values"
- android:defaultValue="1" />
+ <!-- mDNIe Scenario modes -->
+ <com.cyanogenmod.settings.device.mDNIeScenario
+ android:key="mdnie_scenario"
+ android:title="@string/mdnie_scenario_title_head"
+ android:summary="@string/mdnie_scenario_summary_head"
+ android:entries="@array/mdnie_scenario_entries"
+ android:entryValues="@array/mdnie_scenario_entries_values"
+ android:defaultValue="0" />
- <!-- mDNIe Negative mode -->
- <com.cyanogenmod.settings.device.mDNIeNegative
- android:key="mdnie_negative"
- android:title="@string/mdnie_negative_title_head"
- android:summary="@string/mdnie_negative_summary_head"
- android:entries="@array/mdnie_negative_entries"
- android:entryValues="@array/mdnie_negative_entries_values"
- android:defaultValue="0" />
+ <!-- mDNIe Mode -->
+ <com.cyanogenmod.settings.device.mDNIeMode
+ android:key="mdnie_mode"
+ android:title="@string/mdnie_mode_title_head"
+ android:summary="@string/mdnie_mode_summary_head"
+ android:entries="@array/mdnie_mode_entries"
+ android:entryValues="@array/mdnie_mode_entries_values"
+ android:defaultValue="1" />
- <!-- mDNIe Outdoor mode -->
- <com.cyanogenmod.settings.device.mDNIeOutdoor
- android:key="mdnie_outdoor"
- android:title="@string/mdnie_outdoor_title_head"
- android:summary="@string/mdnie_outdoor_summary_head"
- android:entries="@array/mdnie_outdoor_entries"
- android:entryValues="@array/mdnie_outdoor_entries_values"
- android:defaultValue="0" />
+ <!-- mDNIe Negative mode -->
+ <com.cyanogenmod.settings.device.mDNIeNegative
+ android:key="mdnie_negative"
+ android:title="@string/mdnie_negative_title_head"
+ android:summary="@string/mdnie_negative_summary_head"
+ android:entries="@array/mdnie_negative_entries"
+ android:entryValues="@array/mdnie_negative_entries_values"
+ android:defaultValue="0" />
- <!-- Panel gamma -->
- <com.cyanogenmod.settings.device.PanelGamma
+ <!-- mDNIe Outdoor mode -->
+ <com.cyanogenmod.settings.device.mDNIeOutdoor
+ android:key="mdnie_outdoor"
+ android:title="@string/mdnie_outdoor_title_head"
+ android:summary="@string/mdnie_outdoor_summary_head"
+ android:entries="@array/mdnie_outdoor_entries"
+ android:entryValues="@array/mdnie_outdoor_entries_values"
+ android:defaultValue="0" />
+
+ <!-- Panel gamma -->
+ <com.cyanogenmod.settings.device.PanelGamma
android:key="panel_gamma"
android:title="@string/panel_gamma_title_head"
android:summary="@string/panel_gamma_summary_head"
android:entries="@array/panel_gamma_entries"
- android:entryValues="@array/panel_gamma_entries_values"
- android:defaultValue="0" />
-
+ android:entryValues="@array/panel_gamma_entries_values"
+ android:defaultValue="0" />
</PreferenceCategory>
+
+ <!-- Touchscreen -->
<PreferenceCategory
- android:title="@string/touchscreen_subcat_title">
- <com.cyanogenmod.settings.device.TouchscreenSensitivity
+ android:title="@string/touchscreen_subcat_title">
+ <com.cyanogenmod.settings.device.TouchscreenSensitivity
android:key="touchscreen_sensitivity"
android:title="@string/touchscreen_sensitivity_title_head"
android:summary="@string/touchscreen_sensitivity_summary_head"
@@ -62,22 +69,21 @@
android:defaultValue="50" />
</PreferenceCategory>
+ <!-- Touchkeys -->
<PreferenceCategory
- android:title="@string/touchkey_subcat_title">
- <!-- Touchkey backlight -->
- <CheckBoxPreference
+ android:title="@string/touchkey_subcat_title">
+ <CheckBoxPreference
android:key="touchkey_light"
android:title="@string/touchkey_light_title_head"
android:summary="@string/touchkey_light_summary_head"
- android:defaultValue="true"
- />
- <com.cyanogenmod.settings.device.TouchkeyTimeout
+ android:defaultValue="true" />
+ <com.cyanogenmod.settings.device.TouchkeyTimeout
android:key="touchkey_timeout"
android:title="@string/touchkey_timeout_title_head"
android:summary="@string/touchkey_timeout_summary_head"
android:entries="@array/touchkey_timeout_entries"
android:entryValues="@array/touchkey_timeout_entries_values"
- android:defaultValue="3"
- />
+ android:defaultValue="3" />
</PreferenceCategory>
+
</PreferenceScreen>
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/CABC.java b/DeviceSettings/src/com/cyanogenmod/settings/device/CABC.java
new file mode 100644
index 0000000..af247d8
--- /dev/null
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/CABC.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2013 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.cyanogenmod.settings.device;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.preference.CheckBoxPreference;
+import android.preference.Preference;
+import android.preference.Preference.OnPreferenceChangeListener;
+import android.preference.PreferenceManager;
+import android.util.AttributeSet;
+
+public class CABC extends CheckBoxPreference implements OnPreferenceChangeListener {
+
+ public CABC(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ this.setOnPreferenceChangeListener(this);
+ }
+
+ private static final String FILE = "/sys/class/lcd/panel/power_reduce";
+
+ public static boolean isSupported() {
+ return Utils.fileExists(FILE);
+ }
+
+ /**
+ * Restore cabc setting from SharedPreferences. (Write to kernel.)
+ * @param context The context to read the SharedPreferences from
+ */
+ public static void restore(Context context) {
+ if (!isSupported()) {
+ return;
+ }
+
+ SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
+ Utils.writeValue(FILE, sharedPrefs.getBoolean(DeviceSettings.KEY_CABC, true) ? "1" : "0");
+ }
+
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ Utils.writeValue(FILE, (Boolean)newValue ? "1" : "0");
+ return true;
+ }
+
+}
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java b/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java
index c4ff285..9e35889 100644
--- a/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java
@@ -35,6 +35,7 @@ public class DeviceSettings extends FragmentActivity {
public static final String SHARED_PREFERENCES_BASENAME = "com.cyanogenmod.settings.device";
public static final String ACTION_UPDATE_PREFERENCES = "com.cyanogenmod.settings.device.UPDATE";
+ public static final String KEY_CABC = "cabc";
public static final String KEY_MDNIE_SCENARIO = "mdnie_scenario";
public static final String KEY_MDNIE_MODE = "mdnie_mode";
public static final String KEY_MDNIE_NEGATIVE = "mdnie_negative";
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/ScreenFragmentActivity.java b/DeviceSettings/src/com/cyanogenmod/settings/device/ScreenFragmentActivity.java
index 9ba40f7..29c08a9 100755
--- a/DeviceSettings/src/com/cyanogenmod/settings/device/ScreenFragmentActivity.java
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/ScreenFragmentActivity.java
@@ -37,6 +37,7 @@ public class ScreenFragmentActivity extends PreferenceFragment {
private static final String FILE_TOUCHKEY_DISABLE = "/sys/class/sec/sec_touchkey/force_disable";
private static final String FILE_TOUCHKEY_BRIGHTNESS = "/sys/class/sec/sec_touchkey/brightness";
+ private CABC mCABC;
private mDNIeScenario mmDNIeScenario;
private mDNIeMode mmDNIeMode;
private mDNIeNegative mmDNIeNegative;
@@ -51,6 +52,9 @@ public class ScreenFragmentActivity extends PreferenceFragment {
addPreferencesFromResource(R.xml.screen_preferences);
PreferenceScreen prefSet = getPreferenceScreen();
+ mCABC = (CABC) findPreference(DeviceSettings.KEY_CABC);
+ mCABC.setEnabled(CABC.isSupported());
+
mmDNIeScenario = (mDNIeScenario) findPreference(DeviceSettings.KEY_MDNIE_SCENARIO);
mmDNIeScenario.setEnabled(mDNIeScenario.isSupported());
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java b/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java
index e9c1b49..da05d7f 100644
--- a/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java
@@ -24,6 +24,7 @@ public class Startup extends BroadcastReceiver {
@Override
public void onReceive(final Context context, final Intent bootintent) {
+ CABC.restore(context);
DockFragmentActivity.restore(context);
HapticFragmentActivity.restore(context);
mDNIeScenario.restore(context);