diff options
author | Nebojsa Cvetkovic <nebkat@gmail.com> | 2013-02-19 21:09:32 +0000 |
---|---|---|
committer | Nebojsa Cvetkovic <nebkat@gmail.com> | 2013-02-19 21:09:32 +0000 |
commit | c1935baa9297523af64c2c0c57656ab543e5b182 (patch) | |
tree | bd3f7a332e93308cc70f803a9727f1917da2563e | |
parent | f7ad3af0a7a2aa64fa284d2968bbaf9c136f5860 (diff) | |
download | device_samsung_n7100-c1935baa9297523af64c2c0c57656ab543e5b182.zip device_samsung_n7100-c1935baa9297523af64c2c0c57656ab543e5b182.tar.gz device_samsung_n7100-c1935baa9297523af64c2c0c57656ab543e5b182.tar.bz2 |
DeviceParts: S-Pen Power Saving Mode
Change-Id: Iff65e5517f3f0e74c177ca88d4c0332a37f352b5
5 files changed, 73 insertions, 0 deletions
diff --git a/DeviceSettings/res/values/strings.xml b/DeviceSettings/res/values/strings.xml index 7a1ed16..c01afd5 100644 --- a/DeviceSettings/res/values/strings.xml +++ b/DeviceSettings/res/values/strings.xml @@ -24,6 +24,10 @@ <string name="led_fade_title_head">LED Fading</string> <string name="led_fade_summary_head">Enable LED smooth fading instead of sharp blinking.</string> + <string name="spen_subcat_title">S-Pen</string> + <string name="spen_power_save_title_head">S-Pen Power Saving Mode</string> + <string name="spen_power_save_summary_head">Disable stylus digitizer when S-Pen is in device</string> + <string name="touchkey_subcat_title">Touchkeys</string> <string name="touchkey_light_title_head">Backlight</string> <string name="touchkey_light_summary_off">Enable backlight</string> diff --git a/DeviceSettings/res/xml/screen_preferences.xml b/DeviceSettings/res/xml/screen_preferences.xml index aff39c0..09b484c 100644 --- a/DeviceSettings/res/xml/screen_preferences.xml +++ b/DeviceSettings/res/xml/screen_preferences.xml @@ -44,6 +44,15 @@ </PreferenceCategory> <PreferenceCategory + android:title="@string/spen_subcat_title"> + <!-- SPen power saving mode --> + <com.cyanogenmod.settings.device.SPenPowerSavingMode + android:key="spen_power_save" + android:title="@string/spen_power_save_title_head" + android:summary="@string/spen_power_save_summary_head" /> + </PreferenceCategory> + + <PreferenceCategory android:title="@string/touchkey_subcat_title"> <!-- Touchkey backlight --> <CheckBoxPreference diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java b/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java index 152e361..feb1f37 100644 --- a/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java +++ b/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java @@ -44,6 +44,7 @@ public class DeviceSettings extends FragmentActivity { 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_SPEN_POWER_SAVING_MODE = "spen_power_saving"; ViewPager mViewPager; TabsAdapter mTabsAdapter; diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/SPenPowerSavingMode.java b/DeviceSettings/src/com/cyanogenmod/settings/device/SPenPowerSavingMode.java new file mode 100644 index 0000000..719139f --- /dev/null +++ b/DeviceSettings/src/com/cyanogenmod/settings/device/SPenPowerSavingMode.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2012 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.Intent; +import android.content.SharedPreferences; +import android.util.AttributeSet; +import android.preference.CheckBoxPreference; +import android.preference.Preference; +import android.preference.Preference.OnPreferenceChangeListener; +import android.preference.PreferenceManager; + +public class SPenPowerSavingMode extends CheckBoxPreference implements OnPreferenceChangeListener { + + private static final String FILE = "/sys/class/sec/sec_epen/epen_saving_mode"; + + public SPenPowerSavingMode(Context context, AttributeSet attrs) { + super(context, attrs); + this.setOnPreferenceChangeListener(this); + } + + public static boolean isSupported() { + return Utils.fileExists(FILE); + } + + /** + * Restore s-pen 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_SPEN_POWER_SAVING_MODE, false) ? "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/Startup.java b/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java index dc9ec9c..a24185c 100644 --- a/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java +++ b/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java @@ -34,5 +34,6 @@ public class Startup extends BroadcastReceiver { LedFade.restore(context); VibratorIntensity.restore(context); TouchkeyTimeout.restore(context); + SPenPowerSavingMode.restore(context); } } |