aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java12
-rw-r--r--java/src/com/android/inputmethod/keyboard/MainKeyboardView.java14
-rw-r--r--java/src/com/android/inputmethod/keyboard/PointerTracker.java12
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java12
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java4
-rw-r--r--java/src/com/android/inputmethod/research/ResearchLogger.java46
6 files changed, 61 insertions, 39 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
index 83f109014..7295efab1 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -274,30 +274,30 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
// Implements {@link KeyboardState.SwitchActions}.
@Override
- public void startDoubleTapTimer() {
+ public void startDoubleTapShiftKeyTimer() {
final MainKeyboardView keyboardView = getMainKeyboardView();
if (keyboardView != null) {
final TimerProxy timer = keyboardView.getTimerProxy();
- timer.startDoubleTapTimer();
+ timer.startDoubleTapShiftKeyTimer();
}
}
// Implements {@link KeyboardState.SwitchActions}.
@Override
- public void cancelDoubleTapTimer() {
+ public void cancelDoubleTapShiftKeyTimer() {
final MainKeyboardView keyboardView = getMainKeyboardView();
if (keyboardView != null) {
final TimerProxy timer = keyboardView.getTimerProxy();
- timer.cancelDoubleTapTimer();
+ timer.cancelDoubleTapShiftKeyTimer();
}
}
// Implements {@link KeyboardState.SwitchActions}.
@Override
- public boolean isInDoubleTapTimeout() {
+ public boolean isInDoubleTapShiftKeyTimeout() {
final MainKeyboardView keyboardView = getMainKeyboardView();
return (keyboardView != null)
- ? keyboardView.getTimerProxy().isInDoubleTapTimeout() : false;
+ ? keyboardView.getTimerProxy().isInDoubleTapShiftKeyTimeout() : false;
}
// Implements {@link KeyboardState.SwitchActions}.
diff --git a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
index 7493df874..435adb6f5 100644
--- a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
@@ -202,7 +202,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
private static final int MSG_TYPING_STATE_EXPIRED = 0;
private static final int MSG_REPEAT_KEY = 1;
private static final int MSG_LONGPRESS_KEY = 2;
- private static final int MSG_DOUBLE_TAP = 3;
+ private static final int MSG_DOUBLE_TAP_SHIFT_KEY = 3;
private static final int MSG_UPDATE_BATCH_INPUT = 4;
private final int mKeyRepeatStartTimeout;
@@ -392,19 +392,19 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
}
@Override
- public void startDoubleTapTimer() {
- sendMessageDelayed(obtainMessage(MSG_DOUBLE_TAP),
+ public void startDoubleTapShiftKeyTimer() {
+ sendMessageDelayed(obtainMessage(MSG_DOUBLE_TAP_SHIFT_KEY),
ViewConfiguration.getDoubleTapTimeout());
}
@Override
- public void cancelDoubleTapTimer() {
- removeMessages(MSG_DOUBLE_TAP);
+ public void cancelDoubleTapShiftKeyTimer() {
+ removeMessages(MSG_DOUBLE_TAP_SHIFT_KEY);
}
@Override
- public boolean isInDoubleTapTimeout() {
- return hasMessages(MSG_DOUBLE_TAP);
+ public boolean isInDoubleTapShiftKeyTimeout() {
+ return hasMessages(MSG_DOUBLE_TAP_SHIFT_KEY);
}
@Override
diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
index 5df7011cb..a28bd1a1e 100644
--- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java
+++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
@@ -94,9 +94,9 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
public void startLongPressTimer(PointerTracker tracker);
public void startLongPressTimer(int code);
public void cancelLongPressTimer();
- public void startDoubleTapTimer();
- public void cancelDoubleTapTimer();
- public boolean isInDoubleTapTimeout();
+ public void startDoubleTapShiftKeyTimer();
+ public void cancelDoubleTapShiftKeyTimer();
+ public boolean isInDoubleTapShiftKeyTimeout();
public void cancelKeyTimers();
public void startUpdateBatchInputTimer(PointerTracker tracker);
public void cancelUpdateBatchInputTimer(PointerTracker tracker);
@@ -116,11 +116,11 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
@Override
public void cancelLongPressTimer() {}
@Override
- public void startDoubleTapTimer() {}
+ public void startDoubleTapShiftKeyTimer() {}
@Override
- public void cancelDoubleTapTimer() {}
+ public void cancelDoubleTapShiftKeyTimer() {}
@Override
- public boolean isInDoubleTapTimeout() { return false; }
+ public boolean isInDoubleTapShiftKeyTimeout() { return false; }
@Override
public void cancelKeyTimers() {}
@Override
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java
index 9f6374bf7..bb6dec69e 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java
@@ -53,9 +53,9 @@ public final class KeyboardState {
*/
public void requestUpdatingShiftState();
- public void startDoubleTapTimer();
- public boolean isInDoubleTapTimeout();
- public void cancelDoubleTapTimer();
+ public void startDoubleTapShiftKeyTimer();
+ public boolean isInDoubleTapShiftKeyTimeout();
+ public void cancelDoubleTapShiftKeyTimer();
public void startLongPressTimer(int code);
public void cancelLongPressTimer();
}
@@ -325,7 +325,7 @@ public final class KeyboardState {
} else if (code == Constants.CODE_SWITCH_ALPHA_SYMBOL) {
onPressSymbol();
} else {
- mSwitchActions.cancelDoubleTapTimer();
+ mSwitchActions.cancelDoubleTapShiftKeyTimer();
mSwitchActions.cancelLongPressTimer();
mLongPressShiftLockFired = false;
mShiftKeyState.onOtherKeyPressed();
@@ -450,10 +450,10 @@ public final class KeyboardState {
// importantly the double tap timer.
if (RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE != mRecapitalizeMode) return;
if (mIsAlphabetMode) {
- mIsInDoubleTapShiftKey = mSwitchActions.isInDoubleTapTimeout();
+ mIsInDoubleTapShiftKey = mSwitchActions.isInDoubleTapShiftKeyTimeout();
if (!mIsInDoubleTapShiftKey) {
// This is first tap.
- mSwitchActions.startDoubleTapTimer();
+ mSwitchActions.startDoubleTapShiftKeyTimer();
}
if (mIsInDoubleTapShiftKey) {
if (mAlphabetShiftState.isManualShifted() || mIsInAlphabetUnshiftedFromShifted) {
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 70f8d0de8..98008ac1c 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1637,8 +1637,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
public void onStartBatchInput(final LatinIME latinIme) {
synchronized (mLock) {
mHandler.removeMessages(MSG_UPDATE_GESTURE_PREVIEW_AND_SUGGESTION_STRIP);
- mLatinIme = latinIme;
mInBatchInput = true;
+ mLatinIme = latinIme;
+ mLatinIme.mHandler.showGesturePreviewAndSuggestionStrip(
+ SuggestedWords.EMPTY, false /* dismissGestureFloatingPreviewText */);
}
}
diff --git a/java/src/com/android/inputmethod/research/ResearchLogger.java b/java/src/com/android/inputmethod/research/ResearchLogger.java
index ec54616b7..57b740b95 100644
--- a/java/src/com/android/inputmethod/research/ResearchLogger.java
+++ b/java/src/com/android/inputmethod/research/ResearchLogger.java
@@ -83,6 +83,8 @@ import java.util.List;
import java.util.Random;
import java.util.regex.Pattern;
+// TODO: Add a unit test for every "logging" method (i.e. that is called from the IME and calls
+// enqueueEvent to record a LogStatement).
/**
* Logs the use of the LatinIME keyboard.
*
@@ -1463,21 +1465,39 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
public static void latinIME_revertCommit(final String committedWord,
final String originallyTypedWord, final boolean isBatchMode,
final String separatorString) {
+ // TODO: Prioritize adding a unit test for this method (as it is especially complex)
+ // TODO: Update the UserRecording LogBuffer as well as the MainLogBuffer
final ResearchLogger researchLogger = getInstance();
- // TODO: Verify that mCurrentLogUnit has been restored and contains the reverted word.
- final LogUnit logUnit;
- logUnit = researchLogger.mMainLogBuffer.peekLastLogUnit();
- if (originallyTypedWord.length() > 0 && hasLetters(originallyTypedWord)) {
- if (logUnit != null) {
- logUnit.setWords(originallyTypedWord);
- }
- }
- researchLogger.enqueueEvent(logUnit != null ? logUnit : researchLogger.mCurrentLogUnit,
- LOGSTATEMENT_LATINIME_REVERTCOMMIT, committedWord, originallyTypedWord,
- separatorString);
- if (logUnit != null) {
- logUnit.setContainsUserDeletions();
+ //
+ // 1. Remove separator LogUnit
+ final LogUnit lastLogUnit = researchLogger.mMainLogBuffer.peekLastLogUnit();
+ // Check that we're not at the beginning of input
+ if (lastLogUnit == null) return;
+ // Check that we're after a separator
+ if (lastLogUnit.getWordsAsString() != null) return;
+ // Remove separator
+ final LogUnit separatorLogUnit = researchLogger.mMainLogBuffer.unshiftIn();
+
+ // 2. Add revert LogStatement
+ final LogUnit revertedLogUnit = researchLogger.mMainLogBuffer.peekLastLogUnit();
+ if (revertedLogUnit == null) return;
+ if (!revertedLogUnit.getWordsAsString().equals(scrubDigitsFromString(committedWord))) {
+ // Any word associated with the reverted LogUnit has already had its digits scrubbed, so
+ // any digits in the committedWord argument must also be scrubbed for an accurate
+ // comparison.
+ return;
}
+ researchLogger.enqueueEvent(revertedLogUnit, LOGSTATEMENT_LATINIME_REVERTCOMMIT,
+ committedWord, originallyTypedWord, separatorString);
+
+ // 3. Update the word associated with the LogUnit
+ revertedLogUnit.setWords(originallyTypedWord);
+ revertedLogUnit.setContainsUserDeletions();
+
+ // 4. Re-add the separator LogUnit
+ researchLogger.mMainLogBuffer.shiftIn(separatorLogUnit);
+
+ // 5. Record stats
researchLogger.mStatistics.recordRevertCommit(SystemClock.uptimeMillis());
}