Merge remote-tracking branch 'goog/master' into mergescript

Conflicts:
	java/src/com/android/inputmethod/latin/SuggestedWords.java

Change-Id: I1ce6cd0846cb93a5c9bb2d9c3638d59f90232c26
main
Satoshi Kataoka 2012-07-04 19:21:16 +09:00
commit 12bbd2cd5e
5 changed files with 32 additions and 31 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;
@ -1508,8 +1509,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;
@ -129,28 +128,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();
@ -175,13 +156,12 @@ public class WordComposer {
* Internal method to retrieve reasonable proximity info for a character.
*/
private void addKeyInfo(final int codePoint, final Keyboard keyboard) {
for (final Key key : keyboard.mKeys) {
if (key.mCode == codePoint) {
final int x = key.mX + key.mWidth / 2;
final int y = key.mY + key.mHeight / 2;
add(codePoint, x, y);
return;
}
final Key key = keyboard.getKey(codePoint);
if (key != null) {
final int x = key.mX + key.mWidth / 2;
final int y = key.mY + key.mHeight / 2;
add(codePoint, x, y);
return;
}
add(codePoint, WordComposer.NOT_A_COORDINATE, WordComposer.NOT_A_COORDINATE);
}

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);
}
}