From 01917c8934400b75dd4e1af6c9dd2a7632e9a51f Mon Sep 17 00:00:00 2001 From: Daniel Hillenbrand Date: Sun, 9 Jun 2013 11:07:54 +0200 Subject: [PATCH] galaxys2: advanced settings: add content adaptive backlight control Change-Id: I325d9663d7d1b82a7ebfb112e983a485689b063b --- DeviceSettings/res/values/strings.xml | 12 ++ DeviceSettings/res/xml/screen_preferences.xml | 106 +++++++++--------- .../com/cyanogenmod/settings/device/CABC.java | 58 ++++++++++ .../settings/device/DeviceSettings.java | 1 + .../device/ScreenFragmentActivity.java | 4 + .../cyanogenmod/settings/device/Startup.java | 1 + 6 files changed, 132 insertions(+), 50 deletions(-) create mode 100644 DeviceSettings/src/com/cyanogenmod/settings/device/CABC.java 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 @@ Reset to default + Screen Colors + + + CABC + Enable content adaptive backlight control + + Scenario Set the mDNIe Scenario Mode @@ -17,16 +24,19 @@ Screen Gamma Set screen gamma value + Touchscreen Touch sensitivity Set touch panel sensitivity + Touchkeys Enable keys backlight Light up touchkeys when screen is on Backlight timeout Delay after a keypress before backlight turns off + Sensors Accelerometer Use calibration data @@ -45,10 +55,12 @@ Adjust the strength of the vibration feedback Values higher than %1$d are not recommended + Radio HSPA Enable HSDPA/HSUPA + Dock Audio Use Dock USB Audio 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 @@ + android:title="@string/app_name"> - - - + android:title="@string/screen_colors_title"> + + - - + + - - + + - - + + - - + + + + - + android:entryValues="@array/panel_gamma_entries_values" + android:defaultValue="0" /> + + - + + - - + - + + android:defaultValue="3" /> + 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);