aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java4
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardView.java30
-rw-r--r--java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java9
-rw-r--r--java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java13
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java8
-rw-r--r--java/src/com/android/inputmethod/latin/Settings.java82
6 files changed, 102 insertions, 44 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
index 333fbc779..384139112 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -153,7 +153,9 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
final KeyboardId id = getKeyboardId(attribute, isSymbols);
makeSymbolsKeyboardIds(id.mMode, attribute);
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));
}
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
index 31188480f..4f85c0348 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
@@ -120,10 +120,10 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
private TextView mPreviewText;
private float mPreviewTextRatio;
private int mPreviewTextSize;
- private boolean mShowKeyPreview = true;
- private int mKeyPreviewDisplayedY;
+ private boolean mShowKeyPreviewPopup = true;
+ private int mKeyPreviewPopupDisplayedY;
private final int mDelayBeforePreview;
- private final int mDelayAfterPreview;
+ private int mDelayAfterPreview;
private ViewGroup mPreviewPlacer;
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);
mPreviewTextRatio = getRatio(res, R.fraction.key_preview_text_ratio);
} else {
- mShowKeyPreview = false;
+ mShowKeyPreviewPopup = false;
}
mDelayBeforePreview = res.getInteger(R.integer.config_delay_before_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
* version of the depressed key. By default the preview is enabled.
* @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) {
- mShowKeyPreview = previewEnabled;
+ public void setKeyPreviewPopupEnabled(boolean previewEnabled, int delay) {
+ mShowKeyPreviewPopup = previewEnabled;
+ mDelayAfterPreview = delay;
}
/**
* Returns the enabled state of the key feedback preview
* @return whether or not the key feedback preview is enabled
- * @see #setKeyPreviewEnabled(boolean)
+ * @see #setKeyPreviewPopupEnabled(boolean, int)
*/
- public boolean isKeyPreviewEnabled() {
- return mShowKeyPreview;
+ public boolean isKeyPreviewPopupEnabled() {
+ return mShowKeyPreviewPopup;
}
public int getColorScheme() {
@@ -851,7 +853,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
@Override
public void showKeyPreview(int keyIndex, PointerTracker tracker) {
- if (mShowKeyPreview) {
+ if (mShowKeyPreviewPopup) {
mHandler.showKeyPreview(mDelayBeforePreview, keyIndex, tracker);
} else if (mKeyboard.needSpacebarPreview(keyIndex)) {
// 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
public void dismissKeyPreview(PointerTracker tracker) {
- if (mShowKeyPreview) {
+ if (mShowKeyPreviewPopup) {
mHandler.cancelShowKeyPreview(tracker);
mHandler.dismissKeyPreview(mDelayAfterPreview, tracker);
} 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 previewY = key.mY - previewHeight + mCoordinates[1] + mPreviewOffset;
// Record key preview position to display mini-keyboard later at the same position
- mKeyPreviewDisplayedY = previewY;
+ mKeyPreviewPopupDisplayedY = previewY;
// Place the key preview.
// 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);
}
mPopupMiniKeyboardPanel = popupPanel;
- popupPanel.showPanel(this, parentKey, tracker, mKeyPreviewDisplayedY, mPopupWindow);
+ popupPanel.showPanel(this, parentKey, tracker, mKeyPreviewPopupDisplayedY, mPopupWindow);
invalidateAllKeys();
return true;
diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
index c98076f35..583b997ee 100644
--- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
@@ -55,14 +55,14 @@ public class LatinKeyboardView extends KeyboardView {
}
@Override
- public void setKeyPreviewEnabled(boolean previewEnabled) {
+ public void setKeyPreviewPopupEnabled(boolean previewEnabled, int delay) {
LatinKeyboard latinKeyboard = getLatinKeyboard();
if (latinKeyboard != null
&& (latinKeyboard.isPhoneKeyboard() || latinKeyboard.isNumberKeyboard())) {
// Phone and number keyboard never shows popup preview (except language switch).
- super.setKeyPreviewEnabled(false);
+ super.setKeyPreviewPopupEnabled(false, delay);
} else {
- super.setKeyPreviewEnabled(previewEnabled);
+ super.setKeyPreviewPopupEnabled(previewEnabled, delay);
}
}
@@ -173,7 +173,8 @@ public class LatinKeyboardView extends KeyboardView {
if (!mDroppingEvents) {
mDroppingEvents = true;
// Send an up event
- MotionEvent translated = MotionEvent.obtain(me.getEventTime(), me.getEventTime(),
+ MotionEvent translated = MotionEvent.obtain(
+ me.getEventTime(), me.getEventTime(),
MotionEvent.ACTION_UP,
mLastX, mLastY, me.getMetaState());
super.onTouchEvent(translated);
diff --git a/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java b/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java
index 12031f1ea..561dcbcef 100644
--- a/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java
@@ -55,13 +55,14 @@ public class PopupMiniKeyboardView extends KeyboardView implements PopupPanel {
R.dimen.mini_keyboard_slide_allowance));
// Remove gesture detector on mini-keyboard
mGestureDetector = null;
- setKeyPreviewEnabled(false);
+ setKeyPreviewPopupEnabled(false, 0);
}
@Override
- public void setKeyPreviewEnabled(boolean previewEnabled) {
- // Mini keyboard needs no pop-up key preview displayed.
- super.setKeyPreviewEnabled(false);
+ public void setKeyPreviewPopupEnabled(boolean previewEnabled, int delay) {
+ // Mini keyboard needs no pop-up key preview displayed, so we pass always false with a
+ // delay of 0. The delay does not matter actually since the popup is not shown anyway.
+ super.setKeyPreviewPopupEnabled(false, 0);
}
@Override
@@ -82,8 +83,8 @@ public class PopupMiniKeyboardView extends KeyboardView implements PopupPanel {
- (container.getMeasuredHeight() - container.getPaddingBottom())
+ parentKeyboardView.getPaddingTop() + mCoordinates[1];
final int x = miniKeyboardX;
- final int y = parentKeyboardView.isKeyPreviewEnabled() && miniKeyboard.isOneRowKeyboard()
- ? keyPreviewY : miniKeyboardY;
+ final int y = parentKeyboardView.isKeyPreviewPopupEnabled() &&
+ miniKeyboard.isOneRowKeyboard() ? keyPreviewY : miniKeyboardY;
if (miniKeyboard.setShifted(parentKeyboard.isShiftedOrShiftLocked())) {
invalidateAllKeys();
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 126fe0c18..29ff2b02c 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -556,7 +556,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
updateCorrectionMode();
- inputView.setKeyPreviewEnabled(mSettingsValues.mPopupOn);
+ inputView.setKeyPreviewPopupEnabled(mSettingsValues.mKeyPreviewPopupOn,
+ mSettingsValues.mKeyPreviewPopupDismissDelay);
inputView.setProximityCorrectionEnabled(true);
// If we just entered a text field, maybe it has some old text that requires correction
mRecorrection.checkRecorrectionOnStart();
@@ -1917,9 +1918,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
return mWord;
}
- public boolean getPopupOn() {
- return mSettingsValues.mPopupOn;
- }
boolean isSoundOn() {
return mSettingsValues.mSoundOn && !mSilentModeOn;
}
@@ -2063,7 +2061,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
p.println(" TextEntryState.state=" + TextEntryState.getState());
p.println(" mSoundOn=" + mSettingsValues.mSoundOn);
p.println(" mVibrateOn=" + mSettingsValues.mVibrateOn);
- p.println(" mPopupOn=" + mSettingsValues.mPopupOn);
+ p.println(" mKeyPreviewPopupOn=" + mSettingsValues.mKeyPreviewPopupOn);
}
// Characters per second measurement
diff --git a/java/src/com/android/inputmethod/latin/Settings.java b/java/src/com/android/inputmethod/latin/Settings.java
index 8953731a5..7c323c155 100644
--- a/java/src/com/android/inputmethod/latin/Settings.java
+++ b/java/src/com/android/inputmethod/latin/Settings.java
@@ -56,7 +56,7 @@ public class Settings extends PreferenceActivity
public static final String PREF_GENERAL_SETTINGS_KEY = "general_settings";
public static final String PREF_VIBRATE_ON = "vibrate_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_AUTO_CAP = "auto_cap";
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_KEY_PREVIEW_POPUP_DISMISS_DELAY =
+ "pref_key_preview_popup_dismiss_delay";
+
public static final String PREF_USABILITY_STUDY_MODE = "usability_study_mode";
// Dialog ids
@@ -102,7 +105,8 @@ public class Settings extends PreferenceActivity
// From preferences:
public final boolean mSoundOn; // Sound setting private to Latin IME (see mSilentModeOn)
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 mQuickFixes;
public final boolean mAutoCorrectEnabled;
@@ -161,7 +165,8 @@ public class Settings extends PreferenceActivity
mSoundOn = prefs.getBoolean(Settings.PREF_SOUND_ON,
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);
mQuickFixes = isQuickFixesEnabled(prefs, res);
@@ -202,6 +207,7 @@ public class Settings extends PreferenceActivity
return sp.getBoolean(Settings.PREF_QUICK_FIXES, resources.getBoolean(
R.bool.config_default_quick_fixes));
}
+
private static boolean isAutoCorrectEnabled(SharedPreferences sp, Resources resources) {
final String currentAutoCorrectionSetting = sp.getString(
Settings.PREF_AUTO_CORRECTION_THRESHOLD,
@@ -210,13 +216,24 @@ public class Settings extends PreferenceActivity
R.string.auto_correction_threshold_mode_index_off);
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(
R.bool.config_enable_show_popup_on_keypress_option);
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));
}
+
+ // 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,
boolean autoCorrectEnabled) {
final boolean showBigramSuggestionsOption = resources.getBoolean(
@@ -227,11 +244,13 @@ public class Settings extends PreferenceActivity
return sp.getBoolean(Settings.PREF_BIGRAM_SUGGESTIONS, resources.getBoolean(
R.bool.config_default_bigram_suggestions));
}
+
private static boolean isBigramPredictionEnabled(SharedPreferences sp,
Resources resources) {
return sp.getBoolean(Settings.PREF_BIGRAM_PREDICTIONS, resources.getBoolean(
R.bool.config_default_bigram_prediction));
}
+
private static double getAutoCorrectionThreshold(SharedPreferences sp,
Resources resources) {
final String currentAutoCorrectionSetting = sp.getString(
@@ -257,6 +276,7 @@ public class Settings extends PreferenceActivity
}
return autoCorrectionThreshold;
}
+
private static SuggestedWords createSuggestPuncList(final String puncs) {
SuggestedWords.Builder builder = new SuggestedWords.Builder();
if (puncs != null) {
@@ -274,6 +294,7 @@ public class Settings extends PreferenceActivity
private ListPreference mSettingsKeyPreference;
private ListPreference mShowCorrectionSuggestionsPreference;
private ListPreference mAutoCorrectionThreshold;
+ private ListPreference mKeyPreviewPopupDismissDelay;
// Suggestion: use bigrams to adjust scores of suggestions obtained from unigram dictionary
private CheckBoxPreference mBigramSuggestion;
// 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
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
+ final Resources res = getResources();
+
addPreferencesFromResource(R.xml.prefs);
mInputLanguageSelection = (PreferenceScreen) findPreference(PREF_SUBTYPES);
mInputLanguageSelection.setOnPreferenceClickListener(this);
@@ -334,13 +357,13 @@ public class Settings extends PreferenceActivity
final PreferenceGroup bigramGroup =
(PreferenceGroup) findPreference(PREF_NGRAM_SETTINGS_KEY);
- final boolean showSettingsKeyOption = getResources().getBoolean(
+ final boolean showSettingsKeyOption = res.getBoolean(
R.bool.config_enable_show_settings_key_option);
if (!showSettingsKeyOption) {
generalSettings.removePreference(mSettingsKeyPreference);
}
- final boolean showVoiceKeyOption = getResources().getBoolean(
+ final boolean showVoiceKeyOption = res.getBoolean(
R.bool.config_enable_show_voice_key_option);
if (!showVoiceKeyOption) {
generalSettings.removePreference(mVoicePreference);
@@ -350,43 +373,60 @@ public class Settings extends PreferenceActivity
generalSettings.removePreference(findPreference(PREF_VIBRATE_ON));
}
- final boolean showSubtypeSettings = getResources().getBoolean(
+ final boolean showSubtypeSettings = res.getBoolean(
R.bool.config_enable_show_subtype_settings);
if (InputMethodServiceCompatWrapper.CAN_HANDLE_ON_CURRENT_INPUT_METHOD_SUBTYPE_CHANGED
&& !showSubtypeSettings) {
generalSettings.removePreference(findPreference(PREF_SUBTYPES));
}
- final boolean showPopupOption = getResources().getBoolean(
+ final boolean showPopupOption = res.getBoolean(
R.bool.config_enable_show_popup_on_keypress_option);
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);
if (!showRecorrectionOption) {
generalSettings.removePreference(findPreference(PREF_RECORRECTION_ENABLED));
}
- final boolean showQuickFixesOption = getResources().getBoolean(
+ final boolean showQuickFixesOption = res.getBoolean(
R.bool.config_enable_quick_fixes_option);
if (!showQuickFixesOption) {
textCorrectionGroup.removePreference(findPreference(PREF_QUICK_FIXES));
}
- final boolean showBigramSuggestionsOption = getResources().getBoolean(
+ final boolean showBigramSuggestionsOption = res.getBoolean(
R.bool.config_enable_bigram_suggestions_option);
if (!showBigramSuggestionsOption) {
textCorrectionGroup.removePreference(findPreference(PREF_BIGRAM_SUGGESTIONS));
textCorrectionGroup.removePreference(findPreference(PREF_BIGRAM_PREDICTIONS));
}
- final boolean showUsabilityModeStudyOption = getResources().getBoolean(
+ final boolean showUsabilityModeStudyOption = res.getBoolean(
R.bool.config_enable_usability_study_mode_option);
if (!showUsabilityModeStudyOption) {
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
@@ -405,6 +445,7 @@ public class Settings extends PreferenceActivity
}
updateSettingsKeySummary();
updateShowCorrectionSuggestionsSummary();
+ updateKeyPreviewPopupDelaySummary();
}
@Override
@@ -423,6 +464,12 @@ public class Settings extends PreferenceActivity
.equals(mVoiceModeOff)) {
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();
mVoiceOn = !(prefs.getString(PREF_VOICE_SETTINGS_KEY, mVoiceModeOff)
@@ -430,6 +477,7 @@ public class Settings extends PreferenceActivity
updateVoiceModeSummary();
updateSettingsKeySummary();
updateShowCorrectionSuggestionsSummary();
+ updateKeyPreviewPopupDelaySummary();
}
@Override
@@ -451,11 +499,17 @@ public class Settings extends PreferenceActivity
}
private void updateSettingsKeySummary() {
+ final ListPreference lp = mSettingsKeyPreference;
mSettingsKeyPreference.setSummary(
getResources().getStringArray(R.array.settings_key_modes)
[mSettingsKeyPreference.findIndexOfValue(mSettingsKeyPreference.getValue())]);
}
+ private void updateKeyPreviewPopupDelaySummary() {
+ final ListPreference lp = mKeyPreviewPopupDismissDelay;
+ lp.setSummary(lp.getEntries()[lp.findIndexOfValue(lp.getValue())]);
+ }
+
private void showVoiceConfirmation() {
mOkClicked = false;
showDialog(VOICE_INPUT_CONFIRM_DIALOG);