aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/latin')
-rw-r--r--java/src/com/android/inputmethod/latin/Settings.java18
-rw-r--r--java/src/com/android/inputmethod/latin/SharedPreferencesCompat.java53
2 files changed, 15 insertions, 56 deletions
diff --git a/java/src/com/android/inputmethod/latin/Settings.java b/java/src/com/android/inputmethod/latin/Settings.java
index a2e896619..bd94bab34 100644
--- a/java/src/com/android/inputmethod/latin/Settings.java
+++ b/java/src/com/android/inputmethod/latin/Settings.java
@@ -328,6 +328,7 @@ public class Settings extends InputMethodSettingsActivity
}
private PreferenceScreen mInputLanguageSelection;
+ private PreferenceScreen mVibrationDurationSettingsPref;
private ListPreference mVoicePreference;
private CheckBoxPreference mShowSettingsKeyPreference;
private ListPreference mShowCorrectionSuggestionsPreference;
@@ -483,10 +484,10 @@ public class Settings extends InputMethodSettingsActivity
}
}
- final PreferenceScreen vibrationSettingsPref =
+ mVibrationDurationSettingsPref =
(PreferenceScreen) findPreference(PREF_VIBRATION_DURATION_SETTINGS);
- if (vibrationSettingsPref != null) {
- vibrationSettingsPref.setOnPreferenceClickListener(
+ if (mVibrationDurationSettingsPref != null) {
+ mVibrationDurationSettingsPref.setOnPreferenceClickListener(
new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference arg0) {
@@ -494,6 +495,7 @@ public class Settings extends InputMethodSettingsActivity
return true;
}
});
+ updateVibrationDurationSettingsSummary(prefs, res);
}
}
@@ -642,9 +644,18 @@ public class Settings extends InputMethodSettingsActivity
}
}
+ private void updateVibrationDurationSettingsSummary(SharedPreferences sp, Resources res) {
+ if (mVibrationDurationSettingsPref != null) {
+ mVibrationDurationSettingsPref.setSummary(
+ Utils.getCurrentVibrationDuration(sp, res)
+ + res.getString(R.string.settings_ms));
+ }
+ }
+
private void showVibrationSettingsDialog() {
final SharedPreferences sp = getPreferenceManager().getSharedPreferences();
final Activity context = getActivityInternal();
+ final Resources res = context.getResources();
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(R.string.prefs_vibration_duration_settings);
builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@@ -652,6 +663,7 @@ public class Settings extends InputMethodSettingsActivity
public void onClick(DialogInterface dialog, int whichButton) {
final int ms = Integer.valueOf(mVibrationSettingsTextView.getText().toString());
sp.edit().putInt(Settings.PREF_VIBRATION_DURATION_SETTINGS, ms).apply();
+ updateVibrationDurationSettingsSummary(sp, res);
}
});
builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
diff --git a/java/src/com/android/inputmethod/latin/SharedPreferencesCompat.java b/java/src/com/android/inputmethod/latin/SharedPreferencesCompat.java
deleted file mode 100644
index 1d36c0b98..000000000
--- a/java/src/com/android/inputmethod/latin/SharedPreferencesCompat.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source 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.android.inputmethod.latin;
-
-import android.content.SharedPreferences;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-/**
- * Reflection utils to call SharedPreferences$Editor.apply when possible,
- * falling back to commit when apply isn't available.
- */
-public class SharedPreferencesCompat {
- private static final Method sApplyMethod = findApplyMethod();
-
- private static Method findApplyMethod() {
- try {
- return SharedPreferences.Editor.class.getMethod("apply");
- } catch (NoSuchMethodException unused) {
- // fall through
- }
- return null;
- }
-
- public static void apply(SharedPreferences.Editor editor) {
- if (sApplyMethod != null) {
- try {
- sApplyMethod.invoke(editor);
- return;
- } catch (InvocationTargetException unused) {
- // fall through
- } catch (IllegalAccessException unused) {
- // fall through
- }
- }
- editor.commit();
- }
-}