aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com')
-rw-r--r--java/src/com/android/inputmethod/keyboard/Key.java4
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java23
-rw-r--r--java/src/com/android/inputmethod/latin/Settings.java30
-rw-r--r--java/src/com/android/inputmethod/latin/SubtypeSwitcher.java10
-rw-r--r--java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java34
5 files changed, 66 insertions, 35 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java
index 8b8930a86..0ee8d7174 100644
--- a/java/src/com/android/inputmethod/keyboard/Key.java
+++ b/java/src/com/android/inputmethod/keyboard/Key.java
@@ -159,6 +159,8 @@ public class Key {
private static final Map<Integer, Integer> sRtlParenthesisMap = new HashMap<Integer, Integer>();
static {
+ // The all letters need to be mirrored are found at
+ // http://www.unicode.org/Public/6.0.0/ucd/extracted/DerivedBinaryProperties.txt
addRtlParenthesisPair('(', ')');
addRtlParenthesisPair('[', ']');
addRtlParenthesisPair('{', '}');
@@ -179,7 +181,7 @@ public class Key {
sRtlParenthesisMap.put(right, left);
}
- private static int getRtlParenthesisCode(int code) {
+ public static int getRtlParenthesisCode(int code) {
if (sRtlParenthesisMap.containsKey(code)) {
return sRtlParenthesisMap.get(code);
} else {
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 3457ac984..d9d421411 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -60,6 +60,7 @@ import com.android.inputmethod.compat.SuggestionSpanUtils;
import com.android.inputmethod.deprecated.LanguageSwitcherProxy;
import com.android.inputmethod.deprecated.VoiceProxy;
import com.android.inputmethod.deprecated.recorrection.Recorrection;
+import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.KeyboardActionListener;
import com.android.inputmethod.keyboard.KeyboardSwitcher;
@@ -1441,8 +1442,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
// not to auto correct, but accept the typed word. For instance,
// in Italian dov' should not be expanded to dove' because the elision
// requires the last vowel to be removed.
- final boolean shouldAutoCorrect =
- (mSettingsValues.mAutoCorrectEnabled || mSettingsValues.mQuickFixes)
+ final boolean shouldAutoCorrect = mSettingsValues.mAutoCorrectEnabled
&& !mInputTypeNoAutoCorrect && mHasDictionary;
if (shouldAutoCorrect && primaryCode != Keyboard.CODE_SINGLE_QUOTE) {
pickedDefault = pickDefaultSuggestion(primaryCode);
@@ -1695,7 +1695,12 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
// for punctuation entered through the suggestion strip, it should be considered
// a magic space even if it was a normal space. This is meant to help in case the user
// pressed space on purpose of displaying the suggestion strip punctuation.
- final char primaryCode = suggestion.charAt(0);
+ final int rawPrimaryCode = suggestion.charAt(0);
+ // Maybe apply the "bidi mirrored" conversions for parentheses
+ final LatinKeyboard keyboard = mKeyboardSwitcher.getLatinKeyboard();
+ final int primaryCode = keyboard.isRtlKeyboard()
+ ? Key.getRtlParenthesisCode(rawPrimaryCode) : rawPrimaryCode;
+
final CharSequence beforeText = ic != null ? ic.getTextBeforeCursor(1, 0) : "";
final int toLeft = (ic == null || TextUtils.isEmpty(beforeText))
? 0 : beforeText.charAt(0);
@@ -2079,8 +2084,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
private void updateCorrectionMode() {
// TODO: cleanup messy flags
mHasDictionary = mSuggest != null ? mSuggest.hasMainDictionary() : false;
- final boolean shouldAutoCorrect = (mSettingsValues.mAutoCorrectEnabled
- || mSettingsValues.mQuickFixes) && !mInputTypeNoAutoCorrect && mHasDictionary;
+ final boolean shouldAutoCorrect = mSettingsValues.mAutoCorrectEnabled
+ && !mInputTypeNoAutoCorrect && mHasDictionary;
mCorrectionMode = (shouldAutoCorrect && mSettingsValues.mAutoCorrectEnabled)
? Suggest.CORRECTION_FULL
: (shouldAutoCorrect ? Suggest.CORRECTION_BASIC : Suggest.CORRECTION_NONE);
@@ -2094,7 +2099,13 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
private void updateAutoTextEnabled() {
if (mSuggest == null) return;
- mSuggest.setQuickFixesEnabled(mSettingsValues.mQuickFixes
+ // We want to use autotext if the settings are asking for auto corrections, and if
+ // the input language is the same as the system language (because autotext will only
+ // work in the system language so if we are entering text in a different language we
+ // do not want it on).
+ // We used to look at the "quick fixes" option instead of mAutoCorrectEnabled, but
+ // this option was redundant and confusing and therefore removed.
+ mSuggest.setQuickFixesEnabled(mSettingsValues.mAutoCorrectEnabled
&& SubtypeSwitcher.getInstance().isSystemLanguageSameAsInputLanguage());
}
diff --git a/java/src/com/android/inputmethod/latin/Settings.java b/java/src/com/android/inputmethod/latin/Settings.java
index b6171d276..dbab227db 100644
--- a/java/src/com/android/inputmethod/latin/Settings.java
+++ b/java/src/com/android/inputmethod/latin/Settings.java
@@ -69,7 +69,6 @@ public class Settings extends InputMethodSettingsActivity
public static final String PREF_CONFIGURE_DICTIONARIES_KEY = "configure_dictionaries_key";
public static final String PREF_CORRECTION_SETTINGS_KEY = "correction_settings";
- public static final String PREF_QUICK_FIXES = "quick_fixes";
public static final String PREF_SHOW_SUGGESTIONS_SETTING = "show_suggestions_setting";
public static final String PREF_AUTO_CORRECTION_THRESHOLD = "auto_correction_threshold";
public static final String PREF_DEBUG_SETTINGS = "debug_settings";
@@ -111,7 +110,6 @@ public class Settings extends InputMethodSettingsActivity
public final boolean mKeyPreviewPopupOn;
public final int mKeyPreviewPopupDismissDelay;
public final boolean mAutoCap;
- public final boolean mQuickFixes;
public final boolean mAutoCorrectEnabled;
public final double mAutoCorrectionThreshold;
// Suggestion: use bigrams to adjust scores of suggestions obtained from unigram dictionary
@@ -171,7 +169,6 @@ public class Settings extends InputMethodSettingsActivity
mKeyPreviewPopupOn = isKeyPreviewPopupEnabled(prefs, res);
mKeyPreviewPopupDismissDelay = getKeyPreviewPopupDismissDelay(prefs, res);
mAutoCap = prefs.getBoolean(Settings.PREF_AUTO_CAP, true);
- mQuickFixes = isQuickFixesEnabled(prefs, res);
mAutoCorrectEnabled = isAutoCorrectEnabled(prefs, res);
mBigramSuggestionEnabled = mAutoCorrectEnabled
@@ -183,11 +180,11 @@ public class Settings extends InputMethodSettingsActivity
mUseContactsDict = prefs.getBoolean(Settings.PREF_KEY_USE_CONTACTS_DICT, true);
- final String voiceMode = prefs.getString(PREF_VOICE_SETTINGS_KEY, null);
- mVoiceButtonEnabled = voiceMode != null && !voiceMode.equals(
- res.getString(R.string.voice_mode_off));
- mVoiceButtonOnPrimary = voiceMode != null && voiceMode.equals(
- res.getString(R.string.voice_mode_main));
+ final String voiceModeMain = res.getString(R.string.voice_mode_main);
+ final String voiceModeOff = res.getString(R.string.voice_mode_off);
+ final String voiceMode = prefs.getString(PREF_VOICE_SETTINGS_KEY, voiceModeMain);
+ mVoiceButtonEnabled = voiceMode != null && !voiceMode.equals(voiceModeOff);
+ mVoiceButtonOnPrimary = voiceMode != null && voiceMode.equals(voiceModeMain);
Utils.setSystemLocale(res, savedLocale);
}
@@ -208,17 +205,6 @@ public class Settings extends InputMethodSettingsActivity
return mMagicSpaceSwappers.contains(String.valueOf((char)code));
}
- // Helper methods
- private static boolean isQuickFixesEnabled(SharedPreferences sp, Resources resources) {
- final boolean showQuickFixesOption = resources.getBoolean(
- R.bool.config_enable_quick_fixes_option);
- if (!showQuickFixesOption) {
- return isAutoCorrectEnabled(sp, resources);
- }
- 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,
@@ -419,12 +405,6 @@ public class Settings extends InputMethodSettingsActivity
generalSettings.removePreference(findPreference(PREF_RECORRECTION_ENABLED));
}
- final boolean showQuickFixesOption = res.getBoolean(
- R.bool.config_enable_quick_fixes_option);
- if (!showQuickFixesOption) {
- textCorrectionGroup.removePreference(findPreference(PREF_QUICK_FIXES));
- }
-
final boolean showBigramSuggestionsOption = res.getBoolean(
R.bool.config_enable_bigram_suggestions_option);
if (!showBigramSuggestionsOption) {
diff --git a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java
index 6580cbc08..f10b1b845 100644
--- a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java
+++ b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java
@@ -361,13 +361,17 @@ public class SubtypeSwitcher {
}
public boolean isShortcutImeEnabled() {
- if (mShortcutInputMethodInfo == null)
+ if (mShortcutInputMethodInfo == null) {
return false;
- if (mShortcutSubtype == null)
+ }
+ if (mShortcutSubtype == null) {
return true;
+ }
// For compatibility, if the shortcut subtype is dummy, we assume the shortcut IME
// (built-in voice dummy subtype) is available.
- if (!mShortcutSubtype.hasOriginalObject()) return true;
+ if (!mShortcutSubtype.hasOriginalObject()) {
+ return true;
+ }
final boolean allowsImplicitlySelectedSubtypes = true;
for (final InputMethodSubtypeCompatWrapper enabledSubtype :
mImm.getEnabledInputMethodSubtypeList(
diff --git a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
new file mode 100644
index 000000000..156510b40
--- /dev/null
+++ b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2011 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.spellcheck;
+
+import android.service.textservice.SpellCheckerService;
+import android.view.textservice.SuggestionsInfo;
+import android.view.textservice.TextInfo;
+
+/**
+ * Service for spell checking, using LatinIME's dictionaries and mechanisms.
+ */
+public class AndroidSpellCheckerService extends SpellCheckerService {
+ @Override
+ public SuggestionsInfo getSuggestions(TextInfo textInfo, int suggestionsLimit,
+ String locale) {
+ // TODO: implement this
+ String[] candidates = new String[] {"candidate1", "candidate2", "candidate3"};
+ return new SuggestionsInfo(0, candidates);
+ }
+}