diff options
author | Daniel Hillenbrand <daniel.hillenbrand@codeworkx.de> | 2012-06-16 17:16:57 +0200 |
---|---|---|
committer | Daniel Hillenbrand <daniel.hillenbrand@codeworkx.de> | 2012-06-16 17:16:57 +0200 |
commit | dcef91f68afb8349cf5bd70142c22f35b2e780b8 (patch) | |
tree | ca2753c04f42a8dbef52173cfb03f139fdc8d9ec /DeviceSettings | |
parent | 6ad64f9380d8016dbc9dd4bb35e2e1bbd89f1f9d (diff) | |
download | device_samsung_i9300-dcef91f68afb8349cf5bd70142c22f35b2e780b8.zip device_samsung_i9300-dcef91f68afb8349cf5bd70142c22f35b2e780b8.tar.gz device_samsung_i9300-dcef91f68afb8349cf5bd70142c22f35b2e780b8.tar.bz2 |
settings: touchkey timeout and force disable
Diffstat (limited to 'DeviceSettings')
-rw-r--r-- | DeviceSettings/res/values-de/arrays.xml | 38 | ||||
-rw-r--r-- | DeviceSettings/res/values-de/strings.xml | 23 | ||||
-rw-r--r-- | DeviceSettings/res/values/arrays.xml | 81 | ||||
-rw-r--r-- | DeviceSettings/res/values/strings.xml | 13 | ||||
-rw-r--r-- | DeviceSettings/res/xml/screen_preferences.xml (renamed from DeviceSettings/res/xml/mdnie_preferences.xml) | 30 | ||||
-rw-r--r-- | DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java | 7 | ||||
-rw-r--r-- | DeviceSettings/src/com/cyanogenmod/settings/device/ScreenFragmentActivity.java | 88 | ||||
-rw-r--r-- | DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java | 1 | ||||
-rw-r--r-- | DeviceSettings/src/com/cyanogenmod/settings/device/TouchkeyTimeout.java | 59 | ||||
-rwxr-xr-x | DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeFragmentActivity.java | 49 |
10 files changed, 297 insertions, 92 deletions
diff --git a/DeviceSettings/res/values-de/arrays.xml b/DeviceSettings/res/values-de/arrays.xml index f3e59cb..ee5c510 100644 --- a/DeviceSettings/res/values-de/arrays.xml +++ b/DeviceSettings/res/values-de/arrays.xml @@ -14,4 +14,42 @@ <item>HSDPA + HSUPA</item> </string-array> + <string-array name="mdnie_scenario_entries"> + <item>Kamera (Standard)</item> + <item>Video</item> + <item>Video warm</item> + <item>Video kalt</item> + <item>UI</item> + <item>Navigation</item> + <item>Gallerie</item> + <item>VT</item> + </string-array> + + <string-array name="mdnie_mode_entries"> + <item>Standard (Standard)</item> + <item>Dynamisch</item> + <item>Natürlich</item> + <item>Film</item> + </string-array> + + <string-array name="mdnie_negative_entries"> + <item>Normal</item> + <item>Invertiert</item> + </string-array> + + <string-array name="led_fade_entries"> + <item>Blinken</item> + <item>Verblassen</item> + </string-array> + + <string-array name="touchkey_timeout_entries"> + <item>Niemals</item> + <item>1 Sekunde</item> + <item>2 Sekunden</item> + <item>3 Sekunden (Standard)</item> + <item>4 Sekunden</item> + <item>5 Sekunden</item> + <item>6 Sekunden</item> + </string-array> + </resources> diff --git a/DeviceSettings/res/values-de/strings.xml b/DeviceSettings/res/values-de/strings.xml index db6c767..50c66a6 100644 --- a/DeviceSettings/res/values-de/strings.xml +++ b/DeviceSettings/res/values-de/strings.xml @@ -5,9 +5,30 @@ <string name="category_haptic_title">Haptik</string> <string name="vibrator_subcat_title">Vibrator</string> <string name="vibrator_intensity_title_head">Vibrator Intensität</string> - <string name="vibrator_intensity_summary_head">Setze Vibrator Intensität</string> + <string name="vibrator_intensity_summary_head">Wähle Vibrator Intensität</string> <string name="category_radio_title">Mobilfunk</string> <string name="hspa_title_head">HSPA</string> <string name="hspa_summary_head">Aktiviere HSDPA/HSUPA</string> + + <string name="category_screen_title">Display</string> + <string name="mdnie_subcat_title">Farben</string> + <string name="mdnie_scenario_title_head">Szenario</string> + <string name="mdnie_scenario_summary_head">Wähle das mDNIe Szenario</string> + <string name="mdnie_mode_title_head">Modus</string> + <string name="mdnie_mode_summary_head">Wähle den mDNIe Modus</string> + <string name="mdnie_negative_title_head">Negativ Modus</string> + <string name="mdnie_negative_summary_head">Invertiere Farben</string> + + <string name="led_subcat_title">Benachrichtigungslicht</string> + <string name="led_fade_title_head">Modus</string> + <string name="led_fade_summary_head">Wähle zwischen sanftem Verblassen und Blinken</string> + + <string name="touchkey_subcat_title">Touchkeys</string> + <string name="touchkey_light_title_head">Beleuchtung</string> + <string name="touchkey_light_summary_off">Aktiviere Beleuchtung</string> + <string name="touchkey_light_summary_on">Deaktiviere Beleuchtung</string> + <string name="touchkey_timeout_title_head">Zeitabschaltung der Beleuchtung</string> + <string name="touchkey_timeout_summary_head">Setze Zeit für automatische Abschaltung</string> + </resources> diff --git a/DeviceSettings/res/values/arrays.xml b/DeviceSettings/res/values/arrays.xml index 28db3ae..dc527cf 100644 --- a/DeviceSettings/res/values/arrays.xml +++ b/DeviceSettings/res/values/arrays.xml @@ -28,61 +28,80 @@ <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>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>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> + <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> + <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> + <item>Normal</item> + <item>Inverted</item> </string-array> <string-array name="mdnie_negative_entries_values" translatable="false"> - <item>0</item> - <item>1</item> + <item>0</item> + <item>1</item> </string-array> <string-array name="led_fade_entries"> - <item>Blinking</item> - <item>Fading</item> + <item>Blinking</item> + <item>Fading</item> </string-array> <string-array name="led_fade_entries_values" translatable="false"> - <item>0</item> - <item>1</item> + <item>0</item> + <item>1</item> + </string-array> + + <string-array name="touchkey_timeout_entries"> + <item>Never</item> + <item>1 second</item> + <item>2 seconds</item> + <item>3 seconds (Default)</item> + <item>4 seconds</item> + <item>5 seconds</item> + <item>6 seconds</item> + </string-array> + + <string-array name="touchkey_timeout_entries_values" translatable="false"> + <item>0</item> + <item>1</item> + <item>2</item> + <item>3</item> + <item>4</item> + <item>5</item> + <item>6</item> </string-array> </resources> diff --git a/DeviceSettings/res/values/strings.xml b/DeviceSettings/res/values/strings.xml index e4e3cb0..e842ae4 100644 --- a/DeviceSettings/res/values/strings.xml +++ b/DeviceSettings/res/values/strings.xml @@ -11,8 +11,8 @@ <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="category_screen_title">Screen</string> + <string name="mdnie_subcat_title">Colors</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> @@ -20,8 +20,15 @@ <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_subcat_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> + <string name="touchkey_subcat_title">Touchkeys</string> + <string name="touchkey_light_title_head">Backlight</string> + <string name="touchkey_light_summary_off">Enable backlight</string> + <string name="touchkey_light_summary_on">Disable backlight</string> + <string name="touchkey_timeout_title_head">Backlight timeout</string> + <string name="touchkey_timeout_summary_head">Set timeout for the backlight</string> + </resources> diff --git a/DeviceSettings/res/xml/mdnie_preferences.xml b/DeviceSettings/res/xml/screen_preferences.xml index 04a7bb4..e0a5f1b 100644 --- a/DeviceSettings/res/xml/mdnie_preferences.xml +++ b/DeviceSettings/res/xml/screen_preferences.xml @@ -1,10 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> -<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" - android:title="@string/app_name"> +<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <PreferenceCategory - android:title="@string/screen_colors_title"> - + android:title="@string/mdnie_subcat_title"> <!-- mDNIe Scenario modes --> <com.cyanogenmod.settings.device.mDNIeScenario android:key="mdnie_scenario" @@ -32,9 +30,9 @@ android:entryValues="@array/mdnie_negative_entries_values" android:defaultValue="0" /> </PreferenceCategory> - <PreferenceCategory - android:title="@string/led_settings_title"> + <PreferenceCategory + android:title="@string/led_subcat_title"> <!-- LED fading mode --> <com.cyanogenmod.settings.device.LedFade android:key="led_fade" @@ -44,4 +42,24 @@ android:entryValues="@array/led_fade_entries_values" android:defaultValue="1" /> </PreferenceCategory> + + <PreferenceCategory + android:title="@string/touchkey_subcat_title"> + <!-- Touchkey backlight --> + <CheckBoxPreference + android:key="touchkey_light" + android:title="@string/touchkey_light_title_head" + android:summaryOff="@string/touchkey_light_summary_off" + android:summaryOn="@string/touchkey_light_summary_on" + android:defaultValue="true" + /> + <com.cyanogenmod.settings.device.TouchkeyTimeout + android:key="touchkey_timeout" + android:title="@string/touchkey_timeout_title_head" + android:summary="@string/touchkey_timeout_summary_head" + android:entries="@array/touchkey_timeout_entries" + android:entryValues="@array/touchkey_timeout_entries_values" + android:defaultValue="3" /> + </PreferenceCategory> + </PreferenceScreen> diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java b/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java index cec9147..2f5f210 100644 --- a/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java +++ b/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java @@ -41,6 +41,8 @@ public class DeviceSettings extends FragmentActivity { 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"; + public static final String KEY_TOUCHKEY_LIGHT = "touchkey_light"; + public static final String KEY_TOUCHKEY_TIMEOUT = "touchkey_timeout"; ViewPager mViewPager; TabsAdapter mTabsAdapter; @@ -61,10 +63,11 @@ public class DeviceSettings extends FragmentActivity { mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(bar.newTab().setText(R.string.category_radio_title), RadioFragmentActivity.class, null); + mTabsAdapter.addTab(bar.newTab().setText(R.string.category_screen_title), + ScreenFragmentActivity.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/ScreenFragmentActivity.java b/DeviceSettings/src/com/cyanogenmod/settings/device/ScreenFragmentActivity.java new file mode 100644 index 0000000..9afc3c0 --- /dev/null +++ b/DeviceSettings/src/com/cyanogenmod/settings/device/ScreenFragmentActivity.java @@ -0,0 +1,88 @@ +/* + * 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.os.Bundle; +import android.preference.CheckBoxPreference; +import android.preference.ListPreference; +import android.preference.Preference; +import android.preference.PreferenceActivity; +import android.preference.PreferenceFragment; +import android.preference.PreferenceManager; +import android.preference.PreferenceScreen; +import android.util.Log; + +import com.cyanogenmod.settings.device.R; + +public class ScreenFragmentActivity extends PreferenceFragment { + + private static final String PREF_ENABLED = "1"; + private static final String TAG = "GalaxyS3Parts_General"; + private mDNIeScenario mmDNIeScenario; + private mDNIeMode mmDNIeMode; + private mDNIeNegative mmDNIeNegative; + private LedFade mLedFade; + + 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"; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + addPreferencesFromResource(R.xml.screen_preferences); + + PreferenceScreen prefSet = getPreferenceScreen(); + 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()); + } + + @Override + public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { + + String key = preference.getKey(); + + Log.w(TAG, "key: " + key); + + if (key.compareTo(DeviceSettings.KEY_TOUCHKEY_LIGHT) == 0) { + Utils.writeValue(FILE_TOUCHKEY_BRIGHTNESS, ((CheckBoxPreference)preference).isChecked() ? "1" : "2"); + Utils.writeValue(FILE_TOUCHKEY_DISABLE, ((CheckBoxPreference)preference).isChecked() ? "0" : "1"); + } + return true; + } + + public static boolean isSupported(String FILE) { + return Utils.fileExists(FILE); + } + + public static void restore(Context context) { + SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context); + Utils.writeValue(FILE_TOUCHKEY_BRIGHTNESS, sharedPrefs.getString(DeviceSettings.KEY_TOUCHKEY_LIGHT, "1")); + Utils.writeValue(FILE_TOUCHKEY_DISABLE, sharedPrefs.getString(DeviceSettings.KEY_TOUCHKEY_LIGHT, "0")); + } +} diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java b/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java index 5073489..a48a7fd 100644 --- a/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java +++ b/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java @@ -28,5 +28,6 @@ public class Startup extends BroadcastReceiver { Hspa.restore(context); RadioFragmentActivity.restore(context); VibratorIntensity.restore(context); + TouchkeyTimeout.restore(context); } } diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/TouchkeyTimeout.java b/DeviceSettings/src/com/cyanogenmod/settings/device/TouchkeyTimeout.java new file mode 100644 index 0000000..6ea9bfb --- /dev/null +++ b/DeviceSettings/src/com/cyanogenmod/settings/device/TouchkeyTimeout.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 TouchkeyTimeout extends ListPreference implements OnPreferenceChangeListener { + + public TouchkeyTimeout(Context context, AttributeSet attrs) { + super(context, attrs); + this.setOnPreferenceChangeListener(this); + } + + private static final String FILE_TOUCHKEY_TIMEOUT = "/sys/class/sec/sec_touchkey/timeout"; + + public static boolean isSupported() { + return Utils.fileExists(FILE_TOUCHKEY_TIMEOUT); + } + + /** + * Restore touchscreen sensitivity 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_TOUCHKEY_TIMEOUT, sharedPrefs.getString(DeviceSettings.KEY_TOUCHKEY_TIMEOUT, "3")); + } + + public boolean onPreferenceChange(Preference preference, Object newValue) { + Utils.writeValue(FILE_TOUCHKEY_TIMEOUT, (String) newValue); + return true; + } + +} diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeFragmentActivity.java b/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeFragmentActivity.java deleted file mode 100755 index e5b29ea..0000000 --- a/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeFragmentActivity.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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()); - } - -} |