diff options
Diffstat (limited to 'DeviceSettings/src')
8 files changed, 74 insertions, 10 deletions
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. |