aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/keyboard/Key.java4
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardView.java5
-rw-r--r--java/src/com/android/inputmethod/keyboard/LatinKeyboardBaseView.java12
-rw-r--r--java/src/com/android/inputmethod/keyboard/PointerTracker.java20
-rw-r--r--java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java10
-rw-r--r--java/src/com/android/inputmethod/keyboard/PopupPanel.java2
-rw-r--r--java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java1
-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
11 files changed, 104 insertions, 47 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/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
index 1010adbe0..f54084b3a 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
@@ -865,6 +865,11 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
requestLayout();
}
+ @Override
+ public boolean dismissPopupPanel() {
+ return false;
+ }
+
public void purgeKeyboardAndClosing() {
mKeyboard = null;
closing();
diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardBaseView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardBaseView.java
index 0ad91dbb0..22752d037 100644
--- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardBaseView.java
+++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardBaseView.java
@@ -400,11 +400,10 @@ public class LatinKeyboardBaseView extends KeyboardView implements PointerTracke
mPopupPanel = popupPanel;
mPopupPanelPointerTrackerId = tracker.mPointerId;
- tracker.onLongPressed();
- popupPanel.showPanel(this, parentKey, tracker, mPopupWindow);
+ popupPanel.showPopupPanel(this, parentKey, tracker, mPopupWindow);
final int translatedX = popupPanel.translateX(tracker.getLastX());
final int translatedY = popupPanel.translateY(tracker.getLastY());
- tracker.onDownEvent(translatedX, translatedY, SystemClock.uptimeMillis(), popupPanel);
+ tracker.onShowPopupPanel(translatedX, translatedY, SystemClock.uptimeMillis(), popupPanel);
invalidateAllKeys();
return true;
@@ -546,11 +545,12 @@ public class LatinKeyboardBaseView extends KeyboardView implements PointerTracke
@Override
public void closing() {
super.closing();
- dismissMiniKeyboard();
+ dismissPopupPanel();
mPopupPanelCache.clear();
}
- public boolean dismissMiniKeyboard() {
+ @Override
+ public boolean dismissPopupPanel() {
if (mPopupWindow != null && mPopupWindow.isShowing()) {
mPopupWindow.dismiss();
mPopupPanel = null;
@@ -562,7 +562,7 @@ public class LatinKeyboardBaseView extends KeyboardView implements PointerTracke
}
public boolean handleBack() {
- return dismissMiniKeyboard();
+ return dismissPopupPanel();
}
@Override
diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
index e66ea7b79..f27f74ca4 100644
--- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java
+++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
@@ -67,6 +67,7 @@ public class PointerTracker {
public void showKeyPreview(int keyIndex, PointerTracker tracker);
public void cancelShowKeyPreview(PointerTracker tracker);
public void dismissKeyPreview(PointerTracker tracker);
+ public boolean dismissPopupPanel();
}
public interface TimerProxy {
@@ -117,9 +118,12 @@ public class PointerTracker {
// true if keyboard layout has been changed.
private boolean mKeyboardLayoutHasBeenChanged;
- // true if event is already translated to a key action (long press or mini-keyboard)
+ // true if event is already translated to a key action.
private boolean mKeyAlreadyProcessed;
+ // true if this pointer has been long-pressed and is showing a popup panel.
+ private boolean mIsShowingPopupPanel;
+
// true if this pointer is repeatable key
private boolean mIsRepeatableKey;
@@ -579,6 +583,10 @@ public class PointerTracker {
}
final int keyIndex = onUpKey(keyX, keyY, eventTime);
setReleasedKeyGraphics(keyIndex);
+ if (mIsShowingPopupPanel) {
+ mDrawingProxy.dismissPopupPanel();
+ mIsShowingPopupPanel = false;
+ }
if (mKeyAlreadyProcessed)
return;
if (!mIsRepeatableKey) {
@@ -586,6 +594,12 @@ public class PointerTracker {
}
}
+ public void onShowPopupPanel(int x, int y, long eventTime, KeyEventHandler handler) {
+ onLongPressed();
+ onDownEvent(x, y, eventTime, handler);
+ mIsShowingPopupPanel = true;
+ }
+
public void onLongPressed() {
mKeyAlreadyProcessed = true;
setReleasedKeyGraphics(mKeyIndex);
@@ -612,6 +626,10 @@ public class PointerTracker {
mDrawingProxy.cancelShowKeyPreview(this);
setReleasedKeyGraphics(mKeyIndex);
mIsInSlidingKeyInput = false;
+ if (mIsShowingPopupPanel) {
+ mDrawingProxy.dismissPopupPanel();
+ mIsShowingPopupPanel = false;
+ }
}
private void startRepeatKey(int keyIndex) {
diff --git a/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java b/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java
index a90f57c62..2741ee80b 100644
--- a/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java
@@ -59,19 +59,16 @@ public class PopupMiniKeyboardView extends KeyboardView implements PopupPanel {
public void onCodeInput(int primaryCode, int[] keyCodes, int x, int y) {
mParentKeyboardView.getKeyboardActionListener()
.onCodeInput(primaryCode, keyCodes, x, y);
- mParentKeyboardView.dismissMiniKeyboard();
}
@Override
public void onTextInput(CharSequence text) {
mParentKeyboardView.getKeyboardActionListener().onTextInput(text);
- mParentKeyboardView.dismissMiniKeyboard();
}
@Override
public void onCancelInput() {
mParentKeyboardView.getKeyboardActionListener().onCancelInput();
- mParentKeyboardView.dismissMiniKeyboard();
}
@Override
@@ -159,7 +156,7 @@ public class PopupMiniKeyboardView extends KeyboardView implements PopupPanel {
}
@Override
- public void showPanel(LatinKeyboardBaseView parentKeyboardView, Key parentKey,
+ public void showPopupPanel(LatinKeyboardBaseView parentKeyboardView, Key parentKey,
PointerTracker tracker, PopupWindow window) {
mParentKeyboardView = parentKeyboardView;
final View container = (View)getParent();
@@ -192,6 +189,11 @@ public class PopupMiniKeyboardView extends KeyboardView implements PopupPanel {
}
@Override
+ public boolean dismissPopupPanel() {
+ return mParentKeyboardView.dismissPopupPanel();
+ }
+
+ @Override
public int translateX(int x) {
return x - mOriginX;
}
diff --git a/java/src/com/android/inputmethod/keyboard/PopupPanel.java b/java/src/com/android/inputmethod/keyboard/PopupPanel.java
index f94d1c562..dc526e74f 100644
--- a/java/src/com/android/inputmethod/keyboard/PopupPanel.java
+++ b/java/src/com/android/inputmethod/keyboard/PopupPanel.java
@@ -26,7 +26,7 @@ public interface PopupPanel extends PointerTracker.KeyEventHandler {
* @param tracker the pointer tracker that pressesd the parent key
* @param window PopupWindow to be used to show this popup panel
*/
- public void showPanel(LatinKeyboardBaseView parentKeyboardView, Key parentKey,
+ public void showPopupPanel(LatinKeyboardBaseView parentKeyboardView, Key parentKey,
PointerTracker tracker, PopupWindow window);
/**
diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java b/java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java
index 00d80f566..41b577cf3 100644
--- a/java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java
+++ b/java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java
@@ -107,6 +107,7 @@ public class BinaryDictionaryFileDumper {
if (null == afd) return null;
final String fileName =
copyFileTo(afd.createInputStream(), getCacheFileNameForLocale(locale, context));
+ afd.close();
return Arrays.asList(AssetFileAddress.makeFromFileName(fileName));
}
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);
+ }
+}