Merge "Fix coordinates sent to native code"

This commit is contained in:
satok 2012-03-06 00:07:30 -08:00 committed by Android (Google) Code Review
commit 168d2c094b
2 changed files with 16 additions and 10 deletions

View file

@ -65,11 +65,11 @@ public class KeyDetector {
return mKeyHysteresisDistanceSquared;
}
protected int getTouchX(int x) {
public int getTouchX(int x) {
return x + mCorrectionX;
}
protected int getTouchY(int y) {
public int getTouchY(int y) {
return y + mCorrectionY;
}

View file

@ -123,21 +123,27 @@ public class WordComposer {
}
// TODO: remove input keyDetector
public void add(int primaryCode, int keyX, int keyY, KeyDetector keyDetector) {
public void add(int primaryCode, int x, int y, KeyDetector keyDetector) {
final int[] codes;
if (keyX == KeyboardActionListener.SPELL_CHECKER_COORDINATE
|| keyY == KeyboardActionListener.SPELL_CHECKER_COORDINATE) {
final int keyX;
final int keyY;
if (x == KeyboardActionListener.SPELL_CHECKER_COORDINATE
|| y == 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) {
} else if (x == KeyboardActionListener.SUGGESTION_STRIP_COORDINATE
|| y == KeyboardActionListener.SUGGESTION_STRIP_COORDINATE
|| x == KeyboardActionListener.NOT_A_TOUCH_COORDINATE
|| y == KeyboardActionListener.NOT_A_TOUCH_COORDINATE) {
codes = new int[] { primaryCode };
keyX = x;
keyY = y;
} else {
codes = keyDetector.newCodeArray();
keyDetector.getKeyAndNearbyCodes(keyX, keyY, codes);
keyDetector.getKeyAndNearbyCodes(x, y, codes);
keyX = keyDetector.getTouchX(x);
keyY = keyDetector.getTouchX(y);
}
add(primaryCode, codes, keyX, keyY);
}