Merge "Integrate the logic to calculate the proximities"
commit
231ef8fa3e
|
@ -41,11 +41,6 @@ public interface KeyboardActionListener {
|
||||||
* Send a key code to the listener.
|
* Send a key code to the listener.
|
||||||
*
|
*
|
||||||
* @param primaryCode this is the code of the key that was pressed
|
* @param primaryCode this is the code of the key that was pressed
|
||||||
* @param keyCodes the codes for all the possible alternative keys with the primary code being
|
|
||||||
* the first. If the primary key code is a single character such as an alphabet or
|
|
||||||
* number or symbol, the alternatives will include other characters that may be on
|
|
||||||
* the same key or adjacent keys. These codes are useful to correct for accidental
|
|
||||||
* presses of a key adjacent to the intended key.
|
|
||||||
* @param x x-coordinate pixel of touched event. If {@link #onCodeInput} is not called by
|
* @param x x-coordinate pixel of touched event. If {@link #onCodeInput} is not called by
|
||||||
* {@link PointerTracker#onTouchEvent} or so, the value should be
|
* {@link PointerTracker#onTouchEvent} or so, the value should be
|
||||||
* {@link #NOT_A_TOUCH_COORDINATE}. If it's called on insertion from the suggestion
|
* {@link #NOT_A_TOUCH_COORDINATE}. If it's called on insertion from the suggestion
|
||||||
|
@ -55,10 +50,11 @@ public interface KeyboardActionListener {
|
||||||
* {@link #NOT_A_TOUCH_COORDINATE}. If it's called on insertion from the suggestion
|
* {@link #NOT_A_TOUCH_COORDINATE}. If it's called on insertion from the suggestion
|
||||||
* strip, it should be {@link #SUGGESTION_STRIP_COORDINATE}.
|
* strip, it should be {@link #SUGGESTION_STRIP_COORDINATE}.
|
||||||
*/
|
*/
|
||||||
public void onCodeInput(int primaryCode, int[] keyCodes, int x, int y);
|
public void onCodeInput(int primaryCode, int x, int y);
|
||||||
|
|
||||||
public static final int NOT_A_TOUCH_COORDINATE = -1;
|
public static final int NOT_A_TOUCH_COORDINATE = -1;
|
||||||
public static final int SUGGESTION_STRIP_COORDINATE = -2;
|
public static final int SUGGESTION_STRIP_COORDINATE = -2;
|
||||||
|
public static final int SPELL_CHECKER_COORDINATE = -3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a sequence of characters to the listener.
|
* Sends a sequence of characters to the listener.
|
||||||
|
@ -84,7 +80,7 @@ public interface KeyboardActionListener {
|
||||||
@Override
|
@Override
|
||||||
public void onReleaseKey(int primaryCode, boolean withSliding) {}
|
public void onReleaseKey(int primaryCode, boolean withSliding) {}
|
||||||
@Override
|
@Override
|
||||||
public void onCodeInput(int primaryCode, int[] keyCodes, int x, int y) {}
|
public void onCodeInput(int primaryCode, int x, int y) {}
|
||||||
@Override
|
@Override
|
||||||
public void onTextInput(CharSequence text) {}
|
public void onTextInput(CharSequence text) {}
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -505,7 +505,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
||||||
}
|
}
|
||||||
|
|
||||||
private void invokeCodeInput(int primaryCode) {
|
private void invokeCodeInput(int primaryCode) {
|
||||||
mKeyboardActionListener.onCodeInput(primaryCode, null,
|
mKeyboardActionListener.onCodeInput(primaryCode,
|
||||||
KeyboardActionListener.NOT_A_TOUCH_COORDINATE,
|
KeyboardActionListener.NOT_A_TOUCH_COORDINATE,
|
||||||
KeyboardActionListener.NOT_A_TOUCH_COORDINATE);
|
KeyboardActionListener.NOT_A_TOUCH_COORDINATE);
|
||||||
}
|
}
|
||||||
|
@ -740,6 +740,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
||||||
* @return {@code true} if the event was handled by the view, {@code false}
|
* @return {@code true} if the event was handled by the view, {@code false}
|
||||||
* otherwise
|
* otherwise
|
||||||
*/
|
*/
|
||||||
|
//Should not annotate @override
|
||||||
public boolean dispatchHoverEvent(MotionEvent event) {
|
public boolean dispatchHoverEvent(MotionEvent event) {
|
||||||
if (AccessibilityUtils.getInstance().isTouchExplorationEnabled()) {
|
if (AccessibilityUtils.getInstance().isTouchExplorationEnabled()) {
|
||||||
final PointerTracker tracker = PointerTracker.getPointerTracker(0, this);
|
final PointerTracker tracker = PointerTracker.getPointerTracker(0, this);
|
||||||
|
|
|
@ -46,8 +46,8 @@ public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel
|
||||||
private final KeyboardActionListener mMoreKeysKeyboardListener =
|
private final KeyboardActionListener mMoreKeysKeyboardListener =
|
||||||
new KeyboardActionListener.Adapter() {
|
new KeyboardActionListener.Adapter() {
|
||||||
@Override
|
@Override
|
||||||
public void onCodeInput(int primaryCode, int[] keyCodes, int x, int y) {
|
public void onCodeInput(int primaryCode, int x, int y) {
|
||||||
mListener.onCodeInput(primaryCode, keyCodes, x, y);
|
mListener.onCodeInput(primaryCode, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -105,7 +105,6 @@ public class PointerTracker {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static KeyboardSwitcher sKeyboardSwitcher;
|
|
||||||
// Parameters for pointer handling.
|
// Parameters for pointer handling.
|
||||||
private static LatinKeyboardView.PointerTrackerParams sParams;
|
private static LatinKeyboardView.PointerTrackerParams sParams;
|
||||||
private static int sTouchNoiseThresholdDistanceSquared;
|
private static int sTouchNoiseThresholdDistanceSquared;
|
||||||
|
@ -172,7 +171,6 @@ public class PointerTracker {
|
||||||
}
|
}
|
||||||
|
|
||||||
setParameters(LatinKeyboardView.PointerTrackerParams.DEFAULT);
|
setParameters(LatinKeyboardView.PointerTrackerParams.DEFAULT);
|
||||||
sKeyboardSwitcher = KeyboardSwitcher.getInstance();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setParameters(LatinKeyboardView.PointerTrackerParams params) {
|
public static void setParameters(LatinKeyboardView.PointerTrackerParams params) {
|
||||||
|
@ -254,13 +252,13 @@ public class PointerTracker {
|
||||||
|
|
||||||
// Note that we need primaryCode argument because the keyboard may in shifted state and the
|
// Note that we need primaryCode argument because the keyboard may in shifted state and the
|
||||||
// primaryCode is different from {@link Key#mCode}.
|
// primaryCode is different from {@link Key#mCode}.
|
||||||
private void callListenerOnCodeInput(Key key, int primaryCode, int[] keyCodes, int x, int y) {
|
private void callListenerOnCodeInput(Key key, int primaryCode, int x, int y) {
|
||||||
final boolean ignoreModifierKey = mIgnoreModifierKey && key.isModifier();
|
final boolean ignoreModifierKey = mIgnoreModifierKey && key.isModifier();
|
||||||
final boolean alterCode = key.altCodeWhileTyping() && mTimerProxy.isTyping();
|
final boolean alterCode = key.altCodeWhileTyping() && mTimerProxy.isTyping();
|
||||||
final int code = alterCode ? key.mAltCode : primaryCode;
|
final int code = alterCode ? key.mAltCode : primaryCode;
|
||||||
if (DEBUG_LISTENER) {
|
if (DEBUG_LISTENER) {
|
||||||
Log.d(TAG, "onCodeInput: " + Keyboard.printableCode(code) + " text=" + key.mOutputText
|
Log.d(TAG, "onCodeInput: " + Keyboard.printableCode(code) + " text=" + key.mOutputText
|
||||||
+ " codes="+ KeyDetector.printableCodes(keyCodes) + " x=" + x + " y=" + y
|
+ " x=" + x + " y=" + y
|
||||||
+ " ignoreModifier=" + ignoreModifierKey + " alterCode=" + alterCode
|
+ " ignoreModifier=" + ignoreModifierKey + " alterCode=" + alterCode
|
||||||
+ " enabled=" + key.isEnabled());
|
+ " enabled=" + key.isEnabled());
|
||||||
}
|
}
|
||||||
|
@ -271,7 +269,7 @@ public class PointerTracker {
|
||||||
if (code == Keyboard.CODE_OUTPUT_TEXT) {
|
if (code == Keyboard.CODE_OUTPUT_TEXT) {
|
||||||
mListener.onTextInput(key.mOutputText);
|
mListener.onTextInput(key.mOutputText);
|
||||||
} else if (code != Keyboard.CODE_UNSPECIFIED) {
|
} else if (code != Keyboard.CODE_UNSPECIFIED) {
|
||||||
mListener.onCodeInput(code, keyCodes, x, y);
|
mListener.onCodeInput(code, x, y);
|
||||||
}
|
}
|
||||||
if (!key.altCodeWhileTyping() && !key.isModifier()) {
|
if (!key.altCodeWhileTyping() && !key.isModifier()) {
|
||||||
mTimerProxy.startKeyTypedTimer();
|
mTimerProxy.startKeyTypedTimer();
|
||||||
|
@ -719,10 +717,7 @@ public class PointerTracker {
|
||||||
}
|
}
|
||||||
|
|
||||||
int code = key.mCode;
|
int code = key.mCode;
|
||||||
final int[] codes = mKeyDetector.newCodeArray();
|
callListenerOnCodeInput(key, code, x, y);
|
||||||
mKeyDetector.getKeyAndNearbyCodes(x, y, codes);
|
|
||||||
|
|
||||||
callListenerOnCodeInput(key, code, codes, x, y);
|
|
||||||
callListenerOnRelease(key, code, false);
|
callListenerOnRelease(key, code, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -728,10 +728,17 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
final KeyboardSwitcher switcher = mKeyboardSwitcher;
|
final KeyboardSwitcher switcher = mKeyboardSwitcher;
|
||||||
LatinKeyboardView inputView = switcher.getKeyboardView();
|
LatinKeyboardView inputView = switcher.getKeyboardView();
|
||||||
|
|
||||||
|
if (editorInfo == null) {
|
||||||
|
Log.e(TAG, "Null EditorInfo in onStartInputView()");
|
||||||
|
if (LatinImeLogger.sDBG) {
|
||||||
|
throw new NullPointerException("Null EditorInfo in onStartInputView()");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "onStartInputView: editorInfo:" + ((editorInfo == null) ? "none"
|
Log.d(TAG, "onStartInputView: editorInfo:"
|
||||||
: String.format("inputType=0x%08x imeOptions=0x%08x",
|
+ String.format("inputType=0x%08x imeOptions=0x%08x",
|
||||||
editorInfo.inputType, editorInfo.imeOptions)));
|
editorInfo.inputType, editorInfo.imeOptions));
|
||||||
}
|
}
|
||||||
if (Utils.inPrivateImeOptions(null, IME_OPTION_NO_MICROPHONE_COMPAT, editorInfo)) {
|
if (Utils.inPrivateImeOptions(null, IME_OPTION_NO_MICROPHONE_COMPAT, editorInfo)) {
|
||||||
Log.w(TAG, "Deprecated private IME option specified: "
|
Log.w(TAG, "Deprecated private IME option specified: "
|
||||||
|
@ -761,7 +768,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
// Most such things we decide below in initializeInputAttributesAndGetMode, but we need to
|
// Most such things we decide below in initializeInputAttributesAndGetMode, but we need to
|
||||||
// know now whether this is a password text field, because we need to know now whether we
|
// know now whether this is a password text field, because we need to know now whether we
|
||||||
// want to enable the voice button.
|
// want to enable the voice button.
|
||||||
final int inputType = (editorInfo != null) ? editorInfo.inputType : 0;
|
final int inputType = editorInfo.inputType;
|
||||||
mVoiceProxy.resetVoiceStates(InputTypeCompatUtils.isPasswordInputType(inputType)
|
mVoiceProxy.resetVoiceStates(InputTypeCompatUtils.isPasswordInputType(inputType)
|
||||||
|| InputTypeCompatUtils.isVisiblePasswordInputType(inputType));
|
|| InputTypeCompatUtils.isVisiblePasswordInputType(inputType));
|
||||||
|
|
||||||
|
@ -1245,12 +1252,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
return mOptionsDialog != null && mOptionsDialog.isShowing();
|
return mOptionsDialog != null && mOptionsDialog.isShowing();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void insertPunctuationFromSuggestionStrip(final int code) {
|
|
||||||
onCodeInput(code, new int[] { code },
|
|
||||||
KeyboardActionListener.SUGGESTION_STRIP_COORDINATE,
|
|
||||||
KeyboardActionListener.SUGGESTION_STRIP_COORDINATE);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int getActionId(Keyboard keyboard) {
|
private static int getActionId(Keyboard keyboard) {
|
||||||
return keyboard != null ? keyboard.mId.imeActionId() : EditorInfo.IME_ACTION_NONE;
|
return keyboard != null ? keyboard.mId.imeActionId() : EditorInfo.IME_ACTION_NONE;
|
||||||
}
|
}
|
||||||
|
@ -1279,7 +1280,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
|
|
||||||
// Implementation of {@link KeyboardActionListener}.
|
// Implementation of {@link KeyboardActionListener}.
|
||||||
@Override
|
@Override
|
||||||
public void onCodeInput(int primaryCode, int[] keyCodes, int x, int y) {
|
public void onCodeInput(int primaryCode, int x, int y) {
|
||||||
final long when = SystemClock.uptimeMillis();
|
final long when = SystemClock.uptimeMillis();
|
||||||
if (primaryCode != Keyboard.CODE_DELETE || when > mLastKeyTime + QUICK_PRESS) {
|
if (primaryCode != Keyboard.CODE_DELETE || when > mLastKeyTime + QUICK_PRESS) {
|
||||||
mDeleteCount = 0;
|
mDeleteCount = 0;
|
||||||
|
@ -1331,7 +1332,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
if (mSettingsValues.isWordSeparator(primaryCode)) {
|
if (mSettingsValues.isWordSeparator(primaryCode)) {
|
||||||
didAutoCorrect = handleSeparator(primaryCode, x, y, spaceState);
|
didAutoCorrect = handleSeparator(primaryCode, x, y, spaceState);
|
||||||
} else {
|
} else {
|
||||||
handleCharacter(primaryCode, keyCodes, x, y, spaceState);
|
handleCharacter(primaryCode, x, y, spaceState);
|
||||||
}
|
}
|
||||||
mExpectingUpdateSelection = true;
|
mExpectingUpdateSelection = true;
|
||||||
break;
|
break;
|
||||||
|
@ -1498,18 +1499,18 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleCharacter(final int primaryCode, final int[] keyCodes, final int x,
|
private void handleCharacter(final int primaryCode, final int x,
|
||||||
final int y, final int spaceState) {
|
final int y, final int spaceState) {
|
||||||
mVoiceProxy.handleCharacter();
|
mVoiceProxy.handleCharacter();
|
||||||
final InputConnection ic = getCurrentInputConnection();
|
final InputConnection ic = getCurrentInputConnection();
|
||||||
if (null != ic) ic.beginBatchEdit();
|
if (null != ic) ic.beginBatchEdit();
|
||||||
// TODO: if ic is null, does it make any sense to call this?
|
// TODO: if ic is null, does it make any sense to call this?
|
||||||
handleCharacterWhileInBatchEdit(primaryCode, keyCodes, x, y, spaceState, ic);
|
handleCharacterWhileInBatchEdit(primaryCode, x, y, spaceState, ic);
|
||||||
if (null != ic) ic.endBatchEdit();
|
if (null != ic) ic.endBatchEdit();
|
||||||
}
|
}
|
||||||
|
|
||||||
// "ic" may be null without this crashing, but the behavior will be really strange
|
// "ic" may be null without this crashing, but the behavior will be really strange
|
||||||
private void handleCharacterWhileInBatchEdit(final int primaryCode, final int[] keyCodes,
|
private void handleCharacterWhileInBatchEdit(final int primaryCode,
|
||||||
final int x, final int y, final int spaceState, final InputConnection ic) {
|
final int x, final int y, final int spaceState, final InputConnection ic) {
|
||||||
boolean isComposingWord = mWordComposer.isComposingWord();
|
boolean isComposingWord = mWordComposer.isComposingWord();
|
||||||
|
|
||||||
|
@ -1541,7 +1542,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isComposingWord) {
|
if (isComposingWord) {
|
||||||
mWordComposer.add(primaryCode, keyCodes, x, y);
|
mWordComposer.add(
|
||||||
|
primaryCode, x, y, mKeyboardSwitcher.getKeyboardView().getKeyDetector());
|
||||||
if (ic != null) {
|
if (ic != null) {
|
||||||
// If it's the first letter, make note of auto-caps state
|
// If it's the first letter, make note of auto-caps state
|
||||||
if (mWordComposer.size() == 1) {
|
if (mWordComposer.size() == 1) {
|
||||||
|
@ -1916,7 +1918,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
LatinImeLogger.logOnManualSuggestion("", suggestion.toString(), index, suggestedWords);
|
LatinImeLogger.logOnManualSuggestion("", suggestion.toString(), index, suggestedWords);
|
||||||
// Rely on onCodeInput to do the complicated swapping/stripping logic consistently.
|
// Rely on onCodeInput to do the complicated swapping/stripping logic consistently.
|
||||||
final int primaryCode = suggestion.charAt(0);
|
final int primaryCode = suggestion.charAt(0);
|
||||||
onCodeInput(primaryCode, new int[] { primaryCode },
|
onCodeInput(primaryCode,
|
||||||
KeyboardActionListener.SUGGESTION_STRIP_COORDINATE,
|
KeyboardActionListener.SUGGESTION_STRIP_COORDINATE,
|
||||||
KeyboardActionListener.SUGGESTION_STRIP_COORDINATE);
|
KeyboardActionListener.SUGGESTION_STRIP_COORDINATE);
|
||||||
return;
|
return;
|
||||||
|
@ -2162,7 +2164,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
final String originallyTypedWord = mLastComposedWord.mTypedWord;
|
final String originallyTypedWord = mLastComposedWord.mTypedWord;
|
||||||
final CharSequence committedWord = mLastComposedWord.mCommittedWord;
|
final CharSequence committedWord = mLastComposedWord.mCommittedWord;
|
||||||
final int cancelLength = committedWord.length();
|
final int cancelLength = committedWord.length();
|
||||||
final int separatorLength = mLastComposedWord.getSeparatorLength(
|
final int separatorLength = LastComposedWord.getSeparatorLength(
|
||||||
mLastComposedWord.mSeparatorCode);
|
mLastComposedWord.mSeparatorCode);
|
||||||
// TODO: should we check our saved separator against the actual contents of the text view?
|
// TODO: should we check our saved separator against the actual contents of the text view?
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
|
|
|
@ -323,7 +323,6 @@ public class Suggest implements Dictionary.WordCallback {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Word entered: return only bigrams that match the first char of the typed word
|
// Word entered: return only bigrams that match the first char of the typed word
|
||||||
@SuppressWarnings("null")
|
|
||||||
final char currentChar = consideredWord.charAt(0);
|
final char currentChar = consideredWord.charAt(0);
|
||||||
// TODO: Must pay attention to locale when changing case.
|
// TODO: Must pay attention to locale when changing case.
|
||||||
final char currentCharUpper = Character.toUpperCase(currentChar);
|
final char currentCharUpper = Character.toUpperCase(currentChar);
|
||||||
|
|
|
@ -19,6 +19,9 @@ package com.android.inputmethod.latin;
|
||||||
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.Keyboard;
|
import com.android.inputmethod.keyboard.Keyboard;
|
||||||
|
import com.android.inputmethod.keyboard.KeyboardActionListener;
|
||||||
|
import com.android.inputmethod.latin.spellcheck.AndroidSpellCheckerService;
|
||||||
|
import com.android.inputmethod.latin.spellcheck.SpellCheckerProximityInfo;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -119,19 +122,60 @@ public class WordComposer {
|
||||||
return previous && !Character.isUpperCase(codePoint);
|
return previous && !Character.isUpperCase(codePoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: remove input keyDetector
|
||||||
|
public void add(int primaryCode, int keyX, int keyY, KeyDetector keyDetector) {
|
||||||
|
final int[] codes;
|
||||||
|
if (keyX == KeyboardActionListener.SPELL_CHECKER_COORDINATE
|
||||||
|
|| keyY == KeyboardActionListener.SPELL_CHECKER_COORDINATE) {
|
||||||
|
// only used for tests in InputLogicTests
|
||||||
|
addKeyForSpellChecker(primaryCode, AndroidSpellCheckerService.SCRIPT_LATIN);
|
||||||
|
return;
|
||||||
|
} else if (keyX == KeyboardActionListener.SUGGESTION_STRIP_COORDINATE
|
||||||
|
|| keyY == KeyboardActionListener.SUGGESTION_STRIP_COORDINATE
|
||||||
|
|| keyX == KeyboardActionListener.NOT_A_TOUCH_COORDINATE
|
||||||
|
|| keyY == KeyboardActionListener.NOT_A_TOUCH_COORDINATE) {
|
||||||
|
codes = new int[] { primaryCode };
|
||||||
|
} else {
|
||||||
|
codes = keyDetector.newCodeArray();
|
||||||
|
keyDetector.getKeyAndNearbyCodes(keyX, keyY, codes);
|
||||||
|
}
|
||||||
|
add(primaryCode, codes, keyX, keyY);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove this function
|
||||||
|
public void addKeyForSpellChecker(int primaryCode, int script) {
|
||||||
|
final int[] proximities;
|
||||||
|
final int proximityIndex =
|
||||||
|
SpellCheckerProximityInfo.getIndexOfCodeForScript(primaryCode, script);
|
||||||
|
if (-1 == proximityIndex) {
|
||||||
|
proximities = new int[] { primaryCode };
|
||||||
|
} else {
|
||||||
|
// TODO: an initial examination seems to reveal this is actually used
|
||||||
|
// read-only. It should be possible to compute the arrays statically once
|
||||||
|
// and skip doing a copy each time here.
|
||||||
|
proximities = Arrays.copyOfRange(
|
||||||
|
SpellCheckerProximityInfo.getProximityForScript(script),
|
||||||
|
proximityIndex,
|
||||||
|
proximityIndex + SpellCheckerProximityInfo.ROW_SIZE);
|
||||||
|
}
|
||||||
|
add(primaryCode, proximities,
|
||||||
|
KeyboardActionListener.NOT_A_TOUCH_COORDINATE,
|
||||||
|
KeyboardActionListener.NOT_A_TOUCH_COORDINATE);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new keystroke, with codes[0] containing the pressed key's unicode and the rest of
|
* Add a new keystroke, with codes[0] containing the pressed key's unicode and the rest of
|
||||||
* the array containing unicode for adjacent keys, sorted by reducing probability/proximity.
|
* the array containing unicode for adjacent keys, sorted by reducing probability/proximity.
|
||||||
* @param codes the array of unicode values
|
* @param codes the array of unicode values
|
||||||
*/
|
*/
|
||||||
public void add(int primaryCode, int[] codes, int x, int y) {
|
private void add(int primaryCode, int[] codes, int keyX, int keyY) {
|
||||||
final int newIndex = mCodes.size();
|
final int newIndex = mCodes.size();
|
||||||
mTypedWord.appendCodePoint(primaryCode);
|
mTypedWord.appendCodePoint(primaryCode);
|
||||||
correctPrimaryJuxtapos(primaryCode, codes);
|
correctPrimaryJuxtapos(primaryCode, codes);
|
||||||
mCodes.add(codes);
|
mCodes.add(codes);
|
||||||
if (newIndex < BinaryDictionary.MAX_WORD_LENGTH) {
|
if (newIndex < BinaryDictionary.MAX_WORD_LENGTH) {
|
||||||
mXCoordinates[newIndex] = x;
|
mXCoordinates[newIndex] = keyX;
|
||||||
mYCoordinates[newIndex] = y;
|
mYCoordinates[newIndex] = keyY;
|
||||||
}
|
}
|
||||||
mIsFirstCharCapitalized = isFirstCharCapitalized(
|
mIsFirstCharCapitalized = isFirstCharCapitalized(
|
||||||
newIndex, primaryCode, mIsFirstCharCapitalized);
|
newIndex, primaryCode, mIsFirstCharCapitalized);
|
||||||
|
|
|
@ -570,23 +570,7 @@ public class AndroidSpellCheckerService extends SpellCheckerService
|
||||||
final WordComposer composer = new WordComposer();
|
final WordComposer composer = new WordComposer();
|
||||||
final int length = text.length();
|
final int length = text.length();
|
||||||
for (int i = 0; i < length; i = text.offsetByCodePoints(i, 1)) {
|
for (int i = 0; i < length; i = text.offsetByCodePoints(i, 1)) {
|
||||||
final int character = text.codePointAt(i);
|
composer.addKeyForSpellChecker(text.codePointAt(i), mScript);
|
||||||
final int proximityIndex =
|
|
||||||
SpellCheckerProximityInfo.getIndexOfCodeForScript(character, mScript);
|
|
||||||
final int[] proximities;
|
|
||||||
if (-1 == proximityIndex) {
|
|
||||||
proximities = new int[] { character };
|
|
||||||
} else {
|
|
||||||
// TODO: an initial examination seems to reveal this is actually used
|
|
||||||
// read-only. It should be possible to compute the arrays statically once
|
|
||||||
// and skip doing a copy each time here.
|
|
||||||
proximities = Arrays.copyOfRange(
|
|
||||||
SpellCheckerProximityInfo.getProximityForScript(mScript),
|
|
||||||
proximityIndex,
|
|
||||||
proximityIndex + SpellCheckerProximityInfo.ROW_SIZE);
|
|
||||||
}
|
|
||||||
composer.add(character, proximities,
|
|
||||||
WordComposer.NOT_A_COORDINATE, WordComposer.NOT_A_COORDINATE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final int capitalizeType = getCapitalizationType(text);
|
final int capitalizeType = getCapitalizationType(text);
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class MoreSuggestionsView extends KeyboardView implements MoreKeysPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCodeInput(int primaryCode, int[] keyCodes, int x, int y) {
|
public void onCodeInput(int primaryCode, int x, int y) {
|
||||||
final int index = primaryCode - MoreSuggestions.SUGGESTION_CODE_BASE;
|
final int index = primaryCode - MoreSuggestions.SUGGESTION_CODE_BASE;
|
||||||
if (index >= 0 && index < SuggestionsView.MAX_SUGGESTIONS) {
|
if (index >= 0 && index < SuggestionsView.MAX_SUGGESTIONS) {
|
||||||
mListener.onCustomRequest(index);
|
mListener.onCustomRequest(index);
|
||||||
|
|
|
@ -51,29 +51,9 @@ public class InputLogicTests extends ServiceTestCase<LatinIME> {
|
||||||
private LatinIME mLatinIME;
|
private LatinIME mLatinIME;
|
||||||
private TextView mTextView;
|
private TextView mTextView;
|
||||||
private InputConnection mInputConnection;
|
private InputConnection mInputConnection;
|
||||||
private HashMap<Integer, int[]> mProximity;
|
|
||||||
|
|
||||||
public InputLogicTests() {
|
public InputLogicTests() {
|
||||||
super(LatinIME.class);
|
super(LatinIME.class);
|
||||||
mProximity = createProximity();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static HashMap<Integer, int[]> createProximity() {
|
|
||||||
final HashMap<Integer, int[]> proximity = new HashMap<Integer, int[]>();
|
|
||||||
final int[] testProximity = SpellCheckerProximityInfo.getProximityForScript(
|
|
||||||
AndroidSpellCheckerService.SCRIPT_LATIN);
|
|
||||||
final int ROW_SIZE = SpellCheckerProximityInfo.ROW_SIZE;
|
|
||||||
final int NUL = SpellCheckerProximityInfo.NUL;
|
|
||||||
for (int row = 0; row * ROW_SIZE < testProximity.length; ++row) {
|
|
||||||
final int rowBase = row * ROW_SIZE;
|
|
||||||
int column;
|
|
||||||
for (column = 1; NUL != testProximity[rowBase + column]; ++column) {
|
|
||||||
// Do nothing, just search for a NUL element
|
|
||||||
}
|
|
||||||
proximity.put(testProximity[row * ROW_SIZE],
|
|
||||||
Arrays.copyOfRange(testProximity, rowBase, rowBase + column));
|
|
||||||
}
|
|
||||||
return proximity;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns the previous setting value
|
// returns the previous setting value
|
||||||
|
@ -185,13 +165,9 @@ public class InputLogicTests extends ServiceTestCase<LatinIME> {
|
||||||
// to keep these tests as pinpoint as possible and avoid bringing it too many dependencies,
|
// to keep these tests as pinpoint as possible and avoid bringing it too many dependencies,
|
||||||
// but keep them in mind if something breaks. Commenting them out as is should work.
|
// but keep them in mind if something breaks. Commenting them out as is should work.
|
||||||
//mLatinIME.onPressKey(codePoint);
|
//mLatinIME.onPressKey(codePoint);
|
||||||
int[] proximityKeys = mProximity.get(codePoint);
|
mLatinIME.onCodeInput(codePoint,
|
||||||
if (null == proximityKeys) {
|
KeyboardActionListener.SPELL_CHECKER_COORDINATE,
|
||||||
proximityKeys = new int[] { codePoint };
|
KeyboardActionListener.SPELL_CHECKER_COORDINATE);
|
||||||
}
|
|
||||||
mLatinIME.onCodeInput(codePoint, proximityKeys,
|
|
||||||
KeyboardActionListener.NOT_A_TOUCH_COORDINATE,
|
|
||||||
KeyboardActionListener.NOT_A_TOUCH_COORDINATE);
|
|
||||||
//mLatinIME.onReleaseKey(codePoint, false);
|
//mLatinIME.onReleaseKey(codePoint, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue