aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java29
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardView.java66
-rw-r--r--java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java4
-rw-r--r--java/src/com/android/inputmethod/keyboard/PointerTracker.java40
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java27
5 files changed, 43 insertions, 123 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java b/java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java
index e52db2957..848cc9693 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java
@@ -40,10 +40,10 @@ public interface KeyboardActionListener {
void onRelease(int primaryCode);
/**
- * Send a key press to the listener.
+ * Send a key code to the listener.
*
* @param primaryCode
- * this is the key that was pressed
+ * this is the code of the key that was pressed
* @param keyCodes
* the codes for all the possible alternative keys with
* the primary code being the first. If the primary key
@@ -60,7 +60,7 @@ public interface KeyboardActionListener {
* y-coordinate pixel of touched event. If onKey is not called by onTouchEvent,
* the value should be NOT_A_TOUCH_COORDINATE.
*/
- void onKey(int primaryCode, int[] keyCodes, int x, int y);
+ void onCodeInput(int primaryCode, int[] keyCodes, int x, int y);
/**
* Sends a sequence of characters to the listener.
@@ -68,32 +68,15 @@ public interface KeyboardActionListener {
* @param text
* the sequence of characters to be displayed.
*/
- void onText(CharSequence text);
+ void onTextInput(CharSequence text);
/**
* Called when user released a finger outside any key.
*/
- void onCancel();
-
- /**
- * Called when the user quickly moves the finger from right to
- * left.
- */
- void swipeLeft();
-
- /**
- * Called when the user quickly moves the finger from left to
- * right.
- */
- void swipeRight();
+ void onCancelInput();
/**
* Called when the user quickly moves the finger from up to down.
*/
- void swipeDown();
-
- /**
- * Called when the user quickly moves the finger from down to up.
- */
- void swipeUp();
+ void onSwipeDown();
}
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
index 11b7ec241..7f573b24c 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
@@ -409,31 +409,13 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
float velocityY) {
final float absX = Math.abs(velocityX);
final float absY = Math.abs(velocityY);
- float deltaX = me2.getX() - me1.getX();
float deltaY = me2.getY() - me1.getY();
- int travelX = getWidth() / 2; // Half the keyboard width
int travelY = getHeight() / 2; // Half the keyboard height
mSwipeTracker.computeCurrentVelocity(1000);
- final float endingVelocityX = mSwipeTracker.getXVelocity();
final float endingVelocityY = mSwipeTracker.getYVelocity();
- if (velocityX > mSwipeThreshold && absY < absX && deltaX > travelX) {
- if (mDisambiguateSwipe && endingVelocityX >= velocityX / 4) {
- swipeRight();
- return true;
- }
- } else if (velocityX < -mSwipeThreshold && absY < absX && deltaX < -travelX) {
- if (mDisambiguateSwipe && endingVelocityX <= velocityX / 4) {
- swipeLeft();
- return true;
- }
- } else if (velocityY < -mSwipeThreshold && absX < absY && deltaY < -travelY) {
- if (mDisambiguateSwipe && endingVelocityY <= velocityY / 4) {
- swipeUp();
- return true;
- }
- } else if (velocityY > mSwipeThreshold && absX < absY / 2 && deltaY > travelY) {
+ if (velocityY > mSwipeThreshold && absX < absY / 2 && deltaY > travelY) {
if (mDisambiguateSwipe && endingVelocityY >= velocityY / 4) {
- swipeDown();
+ onSwipeDown();
return true;
}
}
@@ -1089,14 +1071,14 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
private void onLongPressShiftKey(PointerTracker tracker) {
tracker.setAlreadyProcessed();
mPointerQueue.remove(tracker);
- mKeyboardActionListener.onKey(Keyboard.CODE_CAPSLOCK, null, 0, 0);
+ mKeyboardActionListener.onCodeInput(Keyboard.CODE_CAPSLOCK, null, 0, 0);
}
private void onDoubleTapShiftKey(@SuppressWarnings("unused") PointerTracker tracker) {
// When shift key is double tapped, the first tap is correctly processed as usual tap. And
// the second tap is treated as this double tap event, so that we need not mark tracker
// calling setAlreadyProcessed() nor remove the tracker from mPointerQueueueue.
- mKeyboardActionListener.onKey(Keyboard.CODE_CAPSLOCK, null, 0, 0);
+ mKeyboardActionListener.onCodeInput(Keyboard.CODE_CAPSLOCK, null, 0, 0);
}
private View inflateMiniKeyboardContainer(Key popupKey) {
@@ -1111,36 +1093,24 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
(KeyboardView)container.findViewById(R.id.KeyboardView);
miniKeyboard.setOnKeyboardActionListener(new KeyboardActionListener() {
@Override
- public void onKey(int primaryCode, int[] keyCodes, int x, int y) {
- mKeyboardActionListener.onKey(primaryCode, keyCodes, x, y);
+ public void onCodeInput(int primaryCode, int[] keyCodes, int x, int y) {
+ mKeyboardActionListener.onCodeInput(primaryCode, keyCodes, x, y);
dismissPopupKeyboard();
}
@Override
- public void onText(CharSequence text) {
- mKeyboardActionListener.onText(text);
+ public void onTextInput(CharSequence text) {
+ mKeyboardActionListener.onTextInput(text);
dismissPopupKeyboard();
}
@Override
- public void onCancel() {
+ public void onCancelInput() {
dismissPopupKeyboard();
}
@Override
- public void swipeLeft() {
- // Nothing to do.
- }
- @Override
- public void swipeRight() {
- // Nothing to do.
- }
- @Override
- public void swipeUp() {
- // Nothing to do.
- }
- @Override
- public void swipeDown() {
+ public void onSwipeDown() {
// Nothing to do.
}
@Override
@@ -1461,20 +1431,8 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
mPointerQueue.remove(tracker);
}
- protected void swipeRight() {
- mKeyboardActionListener.swipeRight();
- }
-
- protected void swipeLeft() {
- mKeyboardActionListener.swipeLeft();
- }
-
- protected void swipeUp() {
- mKeyboardActionListener.swipeUp();
- }
-
- protected void swipeDown() {
- mKeyboardActionListener.swipeDown();
+ protected void onSwipeDown() {
+ mKeyboardActionListener.onSwipeDown();
}
public void closing() {
diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
index 4d4046b98..2243e93cf 100644
--- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
@@ -94,7 +94,7 @@ public class LatinKeyboardView extends KeyboardView {
}
private boolean invokeOnKey(int primaryCode) {
- getOnKeyboardActionListener().onKey(primaryCode, null,
+ getOnKeyboardActionListener().onCodeInput(primaryCode, null,
KeyboardView.NOT_A_TOUCH_COORDINATE,
KeyboardView.NOT_A_TOUCH_COORDINATE);
return true;
@@ -205,7 +205,7 @@ public class LatinKeyboardView extends KeyboardView {
if (me.getAction() == MotionEvent.ACTION_UP) {
int languageDirection = keyboard.getLanguageChangeDirection();
if (languageDirection != 0) {
- getOnKeyboardActionListener().onKey(
+ getOnKeyboardActionListener().onCodeInput(
languageDirection == 1
? Keyboard.CODE_NEXT_LANGUAGE : Keyboard.CODE_PREV_LANGUAGE,
null, mLastX, mLastY);
diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
index e4312a8ca..c0761117f 100644
--- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java
+++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
@@ -92,19 +92,13 @@ public class PointerTracker {
@Override
public void onRelease(int primaryCode) {}
@Override
- public void onKey(int primaryCode, int[] keyCodes, int x, int y) {}
+ public void onCodeInput(int primaryCode, int[] keyCodes, int x, int y) {}
@Override
- public void onText(CharSequence text) {}
+ public void onTextInput(CharSequence text) {}
@Override
- public void onCancel() {}
+ public void onCancelInput() {}
@Override
- public void swipeLeft() {}
- @Override
- public void swipeRight() {}
- @Override
- public void swipeDown() {}
- @Override
- public void swipeUp() {}
+ public void onSwipeDown() {}
};
public PointerTracker(int id, UIHandler handler, KeyDetector keyDetector, UIProxy proxy,
@@ -136,17 +130,17 @@ public class PointerTracker {
mListener.onPress(primaryCode);
}
- private void callListenerOnKey(int primaryCode, int[] keyCodes, int x, int y) {
+ private void callListenerOnCodeInput(int primaryCode, int[] keyCodes, int x, int y) {
if (DEBUG_LISTENER)
- Log.d(TAG, "onKey : " + keyCodePrintable(primaryCode)
+ Log.d(TAG, "onCodeInput: " + keyCodePrintable(primaryCode)
+ " codes="+ Arrays.toString(keyCodes) + " x=" + x + " y=" + y);
- mListener.onKey(primaryCode, keyCodes, x, y);
+ mListener.onCodeInput(primaryCode, keyCodes, x, y);
}
- private void callListenerOnText(CharSequence text) {
+ private void callListenerOnTextInput(CharSequence text) {
if (DEBUG_LISTENER)
- Log.d(TAG, "onText : text=" + text);
- mListener.onText(text);
+ Log.d(TAG, "onTextInput: text=" + text);
+ mListener.onTextInput(text);
}
private void callListenerOnRelease(int primaryCode) {
@@ -155,10 +149,10 @@ public class PointerTracker {
mListener.onRelease(primaryCode);
}
- private void callListenerOnCancel() {
+ private void callListenerOnCancelInput() {
if (DEBUG_LISTENER)
- Log.d(TAG, "onCancel");
- mListener.onCancel();
+ Log.d(TAG, "onCancelInput");
+ mListener.onCancelInput();
}
public void setKeyboard(Keyboard keyboard, Key[] keys, float keyHysteresisDistance) {
@@ -446,11 +440,11 @@ public class PointerTracker {
private void detectAndSendKey(int index, int x, int y, long eventTime) {
final Key key = getKey(index);
if (key == null) {
- callListenerOnCancel();
+ callListenerOnCancelInput();
return;
}
if (key.mOutputText != null) {
- callListenerOnText(key.mOutputText);
+ callListenerOnTextInput(key.mOutputText);
callListenerOnRelease(key.mCodes[0]);
} else {
int code = key.mCodes[0];
@@ -459,7 +453,7 @@ public class PointerTracker {
// Multi-tap
if (mInMultiTap) {
if (mTapCount != -1) {
- callListenerOnKey(Keyboard.CODE_DELETE, KEY_DELETE, x, y);
+ callListenerOnCodeInput(Keyboard.CODE_DELETE, KEY_DELETE, x, y);
} else {
mTapCount = 0;
}
@@ -480,7 +474,7 @@ public class PointerTracker {
codes[1] = codes[0];
codes[0] = code;
}
- callListenerOnKey(code, codes, x, y);
+ callListenerOnCodeInput(code, codes, x, y);
callListenerOnRelease(code);
}
mLastSentIndex = index;
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 45785ab36..9a240cb41 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1047,7 +1047,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// Implementation of KeyboardViewListener
@Override
- public void onKey(int primaryCode, int[] keyCodes, int x, int y) {
+ public void onCodeInput(int primaryCode, int[] keyCodes, int x, int y) {
long when = SystemClock.uptimeMillis();
if (primaryCode != Keyboard.CODE_DELETE || when > mLastKeyTime + QUICK_PRESS) {
mDeleteCount = 0;
@@ -1117,7 +1117,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
}
@Override
- public void onText(CharSequence text) {
+ public void onTextInput(CharSequence text) {
mVoiceConnector.commitVoiceInput();
InputConnection ic = getCurrentInputConnection();
if (ic == null) return;
@@ -1135,7 +1135,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
}
@Override
- public void onCancel() {
+ public void onCancelInput() {
// User released a finger outside any key
}
@@ -1257,7 +1257,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
} else {
// Some keys, such as [eszett], have upper case as multi-characters.
String upperCase = new String(new int[] {code}, 0, 1).toUpperCase();
- onText(upperCase);
+ onTextInput(upperCase);
return;
}
}
@@ -1570,7 +1570,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
LatinImeLogger.logOnManualSuggestion(
"", suggestion.toString(), index, suggestions.mWords);
final char primaryCode = suggestion.charAt(0);
- onKey(primaryCode, new int[]{primaryCode}, KeyboardView.NOT_A_TOUCH_COORDINATE,
+ onCodeInput(primaryCode, new int[]{primaryCode}, KeyboardView.NOT_A_TOUCH_COORDINATE,
KeyboardView.NOT_A_TOUCH_COORDINATE);
if (ic != null) {
ic.endBatchEdit();
@@ -1866,26 +1866,11 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
}
@Override
- public void swipeRight() {
- // Nothing to do
- }
-
- @Override
- public void swipeLeft() {
- // Nothing to do
- }
-
- @Override
- public void swipeDown() {
+ public void onSwipeDown() {
handleClose();
}
@Override
- public void swipeUp() {
- // Nothing to do
- }
-
- @Override
public void onPress(int primaryCode) {
if (mKeyboardSwitcher.isVibrateAndSoundFeedbackRequired()) {
vibrate();