Merge "Remove WordComposer.add(int, int, int, KeyDetector) method"

main
Tadashi G. Takaoka 2012-07-04 01:48:42 -07:00 committed by Android (Google) Code Review
commit ac3bd96192
5 changed files with 26 additions and 24 deletions

View File

@ -53,6 +53,7 @@ public class KeyDetector {
return x + mCorrectionX;
}
// TODO: Remove vertical correction.
public int getTouchY(int y) {
return y + mCorrectionY;
}

View File

@ -52,6 +52,7 @@ public interface KeyboardActionListener {
*/
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 SUGGESTION_STRIP_COORDINATE = -2;
public static final int SPELL_CHECKER_COORDINATE = -3;
@ -89,5 +90,13 @@ public interface KeyboardActionListener {
public boolean onCustomRequest(int requestCode) {
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;
}
}
}

View File

@ -63,6 +63,7 @@ import com.android.inputmethod.accessibility.AccessibleKeyboardViewProxy;
import com.android.inputmethod.compat.CompatUtils;
import com.android.inputmethod.compat.InputMethodManagerCompatWrapper;
import com.android.inputmethod.compat.SuggestionSpanUtils;
import com.android.inputmethod.keyboard.KeyDetector;
import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.KeyboardActionListener;
import com.android.inputmethod.keyboard.KeyboardId;
@ -1505,8 +1506,18 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
clearSuggestions();
}
if (isComposingWord) {
mWordComposer.add(
primaryCode, x, y, mKeyboardSwitcher.getKeyboardView().getKeyDetector());
final int keyX, keyY;
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 (mWordComposer.size() == 1) {
mWordComposer.setAutoCapitalized(

View File

@ -19,7 +19,6 @@ package com.android.inputmethod.latin;
import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.KeyDetector;
import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.KeyboardActionListener;
import java.util.Arrays;
@ -121,28 +120,10 @@ public class WordComposer {
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.
*/
private void add(int primaryCode, int keyX, int keyY) {
public void add(int primaryCode, int keyX, int keyY) {
final int newIndex = size();
mTypedWord.appendCodePoint(primaryCode);
refreshSize();

View File

@ -768,9 +768,9 @@ public class AndroidSpellCheckerService extends SpellCheckerService
codePoint, mScript);
if (SpellCheckerProximityInfo.NOT_A_COORDINATE_PAIR == xy) {
composer.add(codePoint, WordComposer.NOT_A_COORDINATE,
WordComposer.NOT_A_COORDINATE, null);
WordComposer.NOT_A_COORDINATE);
} else {
composer.add(codePoint, xy & 0xFFFF, xy >> 16, null);
composer.add(codePoint, xy & 0xFFFF, xy >> 16);
}
}