Fix coordinates sent to native code

Change-Id: I2c8b093b59ad36ffe860c3c4d360d87251d101c4
main
satok 2012-03-06 16:38:00 +09:00
parent 231ef8fa3e
commit 691f1c174b
2 changed files with 16 additions and 10 deletions

View File

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

View File

@ -123,21 +123,27 @@ public class WordComposer {
} }
// TODO: remove input keyDetector // 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; final int[] codes;
if (keyX == KeyboardActionListener.SPELL_CHECKER_COORDINATE final int keyX;
|| keyY == KeyboardActionListener.SPELL_CHECKER_COORDINATE) { final int keyY;
if (x == KeyboardActionListener.SPELL_CHECKER_COORDINATE
|| y == KeyboardActionListener.SPELL_CHECKER_COORDINATE) {
// only used for tests in InputLogicTests // only used for tests in InputLogicTests
addKeyForSpellChecker(primaryCode, AndroidSpellCheckerService.SCRIPT_LATIN); addKeyForSpellChecker(primaryCode, AndroidSpellCheckerService.SCRIPT_LATIN);
return; return;
} else if (keyX == KeyboardActionListener.SUGGESTION_STRIP_COORDINATE } else if (x == KeyboardActionListener.SUGGESTION_STRIP_COORDINATE
|| keyY == KeyboardActionListener.SUGGESTION_STRIP_COORDINATE || y == KeyboardActionListener.SUGGESTION_STRIP_COORDINATE
|| keyX == KeyboardActionListener.NOT_A_TOUCH_COORDINATE || x == KeyboardActionListener.NOT_A_TOUCH_COORDINATE
|| keyY == KeyboardActionListener.NOT_A_TOUCH_COORDINATE) { || y == KeyboardActionListener.NOT_A_TOUCH_COORDINATE) {
codes = new int[] { primaryCode }; codes = new int[] { primaryCode };
keyX = x;
keyY = y;
} else { } else {
codes = keyDetector.newCodeArray(); 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); add(primaryCode, codes, keyX, keyY);
} }