From 02624f240fdfeab58ac22d3a120e013959cba0a4 Mon Sep 17 00:00:00 2001 From: sbrissen Date: Tue, 23 Jul 2013 15:17:41 -0400 Subject: DeviceSettings: Disable touchkey timeout if it is not supported, move mdnie sysfs files to config.xml to allow them to be overriden Change-Id: Ib6cfc12704d3272cc3a66fbd44822faf4863c04e --- DeviceSettings/res/values/config.xml | 6 ++++++ DeviceSettings/src/com/cyanogenmod/settings/device/CABC.java | 12 +++++++----- .../cyanogenmod/settings/device/ScreenFragmentActivity.java | 11 +++++++---- .../src/com/cyanogenmod/settings/device/mDNIeMode.java | 12 +++++++----- .../src/com/cyanogenmod/settings/device/mDNIeNegative.java | 12 +++++++----- .../src/com/cyanogenmod/settings/device/mDNIeScenario.java | 12 +++++++----- 6 files changed, 41 insertions(+), 24 deletions(-) diff --git a/DeviceSettings/res/values/config.xml b/DeviceSettings/res/values/config.xml index 5fdb6ac..5e4be8f 100644 --- a/DeviceSettings/res/values/config.xml +++ b/DeviceSettings/res/values/config.xml @@ -49,4 +49,10 @@ true + + "/sys/class/lcd/panel/power_reduce" + "/sys/class/mdnie/mdnie/scenario" + "/sys/class/mdnie/mdnie/mode" + "/sys/class/mdnie/mdnie/negative" + diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/CABC.java b/DeviceSettings/src/com/cyanogenmod/settings/device/CABC.java index af247d8..9e0ab7c 100644 --- a/DeviceSettings/src/com/cyanogenmod/settings/device/CABC.java +++ b/DeviceSettings/src/com/cyanogenmod/settings/device/CABC.java @@ -26,15 +26,16 @@ import android.util.AttributeSet; public class CABC extends CheckBoxPreference implements OnPreferenceChangeListener { + private static String FILE = null; + public CABC(Context context, AttributeSet attrs) { super(context, attrs); this.setOnPreferenceChangeListener(this); + FILE = context.getResources().getString(R.string.mdnie_cabc_sysfs_file); } - private static final String FILE = "/sys/class/lcd/panel/power_reduce"; - - public static boolean isSupported() { - return Utils.fileExists(FILE); + public static boolean isSupported(String filePath) { + return Utils.fileExists(filePath); } /** @@ -42,7 +43,8 @@ public class CABC extends CheckBoxPreference implements OnPreferenceChangeListen * @param context The context to read the SharedPreferences from */ public static void restore(Context context) { - if (!isSupported()) { + FILE = context.getResources().getString(R.string.mdnie_cabc_sysfs_file); + if (!isSupported(FILE)) { return; } diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/ScreenFragmentActivity.java b/DeviceSettings/src/com/cyanogenmod/settings/device/ScreenFragmentActivity.java index f5c33b5..e7e1b33 100644 --- a/DeviceSettings/src/com/cyanogenmod/settings/device/ScreenFragmentActivity.java +++ b/DeviceSettings/src/com/cyanogenmod/settings/device/ScreenFragmentActivity.java @@ -42,6 +42,7 @@ public class ScreenFragmentActivity extends PreferenceFragment { private mDNIeNegative mmDNIeNegative; private LedFade mLedFade; private CheckBoxPreference mTouchKey; + private TouchkeyTimeout mTouchKeyTimeout; private static boolean sSPenSupported; private static boolean sTouchkeySupport; @@ -80,10 +81,12 @@ public class ScreenFragmentActivity extends PreferenceFragment { mTouchKey = (CheckBoxPreference)preferenceScreen.findPreference(DeviceSettings.KEY_TOUCHKEY_LIGHT); mTouchKey.setEnabled(sTouchkeySupport); + mTouchKeyTimeout = (TouchkeyTimeout)preferenceScreen.findPreference(DeviceSettings.KEY_TOUCHKEY_TIMEOUT); + if (mTouchKey.isChecked() && mTouchKey.isEnabled()) { - preferenceScreen.findPreference(DeviceSettings.KEY_TOUCHKEY_TIMEOUT).setEnabled(true); + mTouchKeyTimeout.setEnabled(mTouchKeyTimeout.isSupported()); } else { - preferenceScreen.findPreference(DeviceSettings.KEY_TOUCHKEY_TIMEOUT).setEnabled(false); + mTouchKeyTimeout.setEnabled(false); } /* S-Pen */ @@ -106,11 +109,11 @@ public class ScreenFragmentActivity extends PreferenceFragment { if (((CheckBoxPreference)preference).isChecked()) { Utils.writeValue(FILE_TOUCHKEY_DISABLE, "0"); Utils.writeValue(FILE_TOUCHKEY_BRIGHTNESS, "1"); - preferenceScreen.findPreference(DeviceSettings.KEY_TOUCHKEY_TIMEOUT).setEnabled(true); + mTouchKeyTimeout.setEnabled(mTouchKeyTimeout.isSupported()); } else { Utils.writeValue(FILE_TOUCHKEY_DISABLE, "1"); Utils.writeValue(FILE_TOUCHKEY_BRIGHTNESS, "2"); - preferenceScreen.findPreference(DeviceSettings.KEY_TOUCHKEY_TIMEOUT).setEnabled(false); + mTouchKeyTimeout.setEnabled(false); } } return true; diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeMode.java b/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeMode.java index 7969637..2e473e6 100644 --- a/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeMode.java +++ b/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeMode.java @@ -27,15 +27,16 @@ import android.preference.PreferenceManager; public class mDNIeMode extends ListPreference implements OnPreferenceChangeListener { + private static String FILE = null; + public mDNIeMode(Context context, AttributeSet attrs) { super(context, attrs); this.setOnPreferenceChangeListener(this); + FILE = context.getResources().getString(R.string.mdnie_mode_sysfs_file); } - private static final String FILE = "/sys/class/mdnie/mdnie/mode"; - - public static boolean isSupported() { - return Utils.fileExists(FILE); + public static boolean isSupported(String filePath) { + return Utils.fileExists(filePath); } /** @@ -43,7 +44,8 @@ public class mDNIeMode extends ListPreference implements OnPreferenceChangeListe * @param context The context to read the SharedPreferences from */ public static void restore(Context context) { - if (!isSupported()) { + FILE = context.getResources().getString(R.string.mdnie_mode_sysfs_file); + if (!isSupported(FILE)) { return; } diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeNegative.java b/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeNegative.java index c2ccc7b..3851c85 100644 --- a/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeNegative.java +++ b/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeNegative.java @@ -27,15 +27,16 @@ import android.preference.PreferenceManager; public class mDNIeNegative extends ListPreference implements OnPreferenceChangeListener { + private static String FILE = null; + public mDNIeNegative(Context context, AttributeSet attrs) { super(context, attrs); this.setOnPreferenceChangeListener(this); + FILE = context.getResources().getString(R.string.mdnie_negative_sysfs_file); } - private static final String FILE = "/sys/class/mdnie/mdnie/negative"; - - public static boolean isSupported() { - return Utils.fileExists(FILE); + public static boolean isSupported(String filePath) { + return Utils.fileExists(filePath); } /** @@ -43,7 +44,8 @@ public class mDNIeNegative extends ListPreference implements OnPreferenceChangeL * @param context The context to read the SharedPreferences from */ public static void restore(Context context) { - if (!isSupported()) { + FILE = context.getResources().getString(R.string.mdnie_negative_sysfs_file); + if (!isSupported(FILE)) { return; } diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeScenario.java b/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeScenario.java index a9c935a..2a852a3 100644 --- a/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeScenario.java +++ b/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeScenario.java @@ -27,15 +27,16 @@ import android.preference.PreferenceManager; public class mDNIeScenario extends ListPreference implements OnPreferenceChangeListener { + private static String FILE = null; + public mDNIeScenario(Context context, AttributeSet attrs) { super(context,attrs); this.setOnPreferenceChangeListener(this); + FILE = context.getResources().getString(R.string.mdnie_scenario_sysfs_file); } - private static final String FILE = "/sys/class/mdnie/mdnie/scenario"; - - public static boolean isSupported() { - return Utils.fileExists(FILE); + public static boolean isSupported(String filePath) { + return Utils.fileExists(filePath); } /** @@ -43,7 +44,8 @@ public class mDNIeScenario extends ListPreference implements OnPreferenceChangeL * @param context The context to read the SharedPreferences from */ public static void restore(Context context) { - if (!isSupported()) { + FILE = context.getResources().getString(R.string.mdnie_scenario_sysfs_file); + if (!isSupported(FILE)) { return; } -- cgit v1.1