summaryrefslogtreecommitdiffstats
path: root/AdvancedDisplay/src/com/cyanogenmod/settings/device/mDNIeMode.java
diff options
context:
space:
mode:
authorRicardo Cerqueira <cyanogenmod@cerqueira.org>2014-02-02 01:14:13 +0000
committerRicardo Cerqueira <cyanogenmod@cerqueira.org>2014-02-02 01:26:48 +0000
commit01c7ed697ffd397ba5ce695e1d4bf6cb2c480096 (patch)
tree80a5f0f8f40848b21c2c87a62146908955dbb96a /AdvancedDisplay/src/com/cyanogenmod/settings/device/mDNIeMode.java
parentee7630eef4e5566f079b6739b96d39a7a54710f3 (diff)
downloaddevice_samsung_galaxys2-common-01c7ed697ffd397ba5ce695e1d4bf6cb2c480096.zip
device_samsung_galaxys2-common-01c7ed697ffd397ba5ce695e1d4bf6cb2c480096.tar.gz
device_samsung_galaxys2-common-01c7ed697ffd397ba5ce695e1d4bf6cb2c480096.tar.bz2
galaxys2: add AdvancedDisplay
This partially reverts commit 99d12c6a903a3199ba4956add53b82837d90ca9c, we want to reuse some of it. The implementation appears to be fully compatible with smdk4412's, so let's make this a common thing at some point Change-Id: I080484ad010f881a22a4486a6c082d0fbc17a529
Diffstat (limited to 'AdvancedDisplay/src/com/cyanogenmod/settings/device/mDNIeMode.java')
-rw-r--r--AdvancedDisplay/src/com/cyanogenmod/settings/device/mDNIeMode.java61
1 files changed, 61 insertions, 0 deletions
diff --git a/AdvancedDisplay/src/com/cyanogenmod/settings/device/mDNIeMode.java b/AdvancedDisplay/src/com/cyanogenmod/settings/device/mDNIeMode.java
new file mode 100644
index 0000000..c777d72
--- /dev/null
+++ b/AdvancedDisplay/src/com/cyanogenmod/settings/device/mDNIeMode.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.SharedPreferences;
+import android.util.AttributeSet;
+import android.preference.Preference;
+import android.preference.ListPreference;
+import android.preference.Preference.OnPreferenceChangeListener;
+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);
+ }
+
+ public static boolean isSupported(String filePath) {
+ return Utils.fileExists(filePath);
+ }
+
+ /**
+ * Restore mdnie user mode setting from SharedPreferences. (Write to kernel.)
+ * @param context The context to read the SharedPreferences from
+ */
+ public static void restore(Context context) {
+ FILE = context.getResources().getString(R.string.mdnie_mode_sysfs_file);
+ if (!isSupported(FILE)) {
+ return;
+ }
+
+ SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
+ Utils.writeValue(FILE, sharedPrefs.getString(DisplaySettings.KEY_MDNIE_MODE, "0"));
+ }
+
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ Utils.writeValue(FILE, (String) newValue);
+ return true;
+ }
+
+}