2009-03-13 22:11:42 +00:00
|
|
|
/*
|
2010-03-26 22:07:10 +00:00
|
|
|
* Copyright (C) 2008 The Android Open Source Project
|
2011-01-19 08:44:39 +00:00
|
|
|
*
|
2009-03-13 22:11:42 +00:00
|
|
|
* 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
|
2010-01-28 18:09:44 +00:00
|
|
|
*
|
2009-03-13 22:11:42 +00:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2010-01-28 18:09:44 +00:00
|
|
|
*
|
2009-03-13 22:11:42 +00:00
|
|
|
* 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;
|
|
|
|
|
2010-01-16 20:21:23 +00:00
|
|
|
import android.app.AlertDialog;
|
2010-03-05 23:49:16 +00:00
|
|
|
import android.app.backup.BackupManager;
|
2011-05-10 06:51:43 +00:00
|
|
|
import android.content.Context;
|
2010-01-16 20:21:23 +00:00
|
|
|
import android.content.DialogInterface;
|
2011-04-01 10:31:30 +00:00
|
|
|
import android.content.Intent;
|
2009-07-05 20:17:13 +00:00
|
|
|
import android.content.SharedPreferences;
|
2011-05-10 06:51:43 +00:00
|
|
|
import android.content.res.Resources;
|
2011-10-11 07:39:11 +00:00
|
|
|
import android.media.AudioManager;
|
2009-03-13 22:11:42 +00:00
|
|
|
import android.os.Bundle;
|
2009-03-26 00:39:38 +00:00
|
|
|
import android.preference.CheckBoxPreference;
|
2010-02-09 22:17:30 +00:00
|
|
|
import android.preference.ListPreference;
|
2011-01-14 05:02:46 +00:00
|
|
|
import android.preference.Preference;
|
|
|
|
import android.preference.Preference.OnPreferenceClickListener;
|
2009-03-13 22:11:42 +00:00
|
|
|
import android.preference.PreferenceGroup;
|
2011-01-14 05:02:46 +00:00
|
|
|
import android.preference.PreferenceScreen;
|
2012-04-13 10:53:44 +00:00
|
|
|
import android.view.LayoutInflater;
|
2011-09-28 11:11:05 +00:00
|
|
|
import android.view.View;
|
2012-04-13 07:41:24 +00:00
|
|
|
import android.view.inputmethod.InputMethodSubtype;
|
2011-09-28 11:11:05 +00:00
|
|
|
import android.widget.SeekBar;
|
|
|
|
import android.widget.SeekBar.OnSeekBarChangeListener;
|
2010-11-30 14:35:56 +00:00
|
|
|
import android.widget.TextView;
|
2010-01-16 20:21:23 +00:00
|
|
|
|
2012-03-26 13:10:21 +00:00
|
|
|
import com.android.inputmethod.latin.define.ProductionFlag;
|
2012-04-13 10:53:44 +00:00
|
|
|
import com.android.inputmethodcommon.InputMethodSettingsFragment;
|
2011-07-21 05:57:28 +00:00
|
|
|
|
2012-04-13 10:53:44 +00:00
|
|
|
public class Settings extends InputMethodSettingsFragment
|
2012-04-02 12:25:01 +00:00
|
|
|
implements SharedPreferences.OnSharedPreferenceChangeListener {
|
2011-09-14 05:07:10 +00:00
|
|
|
public static final boolean ENABLE_EXPERIMENTAL_SETTINGS = false;
|
|
|
|
|
2011-12-09 07:41:05 +00:00
|
|
|
// In the same order as xml/prefs.xml
|
2011-12-09 08:58:51 +00:00
|
|
|
public static final String PREF_GENERAL_SETTINGS = "general_settings";
|
2011-12-09 07:41:05 +00:00
|
|
|
public static final String PREF_AUTO_CAP = "auto_cap";
|
2010-12-09 12:06:26 +00:00
|
|
|
public static final String PREF_VIBRATE_ON = "vibrate_on";
|
|
|
|
public static final String PREF_SOUND_ON = "sound_on";
|
2011-12-09 08:58:51 +00:00
|
|
|
public static final String PREF_POPUP_ON = "popup_on";
|
|
|
|
public static final String PREF_VOICE_MODE = "voice_mode";
|
|
|
|
public static final String PREF_CORRECTION_SETTINGS = "correction_settings";
|
2011-12-09 07:41:05 +00:00
|
|
|
public static final String PREF_CONFIGURE_DICTIONARIES_KEY = "configure_dictionaries_key";
|
2010-12-11 08:06:24 +00:00
|
|
|
public static final String PREF_AUTO_CORRECTION_THRESHOLD = "auto_correction_threshold";
|
2011-12-09 07:41:05 +00:00
|
|
|
public static final String PREF_SHOW_SUGGESTIONS_SETTING = "show_suggestions_setting";
|
2011-12-09 08:58:51 +00:00
|
|
|
public static final String PREF_MISC_SETTINGS = "misc_settings";
|
2011-12-09 07:41:05 +00:00
|
|
|
public static final String PREF_USABILITY_STUDY_MODE = "usability_study_mode";
|
2012-05-18 12:28:09 +00:00
|
|
|
public static final String PREF_LAST_USER_DICTIONARY_WRITE_TIME =
|
|
|
|
"last_user_dictionary_write_time";
|
2011-12-09 07:41:05 +00:00
|
|
|
public static final String PREF_ADVANCED_SETTINGS = "pref_advanced_settings";
|
2012-02-18 01:46:01 +00:00
|
|
|
public static final String PREF_SUPPRESS_LANGUAGE_SWITCH_KEY =
|
|
|
|
"pref_suppress_language_switch_key";
|
|
|
|
public static final String PREF_INCLUDE_OTHER_IMES_IN_LANGUAGE_SWITCH_LIST =
|
|
|
|
"pref_include_other_imes_in_language_switch_list";
|
2012-04-18 13:13:29 +00:00
|
|
|
public static final String PREF_CUSTOM_INPUT_STYLES = "custom_input_styles";
|
2011-05-11 11:51:07 +00:00
|
|
|
public static final String PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY =
|
|
|
|
"pref_key_preview_popup_dismiss_delay";
|
2011-12-09 07:41:05 +00:00
|
|
|
public static final String PREF_KEY_USE_CONTACTS_DICT = "pref_key_use_contacts_dict";
|
2012-04-05 11:49:37 +00:00
|
|
|
public static final String PREF_BIGRAM_PREDICTIONS = "next_word_prediction";
|
2011-12-09 08:58:51 +00:00
|
|
|
public static final String PREF_VIBRATION_DURATION_SETTINGS =
|
2011-09-28 11:11:05 +00:00
|
|
|
"pref_vibration_duration_settings";
|
2011-10-11 07:39:11 +00:00
|
|
|
public static final String PREF_KEYPRESS_SOUND_VOLUME =
|
|
|
|
"pref_keypress_sound_volume";
|
2011-12-09 07:41:05 +00:00
|
|
|
|
|
|
|
public static final String PREF_INPUT_LANGUAGE = "input_language";
|
|
|
|
public static final String PREF_SELECTED_LANGUAGES = "selected_languages";
|
|
|
|
public static final String PREF_DEBUG_SETTINGS = "debug_settings";
|
|
|
|
|
2011-10-11 07:39:11 +00:00
|
|
|
private PreferenceScreen mKeypressVibrationDurationSettingsPref;
|
|
|
|
private PreferenceScreen mKeypressSoundVolumeSettingsPref;
|
2010-02-09 22:17:30 +00:00
|
|
|
private ListPreference mVoicePreference;
|
2011-01-25 08:23:46 +00:00
|
|
|
private ListPreference mShowCorrectionSuggestionsPreference;
|
2011-08-03 08:00:14 +00:00
|
|
|
private ListPreference mAutoCorrectionThresholdPreference;
|
2011-05-11 11:51:07 +00:00
|
|
|
private ListPreference mKeyPreviewPopupDismissDelay;
|
2012-06-20 22:00:45 +00:00
|
|
|
// Use bigrams to predict the next word when there is no input for it yet
|
2011-04-22 04:08:35 +00:00
|
|
|
private CheckBoxPreference mBigramPrediction;
|
2011-04-01 10:31:30 +00:00
|
|
|
private Preference mDebugSettingsPreference;
|
2010-01-28 18:09:44 +00:00
|
|
|
|
2011-10-11 07:39:11 +00:00
|
|
|
private TextView mKeypressVibrationDurationSettingsTextView;
|
|
|
|
private TextView mKeypressSoundVolumeSettingsTextView;
|
2010-11-30 14:35:56 +00:00
|
|
|
|
2010-12-11 08:06:24 +00:00
|
|
|
private void ensureConsistencyOfAutoCorrectionSettings() {
|
|
|
|
final String autoCorrectionOff = getResources().getString(
|
2010-12-13 03:37:23 +00:00
|
|
|
R.string.auto_correction_threshold_mode_index_off);
|
2011-08-03 08:00:14 +00:00
|
|
|
final String currentSetting = mAutoCorrectionThresholdPreference.getValue();
|
2011-08-31 10:02:50 +00:00
|
|
|
if (null != mBigramPrediction) {
|
|
|
|
mBigramPrediction.setEnabled(!currentSetting.equals(autoCorrectionOff));
|
|
|
|
}
|
2010-09-28 03:23:26 +00:00
|
|
|
}
|
2011-01-14 05:02:46 +00:00
|
|
|
|
2009-03-13 22:11:42 +00:00
|
|
|
@Override
|
2011-07-01 10:40:31 +00:00
|
|
|
public void onCreate(Bundle icicle) {
|
2009-03-13 22:11:42 +00:00
|
|
|
super.onCreate(icicle);
|
2011-07-08 23:15:06 +00:00
|
|
|
setInputMethodSettingsCategoryTitle(R.string.language_selection_title);
|
|
|
|
setSubtypeEnablerTitle(R.string.select_language);
|
2012-04-13 10:53:44 +00:00
|
|
|
addPreferencesFromResource(R.xml.prefs);
|
|
|
|
|
2011-05-11 11:51:07 +00:00
|
|
|
final Resources res = getResources();
|
2012-04-13 10:53:44 +00:00
|
|
|
final Context context = getActivity();
|
2011-05-11 11:51:07 +00:00
|
|
|
|
2012-07-04 09:22:40 +00:00
|
|
|
// When we are called from the Settings application but we are not already running, the
|
|
|
|
// {@link SubtypeLocale} class may not have been initialized. It is safe to call
|
|
|
|
// {@link SubtypeLocale#init(Context)} multiple times.
|
|
|
|
SubtypeLocale.init(context);
|
2011-12-09 08:58:51 +00:00
|
|
|
mVoicePreference = (ListPreference) findPreference(PREF_VOICE_MODE);
|
2011-01-25 08:23:46 +00:00
|
|
|
mShowCorrectionSuggestionsPreference =
|
|
|
|
(ListPreference) findPreference(PREF_SHOW_SUGGESTIONS_SETTING);
|
2010-01-16 20:21:23 +00:00
|
|
|
SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
|
|
|
|
prefs.registerOnSharedPreferenceChangeListener(this);
|
2010-01-28 18:09:44 +00:00
|
|
|
|
2011-08-03 08:00:14 +00:00
|
|
|
mAutoCorrectionThresholdPreference =
|
|
|
|
(ListPreference) findPreference(PREF_AUTO_CORRECTION_THRESHOLD);
|
2011-04-22 04:08:35 +00:00
|
|
|
mBigramPrediction = (CheckBoxPreference) findPreference(PREF_BIGRAM_PREDICTIONS);
|
2011-04-01 10:31:30 +00:00
|
|
|
mDebugSettingsPreference = findPreference(PREF_DEBUG_SETTINGS);
|
|
|
|
if (mDebugSettingsPreference != null) {
|
|
|
|
final Intent debugSettingsIntent = new Intent(Intent.ACTION_MAIN);
|
2011-07-01 10:40:31 +00:00
|
|
|
debugSettingsIntent.setClassName(
|
|
|
|
context.getPackageName(), DebugSettings.class.getName());
|
2011-04-01 10:31:30 +00:00
|
|
|
mDebugSettingsPreference.setIntent(debugSettingsIntent);
|
|
|
|
}
|
|
|
|
|
2010-12-11 08:06:24 +00:00
|
|
|
ensureConsistencyOfAutoCorrectionSettings();
|
2010-10-22 05:28:12 +00:00
|
|
|
|
2011-01-19 06:07:14 +00:00
|
|
|
final PreferenceGroup generalSettings =
|
2011-12-09 08:58:51 +00:00
|
|
|
(PreferenceGroup) findPreference(PREF_GENERAL_SETTINGS);
|
2011-01-19 08:44:39 +00:00
|
|
|
final PreferenceGroup textCorrectionGroup =
|
2011-12-09 08:58:51 +00:00
|
|
|
(PreferenceGroup) findPreference(PREF_CORRECTION_SETTINGS);
|
2011-09-14 05:07:10 +00:00
|
|
|
final PreferenceGroup miscSettings =
|
2011-12-09 08:58:51 +00:00
|
|
|
(PreferenceGroup) findPreference(PREF_MISC_SETTINGS);
|
2011-01-19 06:07:14 +00:00
|
|
|
|
2011-05-11 11:51:07 +00:00
|
|
|
final boolean showVoiceKeyOption = res.getBoolean(
|
2010-11-30 14:35:56 +00:00
|
|
|
R.bool.config_enable_show_voice_key_option);
|
|
|
|
if (!showVoiceKeyOption) {
|
2011-01-19 06:07:14 +00:00
|
|
|
generalSettings.removePreference(mVoicePreference);
|
2010-11-30 14:35:56 +00:00
|
|
|
}
|
2010-11-11 09:15:41 +00:00
|
|
|
|
2012-06-25 15:40:53 +00:00
|
|
|
final PreferenceGroup advancedSettings =
|
|
|
|
(PreferenceGroup) findPreference(PREF_ADVANCED_SETTINGS);
|
2012-03-30 09:47:24 +00:00
|
|
|
if (!VibratorUtils.getInstance(context).hasVibrator()) {
|
2011-01-19 06:07:14 +00:00
|
|
|
generalSettings.removePreference(findPreference(PREF_VIBRATE_ON));
|
2012-05-30 05:57:24 +00:00
|
|
|
if (null != advancedSettings) { // Theoretically advancedSettings cannot be null
|
|
|
|
advancedSettings.removePreference(findPreference(PREF_VIBRATION_DURATION_SETTINGS));
|
|
|
|
}
|
2010-11-11 09:15:41 +00:00
|
|
|
}
|
2010-12-13 03:06:57 +00:00
|
|
|
|
2012-06-25 15:40:53 +00:00
|
|
|
final boolean showKeyPreviewPopupOption = res.getBoolean(
|
2011-01-18 06:20:35 +00:00
|
|
|
R.bool.config_enable_show_popup_on_keypress_option);
|
2012-06-25 15:40:53 +00:00
|
|
|
mKeyPreviewPopupDismissDelay =
|
|
|
|
(ListPreference) findPreference(PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY);
|
|
|
|
if (!showKeyPreviewPopupOption) {
|
2011-12-09 08:58:51 +00:00
|
|
|
generalSettings.removePreference(findPreference(PREF_POPUP_ON));
|
2012-06-25 15:40:53 +00:00
|
|
|
if (null != advancedSettings) { // Theoretically advancedSettings cannot be null
|
|
|
|
advancedSettings.removePreference(mKeyPreviewPopupDismissDelay);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
final String[] entries = new String[] {
|
|
|
|
res.getString(R.string.key_preview_popup_dismiss_no_delay),
|
|
|
|
res.getString(R.string.key_preview_popup_dismiss_default_delay),
|
|
|
|
};
|
|
|
|
final String popupDismissDelayDefaultValue = Integer.toString(res.getInteger(
|
|
|
|
R.integer.config_key_preview_linger_timeout));
|
|
|
|
mKeyPreviewPopupDismissDelay.setEntries(entries);
|
|
|
|
mKeyPreviewPopupDismissDelay.setEntryValues(
|
|
|
|
new String[] { "0", popupDismissDelayDefaultValue });
|
|
|
|
if (null == mKeyPreviewPopupDismissDelay.getValue()) {
|
|
|
|
mKeyPreviewPopupDismissDelay.setValue(popupDismissDelayDefaultValue);
|
|
|
|
}
|
|
|
|
mKeyPreviewPopupDismissDelay.setEnabled(
|
|
|
|
SettingsValues.isKeyPreviewPopupEnabled(prefs, res));
|
2011-01-18 06:20:35 +00:00
|
|
|
}
|
2011-01-18 08:45:22 +00:00
|
|
|
|
2012-02-18 01:46:01 +00:00
|
|
|
final CheckBoxPreference includeOtherImesInLanguageSwitchList =
|
|
|
|
(CheckBoxPreference)findPreference(PREF_INCLUDE_OTHER_IMES_IN_LANGUAGE_SWITCH_LIST);
|
|
|
|
includeOtherImesInLanguageSwitchList.setEnabled(
|
|
|
|
!SettingsValues.isLanguageSwitchKeySupressed(prefs));
|
|
|
|
|
2011-06-24 11:17:38 +00:00
|
|
|
final PreferenceScreen dictionaryLink =
|
|
|
|
(PreferenceScreen) findPreference(PREF_CONFIGURE_DICTIONARIES_KEY);
|
|
|
|
final Intent intent = dictionaryLink.getIntent();
|
|
|
|
|
2011-07-01 10:40:31 +00:00
|
|
|
final int number = context.getPackageManager().queryIntentActivities(intent, 0).size();
|
2011-06-24 11:17:38 +00:00
|
|
|
if (0 >= number) {
|
|
|
|
textCorrectionGroup.removePreference(dictionaryLink);
|
|
|
|
}
|
2011-09-14 05:07:10 +00:00
|
|
|
|
2011-12-09 03:40:43 +00:00
|
|
|
final boolean showUsabilityStudyModeOption =
|
|
|
|
res.getBoolean(R.bool.config_enable_usability_study_mode_option)
|
2012-03-26 13:10:21 +00:00
|
|
|
|| ProductionFlag.IS_EXPERIMENTAL || ENABLE_EXPERIMENTAL_SETTINGS;
|
2011-12-09 03:40:43 +00:00
|
|
|
final Preference usabilityStudyPref = findPreference(PREF_USABILITY_STUDY_MODE);
|
|
|
|
if (!showUsabilityStudyModeOption) {
|
|
|
|
if (usabilityStudyPref != null) {
|
|
|
|
miscSettings.removePreference(usabilityStudyPref);
|
|
|
|
}
|
|
|
|
}
|
2012-03-26 13:10:21 +00:00
|
|
|
if (ProductionFlag.IS_EXPERIMENTAL) {
|
2011-12-09 03:40:43 +00:00
|
|
|
if (usabilityStudyPref instanceof CheckBoxPreference) {
|
|
|
|
CheckBoxPreference checkbox = (CheckBoxPreference)usabilityStudyPref;
|
2012-07-18 20:52:41 +00:00
|
|
|
checkbox.setChecked(prefs.getBoolean(PREF_USABILITY_STUDY_MODE,
|
|
|
|
ResearchLogger.DEFAULT_USABILITY_STUDY_MODE));
|
2011-12-09 03:40:43 +00:00
|
|
|
checkbox.setSummary(R.string.settings_warning_researcher_mode);
|
2011-09-14 05:07:10 +00:00
|
|
|
}
|
|
|
|
}
|
2011-09-28 11:11:05 +00:00
|
|
|
|
2011-10-11 07:39:11 +00:00
|
|
|
mKeypressVibrationDurationSettingsPref =
|
2011-12-09 08:58:51 +00:00
|
|
|
(PreferenceScreen) findPreference(PREF_VIBRATION_DURATION_SETTINGS);
|
2011-10-11 07:39:11 +00:00
|
|
|
if (mKeypressVibrationDurationSettingsPref != null) {
|
|
|
|
mKeypressVibrationDurationSettingsPref.setOnPreferenceClickListener(
|
2011-09-28 11:11:05 +00:00
|
|
|
new OnPreferenceClickListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onPreferenceClick(Preference arg0) {
|
2011-10-11 07:39:11 +00:00
|
|
|
showKeypressVibrationDurationSettingsDialog();
|
2011-09-28 11:11:05 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
2011-10-11 07:39:11 +00:00
|
|
|
updateKeypressVibrationDurationSettingsSummary(prefs, res);
|
2011-09-28 11:11:05 +00:00
|
|
|
}
|
2011-10-11 07:39:11 +00:00
|
|
|
|
|
|
|
mKeypressSoundVolumeSettingsPref =
|
|
|
|
(PreferenceScreen) findPreference(PREF_KEYPRESS_SOUND_VOLUME);
|
|
|
|
if (mKeypressSoundVolumeSettingsPref != null) {
|
|
|
|
mKeypressSoundVolumeSettingsPref.setOnPreferenceClickListener(
|
|
|
|
new OnPreferenceClickListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onPreferenceClick(Preference arg0) {
|
|
|
|
showKeypressSoundVolumeSettingDialog();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
updateKeypressSoundVolumeSummary(prefs, res);
|
|
|
|
}
|
|
|
|
refreshEnablingsOfKeypressSoundAndVibrationSettings(prefs, res);
|
2009-03-13 22:11:42 +00:00
|
|
|
}
|
|
|
|
|
2009-03-26 00:39:38 +00:00
|
|
|
@Override
|
2011-07-01 10:40:31 +00:00
|
|
|
public void onResume() {
|
2009-03-26 00:39:38 +00:00
|
|
|
super.onResume();
|
2011-07-21 05:57:28 +00:00
|
|
|
final boolean isShortcutImeEnabled = SubtypeSwitcher.getInstance().isShortcutImeEnabled();
|
2012-03-30 07:08:11 +00:00
|
|
|
if (isShortcutImeEnabled) {
|
2010-02-09 22:17:30 +00:00
|
|
|
updateVoiceModeSummary();
|
2011-07-21 05:57:28 +00:00
|
|
|
} else {
|
|
|
|
getPreferenceScreen().removePreference(mVoicePreference);
|
2010-01-16 20:21:23 +00:00
|
|
|
}
|
2011-01-25 08:23:46 +00:00
|
|
|
updateShowCorrectionSuggestionsSummary();
|
2011-05-11 11:51:07 +00:00
|
|
|
updateKeyPreviewPopupDelaySummary();
|
2012-04-13 07:41:24 +00:00
|
|
|
updateCustomInputStylesSummary();
|
2009-03-13 22:11:42 +00:00
|
|
|
}
|
2009-07-05 20:17:13 +00:00
|
|
|
|
|
|
|
@Override
|
2011-07-01 10:40:31 +00:00
|
|
|
public void onDestroy() {
|
2009-07-05 20:17:13 +00:00
|
|
|
getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(
|
|
|
|
this);
|
|
|
|
super.onDestroy();
|
|
|
|
}
|
|
|
|
|
2010-12-02 09:46:21 +00:00
|
|
|
@Override
|
2010-02-09 22:17:30 +00:00
|
|
|
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
|
2012-04-13 10:53:44 +00:00
|
|
|
(new BackupManager(getActivity())).dataChanged();
|
2012-03-30 07:08:11 +00:00
|
|
|
if (key.equals(PREF_POPUP_ON)) {
|
2011-05-11 11:51:07 +00:00
|
|
|
final ListPreference popupDismissDelay =
|
|
|
|
(ListPreference)findPreference(PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY);
|
|
|
|
if (null != popupDismissDelay) {
|
2011-12-09 08:58:51 +00:00
|
|
|
popupDismissDelay.setEnabled(prefs.getBoolean(PREF_POPUP_ON, true));
|
2011-05-11 11:51:07 +00:00
|
|
|
}
|
2012-02-18 01:46:01 +00:00
|
|
|
} else if (key.equals(PREF_SUPPRESS_LANGUAGE_SWITCH_KEY)) {
|
|
|
|
final CheckBoxPreference includeOtherImesInLanguageSwicthList =
|
|
|
|
(CheckBoxPreference)findPreference(
|
|
|
|
PREF_INCLUDE_OTHER_IMES_IN_LANGUAGE_SWITCH_LIST);
|
|
|
|
includeOtherImesInLanguageSwicthList.setEnabled(
|
|
|
|
!SettingsValues.isLanguageSwitchKeySupressed(prefs));
|
2010-01-16 20:21:23 +00:00
|
|
|
}
|
2010-12-11 08:06:24 +00:00
|
|
|
ensureConsistencyOfAutoCorrectionSettings();
|
2010-02-09 22:17:30 +00:00
|
|
|
updateVoiceModeSummary();
|
2011-01-25 08:23:46 +00:00
|
|
|
updateShowCorrectionSuggestionsSummary();
|
2011-05-11 11:51:07 +00:00
|
|
|
updateKeyPreviewPopupDelaySummary();
|
2011-10-11 07:39:11 +00:00
|
|
|
refreshEnablingsOfKeypressSoundAndVibrationSettings(prefs, getResources());
|
2010-09-15 04:37:52 +00:00
|
|
|
}
|
|
|
|
|
2011-01-25 08:23:46 +00:00
|
|
|
private void updateShowCorrectionSuggestionsSummary() {
|
|
|
|
mShowCorrectionSuggestionsPreference.setSummary(
|
|
|
|
getResources().getStringArray(R.array.prefs_suggestion_visibilities)
|
|
|
|
[mShowCorrectionSuggestionsPreference.findIndexOfValue(
|
|
|
|
mShowCorrectionSuggestionsPreference.getValue())]);
|
|
|
|
}
|
|
|
|
|
2012-04-13 07:41:24 +00:00
|
|
|
private void updateCustomInputStylesSummary() {
|
|
|
|
final PreferenceScreen customInputStyles =
|
|
|
|
(PreferenceScreen)findPreference(PREF_CUSTOM_INPUT_STYLES);
|
|
|
|
final SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
|
2012-04-25 05:17:49 +00:00
|
|
|
final Resources res = getResources();
|
|
|
|
final String prefSubtype = SettingsValues.getPrefAdditionalSubtypes(prefs, res);
|
2012-04-13 07:41:24 +00:00
|
|
|
final InputMethodSubtype[] subtypes =
|
|
|
|
AdditionalSubtype.createAdditionalSubtypesArray(prefSubtype);
|
|
|
|
final StringBuilder styles = new StringBuilder();
|
|
|
|
for (final InputMethodSubtype subtype : subtypes) {
|
|
|
|
if (styles.length() > 0) styles.append(", ");
|
2012-04-25 05:17:49 +00:00
|
|
|
styles.append(SubtypeLocale.getSubtypeDisplayName(subtype, res));
|
2012-04-13 07:41:24 +00:00
|
|
|
}
|
|
|
|
customInputStyles.setSummary(styles);
|
|
|
|
}
|
|
|
|
|
2011-05-11 11:51:07 +00:00
|
|
|
private void updateKeyPreviewPopupDelaySummary() {
|
|
|
|
final ListPreference lp = mKeyPreviewPopupDismissDelay;
|
2012-06-25 15:40:53 +00:00
|
|
|
final CharSequence[] entries = lp.getEntries();
|
|
|
|
if (entries == null || entries.length <= 0) return;
|
|
|
|
lp.setSummary(entries[lp.findIndexOfValue(lp.getValue())]);
|
2011-05-11 11:51:07 +00:00
|
|
|
}
|
|
|
|
|
2010-02-09 22:17:30 +00:00
|
|
|
private void updateVoiceModeSummary() {
|
|
|
|
mVoicePreference.setSummary(
|
|
|
|
getResources().getStringArray(R.array.voice_input_modes_summary)
|
2012-06-25 15:40:53 +00:00
|
|
|
[mVoicePreference.findIndexOfValue(mVoicePreference.getValue())]);
|
2010-01-16 20:21:23 +00:00
|
|
|
}
|
2010-01-28 18:09:44 +00:00
|
|
|
|
2011-10-11 07:39:11 +00:00
|
|
|
private void refreshEnablingsOfKeypressSoundAndVibrationSettings(
|
|
|
|
SharedPreferences sp, Resources res) {
|
|
|
|
if (mKeypressVibrationDurationSettingsPref != null) {
|
2012-04-13 10:53:44 +00:00
|
|
|
final boolean hasVibrator = VibratorUtils.getInstance(getActivity()).hasVibrator();
|
2011-10-11 07:39:11 +00:00
|
|
|
final boolean vibrateOn = hasVibrator && sp.getBoolean(Settings.PREF_VIBRATE_ON,
|
|
|
|
res.getBoolean(R.bool.config_default_vibration_enabled));
|
|
|
|
mKeypressVibrationDurationSettingsPref.setEnabled(vibrateOn);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mKeypressSoundVolumeSettingsPref != null) {
|
|
|
|
final boolean soundOn = sp.getBoolean(Settings.PREF_SOUND_ON,
|
|
|
|
res.getBoolean(R.bool.config_default_sound_enabled));
|
|
|
|
mKeypressSoundVolumeSettingsPref.setEnabled(soundOn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updateKeypressVibrationDurationSettingsSummary(
|
|
|
|
SharedPreferences sp, Resources res) {
|
|
|
|
if (mKeypressVibrationDurationSettingsPref != null) {
|
|
|
|
mKeypressVibrationDurationSettingsPref.setSummary(
|
2011-12-08 13:14:54 +00:00
|
|
|
SettingsValues.getCurrentVibrationDuration(sp, res)
|
2011-09-30 10:59:04 +00:00
|
|
|
+ res.getString(R.string.settings_ms));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-11 07:39:11 +00:00
|
|
|
private void showKeypressVibrationDurationSettingsDialog() {
|
2011-09-28 11:11:05 +00:00
|
|
|
final SharedPreferences sp = getPreferenceManager().getSharedPreferences();
|
2012-04-13 10:53:44 +00:00
|
|
|
final Context context = getActivity();
|
2011-09-30 10:59:04 +00:00
|
|
|
final Resources res = context.getResources();
|
2011-09-28 11:11:05 +00:00
|
|
|
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
2011-10-11 07:39:11 +00:00
|
|
|
builder.setTitle(R.string.prefs_keypress_vibration_duration_settings);
|
2011-09-28 11:11:05 +00:00
|
|
|
builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int whichButton) {
|
2011-10-11 07:39:11 +00:00
|
|
|
final int ms = Integer.valueOf(
|
|
|
|
mKeypressVibrationDurationSettingsTextView.getText().toString());
|
2011-12-09 08:58:51 +00:00
|
|
|
sp.edit().putInt(Settings.PREF_VIBRATION_DURATION_SETTINGS, ms).apply();
|
2011-10-11 07:39:11 +00:00
|
|
|
updateKeypressVibrationDurationSettingsSummary(sp, res);
|
2011-09-28 11:11:05 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int whichButton) {
|
|
|
|
dialog.dismiss();
|
|
|
|
}
|
|
|
|
});
|
2012-04-13 10:53:44 +00:00
|
|
|
final View v = LayoutInflater.from(context).inflate(
|
2011-09-28 11:11:05 +00:00
|
|
|
R.layout.vibration_settings_dialog, null);
|
2011-12-08 13:14:54 +00:00
|
|
|
final int currentMs = SettingsValues.getCurrentVibrationDuration(
|
2011-09-28 11:11:05 +00:00
|
|
|
getPreferenceManager().getSharedPreferences(), getResources());
|
2011-10-11 07:39:11 +00:00
|
|
|
mKeypressVibrationDurationSettingsTextView = (TextView)v.findViewById(R.id.vibration_value);
|
2011-09-28 11:11:05 +00:00
|
|
|
final SeekBar sb = (SeekBar)v.findViewById(R.id.vibration_settings);
|
|
|
|
sb.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
|
|
|
|
@Override
|
|
|
|
public void onProgressChanged(SeekBar arg0, int arg1, boolean arg2) {
|
|
|
|
final int tempMs = arg1;
|
2011-10-11 07:39:11 +00:00
|
|
|
mKeypressVibrationDurationSettingsTextView.setText(String.valueOf(tempMs));
|
2011-09-28 11:11:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onStartTrackingTouch(SeekBar arg0) {
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onStopTrackingTouch(SeekBar arg0) {
|
|
|
|
final int tempMs = arg0.getProgress();
|
2012-03-30 09:47:24 +00:00
|
|
|
VibratorUtils.getInstance(context).vibrate(tempMs);
|
2011-09-28 11:11:05 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
sb.setProgress(currentMs);
|
2011-10-11 07:39:11 +00:00
|
|
|
mKeypressVibrationDurationSettingsTextView.setText(String.valueOf(currentMs));
|
|
|
|
builder.setView(v);
|
|
|
|
builder.create().show();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updateKeypressSoundVolumeSummary(SharedPreferences sp, Resources res) {
|
|
|
|
if (mKeypressSoundVolumeSettingsPref != null) {
|
2011-12-08 13:14:54 +00:00
|
|
|
mKeypressSoundVolumeSettingsPref.setSummary(String.valueOf(
|
|
|
|
(int)(SettingsValues.getCurrentKeypressSoundVolume(sp, res) * 100)));
|
2011-10-11 07:39:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void showKeypressSoundVolumeSettingDialog() {
|
2012-04-13 10:53:44 +00:00
|
|
|
final Context context = getActivity();
|
|
|
|
final AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
|
2011-10-11 07:39:11 +00:00
|
|
|
final SharedPreferences sp = getPreferenceManager().getSharedPreferences();
|
|
|
|
final Resources res = context.getResources();
|
|
|
|
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
|
|
|
builder.setTitle(R.string.prefs_keypress_sound_volume_settings);
|
|
|
|
builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int whichButton) {
|
|
|
|
final float volume =
|
|
|
|
((float)Integer.valueOf(
|
|
|
|
mKeypressSoundVolumeSettingsTextView.getText().toString())) / 100;
|
|
|
|
sp.edit().putFloat(Settings.PREF_KEYPRESS_SOUND_VOLUME, volume).apply();
|
|
|
|
updateKeypressSoundVolumeSummary(sp, res);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int whichButton) {
|
|
|
|
dialog.dismiss();
|
|
|
|
}
|
|
|
|
});
|
2012-04-13 10:53:44 +00:00
|
|
|
final View v = LayoutInflater.from(context).inflate(
|
2011-10-11 07:39:11 +00:00
|
|
|
R.layout.sound_effect_volume_dialog, null);
|
2011-12-08 13:21:26 +00:00
|
|
|
final int currentVolumeInt =
|
|
|
|
(int)(SettingsValues.getCurrentKeypressSoundVolume(sp, res) * 100);
|
2011-10-11 07:39:11 +00:00
|
|
|
mKeypressSoundVolumeSettingsTextView =
|
|
|
|
(TextView)v.findViewById(R.id.sound_effect_volume_value);
|
|
|
|
final SeekBar sb = (SeekBar)v.findViewById(R.id.sound_effect_volume_bar);
|
|
|
|
sb.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
|
|
|
|
@Override
|
|
|
|
public void onProgressChanged(SeekBar arg0, int arg1, boolean arg2) {
|
|
|
|
final int tempVolume = arg1;
|
|
|
|
mKeypressSoundVolumeSettingsTextView.setText(String.valueOf(tempVolume));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onStartTrackingTouch(SeekBar arg0) {
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onStopTrackingTouch(SeekBar arg0) {
|
|
|
|
final float tempVolume = ((float)arg0.getProgress()) / 100;
|
|
|
|
am.playSoundEffect(AudioManager.FX_KEYPRESS_STANDARD, tempVolume);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
sb.setProgress(currentVolumeInt);
|
|
|
|
mKeypressSoundVolumeSettingsTextView.setText(String.valueOf(currentVolumeInt));
|
2011-09-28 11:11:05 +00:00
|
|
|
builder.setView(v);
|
|
|
|
builder.create().show();
|
|
|
|
}
|
2011-10-27 15:33:15 +00:00
|
|
|
}
|