parent
4112dc0500
commit
3708787fe9
|
@ -24,6 +24,8 @@ import android.util.Log;
|
||||||
import android.util.Xml;
|
import android.util.Xml;
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
|
|
||||||
|
import com.android.inputmethod.keyboard.internal.KeyboardBuilder;
|
||||||
|
import com.android.inputmethod.keyboard.internal.KeyboardParams;
|
||||||
import com.android.inputmethod.keyboard.internal.XmlParseUtils;
|
import com.android.inputmethod.keyboard.internal.XmlParseUtils;
|
||||||
import com.android.inputmethod.latin.LatinIME;
|
import com.android.inputmethod.latin.LatinIME;
|
||||||
import com.android.inputmethod.latin.LatinImeLogger;
|
import com.android.inputmethod.latin.LatinImeLogger;
|
||||||
|
@ -72,8 +74,8 @@ public class KeyboardSet {
|
||||||
Params() {}
|
Params() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final HashMap<KeyboardId, SoftReference<LatinKeyboard>> sKeyboardCache =
|
private static final HashMap<KeyboardId, SoftReference<Keyboard>> sKeyboardCache =
|
||||||
new HashMap<KeyboardId, SoftReference<LatinKeyboard>>();
|
new HashMap<KeyboardId, SoftReference<Keyboard>>();
|
||||||
|
|
||||||
public static void clearKeyboardCache() {
|
public static void clearKeyboardCache() {
|
||||||
sKeyboardCache.clear();
|
sKeyboardCache.clear();
|
||||||
|
@ -84,16 +86,16 @@ public class KeyboardSet {
|
||||||
mParams = params;
|
mParams = params;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LatinKeyboard getMainKeyboard() {
|
public Keyboard getMainKeyboard() {
|
||||||
return getKeyboard(false, false);
|
return getKeyboard(false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LatinKeyboard getSymbolsKeyboard() {
|
public Keyboard getSymbolsKeyboard() {
|
||||||
return getKeyboard(true, false);
|
return getKeyboard(true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LatinKeyboard getSymbolsShiftedKeyboard() {
|
public Keyboard getSymbolsShiftedKeyboard() {
|
||||||
final LatinKeyboard keyboard = getKeyboard(true, true);
|
final Keyboard keyboard = getKeyboard(true, true);
|
||||||
// TODO: Remove this logic once we introduce initial keyboard shift state attribute.
|
// TODO: Remove this logic once we introduce initial keyboard shift state attribute.
|
||||||
// Symbol shift keyboard may have a shift key that has a caps lock style indicator (a.k.a.
|
// Symbol shift keyboard may have a shift key that has a caps lock style indicator (a.k.a.
|
||||||
// sticky shift key). To show or dismiss the indicator, we need to call setShiftLocked()
|
// sticky shift key). To show or dismiss the indicator, we need to call setShiftLocked()
|
||||||
|
@ -102,11 +104,11 @@ public class KeyboardSet {
|
||||||
return keyboard;
|
return keyboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
private LatinKeyboard getKeyboard(boolean isSymbols, boolean isShift) {
|
private Keyboard getKeyboard(boolean isSymbols, boolean isShift) {
|
||||||
final int elementState = Builder.getElementState(mParams.mMode, isSymbols, isShift);
|
final int elementState = Builder.getElementState(mParams.mMode, isSymbols, isShift);
|
||||||
final int xmlId = mParams.mElementKeyboards.get(elementState);
|
final int xmlId = mParams.mElementKeyboards.get(elementState);
|
||||||
final KeyboardId id = Builder.getKeyboardId(elementState, isSymbols, mParams);
|
final KeyboardId id = Builder.getKeyboardId(elementState, isSymbols, mParams);
|
||||||
final LatinKeyboard keyboard = getKeyboard(mContext, xmlId, id);
|
final Keyboard keyboard = getKeyboard(mContext, xmlId, id);
|
||||||
return keyboard;
|
return keyboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,15 +117,16 @@ public class KeyboardSet {
|
||||||
return Builder.getKeyboardId(elementState, false, mParams);
|
return Builder.getKeyboardId(elementState, false, mParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static LatinKeyboard getKeyboard(Context context, int xmlId, KeyboardId id) {
|
private static Keyboard getKeyboard(Context context, int xmlId, KeyboardId id) {
|
||||||
final Resources res = context.getResources();
|
final Resources res = context.getResources();
|
||||||
final SubtypeSwitcher subtypeSwitcher = SubtypeSwitcher.getInstance();
|
final SubtypeSwitcher subtypeSwitcher = SubtypeSwitcher.getInstance();
|
||||||
final SoftReference<LatinKeyboard> ref = sKeyboardCache.get(id);
|
final SoftReference<Keyboard> ref = sKeyboardCache.get(id);
|
||||||
LatinKeyboard keyboard = (ref == null) ? null : ref.get();
|
Keyboard keyboard = (ref == null) ? null : ref.get();
|
||||||
if (keyboard == null) {
|
if (keyboard == null) {
|
||||||
final Locale savedLocale = LocaleUtils.setSystemLocale(res, id.mLocale);
|
final Locale savedLocale = LocaleUtils.setSystemLocale(res, id.mLocale);
|
||||||
try {
|
try {
|
||||||
final LatinKeyboard.Builder builder = new LatinKeyboard.Builder(context);
|
final KeyboardBuilder<KeyboardParams> builder =
|
||||||
|
new KeyboardBuilder<KeyboardParams>(context, new KeyboardParams());
|
||||||
builder.load(xmlId, id);
|
builder.load(xmlId, id);
|
||||||
builder.setTouchPositionCorrectionEnabled(
|
builder.setTouchPositionCorrectionEnabled(
|
||||||
subtypeSwitcher.currentSubtypeContainsExtraValueKey(
|
subtypeSwitcher.currentSubtypeContainsExtraValueKey(
|
||||||
|
@ -132,7 +135,7 @@ public class KeyboardSet {
|
||||||
} finally {
|
} finally {
|
||||||
LocaleUtils.setSystemLocale(res, savedLocale);
|
LocaleUtils.setSystemLocale(res, savedLocale);
|
||||||
}
|
}
|
||||||
sKeyboardCache.put(id, new SoftReference<LatinKeyboard>(keyboard));
|
sKeyboardCache.put(id, new SoftReference<Keyboard>(keyboard));
|
||||||
|
|
||||||
if (DEBUG_CACHE) {
|
if (DEBUG_CACHE) {
|
||||||
Log.d(TAG, "keyboard cache size=" + sKeyboardCache.size() + ": "
|
Log.d(TAG, "keyboard cache size=" + sKeyboardCache.size() + ": "
|
||||||
|
|
|
@ -171,7 +171,7 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAlphabetMode() {
|
public boolean isAlphabetMode() {
|
||||||
final Keyboard keyboard = getLatinKeyboard();
|
final Keyboard keyboard = getKeyboard();
|
||||||
return keyboard != null && keyboard.mId.isAlphabetKeyboard();
|
return keyboard != null && keyboard.mId.isAlphabetKeyboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,12 +180,12 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isShiftedOrShiftLocked() {
|
public boolean isShiftedOrShiftLocked() {
|
||||||
final Keyboard keyboard = getLatinKeyboard();
|
final Keyboard keyboard = getKeyboard();
|
||||||
return keyboard != null && keyboard.isShiftedOrShiftLocked();
|
return keyboard != null && keyboard.isShiftedOrShiftLocked();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isManualTemporaryUpperCase() {
|
public boolean isManualTemporaryUpperCase() {
|
||||||
final Keyboard keyboard = getLatinKeyboard();
|
final Keyboard keyboard = getKeyboard();
|
||||||
return keyboard != null && keyboard.isManualTemporaryUpperCase();
|
return keyboard != null && keyboard.isManualTemporaryUpperCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,11 +195,9 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LatinKeyboard getLatinKeyboard() {
|
public Keyboard getKeyboard() {
|
||||||
if (mKeyboardView != null) {
|
if (mKeyboardView != null) {
|
||||||
final Keyboard keyboard = mKeyboardView.getKeyboard();
|
return mKeyboardView.getKeyboard();
|
||||||
if (keyboard instanceof LatinKeyboard)
|
|
||||||
return (LatinKeyboard)keyboard;
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -208,11 +206,11 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
|
||||||
@Override
|
@Override
|
||||||
public void setShifted(int shiftMode) {
|
public void setShifted(int shiftMode) {
|
||||||
mInputMethodService.mHandler.cancelUpdateShiftState();
|
mInputMethodService.mHandler.cancelUpdateShiftState();
|
||||||
LatinKeyboard latinKeyboard = getLatinKeyboard();
|
Keyboard keyboard = getKeyboard();
|
||||||
if (latinKeyboard == null)
|
if (keyboard == null)
|
||||||
return;
|
return;
|
||||||
if (shiftMode == AUTOMATIC_SHIFT) {
|
if (shiftMode == AUTOMATIC_SHIFT) {
|
||||||
latinKeyboard.setAutomaticTemporaryUpperCase();
|
keyboard.setAutomaticTemporaryUpperCase();
|
||||||
} else {
|
} else {
|
||||||
final boolean shifted = (shiftMode == MANUAL_SHIFT);
|
final boolean shifted = (shiftMode == MANUAL_SHIFT);
|
||||||
// On non-distinct multi touch panel device, we should also turn off the shift locked
|
// On non-distinct multi touch panel device, we should also turn off the shift locked
|
||||||
|
@ -220,9 +218,9 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
|
||||||
// On the other hand, on distinct multi touch panel device, turning off the shift
|
// On the other hand, on distinct multi touch panel device, turning off the shift
|
||||||
// locked state with shift key pressing is handled by onReleaseShift().
|
// locked state with shift key pressing is handled by onReleaseShift().
|
||||||
if (!hasDistinctMultitouch() && !shifted && mState.isShiftLocked()) {
|
if (!hasDistinctMultitouch() && !shifted && mState.isShiftLocked()) {
|
||||||
latinKeyboard.setShiftLocked(false);
|
keyboard.setShiftLocked(false);
|
||||||
}
|
}
|
||||||
latinKeyboard.setShifted(shifted);
|
keyboard.setShifted(shifted);
|
||||||
}
|
}
|
||||||
mKeyboardView.invalidateAllKeys();
|
mKeyboardView.invalidateAllKeys();
|
||||||
}
|
}
|
||||||
|
@ -231,10 +229,10 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
|
||||||
@Override
|
@Override
|
||||||
public void setShiftLocked(boolean shiftLocked) {
|
public void setShiftLocked(boolean shiftLocked) {
|
||||||
mInputMethodService.mHandler.cancelUpdateShiftState();
|
mInputMethodService.mHandler.cancelUpdateShiftState();
|
||||||
LatinKeyboard latinKeyboard = getLatinKeyboard();
|
Keyboard keyboard = getKeyboard();
|
||||||
if (latinKeyboard == null)
|
if (keyboard == null)
|
||||||
return;
|
return;
|
||||||
latinKeyboard.setShiftLocked(shiftLocked);
|
keyboard.setShiftLocked(shiftLocked);
|
||||||
mKeyboardView.invalidateAllKeys();
|
mKeyboardView.invalidateAllKeys();
|
||||||
if (!shiftLocked) {
|
if (!shiftLocked) {
|
||||||
// To be able to turn off caps lock by "double tap" on shift key, we should ignore
|
// To be able to turn off caps lock by "double tap" on shift key, we should ignore
|
||||||
|
|
|
@ -1,53 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2008 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.keyboard;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import com.android.inputmethod.keyboard.internal.KeyboardBuilder;
|
|
||||||
import com.android.inputmethod.keyboard.internal.KeyboardParams;
|
|
||||||
|
|
||||||
// TODO: We should remove this class
|
|
||||||
public class LatinKeyboard extends Keyboard {
|
|
||||||
private LatinKeyboard(KeyboardParams params) {
|
|
||||||
super(params);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder extends KeyboardBuilder<KeyboardParams> {
|
|
||||||
public Builder(Context context) {
|
|
||||||
super(context, new KeyboardParams());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Builder load(int xmlId, KeyboardId id) {
|
|
||||||
super.load(xmlId, id);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LatinKeyboard build() {
|
|
||||||
return new LatinKeyboard(mParams);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Key[] getNearestKeys(int x, int y) {
|
|
||||||
// Avoid dead pixels at edges of the keyboard
|
|
||||||
return super.getNearestKeys(Math.max(0, Math.min(x, mOccupiedWidth - 1)),
|
|
||||||
Math.max(0, Math.min(y, mOccupiedHeight - 1)));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -220,8 +220,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
||||||
@Override
|
@Override
|
||||||
public boolean onDoubleTap(MotionEvent firstDown) {
|
public boolean onDoubleTap(MotionEvent firstDown) {
|
||||||
final Keyboard keyboard = getKeyboard();
|
final Keyboard keyboard = getKeyboard();
|
||||||
if (ENABLE_CAPSLOCK_BY_DOUBLETAP && keyboard instanceof LatinKeyboard
|
if (ENABLE_CAPSLOCK_BY_DOUBLETAP && keyboard.mId.isAlphabetKeyboard()) {
|
||||||
&& ((LatinKeyboard) keyboard).mId.isAlphabetKeyboard()) {
|
|
||||||
final int pointerIndex = firstDown.getActionIndex();
|
final int pointerIndex = firstDown.getActionIndex();
|
||||||
final int id = firstDown.getPointerId(pointerIndex);
|
final int id = firstDown.getPointerId(pointerIndex);
|
||||||
final PointerTracker tracker = getPointerTracker(id);
|
final PointerTracker tracker = getPointerTracker(id);
|
||||||
|
@ -452,16 +451,14 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
||||||
protected boolean onLongPress(Key parentKey, PointerTracker tracker) {
|
protected boolean onLongPress(Key parentKey, PointerTracker tracker) {
|
||||||
final int primaryCode = parentKey.mCode;
|
final int primaryCode = parentKey.mCode;
|
||||||
final Keyboard keyboard = getKeyboard();
|
final Keyboard keyboard = getKeyboard();
|
||||||
if (keyboard instanceof LatinKeyboard) {
|
if (primaryCode == Keyboard.CODE_DIGIT0 && keyboard.mId.isPhoneKeyboard()) {
|
||||||
final LatinKeyboard latinKeyboard = (LatinKeyboard) keyboard;
|
|
||||||
if (primaryCode == Keyboard.CODE_DIGIT0 && latinKeyboard.mId.isPhoneKeyboard()) {
|
|
||||||
tracker.onLongPressed();
|
tracker.onLongPressed();
|
||||||
// Long pressing on 0 in phone number keypad gives you a '+'.
|
// Long pressing on 0 in phone number keypad gives you a '+'.
|
||||||
invokeCodeInput(Keyboard.CODE_PLUS);
|
invokeCodeInput(Keyboard.CODE_PLUS);
|
||||||
invokeReleaseKey(primaryCode);
|
invokeReleaseKey(primaryCode);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (primaryCode == Keyboard.CODE_SHIFT && latinKeyboard.mId.isAlphabetKeyboard()) {
|
if (primaryCode == Keyboard.CODE_SHIFT && keyboard.mId.isAlphabetKeyboard()) {
|
||||||
tracker.onLongPressed();
|
tracker.onLongPressed();
|
||||||
invokeCodeInput(Keyboard.CODE_CAPSLOCK);
|
invokeCodeInput(Keyboard.CODE_CAPSLOCK);
|
||||||
invokeReleaseKey(primaryCode);
|
invokeReleaseKey(primaryCode);
|
||||||
|
@ -475,7 +472,6 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return openMoreKeysPanel(parentKey, tracker);
|
return openMoreKeysPanel(parentKey, tracker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,6 @@ import com.android.inputmethod.keyboard.KeyboardActionListener;
|
||||||
import com.android.inputmethod.keyboard.KeyboardId;
|
import com.android.inputmethod.keyboard.KeyboardId;
|
||||||
import com.android.inputmethod.keyboard.KeyboardSwitcher;
|
import com.android.inputmethod.keyboard.KeyboardSwitcher;
|
||||||
import com.android.inputmethod.keyboard.KeyboardView;
|
import com.android.inputmethod.keyboard.KeyboardView;
|
||||||
import com.android.inputmethod.keyboard.LatinKeyboard;
|
|
||||||
import com.android.inputmethod.keyboard.LatinKeyboardView;
|
import com.android.inputmethod.keyboard.LatinKeyboardView;
|
||||||
import com.android.inputmethod.latin.suggestions.SuggestionsView;
|
import com.android.inputmethod.latin.suggestions.SuggestionsView;
|
||||||
|
|
||||||
|
@ -293,13 +292,13 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
case MSG_FADEOUT_LANGUAGE_ON_SPACEBAR:
|
case MSG_FADEOUT_LANGUAGE_ON_SPACEBAR:
|
||||||
setSpacebarTextFadeFactor(inputView,
|
setSpacebarTextFadeFactor(inputView,
|
||||||
(1.0f + mFinalFadeoutFactorOfLanguageOnSpacebar) / 2,
|
(1.0f + mFinalFadeoutFactorOfLanguageOnSpacebar) / 2,
|
||||||
(LatinKeyboard)msg.obj);
|
(Keyboard)msg.obj);
|
||||||
sendMessageDelayed(obtainMessage(MSG_DISMISS_LANGUAGE_ON_SPACEBAR, msg.obj),
|
sendMessageDelayed(obtainMessage(MSG_DISMISS_LANGUAGE_ON_SPACEBAR, msg.obj),
|
||||||
mDurationOfFadeoutLanguageOnSpacebar);
|
mDurationOfFadeoutLanguageOnSpacebar);
|
||||||
break;
|
break;
|
||||||
case MSG_DISMISS_LANGUAGE_ON_SPACEBAR:
|
case MSG_DISMISS_LANGUAGE_ON_SPACEBAR:
|
||||||
setSpacebarTextFadeFactor(inputView, mFinalFadeoutFactorOfLanguageOnSpacebar,
|
setSpacebarTextFadeFactor(inputView, mFinalFadeoutFactorOfLanguageOnSpacebar,
|
||||||
(LatinKeyboard)msg.obj);
|
(Keyboard)msg.obj);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -340,10 +339,10 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setSpacebarTextFadeFactor(LatinKeyboardView inputView,
|
private static void setSpacebarTextFadeFactor(LatinKeyboardView inputView,
|
||||||
float fadeFactor, LatinKeyboard oldKeyboard) {
|
float fadeFactor, Keyboard oldKeyboard) {
|
||||||
if (inputView == null) return;
|
if (inputView == null) return;
|
||||||
final Keyboard keyboard = inputView.getKeyboard();
|
final Keyboard keyboard = inputView.getKeyboard();
|
||||||
if (keyboard instanceof LatinKeyboard && keyboard == oldKeyboard) {
|
if (keyboard == oldKeyboard) {
|
||||||
inputView.updateSpacebar(fadeFactor,
|
inputView.updateSpacebar(fadeFactor,
|
||||||
SubtypeSwitcher.getInstance().needsToDisplayLanguage(
|
SubtypeSwitcher.getInstance().needsToDisplayLanguage(
|
||||||
keyboard.mId.mLocale));
|
keyboard.mId.mLocale));
|
||||||
|
@ -356,7 +355,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
removeMessages(MSG_DISMISS_LANGUAGE_ON_SPACEBAR);
|
removeMessages(MSG_DISMISS_LANGUAGE_ON_SPACEBAR);
|
||||||
final LatinKeyboardView inputView = latinIme.mKeyboardSwitcher.getKeyboardView();
|
final LatinKeyboardView inputView = latinIme.mKeyboardSwitcher.getKeyboardView();
|
||||||
if (inputView != null) {
|
if (inputView != null) {
|
||||||
final LatinKeyboard keyboard = latinIme.mKeyboardSwitcher.getLatinKeyboard();
|
final Keyboard keyboard = latinIme.mKeyboardSwitcher.getKeyboard();
|
||||||
// The language is always displayed when the delay is negative.
|
// The language is always displayed when the delay is negative.
|
||||||
final boolean needsToDisplayLanguage = localeChanged
|
final boolean needsToDisplayLanguage = localeChanged
|
||||||
|| mDelayBeforeFadeoutLanguageOnSpacebar < 0;
|
|| mDelayBeforeFadeoutLanguageOnSpacebar < 0;
|
||||||
|
@ -1718,7 +1717,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
}
|
}
|
||||||
// getSuggestedWordBuilder handles gracefully a null value of prevWord
|
// getSuggestedWordBuilder handles gracefully a null value of prevWord
|
||||||
final SuggestedWords.Builder builder = mSuggest.getSuggestedWordBuilder(mWordComposer,
|
final SuggestedWords.Builder builder = mSuggest.getSuggestedWordBuilder(mWordComposer,
|
||||||
prevWord, mKeyboardSwitcher.getLatinKeyboard().getProximityInfo(), mCorrectionMode);
|
prevWord, mKeyboardSwitcher.getKeyboard().getProximityInfo(), mCorrectionMode);
|
||||||
|
|
||||||
boolean autoCorrectionAvailable = !mInputAttributes.mInputTypeNoAutoCorrect
|
boolean autoCorrectionAvailable = !mInputAttributes.mInputTypeNoAutoCorrect
|
||||||
&& mSuggest.hasAutoCorrection();
|
&& mSuggest.hasAutoCorrection();
|
||||||
|
@ -1867,7 +1866,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
// pressed space on purpose of displaying the suggestion strip punctuation.
|
// pressed space on purpose of displaying the suggestion strip punctuation.
|
||||||
final int rawPrimaryCode = suggestion.charAt(0);
|
final int rawPrimaryCode = suggestion.charAt(0);
|
||||||
// Maybe apply the "bidi mirrored" conversions for parentheses
|
// Maybe apply the "bidi mirrored" conversions for parentheses
|
||||||
final LatinKeyboard keyboard = mKeyboardSwitcher.getLatinKeyboard();
|
final Keyboard keyboard = mKeyboardSwitcher.getKeyboard();
|
||||||
final boolean isRtl = keyboard != null && keyboard.mIsRtlKeyboard;
|
final boolean isRtl = keyboard != null && keyboard.mIsRtlKeyboard;
|
||||||
final int primaryCode = Key.getRtlParenthesisCode(rawPrimaryCode, isRtl);
|
final int primaryCode = Key.getRtlParenthesisCode(rawPrimaryCode, isRtl);
|
||||||
|
|
||||||
|
@ -1969,7 +1968,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
final CharSequence prevWord = EditingUtils.getThisWord(getCurrentInputConnection(),
|
final CharSequence prevWord = EditingUtils.getThisWord(getCurrentInputConnection(),
|
||||||
mSettingsValues.mWordSeparators);
|
mSettingsValues.mWordSeparators);
|
||||||
SuggestedWords.Builder builder = mSuggest.getSuggestedWordBuilder(sEmptyWordComposer,
|
SuggestedWords.Builder builder = mSuggest.getSuggestedWordBuilder(sEmptyWordComposer,
|
||||||
prevWord, mKeyboardSwitcher.getLatinKeyboard().getProximityInfo(), mCorrectionMode);
|
prevWord, mKeyboardSwitcher.getKeyboard().getProximityInfo(), mCorrectionMode);
|
||||||
|
|
||||||
if (builder.size() > 0) {
|
if (builder.size() > 0) {
|
||||||
// Explicitly supply an empty typed word (the no-second-arg version of
|
// Explicitly supply an empty typed word (the no-second-arg version of
|
||||||
|
@ -2095,7 +2094,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
// "ic" must not be null
|
// "ic" must not be null
|
||||||
private void restartSuggestionsOnWordBeforeCursor(final InputConnection ic,
|
private void restartSuggestionsOnWordBeforeCursor(final InputConnection ic,
|
||||||
final CharSequence word) {
|
final CharSequence word) {
|
||||||
mWordComposer.setComposingWord(word, mKeyboardSwitcher.getLatinKeyboard());
|
mWordComposer.setComposingWord(word, mKeyboardSwitcher.getKeyboard());
|
||||||
mComposingStateManager.onStartComposingText();
|
mComposingStateManager.onStartComposingText();
|
||||||
ic.deleteSurroundingText(word.length(), 0);
|
ic.deleteSurroundingText(word.length(), 0);
|
||||||
ic.setComposingText(word, 1);
|
ic.setComposingText(word, 1);
|
||||||
|
@ -2436,7 +2435,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
|
|
||||||
final Printer p = new PrintWriterPrinter(fout);
|
final Printer p = new PrintWriterPrinter(fout);
|
||||||
p.println("LatinIME state :");
|
p.println("LatinIME state :");
|
||||||
final Keyboard keyboard = mKeyboardSwitcher.getLatinKeyboard();
|
final Keyboard keyboard = mKeyboardSwitcher.getKeyboard();
|
||||||
final int keyboardMode = keyboard != null ? keyboard.mId.mMode : -1;
|
final int keyboardMode = keyboard != null ? keyboard.mId.mMode : -1;
|
||||||
p.println(" Keyboard mode = " + keyboardMode);
|
p.println(" Keyboard mode = " + keyboardMode);
|
||||||
p.println(" mIsSuggestionsRequested=" + mInputAttributes.mIsSettingsSuggestionStripOn);
|
p.println(" mIsSuggestionsRequested=" + mInputAttributes.mIsSettingsSuggestionStripOn);
|
||||||
|
|
|
@ -16,10 +16,9 @@
|
||||||
|
|
||||||
package com.android.inputmethod.latin;
|
package com.android.inputmethod.latin;
|
||||||
|
|
||||||
import com.android.inputmethod.keyboard.Keyboard;
|
|
||||||
import com.android.inputmethod.keyboard.Key;
|
import com.android.inputmethod.keyboard.Key;
|
||||||
import com.android.inputmethod.keyboard.KeyDetector;
|
import com.android.inputmethod.keyboard.KeyDetector;
|
||||||
import com.android.inputmethod.keyboard.LatinKeyboard;
|
import com.android.inputmethod.keyboard.Keyboard;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -174,7 +173,7 @@ public class WordComposer {
|
||||||
/**
|
/**
|
||||||
* Internal method to retrieve reasonable proximity info for a character.
|
* Internal method to retrieve reasonable proximity info for a character.
|
||||||
*/
|
*/
|
||||||
private void addKeyInfo(final int codePoint, final LatinKeyboard keyboard,
|
private void addKeyInfo(final int codePoint, final Keyboard keyboard,
|
||||||
final KeyDetector keyDetector) {
|
final KeyDetector keyDetector) {
|
||||||
for (final Key key : keyboard.mKeys) {
|
for (final Key key : keyboard.mKeys) {
|
||||||
if (key.mCode == codePoint) {
|
if (key.mCode == codePoint) {
|
||||||
|
@ -194,7 +193,7 @@ public class WordComposer {
|
||||||
* Set the currently composing word to the one passed as an argument.
|
* Set the currently composing word to the one passed as an argument.
|
||||||
* This will register NOT_A_COORDINATE for X and Ys, and use the passed keyboard for proximity.
|
* This will register NOT_A_COORDINATE for X and Ys, and use the passed keyboard for proximity.
|
||||||
*/
|
*/
|
||||||
public void setComposingWord(final CharSequence word, final LatinKeyboard keyboard,
|
public void setComposingWord(final CharSequence word, final Keyboard keyboard,
|
||||||
final KeyDetector keyDetector) {
|
final KeyDetector keyDetector) {
|
||||||
reset();
|
reset();
|
||||||
final int length = word.length();
|
final int length = word.length();
|
||||||
|
@ -208,7 +207,7 @@ public class WordComposer {
|
||||||
/**
|
/**
|
||||||
* Shortcut for the above method, this will create a new KeyDetector for the passed keyboard.
|
* Shortcut for the above method, this will create a new KeyDetector for the passed keyboard.
|
||||||
*/
|
*/
|
||||||
public void setComposingWord(final CharSequence word, final LatinKeyboard keyboard) {
|
public void setComposingWord(final CharSequence word, final Keyboard keyboard) {
|
||||||
final KeyDetector keyDetector = new KeyDetector(0);
|
final KeyDetector keyDetector = new KeyDetector(0);
|
||||||
keyDetector.setKeyboard(keyboard, 0, 0);
|
keyDetector.setKeyboard(keyboard, 0, 0);
|
||||||
keyDetector.setProximityCorrectionEnabled(true);
|
keyDetector.setProximityCorrectionEnabled(true);
|
||||||
|
|
|
@ -179,7 +179,7 @@ public class MoreSuggestions extends Keyboard {
|
||||||
|
|
||||||
public Builder layout(SuggestedWords suggestions, int fromPos, int maxWidth,
|
public Builder layout(SuggestedWords suggestions, int fromPos, int maxWidth,
|
||||||
int minWidth, int maxRow) {
|
int minWidth, int maxRow) {
|
||||||
final Keyboard keyboard = KeyboardSwitcher.getInstance().getLatinKeyboard();
|
final Keyboard keyboard = KeyboardSwitcher.getInstance().getKeyboard();
|
||||||
final int xmlId = R.xml.kbd_suggestions_pane_template;
|
final int xmlId = R.xml.kbd_suggestions_pane_template;
|
||||||
load(xmlId, keyboard.mId);
|
load(xmlId, keyboard.mId);
|
||||||
mParams.mVerticalGap = mParams.mTopPadding = keyboard.mVerticalGap / 2;
|
mParams.mVerticalGap = mParams.mTopPadding = keyboard.mVerticalGap / 2;
|
||||||
|
|
|
@ -20,8 +20,10 @@ import android.content.Context;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import com.android.inputmethod.keyboard.KeyDetector;
|
import com.android.inputmethod.keyboard.KeyDetector;
|
||||||
|
import com.android.inputmethod.keyboard.Keyboard;
|
||||||
import com.android.inputmethod.keyboard.KeyboardId;
|
import com.android.inputmethod.keyboard.KeyboardId;
|
||||||
import com.android.inputmethod.keyboard.LatinKeyboard;
|
import com.android.inputmethod.keyboard.internal.KeyboardBuilder;
|
||||||
|
import com.android.inputmethod.keyboard.internal.KeyboardParams;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
@ -29,7 +31,7 @@ import java.util.Locale;
|
||||||
public class SuggestHelper {
|
public class SuggestHelper {
|
||||||
protected final Suggest mSuggest;
|
protected final Suggest mSuggest;
|
||||||
protected int mCorrectionMode;
|
protected int mCorrectionMode;
|
||||||
protected final LatinKeyboard mKeyboard;
|
protected final Keyboard mKeyboard;
|
||||||
private final KeyDetector mKeyDetector;
|
private final KeyDetector mKeyDetector;
|
||||||
|
|
||||||
public static final int ALPHABET_KEYBOARD = com.android.inputmethod.latin.R.xml.kbd_qwerty;
|
public static final int ALPHABET_KEYBOARD = com.android.inputmethod.latin.R.xml.kbd_qwerty;
|
||||||
|
@ -38,7 +40,8 @@ public class SuggestHelper {
|
||||||
// Use null as the locale for Suggest so as to force it to use the internal dictionary
|
// Use null as the locale for Suggest so as to force it to use the internal dictionary
|
||||||
// (and not try to find a dictionary provider for a specified locale)
|
// (and not try to find a dictionary provider for a specified locale)
|
||||||
mSuggest = new Suggest(context, dictionaryId, null);
|
mSuggest = new Suggest(context, dictionaryId, null);
|
||||||
mKeyboard = new LatinKeyboard.Builder(context).load(ALPHABET_KEYBOARD, keyboardId).build();
|
mKeyboard = new KeyboardBuilder<KeyboardParams>(context, new KeyboardParams())
|
||||||
|
.load(ALPHABET_KEYBOARD, keyboardId).build();
|
||||||
mKeyDetector = new KeyDetector(0);
|
mKeyDetector = new KeyDetector(0);
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
@ -47,7 +50,8 @@ public class SuggestHelper {
|
||||||
final long startOffset, final long length, final KeyboardId keyboardId,
|
final long startOffset, final long length, final KeyboardId keyboardId,
|
||||||
final Locale locale) {
|
final Locale locale) {
|
||||||
mSuggest = new Suggest(context, dictionaryPath, startOffset, length, null, locale);
|
mSuggest = new Suggest(context, dictionaryPath, startOffset, length, null, locale);
|
||||||
mKeyboard = new LatinKeyboard.Builder(context).load(ALPHABET_KEYBOARD, keyboardId).build();
|
mKeyboard = new KeyboardBuilder<KeyboardParams>(context, new KeyboardParams())
|
||||||
|
.load(ALPHABET_KEYBOARD, keyboardId).build();
|
||||||
mKeyDetector = new KeyDetector(0);
|
mKeyDetector = new KeyDetector(0);
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue