Merge "Move isInvalidCordinates() method to Constants class"

This commit is contained in:
Tadashi G. Takaoka 2012-10-31 21:24:00 -07:00 committed by Android (Google) Code Review
commit ffb0c093d1
3 changed files with 10 additions and 14 deletions

View file

@ -112,13 +112,5 @@ public interface KeyboardActionListener {
public boolean onCustomRequest(int requestCode) {
return false;
}
// TODO: Remove this method when the vertical correction is removed.
public static boolean isInvalidCoordinate(final int coordinate) {
// Detect {@link Constants#NOT_A_COORDINATE},
// {@link Constants#SUGGESTION_STRIP_COORDINATE}, and
// {@link Constants#SPELL_CHECKER_COORDINATE}.
return coordinate < 0;
}
}
}

View file

@ -136,11 +136,16 @@ public final class Constants {
public static final int NOT_A_CODE = -1;
// See {@link KeyboardActionListener.Adapter#isInvalidCoordinate(int)}.
public static final int NOT_A_COORDINATE = -1;
public static final int SUGGESTION_STRIP_COORDINATE = -2;
public static final int SPELL_CHECKER_COORDINATE = -3;
public static boolean isValidCoordinate(final int coordinate) {
// Detect {@link NOT_A_COORDINATE}, {@link SUGGESTION_STRIP_COORDINATE},
// and {@link SPELL_CHECKER_COORDINATE}.
return coordinate >= 0;
}
/**
* Some common keys code. Must be positive.
*/

View file

@ -1741,15 +1741,14 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
}
if (isComposingWord) {
final int keyX, keyY;
if (KeyboardActionListener.Adapter.isInvalidCoordinate(x)
|| KeyboardActionListener.Adapter.isInvalidCoordinate(y)) {
keyX = x;
keyY = y;
} else {
if (Constants.isValidCoordinate(x) && Constants.isValidCoordinate(y)) {
final KeyDetector keyDetector =
mKeyboardSwitcher.getMainKeyboardView().getKeyDetector();
keyX = keyDetector.getTouchX(x);
keyY = keyDetector.getTouchY(y);
} else {
keyX = x;
keyY = y;
}
mWordComposer.add(primaryCode, keyX, keyY);
// If it's the first letter, make note of auto-caps state