summaryrefslogtreecommitdiffstats
path: root/DeviceSettings/src/com/cyanogenmod
diff options
context:
space:
mode:
Diffstat (limited to 'DeviceSettings/src/com/cyanogenmod')
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java2
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/SPenPowerSavingMode.java61
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/ScreenFragmentActivity.java26
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java1
4 files changed, 86 insertions, 4 deletions
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java b/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java
index 486fe79..310b535 100644
--- a/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java
@@ -46,6 +46,8 @@ public class DeviceSettings extends FragmentActivity {
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";
+ public static final String KEY_CATEGORY_SPEN = "category_spen";
+ 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..e80edd8
--- /dev/null
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/SPenPowerSavingMode.java
@@ -0,0 +1,61 @@
+/*
+ * 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 String FILE_PATH = null;
+
+ public SPenPowerSavingMode(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ this.setOnPreferenceChangeListener(this);
+ FILE_PATH = context.getResources().getString(R.string.spen_powersaving_sysfs_file);
+ }
+
+ public static boolean isSupported(String filePath) {
+ return Utils.fileExists(filePath);
+ }
+
+ /**
+ * Restore s-pen setting from SharedPreferences. (Write to kernel.)
+ * @param context The context to read the SharedPreferences from
+ */
+ public static void restore(Context context) {
+ FILE_PATH = context.getResources().getString(R.string.spen_powersaving_sysfs_file);
+
+ if (!isSupported(FILE_PATH)) {
+ return;
+ }
+
+ SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
+ Utils.writeValue(FILE_PATH, sharedPrefs.getBoolean(DeviceSettings.KEY_SPEN_POWER_SAVING_MODE, false) ? "1" : "0");
+ }
+
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ Utils.writeValue(FILE_PATH, ((Boolean) newValue) ? "1" : "0");
+ return true;
+ }
+}
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/ScreenFragmentActivity.java b/DeviceSettings/src/com/cyanogenmod/settings/device/ScreenFragmentActivity.java
index 5a1576d..9efe06d 100644
--- a/DeviceSettings/src/com/cyanogenmod/settings/device/ScreenFragmentActivity.java
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/ScreenFragmentActivity.java
@@ -17,12 +17,14 @@
package com.cyanogenmod.settings.device;
import android.content.Context;
+import android.content.res.Resources;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
+import android.preference.PreferenceCategory;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
import android.preference.PreferenceScreen;
@@ -40,6 +42,8 @@ public class ScreenFragmentActivity extends PreferenceFragment {
private mDNIeNegative mmDNIeNegative;
private LedFade mLedFade;
+ private static boolean sSPenSupported;
+
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";
@@ -48,11 +52,14 @@ public class ScreenFragmentActivity extends PreferenceFragment {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.screen_preferences);
- PreferenceScreen prefSet = getPreferenceScreen();
+ PreferenceScreen preferenceScreen = getPreferenceScreen();
+ Resources res = getResources();
+ /* CABC */
mCABC = (CABC) findPreference(DeviceSettings.KEY_CABC);
mCABC.setEnabled(CABC.isSupported());
+ /* mDNIe */
mmDNIeScenario = (mDNIeScenario) findPreference(DeviceSettings.KEY_MDNIE_SCENARIO);
mmDNIeScenario.setEnabled(mDNIeScenario.isSupported());
@@ -62,13 +69,24 @@ public class ScreenFragmentActivity extends PreferenceFragment {
mmDNIeNegative = (mDNIeNegative) findPreference(DeviceSettings.KEY_MDNIE_NEGATIVE);
mmDNIeNegative.setEnabled(mDNIeNegative.isSupported());
+ /* LED */
mLedFade = (LedFade) findPreference(DeviceSettings.KEY_LED_FADE);
mLedFade.setEnabled(LedFade.isSupported());
- if (((CheckBoxPreference)prefSet.findPreference(DeviceSettings.KEY_TOUCHKEY_LIGHT)).isChecked()) {
- prefSet.findPreference(DeviceSettings.KEY_TOUCHKEY_TIMEOUT).setEnabled(true);
+ /* Touchkey */
+ if (((CheckBoxPreference)preferenceScreen.findPreference(DeviceSettings.KEY_TOUCHKEY_LIGHT)).isChecked()) {
+ preferenceScreen.findPreference(DeviceSettings.KEY_TOUCHKEY_TIMEOUT).setEnabled(true);
} else {
- prefSet.findPreference(DeviceSettings.KEY_TOUCHKEY_TIMEOUT).setEnabled(false);
+ preferenceScreen.findPreference(DeviceSettings.KEY_TOUCHKEY_TIMEOUT).setEnabled(false);
+ }
+
+ /* S-Pen */
+ String spenFilePath = res.getString(R.string.spen_sysfs_file);
+ sSPenSupported = SPenPowerSavingMode.isSupported(spenFilePath);
+
+ PreferenceCategory spenCategory = (PreferenceCategory) findPreference(DeviceSettings.KEY_CATEGORY_SPEN);
+ if (!sSPenSupported) {
+ preferenceScreen.removePreference(spenCategory);
}
}
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java b/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java
index 950220e..d93d6bf 100644
--- a/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java
@@ -36,5 +36,6 @@ public class Startup extends BroadcastReceiver {
LedFade.restore(context);
TouchkeyTimeout.restore(context);
VibratorTuningPreference.restore(context);
+ SPenPowerSavingMode.restore(context);
}
}