Remove WordComposer.add(int, int, int, KeyDetector) method
Change-Id: Ie6af46acba18a2d1cf3ddd1578d60ded4c90f89a
This commit is contained in:
parent
040aa28ed4
commit
5c641a9f59
5 changed files with 26 additions and 24 deletions
|
@ -53,6 +53,7 @@ public class KeyDetector {
|
||||||
return x + mCorrectionX;
|
return x + mCorrectionX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Remove vertical correction.
|
||||||
public int getTouchY(int y) {
|
public int getTouchY(int y) {
|
||||||
return y + mCorrectionY;
|
return y + mCorrectionY;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,7 @@ public interface KeyboardActionListener {
|
||||||
*/
|
*/
|
||||||
public void onCodeInput(int primaryCode, int x, int y);
|
public void onCodeInput(int primaryCode, int x, int y);
|
||||||
|
|
||||||
|
// See {@link Adapter#isInvalidCoordinate(int)}.
|
||||||
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;
|
public static final int SPELL_CHECKER_COORDINATE = -3;
|
||||||
|
@ -89,5 +90,13 @@ public interface KeyboardActionListener {
|
||||||
public boolean onCustomRequest(int requestCode) {
|
public boolean onCustomRequest(int requestCode) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Remove this method when the vertical correction is removed.
|
||||||
|
public static boolean isInvalidCoordinate(int coordinate) {
|
||||||
|
// Detect {@link KeyboardActionListener#NOT_A_TOUCH_COORDINATE},
|
||||||
|
// {@link KeyboardActionListener#SUGGESTION_STRIP_COORDINATE}, and
|
||||||
|
// {@link KeyboardActionListener#SPELL_CHECKER_COORDINATE}.
|
||||||
|
return coordinate < 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,7 @@ import com.android.inputmethod.accessibility.AccessibleKeyboardViewProxy;
|
||||||
import com.android.inputmethod.compat.CompatUtils;
|
import com.android.inputmethod.compat.CompatUtils;
|
||||||
import com.android.inputmethod.compat.InputMethodManagerCompatWrapper;
|
import com.android.inputmethod.compat.InputMethodManagerCompatWrapper;
|
||||||
import com.android.inputmethod.compat.SuggestionSpanUtils;
|
import com.android.inputmethod.compat.SuggestionSpanUtils;
|
||||||
|
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.keyboard.KeyboardActionListener;
|
||||||
import com.android.inputmethod.keyboard.KeyboardId;
|
import com.android.inputmethod.keyboard.KeyboardId;
|
||||||
|
@ -1505,8 +1506,18 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
clearSuggestions();
|
clearSuggestions();
|
||||||
}
|
}
|
||||||
if (isComposingWord) {
|
if (isComposingWord) {
|
||||||
mWordComposer.add(
|
final int keyX, keyY;
|
||||||
primaryCode, x, y, mKeyboardSwitcher.getKeyboardView().getKeyDetector());
|
if (KeyboardActionListener.Adapter.isInvalidCoordinate(x)
|
||||||
|
|| KeyboardActionListener.Adapter.isInvalidCoordinate(y)) {
|
||||||
|
keyX = x;
|
||||||
|
keyY = y;
|
||||||
|
} else {
|
||||||
|
final KeyDetector keyDetector =
|
||||||
|
mKeyboardSwitcher.getKeyboardView().getKeyDetector();
|
||||||
|
keyX = keyDetector.getTouchX(x);
|
||||||
|
keyY = keyDetector.getTouchY(y);
|
||||||
|
}
|
||||||
|
mWordComposer.add(primaryCode, keyX, keyY);
|
||||||
// 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) {
|
||||||
mWordComposer.setAutoCapitalized(
|
mWordComposer.setAutoCapitalized(
|
||||||
|
|
|
@ -19,7 +19,6 @@ 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 java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
@ -121,28 +120,10 @@ public class WordComposer {
|
||||||
return previous && !Character.isUpperCase(codePoint);
|
return previous && !Character.isUpperCase(codePoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: remove input keyDetector
|
|
||||||
public void add(int primaryCode, int x, int y, KeyDetector keyDetector) {
|
|
||||||
final int keyX;
|
|
||||||
final int keyY;
|
|
||||||
if (null == keyDetector
|
|
||||||
|| x == KeyboardActionListener.SUGGESTION_STRIP_COORDINATE
|
|
||||||
|| y == KeyboardActionListener.SUGGESTION_STRIP_COORDINATE
|
|
||||||
|| x == KeyboardActionListener.NOT_A_TOUCH_COORDINATE
|
|
||||||
|| y == KeyboardActionListener.NOT_A_TOUCH_COORDINATE) {
|
|
||||||
keyX = x;
|
|
||||||
keyY = y;
|
|
||||||
} else {
|
|
||||||
keyX = keyDetector.getTouchX(x);
|
|
||||||
keyY = keyDetector.getTouchY(y);
|
|
||||||
}
|
|
||||||
add(primaryCode, keyX, keyY);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new keystroke, with the pressed key's code point with the touch point coordinates.
|
* Add a new keystroke, with the pressed key's code point with the touch point coordinates.
|
||||||
*/
|
*/
|
||||||
private void add(int primaryCode, int keyX, int keyY) {
|
public void add(int primaryCode, int keyX, int keyY) {
|
||||||
final int newIndex = size();
|
final int newIndex = size();
|
||||||
mTypedWord.appendCodePoint(primaryCode);
|
mTypedWord.appendCodePoint(primaryCode);
|
||||||
refreshSize();
|
refreshSize();
|
||||||
|
|
|
@ -768,9 +768,9 @@ public class AndroidSpellCheckerService extends SpellCheckerService
|
||||||
codePoint, mScript);
|
codePoint, mScript);
|
||||||
if (SpellCheckerProximityInfo.NOT_A_COORDINATE_PAIR == xy) {
|
if (SpellCheckerProximityInfo.NOT_A_COORDINATE_PAIR == xy) {
|
||||||
composer.add(codePoint, WordComposer.NOT_A_COORDINATE,
|
composer.add(codePoint, WordComposer.NOT_A_COORDINATE,
|
||||||
WordComposer.NOT_A_COORDINATE, null);
|
WordComposer.NOT_A_COORDINATE);
|
||||||
} else {
|
} else {
|
||||||
composer.add(codePoint, xy & 0xFFFF, xy >> 16, null);
|
composer.add(codePoint, xy & 0xFFFF, xy >> 16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue