Add advanced settings screen

Also add an option for popup dismissal delay so as to inaugurate the
new screen.  Besides, remove a path for options to escape from
LatinIME and replace with a direct read from the settings.

Change-Id: I7ec6e724262871fa6523506ecc39f65c5fbe34da
main
Jean Chalard 2011-05-11 20:51:07 +09:00
parent bdd732721d
commit 240297d0ee
8 changed files with 123 additions and 44 deletions

View File

@ -46,6 +46,18 @@
<!-- Category title for misc options --> <!-- Category title for misc options -->
<string name="misc_category">Other options</string> <string name="misc_category">Other options</string>
<!-- Option name for advanced settings screen [CHAR LIMIT=25] -->
<string name="advanced_settings">Advanced settings</string>
<!-- Option summary for advanced settings screen [CHAR LIMIT=65 (two lines) or 30 (fits on one line, preferable)] -->
<string name="advanced_settings_summary">Options for expert users</string>
<!-- Option for the dismiss delay of the key popup [CHAR LIMIT=25] -->
<string name="key_preview_popup_dismiss_delay">Key popup dismiss delay</string>
<!-- Description for delay for dismissing a popup on keypress: no delay [CHAR LIMIT=15] -->
<string name="key_preview_popup_dismiss_no_delay">No delay</string>
<!-- Description for delay for dismissing a popup on screen: default value of the delay [CHAR LIMIT=15] -->
<string name="key_preview_popup_dismiss_default_delay">Default</string>
<!-- Option to enable auto capitalization of sentences --> <!-- Option to enable auto capitalization of sentences -->
<string name="auto_cap">Auto-capitalization</string> <string name="auto_cap">Auto-capitalization</string>

View File

@ -130,6 +130,15 @@
android:entries="@array/keyboard_layout_modes" android:entries="@array/keyboard_layout_modes"
android:defaultValue="@string/config_default_keyboard_theme_id" /> android:defaultValue="@string/config_default_keyboard_theme_id" />
</PreferenceCategory> </PreferenceCategory>
<PreferenceScreen
android:key="pref_advanced_settings"
android:title="@string/advanced_settings"
android:summary="@string/advanced_settings_summary">
<!-- Values for popup dismiss delay are added programatically -->
<ListPreference
android:key="pref_key_preview_popup_dismiss_delay"
android:title="@string/key_preview_popup_dismiss_delay" />
</PreferenceScreen>
<!-- <Preference <!-- <Preference
android:title="Debug Settings" android:title="Debug Settings"
android:key="debug_settings"> android:key="debug_settings">

View File

@ -153,7 +153,9 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
final KeyboardId id = getKeyboardId(attribute, isSymbols); final KeyboardId id = getKeyboardId(attribute, isSymbols);
makeSymbolsKeyboardIds(id.mMode, attribute); makeSymbolsKeyboardIds(id.mMode, attribute);
mCurrentId = id; mCurrentId = id;
mInputView.setKeyPreviewEnabled(mInputMethodService.getPopupOn()); final Resources res = mInputMethodService.getResources();
mInputView.setKeyPreviewPopupEnabled(Settings.Values.isKeyPreviewPopupEnabled(mPrefs, res),
Settings.Values.getKeyPreviewPopupDismissDelay(mPrefs, res));
setKeyboard(getKeyboard(id)); setKeyboard(getKeyboard(id));
} }

View File

@ -120,10 +120,10 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
private TextView mPreviewText; private TextView mPreviewText;
private float mPreviewTextRatio; private float mPreviewTextRatio;
private int mPreviewTextSize; private int mPreviewTextSize;
private boolean mShowKeyPreview = true; private boolean mShowKeyPreviewPopup = true;
private int mKeyPreviewDisplayedY; private int mKeyPreviewPopupDisplayedY;
private final int mDelayBeforePreview; private final int mDelayBeforePreview;
private final int mDelayAfterPreview; private int mDelayAfterPreview;
private ViewGroup mPreviewPlacer; private ViewGroup mPreviewPlacer;
private final int[] mCoordinates = new int[2]; private final int[] mCoordinates = new int[2];
@ -340,7 +340,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
mPreviewText = (TextView) LayoutInflater.from(context).inflate(previewLayout, null); mPreviewText = (TextView) LayoutInflater.from(context).inflate(previewLayout, null);
mPreviewTextRatio = getRatio(res, R.fraction.key_preview_text_ratio); mPreviewTextRatio = getRatio(res, R.fraction.key_preview_text_ratio);
} else { } else {
mShowKeyPreview = false; mShowKeyPreviewPopup = false;
} }
mDelayBeforePreview = res.getInteger(R.integer.config_delay_before_preview); mDelayBeforePreview = res.getInteger(R.integer.config_delay_before_preview);
mDelayAfterPreview = res.getInteger(R.integer.config_delay_after_preview); mDelayAfterPreview = res.getInteger(R.integer.config_delay_after_preview);
@ -516,19 +516,21 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
* Enables or disables the key feedback popup. This is a popup that shows a magnified * Enables or disables the key feedback popup. This is a popup that shows a magnified
* version of the depressed key. By default the preview is enabled. * version of the depressed key. By default the preview is enabled.
* @param previewEnabled whether or not to enable the key feedback preview * @param previewEnabled whether or not to enable the key feedback preview
* @see #isKeyPreviewEnabled() * @param delay the delay after which the preview is dismissed
* @see #isKeyPreviewPopupEnabled()
*/ */
public void setKeyPreviewEnabled(boolean previewEnabled) { public void setKeyPreviewPopupEnabled(boolean previewEnabled, int delay) {
mShowKeyPreview = previewEnabled; mShowKeyPreviewPopup = previewEnabled;
mDelayAfterPreview = delay;
} }
/** /**
* Returns the enabled state of the key feedback preview * Returns the enabled state of the key feedback preview
* @return whether or not the key feedback preview is enabled * @return whether or not the key feedback preview is enabled
* @see #setKeyPreviewEnabled(boolean) * @see #setKeyPreviewPopupEnabled(boolean, int)
*/ */
public boolean isKeyPreviewEnabled() { public boolean isKeyPreviewPopupEnabled() {
return mShowKeyPreview; return mShowKeyPreviewPopup;
} }
public int getColorScheme() { public int getColorScheme() {
@ -851,7 +853,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
@Override @Override
public void showKeyPreview(int keyIndex, PointerTracker tracker) { public void showKeyPreview(int keyIndex, PointerTracker tracker) {
if (mShowKeyPreview) { if (mShowKeyPreviewPopup) {
mHandler.showKeyPreview(mDelayBeforePreview, keyIndex, tracker); mHandler.showKeyPreview(mDelayBeforePreview, keyIndex, tracker);
} else if (mKeyboard.needSpacebarPreview(keyIndex)) { } else if (mKeyboard.needSpacebarPreview(keyIndex)) {
// Show key preview (in this case, slide language switcher) without any delay. // Show key preview (in this case, slide language switcher) without any delay.
@ -861,7 +863,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
@Override @Override
public void dismissKeyPreview(PointerTracker tracker) { public void dismissKeyPreview(PointerTracker tracker) {
if (mShowKeyPreview) { if (mShowKeyPreviewPopup) {
mHandler.cancelShowKeyPreview(tracker); mHandler.cancelShowKeyPreview(tracker);
mHandler.dismissKeyPreview(mDelayAfterPreview, tracker); mHandler.dismissKeyPreview(mDelayAfterPreview, tracker);
} else if (mKeyboard.needSpacebarPreview(KeyDetector.NOT_A_KEY)) { } else if (mKeyboard.needSpacebarPreview(KeyDetector.NOT_A_KEY)) {
@ -946,7 +948,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
final int previewX = keyDrawX - (previewWidth - keyDrawWidth) / 2 + mCoordinates[0]; final int previewX = keyDrawX - (previewWidth - keyDrawWidth) / 2 + mCoordinates[0];
final int previewY = key.mY - previewHeight + mCoordinates[1] + mPreviewOffset; final int previewY = key.mY - previewHeight + mCoordinates[1] + mPreviewOffset;
// Record key preview position to display mini-keyboard later at the same position // Record key preview position to display mini-keyboard later at the same position
mKeyPreviewDisplayedY = previewY; mKeyPreviewPopupDisplayedY = previewY;
// Place the key preview. // Place the key preview.
// TODO: Adjust position of key previews which touch screen edges // TODO: Adjust position of key previews which touch screen edges
@ -1097,7 +1099,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
mPopupWindow.setClippingEnabled(false); mPopupWindow.setClippingEnabled(false);
} }
mPopupMiniKeyboardPanel = popupPanel; mPopupMiniKeyboardPanel = popupPanel;
popupPanel.showPanel(this, parentKey, tracker, mKeyPreviewDisplayedY, mPopupWindow); popupPanel.showPanel(this, parentKey, tracker, mKeyPreviewPopupDisplayedY, mPopupWindow);
invalidateAllKeys(); invalidateAllKeys();
return true; return true;

View File

@ -55,14 +55,14 @@ public class LatinKeyboardView extends KeyboardView {
} }
@Override @Override
public void setKeyPreviewEnabled(boolean previewEnabled) { public void setKeyPreviewPopupEnabled(boolean previewEnabled, int delay) {
LatinKeyboard latinKeyboard = getLatinKeyboard(); LatinKeyboard latinKeyboard = getLatinKeyboard();
if (latinKeyboard != null if (latinKeyboard != null
&& (latinKeyboard.isPhoneKeyboard() || latinKeyboard.isNumberKeyboard())) { && (latinKeyboard.isPhoneKeyboard() || latinKeyboard.isNumberKeyboard())) {
// Phone and number keyboard never shows popup preview (except language switch). // Phone and number keyboard never shows popup preview (except language switch).
super.setKeyPreviewEnabled(false); super.setKeyPreviewPopupEnabled(false, delay);
} else { } else {
super.setKeyPreviewEnabled(previewEnabled); super.setKeyPreviewPopupEnabled(previewEnabled, delay);
} }
} }
@ -173,7 +173,8 @@ public class LatinKeyboardView extends KeyboardView {
if (!mDroppingEvents) { if (!mDroppingEvents) {
mDroppingEvents = true; mDroppingEvents = true;
// Send an up event // Send an up event
MotionEvent translated = MotionEvent.obtain(me.getEventTime(), me.getEventTime(), MotionEvent translated = MotionEvent.obtain(
me.getEventTime(), me.getEventTime(),
MotionEvent.ACTION_UP, MotionEvent.ACTION_UP,
mLastX, mLastY, me.getMetaState()); mLastX, mLastY, me.getMetaState());
super.onTouchEvent(translated); super.onTouchEvent(translated);

View File

@ -55,13 +55,14 @@ public class PopupMiniKeyboardView extends KeyboardView implements PopupPanel {
R.dimen.mini_keyboard_slide_allowance)); R.dimen.mini_keyboard_slide_allowance));
// Remove gesture detector on mini-keyboard // Remove gesture detector on mini-keyboard
mGestureDetector = null; mGestureDetector = null;
setKeyPreviewEnabled(false); setKeyPreviewPopupEnabled(false, 0);
} }
@Override @Override
public void setKeyPreviewEnabled(boolean previewEnabled) { public void setKeyPreviewPopupEnabled(boolean previewEnabled, int delay) {
// Mini keyboard needs no pop-up key preview displayed. // Mini keyboard needs no pop-up key preview displayed, so we pass always false with a
super.setKeyPreviewEnabled(false); // delay of 0. The delay does not matter actually since the popup is not shown anyway.
super.setKeyPreviewPopupEnabled(false, 0);
} }
@Override @Override
@ -82,8 +83,8 @@ public class PopupMiniKeyboardView extends KeyboardView implements PopupPanel {
- (container.getMeasuredHeight() - container.getPaddingBottom()) - (container.getMeasuredHeight() - container.getPaddingBottom())
+ parentKeyboardView.getPaddingTop() + mCoordinates[1]; + parentKeyboardView.getPaddingTop() + mCoordinates[1];
final int x = miniKeyboardX; final int x = miniKeyboardX;
final int y = parentKeyboardView.isKeyPreviewEnabled() && miniKeyboard.isOneRowKeyboard() final int y = parentKeyboardView.isKeyPreviewPopupEnabled() &&
? keyPreviewY : miniKeyboardY; miniKeyboard.isOneRowKeyboard() ? keyPreviewY : miniKeyboardY;
if (miniKeyboard.setShifted(parentKeyboard.isShiftedOrShiftLocked())) { if (miniKeyboard.setShifted(parentKeyboard.isShiftedOrShiftLocked())) {
invalidateAllKeys(); invalidateAllKeys();

View File

@ -556,7 +556,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
updateCorrectionMode(); updateCorrectionMode();
inputView.setKeyPreviewEnabled(mSettingsValues.mPopupOn); inputView.setKeyPreviewPopupEnabled(mSettingsValues.mKeyPreviewPopupOn,
mSettingsValues.mKeyPreviewPopupDismissDelay);
inputView.setProximityCorrectionEnabled(true); inputView.setProximityCorrectionEnabled(true);
// If we just entered a text field, maybe it has some old text that requires correction // If we just entered a text field, maybe it has some old text that requires correction
mRecorrection.checkRecorrectionOnStart(); mRecorrection.checkRecorrectionOnStart();
@ -1917,9 +1918,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
return mWord; return mWord;
} }
public boolean getPopupOn() {
return mSettingsValues.mPopupOn;
}
boolean isSoundOn() { boolean isSoundOn() {
return mSettingsValues.mSoundOn && !mSilentModeOn; return mSettingsValues.mSoundOn && !mSilentModeOn;
} }
@ -2063,7 +2061,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
p.println(" TextEntryState.state=" + TextEntryState.getState()); p.println(" TextEntryState.state=" + TextEntryState.getState());
p.println(" mSoundOn=" + mSettingsValues.mSoundOn); p.println(" mSoundOn=" + mSettingsValues.mSoundOn);
p.println(" mVibrateOn=" + mSettingsValues.mVibrateOn); p.println(" mVibrateOn=" + mSettingsValues.mVibrateOn);
p.println(" mPopupOn=" + mSettingsValues.mPopupOn); p.println(" mKeyPreviewPopupOn=" + mSettingsValues.mKeyPreviewPopupOn);
} }
// Characters per second measurement // Characters per second measurement

View File

@ -56,7 +56,7 @@ public class Settings extends PreferenceActivity
public static final String PREF_GENERAL_SETTINGS_KEY = "general_settings"; public static final String PREF_GENERAL_SETTINGS_KEY = "general_settings";
public static final String PREF_VIBRATE_ON = "vibrate_on"; public static final String PREF_VIBRATE_ON = "vibrate_on";
public static final String PREF_SOUND_ON = "sound_on"; public static final String PREF_SOUND_ON = "sound_on";
public static final String PREF_POPUP_ON = "popup_on"; public static final String PREF_KEY_PREVIEW_POPUP_ON = "popup_on";
public static final String PREF_RECORRECTION_ENABLED = "recorrection_enabled"; public static final String PREF_RECORRECTION_ENABLED = "recorrection_enabled";
public static final String PREF_AUTO_CAP = "auto_cap"; public static final String PREF_AUTO_CAP = "auto_cap";
public static final String PREF_SETTINGS_KEY = "settings_key"; public static final String PREF_SETTINGS_KEY = "settings_key";
@ -77,6 +77,9 @@ public class Settings extends PreferenceActivity
public static final String PREF_MISC_SETTINGS_KEY = "misc_settings"; public static final String PREF_MISC_SETTINGS_KEY = "misc_settings";
public static final String PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY =
"pref_key_preview_popup_dismiss_delay";
public static final String PREF_USABILITY_STUDY_MODE = "usability_study_mode"; public static final String PREF_USABILITY_STUDY_MODE = "usability_study_mode";
// Dialog ids // Dialog ids
@ -102,7 +105,8 @@ public class Settings extends PreferenceActivity
// From preferences: // From preferences:
public final boolean mSoundOn; // Sound setting private to Latin IME (see mSilentModeOn) public final boolean mSoundOn; // Sound setting private to Latin IME (see mSilentModeOn)
public final boolean mVibrateOn; public final boolean mVibrateOn;
public final boolean mPopupOn; // Warning : this escapes through LatinIME#isPopupOn public final boolean mKeyPreviewPopupOn;
public final int mKeyPreviewPopupDismissDelay;
public final boolean mAutoCap; public final boolean mAutoCap;
public final boolean mQuickFixes; public final boolean mQuickFixes;
public final boolean mAutoCorrectEnabled; public final boolean mAutoCorrectEnabled;
@ -161,7 +165,8 @@ public class Settings extends PreferenceActivity
mSoundOn = prefs.getBoolean(Settings.PREF_SOUND_ON, mSoundOn = prefs.getBoolean(Settings.PREF_SOUND_ON,
res.getBoolean(R.bool.config_default_sound_enabled)); res.getBoolean(R.bool.config_default_sound_enabled));
mPopupOn = isPopupEnabled(prefs, res); mKeyPreviewPopupOn = isKeyPreviewPopupEnabled(prefs, res);
mKeyPreviewPopupDismissDelay = getKeyPreviewPopupDismissDelay(prefs, res);
mAutoCap = prefs.getBoolean(Settings.PREF_AUTO_CAP, true); mAutoCap = prefs.getBoolean(Settings.PREF_AUTO_CAP, true);
mQuickFixes = isQuickFixesEnabled(prefs, res); mQuickFixes = isQuickFixesEnabled(prefs, res);
@ -202,6 +207,7 @@ public class Settings extends PreferenceActivity
return sp.getBoolean(Settings.PREF_QUICK_FIXES, resources.getBoolean( return sp.getBoolean(Settings.PREF_QUICK_FIXES, resources.getBoolean(
R.bool.config_default_quick_fixes)); R.bool.config_default_quick_fixes));
} }
private static boolean isAutoCorrectEnabled(SharedPreferences sp, Resources resources) { private static boolean isAutoCorrectEnabled(SharedPreferences sp, Resources resources) {
final String currentAutoCorrectionSetting = sp.getString( final String currentAutoCorrectionSetting = sp.getString(
Settings.PREF_AUTO_CORRECTION_THRESHOLD, Settings.PREF_AUTO_CORRECTION_THRESHOLD,
@ -210,13 +216,24 @@ public class Settings extends PreferenceActivity
R.string.auto_correction_threshold_mode_index_off); R.string.auto_correction_threshold_mode_index_off);
return !currentAutoCorrectionSetting.equals(autoCorrectionOff); return !currentAutoCorrectionSetting.equals(autoCorrectionOff);
} }
private static boolean isPopupEnabled(SharedPreferences sp, Resources resources) {
// Public to access from KeyboardSwitcher. Should it have access to some
// process-global instance instead?
public static boolean isKeyPreviewPopupEnabled(SharedPreferences sp, Resources resources) {
final boolean showPopupOption = resources.getBoolean( final boolean showPopupOption = resources.getBoolean(
R.bool.config_enable_show_popup_on_keypress_option); R.bool.config_enable_show_popup_on_keypress_option);
if (!showPopupOption) return resources.getBoolean(R.bool.config_default_popup_preview); if (!showPopupOption) return resources.getBoolean(R.bool.config_default_popup_preview);
return sp.getBoolean(Settings.PREF_POPUP_ON, return sp.getBoolean(Settings.PREF_KEY_PREVIEW_POPUP_ON,
resources.getBoolean(R.bool.config_default_popup_preview)); resources.getBoolean(R.bool.config_default_popup_preview));
} }
// Likewise
public static int getKeyPreviewPopupDismissDelay(SharedPreferences sp,
Resources resources) {
return Integer.parseInt(sp.getString(Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY,
Integer.toString(resources.getInteger(R.integer.config_delay_after_preview))));
}
private static boolean isBigramSuggestionEnabled(SharedPreferences sp, Resources resources, private static boolean isBigramSuggestionEnabled(SharedPreferences sp, Resources resources,
boolean autoCorrectEnabled) { boolean autoCorrectEnabled) {
final boolean showBigramSuggestionsOption = resources.getBoolean( final boolean showBigramSuggestionsOption = resources.getBoolean(
@ -227,11 +244,13 @@ public class Settings extends PreferenceActivity
return sp.getBoolean(Settings.PREF_BIGRAM_SUGGESTIONS, resources.getBoolean( return sp.getBoolean(Settings.PREF_BIGRAM_SUGGESTIONS, resources.getBoolean(
R.bool.config_default_bigram_suggestions)); R.bool.config_default_bigram_suggestions));
} }
private static boolean isBigramPredictionEnabled(SharedPreferences sp, private static boolean isBigramPredictionEnabled(SharedPreferences sp,
Resources resources) { Resources resources) {
return sp.getBoolean(Settings.PREF_BIGRAM_PREDICTIONS, resources.getBoolean( return sp.getBoolean(Settings.PREF_BIGRAM_PREDICTIONS, resources.getBoolean(
R.bool.config_default_bigram_prediction)); R.bool.config_default_bigram_prediction));
} }
private static double getAutoCorrectionThreshold(SharedPreferences sp, private static double getAutoCorrectionThreshold(SharedPreferences sp,
Resources resources) { Resources resources) {
final String currentAutoCorrectionSetting = sp.getString( final String currentAutoCorrectionSetting = sp.getString(
@ -257,6 +276,7 @@ public class Settings extends PreferenceActivity
} }
return autoCorrectionThreshold; return autoCorrectionThreshold;
} }
private static SuggestedWords createSuggestPuncList(final String puncs) { private static SuggestedWords createSuggestPuncList(final String puncs) {
SuggestedWords.Builder builder = new SuggestedWords.Builder(); SuggestedWords.Builder builder = new SuggestedWords.Builder();
if (puncs != null) { if (puncs != null) {
@ -274,6 +294,7 @@ public class Settings extends PreferenceActivity
private ListPreference mSettingsKeyPreference; private ListPreference mSettingsKeyPreference;
private ListPreference mShowCorrectionSuggestionsPreference; private ListPreference mShowCorrectionSuggestionsPreference;
private ListPreference mAutoCorrectionThreshold; private ListPreference mAutoCorrectionThreshold;
private ListPreference mKeyPreviewPopupDismissDelay;
// Suggestion: use bigrams to adjust scores of suggestions obtained from unigram dictionary // Suggestion: use bigrams to adjust scores of suggestions obtained from unigram dictionary
private CheckBoxPreference mBigramSuggestion; private CheckBoxPreference mBigramSuggestion;
// Prediction: use bigrams to predict the next word when there is no input for it yet // Prediction: use bigrams to predict the next word when there is no input for it yet
@ -299,6 +320,8 @@ public class Settings extends PreferenceActivity
@Override @Override
protected void onCreate(Bundle icicle) { protected void onCreate(Bundle icicle) {
super.onCreate(icicle); super.onCreate(icicle);
final Resources res = getResources();
addPreferencesFromResource(R.xml.prefs); addPreferencesFromResource(R.xml.prefs);
mInputLanguageSelection = (PreferenceScreen) findPreference(PREF_SUBTYPES); mInputLanguageSelection = (PreferenceScreen) findPreference(PREF_SUBTYPES);
mInputLanguageSelection.setOnPreferenceClickListener(this); mInputLanguageSelection.setOnPreferenceClickListener(this);
@ -334,13 +357,13 @@ public class Settings extends PreferenceActivity
final PreferenceGroup bigramGroup = final PreferenceGroup bigramGroup =
(PreferenceGroup) findPreference(PREF_NGRAM_SETTINGS_KEY); (PreferenceGroup) findPreference(PREF_NGRAM_SETTINGS_KEY);
final boolean showSettingsKeyOption = getResources().getBoolean( final boolean showSettingsKeyOption = res.getBoolean(
R.bool.config_enable_show_settings_key_option); R.bool.config_enable_show_settings_key_option);
if (!showSettingsKeyOption) { if (!showSettingsKeyOption) {
generalSettings.removePreference(mSettingsKeyPreference); generalSettings.removePreference(mSettingsKeyPreference);
} }
final boolean showVoiceKeyOption = getResources().getBoolean( final boolean showVoiceKeyOption = res.getBoolean(
R.bool.config_enable_show_voice_key_option); R.bool.config_enable_show_voice_key_option);
if (!showVoiceKeyOption) { if (!showVoiceKeyOption) {
generalSettings.removePreference(mVoicePreference); generalSettings.removePreference(mVoicePreference);
@ -350,43 +373,60 @@ public class Settings extends PreferenceActivity
generalSettings.removePreference(findPreference(PREF_VIBRATE_ON)); generalSettings.removePreference(findPreference(PREF_VIBRATE_ON));
} }
final boolean showSubtypeSettings = getResources().getBoolean( final boolean showSubtypeSettings = res.getBoolean(
R.bool.config_enable_show_subtype_settings); R.bool.config_enable_show_subtype_settings);
if (InputMethodServiceCompatWrapper.CAN_HANDLE_ON_CURRENT_INPUT_METHOD_SUBTYPE_CHANGED if (InputMethodServiceCompatWrapper.CAN_HANDLE_ON_CURRENT_INPUT_METHOD_SUBTYPE_CHANGED
&& !showSubtypeSettings) { && !showSubtypeSettings) {
generalSettings.removePreference(findPreference(PREF_SUBTYPES)); generalSettings.removePreference(findPreference(PREF_SUBTYPES));
} }
final boolean showPopupOption = getResources().getBoolean( final boolean showPopupOption = res.getBoolean(
R.bool.config_enable_show_popup_on_keypress_option); R.bool.config_enable_show_popup_on_keypress_option);
if (!showPopupOption) { if (!showPopupOption) {
generalSettings.removePreference(findPreference(PREF_POPUP_ON)); generalSettings.removePreference(findPreference(PREF_KEY_PREVIEW_POPUP_ON));
} }
final boolean showRecorrectionOption = getResources().getBoolean( final boolean showRecorrectionOption = res.getBoolean(
R.bool.config_enable_show_recorrection_option); R.bool.config_enable_show_recorrection_option);
if (!showRecorrectionOption) { if (!showRecorrectionOption) {
generalSettings.removePreference(findPreference(PREF_RECORRECTION_ENABLED)); generalSettings.removePreference(findPreference(PREF_RECORRECTION_ENABLED));
} }
final boolean showQuickFixesOption = getResources().getBoolean( final boolean showQuickFixesOption = res.getBoolean(
R.bool.config_enable_quick_fixes_option); R.bool.config_enable_quick_fixes_option);
if (!showQuickFixesOption) { if (!showQuickFixesOption) {
textCorrectionGroup.removePreference(findPreference(PREF_QUICK_FIXES)); textCorrectionGroup.removePreference(findPreference(PREF_QUICK_FIXES));
} }
final boolean showBigramSuggestionsOption = getResources().getBoolean( final boolean showBigramSuggestionsOption = res.getBoolean(
R.bool.config_enable_bigram_suggestions_option); R.bool.config_enable_bigram_suggestions_option);
if (!showBigramSuggestionsOption) { if (!showBigramSuggestionsOption) {
textCorrectionGroup.removePreference(findPreference(PREF_BIGRAM_SUGGESTIONS)); textCorrectionGroup.removePreference(findPreference(PREF_BIGRAM_SUGGESTIONS));
textCorrectionGroup.removePreference(findPreference(PREF_BIGRAM_PREDICTIONS)); textCorrectionGroup.removePreference(findPreference(PREF_BIGRAM_PREDICTIONS));
} }
final boolean showUsabilityModeStudyOption = getResources().getBoolean( final boolean showUsabilityModeStudyOption = res.getBoolean(
R.bool.config_enable_usability_study_mode_option); R.bool.config_enable_usability_study_mode_option);
if (!showUsabilityModeStudyOption) { if (!showUsabilityModeStudyOption) {
getPreferenceScreen().removePreference(findPreference(PREF_USABILITY_STUDY_MODE)); getPreferenceScreen().removePreference(findPreference(PREF_USABILITY_STUDY_MODE));
} }
mKeyPreviewPopupDismissDelay =
(ListPreference)findPreference(PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY);
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_delay_after_preview));
mKeyPreviewPopupDismissDelay.setEntries(entries);
mKeyPreviewPopupDismissDelay.setEntryValues(
new String[] { "0", popupDismissDelayDefaultValue });
if (null == mKeyPreviewPopupDismissDelay.getValue()) {
mKeyPreviewPopupDismissDelay.setValue(popupDismissDelayDefaultValue);
}
mKeyPreviewPopupDismissDelay.setEnabled(
Settings.Values.isKeyPreviewPopupEnabled(prefs, res));
} }
@Override @Override
@ -405,6 +445,7 @@ public class Settings extends PreferenceActivity
} }
updateSettingsKeySummary(); updateSettingsKeySummary();
updateShowCorrectionSuggestionsSummary(); updateShowCorrectionSuggestionsSummary();
updateKeyPreviewPopupDelaySummary();
} }
@Override @Override
@ -423,6 +464,12 @@ public class Settings extends PreferenceActivity
.equals(mVoiceModeOff)) { .equals(mVoiceModeOff)) {
showVoiceConfirmation(); showVoiceConfirmation();
} }
} else if (key.equals(PREF_KEY_PREVIEW_POPUP_ON)) {
final ListPreference popupDismissDelay =
(ListPreference)findPreference(PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY);
if (null != popupDismissDelay) {
popupDismissDelay.setEnabled(prefs.getBoolean(PREF_KEY_PREVIEW_POPUP_ON, true));
}
} }
ensureConsistencyOfAutoCorrectionSettings(); ensureConsistencyOfAutoCorrectionSettings();
mVoiceOn = !(prefs.getString(PREF_VOICE_SETTINGS_KEY, mVoiceModeOff) mVoiceOn = !(prefs.getString(PREF_VOICE_SETTINGS_KEY, mVoiceModeOff)
@ -430,6 +477,7 @@ public class Settings extends PreferenceActivity
updateVoiceModeSummary(); updateVoiceModeSummary();
updateSettingsKeySummary(); updateSettingsKeySummary();
updateShowCorrectionSuggestionsSummary(); updateShowCorrectionSuggestionsSummary();
updateKeyPreviewPopupDelaySummary();
} }
@Override @Override
@ -451,11 +499,17 @@ public class Settings extends PreferenceActivity
} }
private void updateSettingsKeySummary() { private void updateSettingsKeySummary() {
final ListPreference lp = mSettingsKeyPreference;
mSettingsKeyPreference.setSummary( mSettingsKeyPreference.setSummary(
getResources().getStringArray(R.array.settings_key_modes) getResources().getStringArray(R.array.settings_key_modes)
[mSettingsKeyPreference.findIndexOfValue(mSettingsKeyPreference.getValue())]); [mSettingsKeyPreference.findIndexOfValue(mSettingsKeyPreference.getValue())]);
} }
private void updateKeyPreviewPopupDelaySummary() {
final ListPreference lp = mKeyPreviewPopupDismissDelay;
lp.setSummary(lp.getEntries()[lp.findIndexOfValue(lp.getValue())]);
}
private void showVoiceConfirmation() { private void showVoiceConfirmation() {
mOkClicked = false; mOkClicked = false;
showDialog(VOICE_INPUT_CONFIRM_DIALOG); showDialog(VOICE_INPUT_CONFIRM_DIALOG);