diff options
author | XpLoDWilD <xplodgui@gmail.com> | 2012-06-16 16:36:17 +0200 |
---|---|---|
committer | XpLoDWilD <xplodgui@gmail.com> | 2012-06-16 16:36:17 +0200 |
commit | 8300f4fd3b79376fa22fcabc91bedddd9adca274 (patch) | |
tree | 1008da81558d47b4828b51b7fab61ed03a97783c | |
parent | fabb781b25fdb90ffaf70fd359fea7ca3e014956 (diff) | |
download | device_samsung_i9300-8300f4fd3b79376fa22fcabc91bedddd9adca274.zip device_samsung_i9300-8300f4fd3b79376fa22fcabc91bedddd9adca274.tar.gz device_samsung_i9300-8300f4fd3b79376fa22fcabc91bedddd9adca274.tar.bz2 |
Add mDNIe and LED settings
9 files changed, 409 insertions, 0 deletions
diff --git a/DeviceSettings/res/values/arrays.xml b/DeviceSettings/res/values/arrays.xml index 25792a7..28db3ae 100644 --- a/DeviceSettings/res/values/arrays.xml +++ b/DeviceSettings/res/values/arrays.xml @@ -28,4 +28,61 @@ <item>23</item> </string-array> + + <string-array name="mdnie_scenario_entries"> + <item>Camera (Default)</item> + <item>Video</item> + <item>Video Warm</item> + <item>Video Cold</item> + <item>UI</item> + <item>Navigation</item> + <item>Gallery</item> + <item>VT</item> + </string-array> + + <string-array name="mdnie_scenario_entries_values" translatable="false"> + <item>4</item> + <item>1</item> + <item>2</item> + <item>3</item> + <item>0</item> + <item>5</item> + <item>6</item> + <item>7</item> + </string-array> + + <string-array name="mdnie_mode_entries"> + <item>Standard (Default)</item> + <item>Dynamic</item> + <item>Natural</item> + <item>Movie</item> + </string-array> + + <string-array name="mdnie_mode_entries_values" translatable="false"> + <item>1</item> + <item>0</item> + <item>2</item> + <item>3</item> + </string-array> + + <string-array name="mdnie_negative_entries"> + <item>Normal</item> + <item>Inverted</item> + </string-array> + + <string-array name="mdnie_negative_entries_values" translatable="false"> + <item>0</item> + <item>1</item> + </string-array> + + <string-array name="led_fade_entries"> + <item>Blinking</item> + <item>Fading</item> + </string-array> + + <string-array name="led_fade_entries_values" translatable="false"> + <item>0</item> + <item>1</item> + </string-array> + </resources> diff --git a/DeviceSettings/res/values/strings.xml b/DeviceSettings/res/values/strings.xml index 8f3e9b4..e4e3cb0 100644 --- a/DeviceSettings/res/values/strings.xml +++ b/DeviceSettings/res/values/strings.xml @@ -10,4 +10,18 @@ <string name="category_radio_title">Radio</string> <string name="hspa_title_head">HSPA</string> <string name="hspa_summary_head">Enable HSDPA/HSUPA</string> + + <string name="screen_colors_title">Colors</string> + <string name="category_mdnie_title">Screen</string> + <string name="mdnie_scenario_title_head">Scenario</string> + <string name="mdnie_scenario_summary_head">Set the mDNIe Scenario</string> + <string name="mdnie_mode_title_head">Mode</string> + <string name="mdnie_mode_summary_head">Set the mDNIe Mode</string> + <string name="mdnie_negative_title_head">Negative Mode</string> + <string name="mdnie_negative_summary_head">Enable/Disable inverted colors</string> + + <string name="led_settings_title">Notification LED</string> + <string name="led_fade_title_head">LED Fading</string> + <string name="led_fade_summary_head">Enable LED smooth fading instead of sharp blinking.</string> + </resources> diff --git a/DeviceSettings/res/xml/mdnie_preferences.xml b/DeviceSettings/res/xml/mdnie_preferences.xml new file mode 100644 index 0000000..04a7bb4 --- /dev/null +++ b/DeviceSettings/res/xml/mdnie_preferences.xml @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="UTF-8"?> +<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" + android:title="@string/app_name"> + + <PreferenceCategory + android:title="@string/screen_colors_title"> + + <!-- mDNIe Scenario modes --> + <com.cyanogenmod.settings.device.mDNIeScenario + android:key="mdnie_scenario" + android:title="@string/mdnie_scenario_title_head" + android:summary="@string/mdnie_scenario_summary_head" + android:entries="@array/mdnie_scenario_entries" + android:entryValues="@array/mdnie_scenario_entries_values" + android:defaultValue="0" /> + + <!-- mDNIe Mode --> + <com.cyanogenmod.settings.device.mDNIeMode + android:key="mdnie_mode" + android:title="@string/mdnie_mode_title_head" + android:summary="@string/mdnie_mode_summary_head" + android:entries="@array/mdnie_mode_entries" + android:entryValues="@array/mdnie_mode_entries_values" + android:defaultValue="1" /> + + <!-- mDNIe Negative mode --> + <com.cyanogenmod.settings.device.mDNIeNegative + android:key="mdnie_negative" + android:title="@string/mdnie_negative_title_head" + android:summary="@string/mdnie_negative_summary_head" + android:entries="@array/mdnie_negative_entries" + android:entryValues="@array/mdnie_negative_entries_values" + android:defaultValue="0" /> + </PreferenceCategory> + <PreferenceCategory + android:title="@string/led_settings_title"> + + <!-- LED fading mode --> + <com.cyanogenmod.settings.device.LedFade + android:key="led_fade" + android:title="@string/led_fade_title_head" + android:summary="@string/led_fade_summary_head" + android:entries="@array/led_fade_entries" + android:entryValues="@array/led_fade_entries_values" + android:defaultValue="1" /> + </PreferenceCategory> +</PreferenceScreen> diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java b/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java index c3b7d99..cec9147 100644 --- a/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java +++ b/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java @@ -37,6 +37,10 @@ public class DeviceSettings extends FragmentActivity { 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_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"; ViewPager mViewPager; TabsAdapter mTabsAdapter; @@ -59,6 +63,8 @@ public class DeviceSettings extends FragmentActivity { RadioFragmentActivity.class, null); mTabsAdapter.addTab(bar.newTab().setText(R.string.category_haptic_title), HapticFragmentActivity.class, null); + mTabsAdapter.addTab(bar.newTab().setText(R.string.category_mdnie_title), + mDNIeFragmentActivity.class, null); if (savedInstanceState != null) { bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0)); diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/LedFade.java b/DeviceSettings/src/com/cyanogenmod/settings/device/LedFade.java new file mode 100644 index 0000000..6d11947 --- /dev/null +++ b/DeviceSettings/src/com/cyanogenmod/settings/device/LedFade.java @@ -0,0 +1,59 @@ +/* + * 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 java.io.IOException; +import android.content.Context; +import android.util.AttributeSet; +import android.content.SharedPreferences; +import android.preference.Preference; +import android.preference.ListPreference; +import android.preference.Preference.OnPreferenceChangeListener; +import android.preference.PreferenceManager; + +public class LedFade extends ListPreference implements OnPreferenceChangeListener { + + public LedFade(Context context, AttributeSet attrs) { + super(context, attrs); + this.setOnPreferenceChangeListener(this); + } + + private static final String FILE = "/sys/class/sec/led/led_fade"; + + public static boolean isSupported() { + return Utils.fileExists(FILE); + } + + /** + * Restore led fading mode 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.getString(DeviceSettings.KEY_LED_FADE, "1")); + } + + public boolean onPreferenceChange(Preference preference, Object newValue) { + Utils.writeValue(FILE, (String) newValue); + return true; + } + +} diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeFragmentActivity.java b/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeFragmentActivity.java new file mode 100755 index 0000000..e5b29ea --- /dev/null +++ b/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeFragmentActivity.java @@ -0,0 +1,49 @@ +/* + * 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.os.Bundle; +import android.preference.PreferenceFragment; +import com.cyanogenmod.settings.device.R; + +public class mDNIeFragmentActivity extends PreferenceFragment { + + private mDNIeScenario mmDNIeScenario; + private mDNIeMode mmDNIeMode; + private mDNIeNegative mmDNIeNegative; + private LedFade mLedFade; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + addPreferencesFromResource(R.xml.mdnie_preferences); + + mmDNIeScenario = (mDNIeScenario) findPreference(DeviceSettings.KEY_MDNIE_SCENARIO); + mmDNIeScenario.setEnabled(mDNIeScenario.isSupported()); + + mmDNIeMode = (mDNIeMode) findPreference(DeviceSettings.KEY_MDNIE_MODE); + mmDNIeMode.setEnabled(mDNIeMode.isSupported()); + + mmDNIeNegative = (mDNIeNegative) findPreference(DeviceSettings.KEY_MDNIE_NEGATIVE); + mmDNIeNegative.setEnabled(mDNIeNegative.isSupported()); + + mLedFade = (LedFade) findPreference(DeviceSettings.KEY_LED_FADE); + mLedFade.setEnabled(LedFade.isSupported()); + } + +} diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeMode.java b/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeMode.java new file mode 100644 index 0000000..c7fc94b --- /dev/null +++ b/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeMode.java @@ -0,0 +1,59 @@ +/* + * 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 { + + public mDNIeMode(Context context, AttributeSet attrs) { + super(context, attrs); + this.setOnPreferenceChangeListener(this); + } + + private static final String FILE = "/sys/class/mdnie/mdnie/mode"; + + public static boolean isSupported() { + return Utils.fileExists(FILE); + } + + /** + * 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) { + if (!isSupported()) { + return; + } + + SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context); + Utils.writeValue(FILE, sharedPrefs.getString(DeviceSettings.KEY_MDNIE_MODE, "1")); + } + + public boolean onPreferenceChange(Preference preference, Object newValue) { + Utils.writeValue(FILE, (String) newValue); + return true; + } + +} diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeNegative.java b/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeNegative.java new file mode 100644 index 0000000..c2ccc7b --- /dev/null +++ b/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeNegative.java @@ -0,0 +1,59 @@ +/* + * 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 java.io.IOException; +import android.content.Context; +import android.util.AttributeSet; +import android.content.SharedPreferences; +import android.preference.Preference; +import android.preference.ListPreference; +import android.preference.Preference.OnPreferenceChangeListener; +import android.preference.PreferenceManager; + +public class mDNIeNegative extends ListPreference implements OnPreferenceChangeListener { + + public mDNIeNegative(Context context, AttributeSet attrs) { + super(context, attrs); + this.setOnPreferenceChangeListener(this); + } + + private static final String FILE = "/sys/class/mdnie/mdnie/negative"; + + public static boolean isSupported() { + return Utils.fileExists(FILE); + } + + /** + * 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) { + if (!isSupported()) { + return; + } + + SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context); + Utils.writeValue(FILE, sharedPrefs.getString(DeviceSettings.KEY_MDNIE_NEGATIVE, "0")); + } + + public boolean onPreferenceChange(Preference preference, Object newValue) { + Utils.writeValue(FILE, (String) newValue); + return true; + } + +} diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeScenario.java b/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeScenario.java new file mode 100644 index 0000000..0557ba3 --- /dev/null +++ b/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeScenario.java @@ -0,0 +1,59 @@ +/* + * 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 mDNIeScenario extends ListPreference implements OnPreferenceChangeListener { + + public mDNIeScenario(Context context, AttributeSet attrs) { + super(context,attrs); + this.setOnPreferenceChangeListener(this); + } + + private static final String FILE = "/sys/class/mdnie/mdnie/scenario"; + + public static boolean isSupported() { + return Utils.fileExists(FILE); + } + + /** + * Restore mdnie "camera" 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.getString(DeviceSettings.KEY_MDNIE_SCENARIO, "4")); + } + + public boolean onPreferenceChange(Preference preference, Object newValue) { + Utils.writeValue(FILE, (String) newValue); + return true; + } + +} |