Show the duration of vibration in settings
bug: 5345401 Change-Id: I666d48d8ddf6c14540eb401129c20ce93972d9cf
This commit is contained in:
parent
9ee8c9c45c
commit
ba76e6ff27
1 changed files with 15 additions and 3 deletions
|
@ -328,6 +328,7 @@ public class Settings extends InputMethodSettingsActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
private PreferenceScreen mInputLanguageSelection;
|
private PreferenceScreen mInputLanguageSelection;
|
||||||
|
private PreferenceScreen mVibrationDurationSettingsPref;
|
||||||
private ListPreference mVoicePreference;
|
private ListPreference mVoicePreference;
|
||||||
private CheckBoxPreference mShowSettingsKeyPreference;
|
private CheckBoxPreference mShowSettingsKeyPreference;
|
||||||
private ListPreference mShowCorrectionSuggestionsPreference;
|
private ListPreference mShowCorrectionSuggestionsPreference;
|
||||||
|
@ -483,10 +484,10 @@ public class Settings extends InputMethodSettingsActivity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final PreferenceScreen vibrationSettingsPref =
|
mVibrationDurationSettingsPref =
|
||||||
(PreferenceScreen) findPreference(PREF_VIBRATION_DURATION_SETTINGS);
|
(PreferenceScreen) findPreference(PREF_VIBRATION_DURATION_SETTINGS);
|
||||||
if (vibrationSettingsPref != null) {
|
if (mVibrationDurationSettingsPref != null) {
|
||||||
vibrationSettingsPref.setOnPreferenceClickListener(
|
mVibrationDurationSettingsPref.setOnPreferenceClickListener(
|
||||||
new OnPreferenceClickListener() {
|
new OnPreferenceClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceClick(Preference arg0) {
|
public boolean onPreferenceClick(Preference arg0) {
|
||||||
|
@ -494,6 +495,7 @@ public class Settings extends InputMethodSettingsActivity
|
||||||
return true;
|
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() {
|
private void showVibrationSettingsDialog() {
|
||||||
final SharedPreferences sp = getPreferenceManager().getSharedPreferences();
|
final SharedPreferences sp = getPreferenceManager().getSharedPreferences();
|
||||||
final Activity context = getActivityInternal();
|
final Activity context = getActivityInternal();
|
||||||
|
final Resources res = context.getResources();
|
||||||
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||||
builder.setTitle(R.string.prefs_vibration_duration_settings);
|
builder.setTitle(R.string.prefs_vibration_duration_settings);
|
||||||
builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
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) {
|
public void onClick(DialogInterface dialog, int whichButton) {
|
||||||
final int ms = Integer.valueOf(mVibrationSettingsTextView.getText().toString());
|
final int ms = Integer.valueOf(mVibrationSettingsTextView.getText().toString());
|
||||||
sp.edit().putInt(Settings.PREF_VIBRATION_DURATION_SETTINGS, ms).apply();
|
sp.edit().putInt(Settings.PREF_VIBRATION_DURATION_SETTINGS, ms).apply();
|
||||||
|
updateVibrationDurationSettingsSummary(sp, res);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
||||||
|
|
Loading…
Reference in a new issue