diff options
author | Javier Ferrer <javi.f.o@gmail.com> | 2013-06-08 02:18:27 +0200 |
---|---|---|
committer | Daniel Hillenbrand <codeworkx@cyanogenmod.org> | 2013-06-09 11:27:08 +0200 |
commit | 2abc20c0daf70b63ae00569e3fb20d21118f909c (patch) | |
tree | 9cd3e79c2fa3f628a615a91ff95dab7254acabe2 /DeviceSettings | |
parent | ff2814916614673220ef719745e00f11a38dca57 (diff) | |
download | device_samsung_i9300-2abc20c0daf70b63ae00569e3fb20d21118f909c.zip device_samsung_i9300-2abc20c0daf70b63ae00569e3fb20d21118f909c.tar.gz device_samsung_i9300-2abc20c0daf70b63ae00569e3fb20d21118f909c.tar.bz2 |
i9300: advanced setting: add content adaptive backlight control
Change-Id: I8979a7434265d76172d6d0180b37abaef61d8aaa
Diffstat (limited to 'DeviceSettings')
11 files changed, 147 insertions, 61 deletions
diff --git a/DeviceSettings/Android.mk b/DeviceSettings/Android.mk index 12c8de5..6605185 100644 --- a/DeviceSettings/Android.mk +++ b/DeviceSettings/Android.mk @@ -7,7 +7,7 @@ LOCAL_STATIC_JAVA_LIBRARIES := android-support-v13 LOCAL_SRC_FILES := $(call all-java-files-under, src) -LOCAL_PACKAGE_NAME := GalaxyS3Settings +LOCAL_PACKAGE_NAME := DeviceSettings LOCAL_CERTIFICATE := platform include $(BUILD_PACKAGE) diff --git a/DeviceSettings/res/values/strings.xml b/DeviceSettings/res/values/strings.xml index 5570385..1bf9807 100644 --- a/DeviceSettings/res/values/strings.xml +++ b/DeviceSettings/res/values/strings.xml @@ -2,22 +2,15 @@ <resources> <string name="app_name">Advanced settings</string> - <string name="category_dock_title">Dock</string> - <string name="dockaudio_subcat_title">Dock Audio</string> - <string name="use_dock_audio_title_head">Use Dock USB Audio</string> - <string name="use_dock_audio_summary_head">Use the passive audio out on the dock</string> - - <string name="category_haptic_title">Haptic</string> - <string name="vibrator_subcat_title">Vibrator</string> - <string name="vibrator_intensity_title_head">Vibrator Intensity</string> - <string name="vibrator_intensity_summary_head">Set vibrator intensity</string> - - <string name="category_radio_title">Radio</string> - <string name="hspa_title_head">HSPA</string> - <string name="hspa_summary_head">Enable HSDPA/HSUPA</string> - + <!-- Screen --> <string name="category_screen_title">Screen</string> <string name="mdnie_subcat_title">Colors</string> + + <!-- CABC --> + <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> @@ -25,10 +18,12 @@ <string name="mdnie_negative_title_head">Negative Mode</string> <string name="mdnie_negative_summary_head">Enable/Disable inverted colors</string> + <!-- LED --> <string name="led_subcat_title">Notification LED</string> <string name="led_fade_title_head">LED Fading</string> <string name="led_fade_summary_head">Enable LED smooth fading instead of sharp blinking.</string> + <!-- Touchkey --> <string name="touchkey_subcat_title">Touchkeys</string> <string name="touchkey_light_title_head">Backlight</string> <string name="touchkey_light_summary_off">Enable backlight</string> @@ -36,4 +31,21 @@ <string name="touchkey_timeout_title_head">Backlight timeout</string> <string name="touchkey_timeout_summary_head">Set timeout for the backlight</string> + <!-- Dock --> + <string name="category_dock_title">Dock</string> + <string name="dockaudio_subcat_title">Dock Audio</string> + <string name="use_dock_audio_title_head">Use Dock USB Audio</string> + <string name="use_dock_audio_summary_head">Use the passive audio out on the dock</string> + + <!-- Haptic --> + <string name="category_haptic_title">Haptic</string> + <string name="vibrator_subcat_title">Vibrator</string> + <string name="vibrator_intensity_title_head">Vibrator Intensity</string> + <string name="vibrator_intensity_summary_head">Set vibrator intensity</string> + + <!-- Radio --> + <string name="category_radio_title">Radio</string> + <string name="hspa_title_head">HSPA</string> + <string name="hspa_summary_head">Enable HSDPA/HSUPA</string> + </resources> diff --git a/DeviceSettings/res/xml/screen_preferences.xml b/DeviceSettings/res/xml/screen_preferences.xml index aff39c0..313f22c 100644 --- a/DeviceSettings/res/xml/screen_preferences.xml +++ b/DeviceSettings/res/xml/screen_preferences.xml @@ -1,59 +1,69 @@ <?xml version="1.0" encoding="UTF-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> + <!-- Screen --> <PreferenceCategory - android:title="@string/mdnie_subcat_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/mdnie_subcat_title"> - <!-- 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="0" /> + <!-- 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 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 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 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="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" /> </PreferenceCategory> + <!-- LED --> <PreferenceCategory - android:title="@string/led_subcat_title"> - <!-- LED fading mode --> - <com.cyanogenmod.settings.device.LedFade + android:title="@string/led_subcat_title"> + <!-- LED fading mode --> + <com.cyanogenmod.settings.device.LedFade android:key="led_fade" android:title="@string/led_fade_title_head" android:summary="@string/led_fade_summary_head" android:entries="@array/led_fade_entries" - android:entryValues="@array/led_fade_entries_values" - android:defaultValue="1" /> + android:entryValues="@array/led_fade_entries_values" + android:defaultValue="1" /> </PreferenceCategory> + <!-- Touchkeys --> <PreferenceCategory - android:title="@string/touchkey_subcat_title"> - <!-- Touchkey backlight --> - <CheckBoxPreference + android:title="@string/touchkey_subcat_title"> + <!-- Touchkey backlight --> + <CheckBoxPreference android:key="touchkey_light" android:title="@string/touchkey_light_title_head" android:summaryOff="@string/touchkey_light_summary_off" android:summaryOn="@string/touchkey_light_summary_on" - 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" 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 6c5fc67..3284e39 100644 --- a/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java +++ b/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java @@ -36,14 +36,15 @@ 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_HSPA = "hspa"; - public static final String KEY_VIBRATOR_INTENSITY = "vibrator_intensity"; + 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"; public static final String KEY_LED_FADE = "led_fade"; public static final String KEY_TOUCHKEY_LIGHT = "touchkey_light"; public static final String KEY_TOUCHKEY_TIMEOUT = "touchkey_timeout"; + public static final String KEY_HSPA = "hspa"; + public static final String KEY_VIBRATOR_INTENSITY = "vibrator_intensity"; public static final String KEY_USE_DOCK_AUDIO = "dock_audio"; ViewPager mViewPager; diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/DockFragmentActivity.java b/DeviceSettings/src/com/cyanogenmod/settings/device/DockFragmentActivity.java index c57cd63..1adf774 100644 --- a/DeviceSettings/src/com/cyanogenmod/settings/device/DockFragmentActivity.java +++ b/DeviceSettings/src/com/cyanogenmod/settings/device/DockFragmentActivity.java @@ -35,7 +35,7 @@ import com.cyanogenmod.settings.device.R; public class DockFragmentActivity extends PreferenceFragment { private static final String PREF_ENABLED = "1"; - private static final String TAG = "GalaxyS3Settings_Dock"; + private static final String TAG = "DeviceSettings_Dock"; @Override public void onCreate(Bundle savedInstanceState) { diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/HapticFragmentActivity.java b/DeviceSettings/src/com/cyanogenmod/settings/device/HapticFragmentActivity.java index 0f3313d..176d80a 100644 --- a/DeviceSettings/src/com/cyanogenmod/settings/device/HapticFragmentActivity.java +++ b/DeviceSettings/src/com/cyanogenmod/settings/device/HapticFragmentActivity.java @@ -33,7 +33,7 @@ import com.cyanogenmod.settings.device.R; public class HapticFragmentActivity extends PreferenceFragment { private static final String PREF_ENABLED = "1"; - private static final String TAG = "GalaxyS3Settings_Haptic"; + private static final String TAG = "DeviceSettings_Haptic"; @Override public void onCreate(Bundle savedInstanceState) { diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/RadioFragmentActivity.java b/DeviceSettings/src/com/cyanogenmod/settings/device/RadioFragmentActivity.java index 62b855c..d094ef2 100644 --- a/DeviceSettings/src/com/cyanogenmod/settings/device/RadioFragmentActivity.java +++ b/DeviceSettings/src/com/cyanogenmod/settings/device/RadioFragmentActivity.java @@ -33,7 +33,7 @@ import com.cyanogenmod.settings.device.R; public class RadioFragmentActivity extends PreferenceFragment { private static final String PREF_ENABLED = "1"; - private static final String TAG = "GalaxyS2Parts_Radio"; + private static final String TAG = "DeviceSettings_Radio"; @Override public void onCreate(Bundle savedInstanceState) { diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/ScreenFragmentActivity.java b/DeviceSettings/src/com/cyanogenmod/settings/device/ScreenFragmentActivity.java index 36180ae..ea0e429 100644 --- a/DeviceSettings/src/com/cyanogenmod/settings/device/ScreenFragmentActivity.java +++ b/DeviceSettings/src/com/cyanogenmod/settings/device/ScreenFragmentActivity.java @@ -33,11 +33,12 @@ import com.cyanogenmod.settings.device.R; public class ScreenFragmentActivity extends PreferenceFragment { private static final String PREF_ENABLED = "1"; - private static final String TAG = "GalaxyS3Settings_Screen"; + private static final String TAG = "DeviceSettings_Screen"; private mDNIeScenario mmDNIeScenario; private mDNIeMode mmDNIeMode; private mDNIeNegative mmDNIeNegative; private LedFade mLedFade; + private CABC mCABC; private static final String FILE_TOUCHKEY_BRIGHTNESS = "/sys/class/sec/sec_touchkey/brightness"; private static final String FILE_TOUCHKEY_DISABLE = "/sys/class/sec/sec_touchkey/force_disable"; @@ -47,8 +48,11 @@ public class ScreenFragmentActivity extends PreferenceFragment { super.onCreate(savedInstanceState); 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 56b903b..8acfd07 100644 --- a/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java +++ b/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java @@ -29,6 +29,7 @@ public class Startup extends BroadcastReceiver { Hspa.restore(context); RadioFragmentActivity.restore(context); ScreenFragmentActivity.restore(context); + CABC.restore(context); mDNIeScenario.restore(context); mDNIeMode.restore(context); mDNIeNegative.restore(context); diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/Utils.java b/DeviceSettings/src/com/cyanogenmod/settings/device/Utils.java index d4df92f..bd8eb65 100644 --- a/DeviceSettings/src/com/cyanogenmod/settings/device/Utils.java +++ b/DeviceSettings/src/com/cyanogenmod/settings/device/Utils.java @@ -29,9 +29,9 @@ import android.content.Context; public class Utils { - private static final String TAG = "GalaxyS3Settings_Utils"; - private static final String TAG_READ = "GalaxyS3Settings_Utils_Read"; - private static final String TAG_WRITE = "GalaxyS3Settings_Utils_Write"; + private static final String TAG = "DeviceSettings_Utils"; + private static final String TAG_READ = "DeviceSettings_Utils_Read"; + private static final String TAG_WRITE = "DeviceSettings_Utils_Write"; /** * Write a string value to the specified file. |