Move isInvalidCordinates() method to Constants class
Change-Id: Iad1464c299ad6055af1db1ff7978e5cd9a14750fmain
parent
01f6a61e51
commit
24ab8055aa
|
@ -112,13 +112,5 @@ 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(final int coordinate) {
|
|
||||||
// Detect {@link Constants#NOT_A_COORDINATE},
|
|
||||||
// {@link Constants#SUGGESTION_STRIP_COORDINATE}, and
|
|
||||||
// {@link Constants#SPELL_CHECKER_COORDINATE}.
|
|
||||||
return coordinate < 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,11 +137,16 @@ public final class Constants {
|
||||||
|
|
||||||
public static final int NOT_A_CODE = -1;
|
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 NOT_A_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;
|
||||||
|
|
||||||
|
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.
|
* Some common keys code. Must be positive.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1741,15 +1741,14 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
||||||
}
|
}
|
||||||
if (isComposingWord) {
|
if (isComposingWord) {
|
||||||
final int keyX, keyY;
|
final int keyX, keyY;
|
||||||
if (KeyboardActionListener.Adapter.isInvalidCoordinate(x)
|
if (Constants.isValidCoordinate(x) && Constants.isValidCoordinate(y)) {
|
||||||
|| KeyboardActionListener.Adapter.isInvalidCoordinate(y)) {
|
|
||||||
keyX = x;
|
|
||||||
keyY = y;
|
|
||||||
} else {
|
|
||||||
final KeyDetector keyDetector =
|
final KeyDetector keyDetector =
|
||||||
mKeyboardSwitcher.getMainKeyboardView().getKeyDetector();
|
mKeyboardSwitcher.getMainKeyboardView().getKeyDetector();
|
||||||
keyX = keyDetector.getTouchX(x);
|
keyX = keyDetector.getTouchX(x);
|
||||||
keyY = keyDetector.getTouchY(y);
|
keyY = keyDetector.getTouchY(y);
|
||||||
|
} else {
|
||||||
|
keyX = x;
|
||||||
|
keyY = y;
|
||||||
}
|
}
|
||||||
mWordComposer.add(primaryCode, keyX, keyY);
|
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
|
||||||
|
|
Loading…
Reference in New Issue