summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DeviceSettings/res/layout/preference_dialog_vibrator_tuning.xml59
-rw-r--r--DeviceSettings/res/values-de/arrays.xml20
-rw-r--r--DeviceSettings/res/values-de/strings.xml35
-rw-r--r--DeviceSettings/res/values-es/arrays.xml7
-rw-r--r--DeviceSettings/res/values-es/strings.xml9
-rw-r--r--DeviceSettings/res/values-fr/arrays.xml7
-rw-r--r--DeviceSettings/res/values-fr/strings.xml9
-rw-r--r--DeviceSettings/res/values-hu/arrays.xml8
-rw-r--r--DeviceSettings/res/values-hu/strings.xml9
-rw-r--r--DeviceSettings/res/values-pl/arrays.xml8
-rw-r--r--DeviceSettings/res/values-pl/strings.xml9
-rw-r--r--DeviceSettings/res/values-pt-rBR/arrays.xml7
-rw-r--r--DeviceSettings/res/values-pt-rBR/strings.xml11
-rw-r--r--DeviceSettings/res/values-ru/arrays.xml8
-rw-r--r--DeviceSettings/res/values-ru/strings.xml35
-rw-r--r--DeviceSettings/res/values-zh-rCN/arrays.xml7
-rw-r--r--DeviceSettings/res/values-zh-rCN/strings.xml7
-rw-r--r--DeviceSettings/res/values/arrays.xml60
-rw-r--r--DeviceSettings/res/values/config.xml29
-rw-r--r--DeviceSettings/res/values/strings.xml35
-rw-r--r--DeviceSettings/res/xml/haptic_preferences.xml13
-rw-r--r--DeviceSettings/res/xml/screen_preferences.xml3
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java5
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/DockFragmentActivity.java3
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/HapticFragmentActivity.java20
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/ScreenFragmentActivity.java2
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java2
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/Utils.java22
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/VibratorIntensity.java59
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/VibratorTuningPreference.java219
30 files changed, 459 insertions, 268 deletions
diff --git a/DeviceSettings/res/layout/preference_dialog_vibrator_tuning.xml b/DeviceSettings/res/layout/preference_dialog_vibrator_tuning.xml
new file mode 100644
index 0000000..1cf116b
--- /dev/null
+++ b/DeviceSettings/res/layout/preference_dialog_vibrator_tuning.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2013 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.
+-->
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <RelativeLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="center_horizontal"
+ android:paddingBottom="20dip">
+
+ <TextView android:id="@+id/vibrator_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/vibrator_tuning_title"
+ android:paddingTop="10dip"
+ android:paddingLeft="20dip"
+ android:paddingRight="20dip" />
+ <TextView android:id="@+id/vibrator_value"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentRight="true"
+ android:paddingTop="10dip"
+ android:paddingLeft="20dip"
+ android:paddingRight="20dip" />
+ <SeekBar android:id="@+id/vibrator_seekbar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/vibrator_text"
+ android:paddingTop="2dip"
+ android:paddingLeft="20dip"
+ android:paddingRight="20dip" />
+
+ <TextView
+ android:id="@+id/textWarn"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/vibrator_seekbar"
+ android:paddingTop="8dip"
+ android:gravity="center"
+ android:text="@string/vibrator_warning"
+ android:textSize="15dp" />
+
+ </RelativeLayout>
+</ScrollView>
diff --git a/DeviceSettings/res/values-de/arrays.xml b/DeviceSettings/res/values-de/arrays.xml
index 9edf346..04b2538 100644
--- a/DeviceSettings/res/values-de/arrays.xml
+++ b/DeviceSettings/res/values-de/arrays.xml
@@ -1,19 +1,5 @@
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string-array name="vibrator_intensity_entries">
- <item>0%</item>
- <item>25%</item>
- <item>50% (Standard)</item>
- <item>75%</item>
- <item>100%</item>
- </string-array>
-
- <string-array name="hspa_entries">
- <item>Nur UMTS</item>
- <item>Nur HSDPA</item>
- <item>HSDPA + HSUPA</item>
- </string-array>
-
<string-array name="mdnie_scenario_entries">
<item>CyanogenMod (Standard)</item>
<item>UI</item>
@@ -53,4 +39,10 @@
<item>6 Sekunden</item>
</string-array>
+ <string-array name="hspa_entries">
+ <item>Nur UMTS</item>
+ <item>Nur HSDPA</item>
+ <item>HSDPA + HSUPA</item>
+ </string-array>
+
</resources>
diff --git a/DeviceSettings/res/values-de/strings.xml b/DeviceSettings/res/values-de/strings.xml
index 099267d..65ce91e 100644
--- a/DeviceSettings/res/values-de/strings.xml
+++ b/DeviceSettings/res/values-de/strings.xml
@@ -1,23 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
- <string name="app_name">Galaxy S III Einstellungen</string>
+ <string name="app_name">Erweiterte Einstellungen</string>
- <string name="category_dock_title">Dock</string>
- <string name="dockaudio_subcat_title">Audio</string>
- <string name="use_dock_audio_title_head">USB-Dock Audio</string>
- <string name="use_dock_audio_summary_head">Passive Audio-Ausgabe des USB-Docks verwenden</string>
-
- <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">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="defaults_button">Zurücksetzen</string>
<string name="category_screen_title">Display</string>
- <string name="mdnie_subcat_title">Farben</string>
+ <string name="screen_colors_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>
@@ -36,4 +24,21 @@
<string name="touchkey_timeout_title_head">Zeitabschaltung der Beleuchtung</string>
<string name="touchkey_timeout_summary_head">Setze Zeit für automatische Abschaltung</string>
+ <!-- Haptic Preference -->
+ <string name="category_haptic_title">Haptik</string>
+
+ <!-- VibratorTuning -->
+ <string name="vibrator_title">Vibrator</string>
+ <string name="vibrator_tuning_title">Vibrationsstärke</string>
+ <string name="vibrator_tuning_summary_head">Stärke des Vibrationseffektes einstellen</string>
+ <string name="vibrator_warning">Vorsicht: Höhere Werte als %1$d werden nicht empfohlen</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_dock_title">Dock</string>
+ <string name="dockaudio_subcat_title">Audio</string>
+ <string name="use_dock_audio_title_head">USB-Dock Audio</string>
+ <string name="use_dock_audio_summary_head">Passive Audio-Ausgabe des USB-Docks verwenden</string>
</resources>
diff --git a/DeviceSettings/res/values-es/arrays.xml b/DeviceSettings/res/values-es/arrays.xml
index 44666bb..c7d02c5 100644
--- a/DeviceSettings/res/values-es/arrays.xml
+++ b/DeviceSettings/res/values-es/arrays.xml
@@ -1,11 +1,4 @@
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string-array name="vibrator_intensity_entries">
- <item>0%</item>
- <item>25%</item>
- <item>50% (por defecto)</item>
- <item>75%</item>
- <item>100%</item>
- </string-array>
<string-array name="hspa_entries">
<item>Sólo UMTS</item>
<item>Sólo HSDPA</item>
diff --git a/DeviceSettings/res/values-es/strings.xml b/DeviceSettings/res/values-es/strings.xml
index b0edbc9..f615d4b 100644
--- a/DeviceSettings/res/values-es/strings.xml
+++ b/DeviceSettings/res/values-es/strings.xml
@@ -6,14 +6,15 @@
<string name="use_dock_audio_title_head">Usar sonido USB</string>
<string name="use_dock_audio_summary_head">Utilizar la salida de audio de la base</string>
<string name="category_haptic_title">Háptica</string>
- <string name="vibrator_subcat_title">Vibración</string>
- <string name="vibrator_intensity_title_head">Intensidad de vibración</string>
- <string name="vibrator_intensity_summary_head">Establecer la intensidad de vibración</string>
+ <string name="vibrator_title">Vibración</string>
+ <string name="vibrator_tuning_title">Intensidad de vibración</string>
+ <string name="vibrator_tuning_summary_head">Establecer la intensidad de vibración</string>
+ <string name="vibrator_warning">No son recomendables valores mayores de %1$d</string>
<string name="category_radio_title">Radio</string>
<string name="hspa_title_head">HSPA</string>
<string name="hspa_summary_head">Habilitar HSDPA/HSUPA</string>
<string name="category_screen_title">Pantalla</string>
- <string name="mdnie_subcat_title">Colores</string>
+ <string name="screen_colors_title">Colores</string>
<string name="mdnie_scenario_title_head">Escenario</string>
<string name="mdnie_scenario_summary_head">Establecer escenario mDNIe</string>
<string name="mdnie_mode_title_head">Modo</string>
diff --git a/DeviceSettings/res/values-fr/arrays.xml b/DeviceSettings/res/values-fr/arrays.xml
index 7b49bf5..11b706d 100644
--- a/DeviceSettings/res/values-fr/arrays.xml
+++ b/DeviceSettings/res/values-fr/arrays.xml
@@ -14,13 +14,6 @@
limitations under the License.
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string-array name="vibrator_intensity_entries">
- <item>Désactivé</item>
- <item>25%</item>
- <item>50% (Défaut)</item>
- <item>75%</item>
- <item>100%</item>
- </string-array>
<string-array name="hspa_entries">
<item>UMTS seulement</item>
<item>HSDPA seulement</item>
diff --git a/DeviceSettings/res/values-fr/strings.xml b/DeviceSettings/res/values-fr/strings.xml
index 5f2ee6f..5556d24 100644
--- a/DeviceSettings/res/values-fr/strings.xml
+++ b/DeviceSettings/res/values-fr/strings.xml
@@ -20,14 +20,15 @@
<string name="use_dock_audio_title_head">Sortie audio</string>
<string name="use_dock_audio_summary_head">Utiliser la sortie audio de la station d\'accueil</string>
<string name="category_haptic_title">Haptique</string>
- <string name="vibrator_subcat_title">Vibreur</string>
- <string name="vibrator_intensity_title_head">Intensité du vibreur</string>
- <string name="vibrator_intensity_summary_head">Définir l\'intensité du vibreur</string>
+ <string name="vibrator_title">Vibreur</string>
+ <string name="vibrator_tuning_title">Intensité du vibreur</string>
+ <string name="vibrator_tuning_summary_head">Définir l\'intensité du vibreur</string>
+ <string name="vibrator_warning">Les valeurs supérieurs à %1$d ne sont pas recommandées</string>
<string name="category_radio_title">Radio</string>
<string name="hspa_title_head">HSPA</string>
<string name="hspa_summary_head">Activer HSDPA/HSUPA</string>
<string name="category_screen_title">Écran</string>
- <string name="mdnie_subcat_title">Couleurs</string>
+ <string name="screen_colors_title">Couleurs</string>
<string name="mdnie_scenario_title_head">Scénario</string>
<string name="mdnie_scenario_summary_head">Définir le scénario mDNIe</string>
<string name="mdnie_mode_title_head">Mode</string>
diff --git a/DeviceSettings/res/values-hu/arrays.xml b/DeviceSettings/res/values-hu/arrays.xml
index 824296d..82074a2 100644
--- a/DeviceSettings/res/values-hu/arrays.xml
+++ b/DeviceSettings/res/values-hu/arrays.xml
@@ -1,13 +1,5 @@
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string-array name="vibrator_intensity_entries">
- <item>0%</item>
- <item>25%</item>
- <item>50% (Alapbeállítás)</item>
- <item>75%</item>
- <item>100%</item>
- </string-array>
-
<string-array name="hspa_entries">
<item>UMTS</item>
<item>HSDPA</item>
diff --git a/DeviceSettings/res/values-hu/strings.xml b/DeviceSettings/res/values-hu/strings.xml
index f776dca..f5f1411 100644
--- a/DeviceSettings/res/values-hu/strings.xml
+++ b/DeviceSettings/res/values-hu/strings.xml
@@ -1,23 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
- <string name="app_name">Galaxy S III Beállítások</string>
+ <string name="app_name">Advanced settings</string>
<string name="category_dock_title">Dokkoló</string>
<string name="dockaudio_subcat_title">Dokkoló hangszórók</string>
<string name="use_dock_audio_title_head">Dokkoló hangszóróinak használata</string>
<string name="use_dock_audio_summary_head">Használja a dokkoló passzív hangkimenetét</string>
- <string name="category_haptic_title">Érintési visszajelzés</string>
- <string name="vibrator_subcat_title">Rezgés</string>
- <string name="vibrator_intensity_title_head">Rezgés erőssége</string>
- <string name="vibrator_intensity_summary_head">Rezgés erősségének beállítása</string>
-
<string name="category_radio_title">GSM Rádió</string>
<string name="hspa_title_head">HSPA</string>
<string name="hspa_summary_head">HSDPA/HSUPA engedélyezése</string>
<string name="category_screen_title">Kijelző</string>
- <string name="mdnie_subcat_title">Színek</string>
+ <string name="screen_colors_title">Színek</string>
<string name="mdnie_scenario_title_head">Megjelenítés</string>
<string name="mdnie_scenario_summary_head">mDNIe megjelenítési beállítások</string>
<string name="mdnie_mode_title_head">Üzemmód</string>
diff --git a/DeviceSettings/res/values-pl/arrays.xml b/DeviceSettings/res/values-pl/arrays.xml
index 268ac03..f9de456 100644
--- a/DeviceSettings/res/values-pl/arrays.xml
+++ b/DeviceSettings/res/values-pl/arrays.xml
@@ -1,13 +1,5 @@
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string-array name="vibrator_intensity_entries">
- <item>0%</item>
- <item>25%</item>
- <item>50% (domyślnie)</item>
- <item>75%</item>
- <item>100%</item>
- </string-array>
-
<string-array name="hspa_entries">
<item>Tylko UMTS</item>
<item>Tylko HSDPA</item>
diff --git a/DeviceSettings/res/values-pl/strings.xml b/DeviceSettings/res/values-pl/strings.xml
index 95c3777..20da92d 100644
--- a/DeviceSettings/res/values-pl/strings.xml
+++ b/DeviceSettings/res/values-pl/strings.xml
@@ -1,23 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
- <string name="app_name">Ustawienia Galaxy S III</string>
+ <string name="app_name">Advanced settings</string>
<string name="category_dock_title">Stacja dokująca</string>
<string name="dockaudio_subcat_title">Dźwięk w stacji dokującej</string>
<string name="use_dock_audio_title_head">Użyj stacji dokującej</string>
<string name="use_dock_audio_summary_head">Użyj pasywnego wyjścia audio w stacji dokującej</string>
- <string name="category_haptic_title">Dotyk</string>
- <string name="vibrator_subcat_title">Wibracje</string>
- <string name="vibrator_intensity_title_head">Intensywność wibracji</string>
- <string name="vibrator_intensity_summary_head">Ustaw intensywność wibracji</string>
-
<string name="category_radio_title">Radio</string>
<string name="hspa_title_head">HSPA</string>
<string name="hspa_summary_head">Aktywuj HSDPA/HSUPA</string>
<string name="category_screen_title">Ekran</string>
- <string name="mdnie_subcat_title">Kolory</string>
+ <string name="screen_colors_title">Kolory</string>
<string name="mdnie_scenario_title_head">Technologia mDNIe</string>
<string name="mdnie_scenario_summary_head">Ustaw scenariusz mDNIe</string>
<string name="mdnie_mode_title_head">Tryb</string>
diff --git a/DeviceSettings/res/values-pt-rBR/arrays.xml b/DeviceSettings/res/values-pt-rBR/arrays.xml
index 7ade7ea..983e35a 100644
--- a/DeviceSettings/res/values-pt-rBR/arrays.xml
+++ b/DeviceSettings/res/values-pt-rBR/arrays.xml
@@ -1,12 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
- <string-array name="vibrator_intensity_entries">
- <item>0%</item>
- <item>25%</item>
- <item>50% (Padrão)</item>
- <item>75%</item>
- <item>100%</item>
- </string-array>
<string-array name="hspa_entries">
<item>Somente UMTS</item>
diff --git a/DeviceSettings/res/values-pt-rBR/strings.xml b/DeviceSettings/res/values-pt-rBR/strings.xml
index 7d99c58..5813d7e 100644
--- a/DeviceSettings/res/values-pt-rBR/strings.xml
+++ b/DeviceSettings/res/values-pt-rBR/strings.xml
@@ -1,14 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Configurações avançadas</string>
- <string name="category_haptic_title">Resposta Tátil</string>
- <string name="vibrator_subcat_title">Vibração</string>
- <string name="vibrator_intensity_title_head">Intensidade da Vibração</string>
- <string name="vibrator_intensity_summary_head">Define a intensidade da vibração</string>
+ <string name="category_haptic_title">Resposta tátil</string>
+ <string name="vibrator_title">Vibração</string>
+ <string name="vibrator_tuning_title">Intensidade da vibração</string>
+ <string name="vibrator_tuning_summary_head">Ajusar a intensidade da resposta por vibração</string>
+ <string name="vibrator_warning">Valores maiores que %1$d não são recomendados</string>
<string name="category_radio_title">Rádio</string>
<string name="hspa_summary_head">Ativar HSDPA/HSUPA</string>
<string name="category_screen_title">Tela</string>
- <string name="mdnie_subcat_title">Cores</string>
+ <string name="screen_colors_title">Cores</string>
<string name="mdnie_scenario_title_head">Cenário</string>
<string name="mdnie_scenario_summary_head">Define o Cenário mDNIe</string>
<string name="mdnie_mode_title_head">Modo</string>
diff --git a/DeviceSettings/res/values-ru/arrays.xml b/DeviceSettings/res/values-ru/arrays.xml
index ed61b6e..a83b7b4 100644
--- a/DeviceSettings/res/values-ru/arrays.xml
+++ b/DeviceSettings/res/values-ru/arrays.xml
@@ -1,13 +1,5 @@
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string-array name="vibrator_intensity_entries">
- <item>0%</item>
- <item>25%</item>
- <item>50% (По умолч.)</item>
- <item>75%</item>
- <item>100%</item>
- </string-array>
-
<string-array name="hspa_entries">
<item>Только UMTS</item>
<item>Только HSDPA</item>
diff --git a/DeviceSettings/res/values-ru/strings.xml b/DeviceSettings/res/values-ru/strings.xml
index 47fe8ff..c7b287a 100644
--- a/DeviceSettings/res/values-ru/strings.xml
+++ b/DeviceSettings/res/values-ru/strings.xml
@@ -1,23 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
- <string name="app_name">Настройки Galaxy S III</string>
-
- <string name="category_dock_title">Док-станция</string>
- <string name="dockaudio_subcat_title">Аудио</string>
- <string name="use_dock_audio_title_head">USB аудио док-станция</string>
- <string name="use_dock_audio_summary_head">Использовать пассивный режим аудио док-станции</string>
-
- <string name="category_haptic_title">Отклик</string>
- <string name="vibrator_subcat_title">Вибрация</string>
- <string name="vibrator_intensity_title_head">Интенсивность вибрации</string>
- <string name="vibrator_intensity_summary_head">Установка интенсивности вибрации</string>
-
- <string name="category_radio_title">Модем</string>
- <string name="hspa_title_head">HSPA</string>
- <string name="hspa_summary_head">Включить HSDPA/HSUPA</string>
+ <string name="app_name">Advanced settings</string>
<string name="category_screen_title">Экран</string>
- <string name="mdnie_subcat_title">Цвета</string>
+ <string name="screen_colors_title">Цвета</string>
<string name="mdnie_scenario_title_head">Сценарий</string>
<string name="mdnie_scenario_summary_head">Установка сценария mDNIe</string>
<string name="mdnie_mode_title_head">Режим</string>
@@ -36,4 +22,21 @@
<string name="touchkey_timeout_title_head">Тайм-аут подсветки</string>
<string name="touchkey_timeout_summary_head">Установка тайм-аута подсветки</string>
+ <!-- Haptic Preference -->
+ <string name="category_haptic_title">Отклик</string>
+
+ <!-- VibratorTuning -->
+ <string name="vibrator_title">Вибрация</string>
+ <string name="vibrator_tuning_title">Интенсивность вибрации</string>
+ <string name="vibrator_tuning_summary_head">Установка интенсивности вибрации</string>
+ <string name="vibrator_warning">Не рекомендуется установка значения выше %1$d</string>
+
+ <string name="category_radio_title">Модем</string>
+ <string name="hspa_title_head">HSPA</string>
+ <string name="hspa_summary_head">Включить HSDPA/HSUPA</string>
+
+ <string name="category_dock_title">Док-станция</string>
+ <string name="dockaudio_subcat_title">Аудио</string>
+ <string name="use_dock_audio_title_head">USB аудио док-станция</string>
+ <string name="use_dock_audio_summary_head">Использовать пассивный режим аудио док-станции</string>
</resources>
diff --git a/DeviceSettings/res/values-zh-rCN/arrays.xml b/DeviceSettings/res/values-zh-rCN/arrays.xml
index 6afb949..373d649 100644
--- a/DeviceSettings/res/values-zh-rCN/arrays.xml
+++ b/DeviceSettings/res/values-zh-rCN/arrays.xml
@@ -15,13 +15,6 @@
-->
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string-array name="vibrator_intensity_entries">
- <item>0%</item>
- <item>25%</item>
- <item>50% (默认)</item>
- <item>75%</item>
- <item>100%</item>
- </string-array>
<string-array name="hspa_entries">
<item>仅使用 UMTS</item>
diff --git a/DeviceSettings/res/values-zh-rCN/strings.xml b/DeviceSettings/res/values-zh-rCN/strings.xml
index b0cc29a..f4158b9 100644
--- a/DeviceSettings/res/values-zh-rCN/strings.xml
+++ b/DeviceSettings/res/values-zh-rCN/strings.xml
@@ -17,17 +17,12 @@
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_name">高级设置</string>
- <string name="category_haptic_title">振动</string>
- <string name="vibrator_subcat_title">振动器</string>
- <string name="vibrator_intensity_title_head">振动器强度</string>
- <string name="vibrator_intensity_summary_head">设置振动器强度</string>
-
<string name="category_radio_title">无线电</string>
<string name="hspa_title_head">HSPA</string>
<string name="hspa_summary_head">启用 HSDPA/HSUPA</string>
<string name="category_screen_title">屏幕</string>
- <string name="mdnie_subcat_title">颜色</string>
+ <string name="screen_colors_title">颜色</string>
<string name="mdnie_scenario_title_head">场景</string>
<string name="mdnie_scenario_summary_head">设置 mDNIe 场景</string>
<string name="mdnie_mode_title_head">模式</string>
diff --git a/DeviceSettings/res/values/arrays.xml b/DeviceSettings/res/values/arrays.xml
index d82ffbc..8e99c95 100644
--- a/DeviceSettings/res/values/arrays.xml
+++ b/DeviceSettings/res/values/arrays.xml
@@ -1,33 +1,5 @@
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string-array name="vibrator_intensity_entries">
- <item>0%</item>
- <item>25%</item>
- <item>50% (Default)</item>
- <item>75%</item>
- <item>100%</item>
- </string-array>
-
- <string-array name="vibrator_intensity_entries_values" translatable="false">
- <item>0</item>
- <item>25</item>
- <item>50</item>
- <item>75</item>
- <item>100</item>
- </string-array>
-
- <string-array name="hspa_entries">
- <item>UMTS Only</item>
- <item>HSDPA Only</item>
- <item>HSDPA + HSUPA</item>
- </string-array>
-
- <string-array name="hspa_entries_values" translatable="false">
- <item>21</item>
- <item>22</item>
- <item>23</item>
- </string-array>
-
<string-array name="mdnie_scenario_entries">
<item>CyanogenMod (Default)</item>
<item>UI</item>
@@ -76,16 +48,6 @@
<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>
-
<string-array name="touchkey_timeout_entries">
<item>Never</item>
<item>1 second</item>
@@ -106,4 +68,26 @@
<item>6</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>
+
+ <string-array name="hspa_entries">
+ <item>UMTS Only</item>
+ <item>HSDPA Only</item>
+ <item>HSDPA + HSUPA</item>
+ </string-array>
+
+ <string-array name="hspa_entries_values" translatable="false">
+ <item>21</item>
+ <item>22</item>
+ <item>23</item>
+ </string-array>
+
</resources>
diff --git a/DeviceSettings/res/values/config.xml b/DeviceSettings/res/values/config.xml
new file mode 100644
index 0000000..5667f97
--- /dev/null
+++ b/DeviceSettings/res/values/config.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2013 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.
+-->
+
+<!-- These resources are around just to allow their values to be customized
+ for different hardware and product builds. -->
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <!-- Vibrator Tuning -->
+ <bool name="has_vibrator_tuning">true</bool>
+ <string name="vibrator_sysfs_file">"/sys/vibrator/pwm_val"</string>
+ <string name="intensity_max_value">100</string>
+ <string name="intensity_warning_threshold">75</string>
+ <string name="intensity_default_value">50</string>
+ <string name="intensity_min_value">0</string>
+
+</resources>
diff --git a/DeviceSettings/res/values/strings.xml b/DeviceSettings/res/values/strings.xml
index 1bf9807..155e9c2 100644
--- a/DeviceSettings/res/values/strings.xml
+++ b/DeviceSettings/res/values/strings.xml
@@ -2,11 +2,13 @@
<resources>
<string name="app_name">Advanced settings</string>
- <!-- Screen -->
+ <string name="defaults_button">Reset to default</string>
+
+ <!-- Screen Preference -->
<string name="category_screen_title">Screen</string>
- <string name="mdnie_subcat_title">Colors</string>
+ <string name="screen_colors_title">Colors</string>
- <!-- CABC -->
+ <!-- Content adaptive backlight control -->
<string name="cabc_title_head">CABC</string>
<string name="cabc_summary_head">Enable content adaptive backlight control</string>
@@ -23,7 +25,7 @@
<string name="led_fade_title_head">LED Fading</string>
<string name="led_fade_summary_head">Enable LED smooth fading instead of sharp blinking.</string>
- <!-- Touchkey -->
+ <!-- Touchkey tuning -->
<string name="touchkey_subcat_title">Touchkeys</string>
<string name="touchkey_light_title_head">Backlight</string>
<string name="touchkey_light_summary_off">Enable backlight</string>
@@ -31,21 +33,24 @@
<string name="touchkey_timeout_title_head">Backlight timeout</string>
<string name="touchkey_timeout_summary_head">Set timeout for the backlight</string>
- <!-- Dock -->
- <string name="category_dock_title">Dock</string>
- <string name="dockaudio_subcat_title">Dock Audio</string>
- <string name="use_dock_audio_title_head">Use Dock USB Audio</string>
- <string name="use_dock_audio_summary_head">Use the passive audio out on the dock</string>
-
- <!-- Haptic -->
+ <!-- Haptic Preference -->
<string name="category_haptic_title">Haptic</string>
- <string name="vibrator_subcat_title">Vibrator</string>
- <string name="vibrator_intensity_title_head">Vibrator Intensity</string>
- <string name="vibrator_intensity_summary_head">Set vibrator intensity</string>
- <!-- Radio -->
+ <!-- VibratorTuning -->
+ <string name="vibrator_title">Vibrator</string>
+ <string name="vibrator_tuning_title">Vibration strength</string>
+ <string name="vibrator_tuning_summary_head">Adjust the strength of the vibration feedback</string>
+ <string name="vibrator_warning">Values higher than %1$d are not recommended</string>
+
+ <!-- Radio Preference -->
<string name="category_radio_title">Radio</string>
<string name="hspa_title_head">HSPA</string>
<string name="hspa_summary_head">Enable HSDPA/HSUPA</string>
+ <!-- Dock Preference -->
+ <string name="category_dock_title">Dock</string>
+ <string name="dockaudio_subcat_title">Audio</string>
+ <string name="use_dock_audio_title_head">Use Dock USB Audio</string>
+ <string name="use_dock_audio_summary_head">Use the passive audio out on the dock</string>
+
</resources>
diff --git a/DeviceSettings/res/xml/haptic_preferences.xml b/DeviceSettings/res/xml/haptic_preferences.xml
index 31c0e21..31070ed 100644
--- a/DeviceSettings/res/xml/haptic_preferences.xml
+++ b/DeviceSettings/res/xml/haptic_preferences.xml
@@ -1,13 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
- android:title="@string/vibrator_subcat_title">
- <com.cyanogenmod.settings.device.VibratorIntensity
- android:key="vibrator_intensity"
- android:title="@string/vibrator_intensity_title_head"
- android:summary="@string/vibrator_intensity_summary_head"
- android:entries="@array/vibrator_intensity_entries"
- android:entryValues="@array/vibrator_intensity_entries_values"
- android:defaultValue="50" />
+ android:title="@string/vibrator_title">
+ <com.cyanogenmod.settings.device.VibratorTuningPreference
+ android:key="vibrator_tuning"
+ android:title="@string/vibrator_tuning_title"
+ android:dialogTitle="@string/vibrator_tuning_title" />
</PreferenceCategory>
</PreferenceScreen>
diff --git a/DeviceSettings/res/xml/screen_preferences.xml b/DeviceSettings/res/xml/screen_preferences.xml
index 313f22c..57d1761 100644
--- a/DeviceSettings/res/xml/screen_preferences.xml
+++ b/DeviceSettings/res/xml/screen_preferences.xml
@@ -3,8 +3,7 @@
<!-- Screen -->
<PreferenceCategory
- android:title="@string/mdnie_subcat_title">
-
+ android:title="@string/screen_colors_title">
<!-- CABC -->
<com.cyanogenmod.settings.device.CABC
android:key="cabc"
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java b/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java
index 3284e39..486fe79 100644
--- a/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java
@@ -65,15 +65,14 @@ public class DeviceSettings extends FragmentActivity {
bar.setDisplayHomeAsUpEnabled(true);
mTabsAdapter = new TabsAdapter(this, mViewPager);
- mTabsAdapter.addTab(bar.newTab().setText(R.string.category_dock_title),
- DockFragmentActivity.class, null);
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_dock_title),
+ DockFragmentActivity.class, null);
if (savedInstanceState != null) {
bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0));
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/DockFragmentActivity.java b/DeviceSettings/src/com/cyanogenmod/settings/device/DockFragmentActivity.java
index 1adf774..0e555e4 100644
--- a/DeviceSettings/src/com/cyanogenmod/settings/device/DockFragmentActivity.java
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/DockFragmentActivity.java
@@ -43,7 +43,6 @@ public class DockFragmentActivity extends PreferenceFragment {
addPreferencesFromResource(R.xml.dock_preferences);
PreferenceScreen prefSet = getPreferenceScreen();
-
}
@Override
@@ -60,7 +59,6 @@ public class DockFragmentActivity extends PreferenceFragment {
i.putExtra("data", boxValue);
ActivityManagerNative.broadcastStickyIntent(i, null, UserHandle.USER_ALL);
}
-
return true;
}
@@ -71,5 +69,4 @@ public class DockFragmentActivity extends PreferenceFragment {
i.putExtra("data", (dockAudio? "1" : "0"));
ActivityManagerNative.broadcastStickyIntent(i, null, UserHandle.USER_ALL);
}
-
}
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/HapticFragmentActivity.java b/DeviceSettings/src/com/cyanogenmod/settings/device/HapticFragmentActivity.java
index 176d80a..f55b59e 100644
--- a/DeviceSettings/src/com/cyanogenmod/settings/device/HapticFragmentActivity.java
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/HapticFragmentActivity.java
@@ -17,9 +17,9 @@
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;
@@ -32,27 +32,33 @@ import com.cyanogenmod.settings.device.R;
public class HapticFragmentActivity extends PreferenceFragment {
- private static final String PREF_ENABLED = "1";
private static final String TAG = "DeviceSettings_Haptic";
+ public static final String KEY_VIBRATOR_TUNING = "vibrator_tuning";
+
+ private static boolean sVibratorTuning;
+ private VibratorTuningPreference mVibratorTuning;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- addPreferencesFromResource(R.xml.haptic_preferences);
+ Resources res = getResources();
+ sVibratorTuning = res.getBoolean(R.bool.has_vibrator_tuning);
- PreferenceScreen prefSet = getPreferenceScreen();
+ addPreferencesFromResource(R.xml.haptic_preferences);
+ if (sVibratorTuning) {
+ String vibratorFilePath = res.getString(R.string.vibrator_sysfs_file);
+ mVibratorTuning = (VibratorTuningPreference) findPreference(KEY_VIBRATOR_TUNING);
+ mVibratorTuning.setEnabled(VibratorTuningPreference.isSupported(vibratorFilePath));
+ }
}
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
-
String boxValue;
String key = preference.getKey();
-
Log.w(TAG, "key: " + key);
-
return true;
}
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/ScreenFragmentActivity.java b/DeviceSettings/src/com/cyanogenmod/settings/device/ScreenFragmentActivity.java
index ea0e429..5a1576d 100644
--- a/DeviceSettings/src/com/cyanogenmod/settings/device/ScreenFragmentActivity.java
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/ScreenFragmentActivity.java
@@ -34,11 +34,11 @@ public class ScreenFragmentActivity extends PreferenceFragment {
private static final String PREF_ENABLED = "1";
private static final String TAG = "DeviceSettings_Screen";
+ private CABC mCABC;
private mDNIeScenario mmDNIeScenario;
private mDNIeMode mmDNIeMode;
private mDNIeNegative mmDNIeNegative;
private LedFade mLedFade;
- private CABC mCABC;
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";
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java b/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java
index 8acfd07..950220e 100644
--- a/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java
@@ -34,7 +34,7 @@ public class Startup extends BroadcastReceiver {
mDNIeMode.restore(context);
mDNIeNegative.restore(context);
LedFade.restore(context);
- VibratorIntensity.restore(context);
TouchkeyTimeout.restore(context);
+ VibratorTuningPreference.restore(context);
}
}
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/Utils.java b/DeviceSettings/src/com/cyanogenmod/settings/device/Utils.java
index bd8eb65..4ca2e9e 100644
--- a/DeviceSettings/src/com/cyanogenmod/settings/device/Utils.java
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/Utils.java
@@ -18,9 +18,11 @@ package com.cyanogenmod.settings.device;
import android.util.Log;
+import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
+import java.io.FileReader;
import java.io.IOException;
import java.io.SyncFailedException;
import android.app.AlertDialog;
@@ -33,6 +35,25 @@ public class Utils {
private static final String TAG_READ = "DeviceSettings_Utils_Read";
private static final String TAG_WRITE = "DeviceSettings_Utils_Write";
+ // Read value from sysfs interface
+ public static String readOneLine(String sFile) {
+ BufferedReader brBuffer;
+ String sLine = null;
+
+ try {
+ brBuffer = new BufferedReader(new FileReader(sFile), 512);
+ try {
+ sLine = brBuffer.readLine();
+ } finally {
+ Log.w(TAG_READ, "file " + sFile + ": " + sLine);
+ brBuffer.close();
+ }
+ } catch (Exception e) {
+ Log.e(TAG_READ, "IO Exception when reading /sys/ file", e);
+ }
+ return sLine;
+ }
+
/**
* Write a string value to the specified file.
*
@@ -128,7 +149,6 @@ public class Utils {
return new File(filename).exists();
}
-
public static void showDialog(Context ctx, String title, String message) {
final AlertDialog alertDialog = new AlertDialog.Builder(ctx).create();
alertDialog.setTitle(title);
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/VibratorIntensity.java b/DeviceSettings/src/com/cyanogenmod/settings/device/VibratorIntensity.java
deleted file mode 100644
index 7a809a5..0000000
--- a/DeviceSettings/src/com/cyanogenmod/settings/device/VibratorIntensity.java
+++ /dev/null
@@ -1,59 +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 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 VibratorIntensity extends ListPreference implements OnPreferenceChangeListener {
-
- public VibratorIntensity(Context context, AttributeSet attrs) {
- super(context, attrs);
- this.setOnPreferenceChangeListener(this);
- }
-
- private static final String FILE = "/sys/vibrator/pwm_val";
-
- public static boolean isSupported() {
- return Utils.fileExists(FILE);
- }
-
- /**
- * Restore vibrator intensity 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_VIBRATOR_INTENSITY, "50"));
- }
-
- public boolean onPreferenceChange(Preference preference, Object newValue) {
- Utils.writeValue(FILE, (String) newValue);
- return true;
- }
-
-}
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/VibratorTuningPreference.java b/DeviceSettings/src/com/cyanogenmod/settings/device/VibratorTuningPreference.java
new file mode 100644
index 0000000..b9e7bb5
--- /dev/null
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/VibratorTuningPreference.java
@@ -0,0 +1,219 @@
+/*
+ * Copyright (C) 2013 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.app.AlertDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.SharedPreferences;
+import android.content.SharedPreferences.Editor;
+import android.graphics.Color;
+import android.graphics.LightingColorFilter;
+import android.graphics.drawable.Drawable;
+import android.graphics.drawable.LayerDrawable;
+import android.os.Bundle;
+import android.os.Vibrator;
+import android.preference.DialogPreference;
+import android.preference.PreferenceManager;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.View;
+import android.widget.SeekBar;
+import android.widget.TextView;
+import android.widget.Button;
+
+import java.lang.Math;
+import java.text.DecimalFormat;
+
+/**
+ * Special preference type that allows configuration of vibrator intensity settings on Sony
+ * Devices
+ */
+public class VibratorTuningPreference extends DialogPreference implements SeekBar.OnSeekBarChangeListener {
+ private static final String TAG = "DeviceSettings_Vibrator";
+
+ private static String FILE_PATH = null;
+ private static int MAX_VALUE;
+ private static int WARNING_THRESHOLD;
+ private static int DEFAULT_VALUE;
+ private static int MIN_VALUE;
+
+ private SeekBar mSeekBar;
+ private TextView mValue;
+ private TextView mWarning;
+
+ private String mOriginalValue;
+ private int mOriginalPercent;
+
+ private Drawable mProgressDrawable;
+ private Drawable mProgressThumb;
+ private LightingColorFilter mRedFilter;
+
+ public VibratorTuningPreference(Context context, AttributeSet attrs) {
+ super(context, attrs);
+
+ FILE_PATH = context.getResources().getString(R.string.vibrator_sysfs_file);
+ MAX_VALUE = Integer.valueOf(context.getResources().getString(R.string.intensity_max_value));
+ WARNING_THRESHOLD = Integer.valueOf(context.getResources().getString(R.string.intensity_warning_threshold));
+ DEFAULT_VALUE = Integer.valueOf(context.getResources().getString(R.string.intensity_default_value));
+ MIN_VALUE = Integer.valueOf(context.getResources().getString(R.string.intensity_min_value));
+
+ setDialogLayoutResource(R.layout.preference_dialog_vibrator_tuning);
+ }
+
+ @Override
+ protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
+ builder.setNeutralButton(R.string.defaults_button, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ }
+ });
+ }
+
+ @Override
+ protected void onBindDialogView(View view) {
+ super.onBindDialogView(view);
+
+ mSeekBar = (SeekBar) view.findViewById(R.id.vibrator_seekbar);
+ mValue = (TextView) view.findViewById(R.id.vibrator_value);
+ mWarning = (TextView) view.findViewById(R.id.textWarn);
+
+ String strWarnMsg = getContext().getResources().getString(R.string.vibrator_warning, strengthToPercent(WARNING_THRESHOLD));
+ mWarning.setText(strWarnMsg);
+
+ Drawable progressDrawable = mSeekBar.getProgressDrawable();
+ if (progressDrawable instanceof LayerDrawable) {
+ LayerDrawable ld = (LayerDrawable) progressDrawable;
+ mProgressDrawable = ld.findDrawableByLayerId(android.R.id.progress);
+ }
+ mProgressThumb = mSeekBar.getThumb();
+ mRedFilter = new LightingColorFilter(Color.BLACK,
+ getContext().getResources().getColor(android.R.color.holo_red_light));
+
+ mOriginalValue = Utils.readOneLine(FILE_PATH);
+ mOriginalPercent = strengthToPercent(Integer.parseInt(mOriginalValue));
+
+ mSeekBar.setOnSeekBarChangeListener(this);
+ mSeekBar.setProgress(Integer.valueOf(mOriginalPercent));
+ }
+
+ @Override
+ protected void showDialog(Bundle state) {
+ super.showDialog(state);
+
+ // can't use onPrepareDialogBuilder for this as we want the dialog
+ // to be kept open on click
+ AlertDialog d = (AlertDialog) getDialog();
+ Button defaultsButton = d.getButton(DialogInterface.BUTTON_NEUTRAL);
+ defaultsButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ mSeekBar.setProgress(strengthToPercent(DEFAULT_VALUE));
+ }
+ });
+ }
+
+ @Override
+ protected void onDialogClosed(boolean positiveResult) {
+ super.onDialogClosed(positiveResult);
+
+ if (positiveResult) {
+ Editor editor = getEditor();
+
+ int strength = percentToStrength(mSeekBar.getProgress());
+ editor.putString(FILE_PATH, String.valueOf(strength));
+ editor.commit();
+ } else {
+ Utils.writeValue(FILE_PATH, String.valueOf(mOriginalPercent));
+ }
+ }
+
+ public static void restore(Context context) {
+ FILE_PATH = context.getResources().getString(R.string.vibrator_sysfs_file);
+
+ if (!isSupported(FILE_PATH)) {
+ return;
+ }
+
+ final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
+ final String value = prefs.getString(FILE_PATH, null);
+
+ if (value != null) {
+ Log.d(TAG, "Restoring vibration setting: " + value);
+ Utils.writeValue(FILE_PATH, value);
+ }
+ }
+
+ public static boolean isSupported(String filePath) {
+ return Utils.fileExists(filePath);
+ }
+
+ @Override
+ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+ boolean shouldWarn = progress >= strengthToPercent(WARNING_THRESHOLD);
+ if (mProgressDrawable != null) {
+ mProgressDrawable.setColorFilter(shouldWarn ? mRedFilter : null);
+ }
+ if (mProgressThumb != null) {
+ mProgressThumb.setColorFilter(shouldWarn ? mRedFilter : null);
+ }
+ Utils.writeValue(FILE_PATH, String.valueOf(percentToStrength(progress)));
+ mValue.setText(String.format("%d%%", progress));
+ }
+
+ @Override
+ public void onStartTrackingTouch(SeekBar seekBar) {
+ // Do nothing
+ }
+
+ @Override
+ public void onStopTrackingTouch(SeekBar seekBar) {
+ Vibrator vib = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE);
+ vib.vibrate(200);
+ }
+
+ /**
+ * Convert vibrator strength to percent
+ */
+ public static int strengthToPercent(int strength) {
+ double maxValue = MAX_VALUE;
+ double minValue = MIN_VALUE;
+
+ double percent = (strength - minValue) * (100 / (maxValue - minValue));
+
+ if (percent > 100)
+ percent = 100;
+ else if (percent < 0)
+ percent = 0;
+
+ return (int) percent;
+ }
+
+ /**
+ * Convert percent to vibrator strength
+ */
+ public static int percentToStrength(int percent) {
+ int strength = Math.round((((MAX_VALUE - MIN_VALUE) * percent) / 100) + MIN_VALUE);
+
+ if (strength > MAX_VALUE)
+ strength = MAX_VALUE;
+ else if (strength < MIN_VALUE)
+ strength = MIN_VALUE;
+
+ return strength;
+ }
+}