diff options
Diffstat (limited to 'java/src/com/android/inputmethod')
9 files changed, 131 insertions, 123 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java b/java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java index 60d09d6fd..9eeee5baf 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java @@ -27,8 +27,9 @@ public interface KeyboardActionListener { * * @param primaryCode the unicode of the key being pressed. If the touch is not on a valid key, * the value will be zero. + * @param isSinglePointer true if pressing has occurred while no other key is being pressed. */ - public void onPressKey(int primaryCode); + public void onPressKey(int primaryCode, boolean isSinglePointer); /** * Called when the user releases a key. This is sent after the {@link #onCodeInput} is called. @@ -88,6 +89,11 @@ public interface KeyboardActionListener { public void onCancelInput(); /** + * Called when user finished sliding key input. + */ + public void onFinishSlidingInput(); + + /** * Send a non-"code input" custom request to the listener. * @return true if the request has been consumed, false otherwise. */ @@ -97,7 +103,7 @@ public interface KeyboardActionListener { public static final Adapter EMPTY_LISTENER = new Adapter(); @Override - public void onPressKey(int primaryCode) {} + public void onPressKey(int primaryCode, boolean isSinglePointer) {} @Override public void onReleaseKey(int primaryCode, boolean withSliding) {} @Override @@ -115,6 +121,8 @@ public interface KeyboardActionListener { @Override public void onCancelInput() {} @Override + public void onFinishSlidingInput() {} + @Override public boolean onCustomRequest(int requestCode) { return false; } diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java index 39afe9072..ad08d6477 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java @@ -216,19 +216,19 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions { mState.onResetKeyboardStateToAlphabet(); } - public void onPressKey(final int code) { + public void onPressKey(final int code, final boolean isSinglePointer) { if (isVibrateAndSoundFeedbackRequired()) { mFeedbackManager.hapticAndAudioFeedback(code, mKeyboardView); } - mState.onPressKey(code, isSinglePointer(), mLatinIME.getCurrentAutoCapsState()); + mState.onPressKey(code, isSinglePointer, mLatinIME.getCurrentAutoCapsState()); } public void onReleaseKey(final int code, final boolean withSliding) { mState.onReleaseKey(code, withSliding); } - public void onCancelInput() { - mState.onCancelInput(isSinglePointer()); + public void onFinishSlidingInput() { + mState.onFinishSlidingInput(); } // Implements {@link KeyboardState.SwitchActions}. @@ -346,15 +346,11 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions { return mKeyboardView != null && !mKeyboardView.isInSlidingKeyInput(); } - private boolean isSinglePointer() { - return mKeyboardView != null && mKeyboardView.getPointerCount() == 1; - } - /** * Updates state machine to figure out when to automatically switch back to the previous mode. */ public void onCodeInput(final int code) { - mState.onCodeInput(code, isSinglePointer(), mLatinIME.getCurrentAutoCapsState()); + mState.onCodeInput(code, mLatinIME.getCurrentAutoCapsState()); } public MainKeyboardView getMainKeyboardView() { diff --git a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java index 3201d2e5b..6c6fc6157 100644 --- a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java @@ -1100,10 +1100,6 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack return false; } - public int getPointerCount() { - return mOldPointerCount; - } - @Override public boolean dispatchTouchEvent(MotionEvent event) { if (AccessibilityUtils.getInstance().isTouchExplorationEnabled()) { diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java index a8327289b..174239325 100644 --- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java +++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java @@ -459,7 +459,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { return false; } if (key.isEnabled()) { - mListener.onPressKey(key.mCode); + mListener.onPressKey(key.mCode, getActivePointerTrackerCount() == 1); final boolean keyboardLayoutHasBeenChanged = mKeyboardLayoutHasBeenChanged; mKeyboardLayoutHasBeenChanged = false; mTimerProxy.startTypingStateTimer(key); @@ -527,6 +527,13 @@ public final class PointerTracker implements PointerTrackerQueue.Element { } } + private void callListenerOnFinishSlidingInput() { + if (DEBUG_LISTENER) { + Log.d(TAG, String.format("[%d] onFinishSlidingInput", mPointerId)); + } + mListener.onFinishSlidingInput(); + } + private void callListenerOnCancelInput() { if (DEBUG_LISTENER) { Log.d(TAG, String.format("[%d] onCancelInput", mPointerId)); @@ -1036,7 +1043,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { private void processSildeOutFromOldKey(final Key oldKey) { setReleasedKeyGraphics(oldKey); - callListenerOnRelease(oldKey, oldKey.mCode, true); + callListenerOnRelease(oldKey, oldKey.mCode, true /* withSliding */); startSlidingKeyInput(oldKey); mTimerProxy.cancelKeyTimers(); } @@ -1169,6 +1176,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { private void onUpEventInternal(final int x, final int y, final long eventTime) { mTimerProxy.cancelKeyTimers(); final boolean isInSlidingKeyInput = mIsInSlidingKeyInput; + final boolean isInSlidingKeyInputFromModifier = mIsInSlidingKeyInputFromModifier; resetSlidingKeyInput(); mIsDetectingGesture = false; final Key currentKey = mCurrentKey; @@ -1189,7 +1197,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { if (sInGesture) { if (currentKey != null) { - callListenerOnRelease(currentKey, currentKey.mCode, true); + callListenerOnRelease(currentKey, currentKey.mCode, true /* withSliding */); } mayEndBatchInput(eventTime); return; @@ -1203,6 +1211,9 @@ public final class PointerTracker implements PointerTrackerQueue.Element { return; } detectAndSendKey(currentKey, mKeyX, mKeyY, eventTime); + if (isInSlidingKeyInputFromModifier) { + callListenerOnFinishSlidingInput(); + } } public void onShowMoreKeysPanel(final int translatedX, final int translatedY, @@ -1328,7 +1339,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { final int code = key.mCode; callListenerOnCodeInput(key, code, x, y, eventTime); - callListenerOnRelease(key, code, false); + callListenerOnRelease(key, code, false /* withSliding */); } private void printTouchEvent(final String title, final int x, final int y, diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java index 962bde91e..6af1bd75f 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java @@ -28,9 +28,9 @@ import com.android.inputmethod.latin.RecapitalizeStatus; * This class contains all keyboard state transition logic. * * The input events are {@link #onLoadKeyboard()}, {@link #onSaveKeyboardState()}, - * {@link #onPressKey(int, boolean, int)}, {@link #onReleaseKey(int, boolean)}, - * {@link #onCodeInput(int, boolean, int)}, {@link #onCancelInput(boolean)}, - * {@link #onUpdateShiftState(int, int)}, {@link #onLongPressTimeout(int)}. + * {@link #onPressKey(int,boolean,int)}, {@link #onReleaseKey(int,boolean)}, + * {@link #onCodeInput(int,int)}, {@link #onFinishSlidingInput()}, {@link #onCancelInput()}, + * {@link #onUpdateShiftState(int,int)}, {@link #onLongPressTimeout(int)}. * * The actions are {@link SwitchActions}'s methods. */ @@ -74,6 +74,7 @@ public final class KeyboardState { private static final int SWITCH_STATE_SYMBOL = 2; private static final int SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL = 3; private static final int SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE = 4; + private static final int SWITCH_STATE_MOMENTARY_ALPHA_SHIFT = 5; private int mSwitchState = SWITCH_STATE_ALPHA; private boolean mIsAlphabetMode; @@ -525,6 +526,9 @@ public final class KeyboardState { } else if (mAlphabetShiftState.isShiftLockShifted() && withSliding) { // In shift locked state, shift has been pressed and slid out to other key. setShiftLocked(true); + } else if (mAlphabetShiftState.isManualShifted() && withSliding) { + // Shift has been pressed and slid out to other key. + mSwitchState = SWITCH_STATE_MOMENTARY_ALPHA_SHIFT; } else if (isShiftLocked && !mAlphabetShiftState.isShiftLockShifted() && (mShiftKeyState.isPressing() || mShiftKeyState.isPressingOnShifted()) && !withSliding) { @@ -554,17 +558,21 @@ public final class KeyboardState { mShiftKeyState.onRelease(); } - public void onCancelInput(final boolean isSinglePointer) { + public void onFinishSlidingInput() { if (DEBUG_EVENT) { - Log.d(TAG, "onCancelInput: single=" + isSinglePointer + " " + this); + Log.d(TAG, "onFinishSlidingInput: " + this); } // Switch back to the previous keyboard mode if the user cancels sliding input. - if (isSinglePointer) { - if (mSwitchState == SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL) { - toggleAlphabetAndSymbols(); - } else if (mSwitchState == SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE) { - toggleShiftInSymbols(); - } + switch (mSwitchState) { + case SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL: + toggleAlphabetAndSymbols(); + break; + case SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE: + toggleShiftInSymbols(); + break; + case SWITCH_STATE_MOMENTARY_ALPHA_SHIFT: + setAlphabetKeyboard(); + break; } } @@ -577,10 +585,9 @@ public final class KeyboardState { return c == Constants.CODE_SPACE || c == Constants.CODE_ENTER; } - public void onCodeInput(final int code, final boolean isSinglePointer, final int autoCaps) { + public void onCodeInput(final int code, final int autoCaps) { if (DEBUG_EVENT) { Log.d(TAG, "onCodeInput: code=" + Constants.printableCode(code) - + " single=" + isSinglePointer + " autoCaps=" + autoCaps + " " + this); } @@ -593,23 +600,12 @@ public final class KeyboardState { } else { mSwitchState = SWITCH_STATE_SYMBOL_BEGIN; } - } else if (isSinglePointer) { - // Switch back to the previous keyboard mode if the user pressed the mode change key - // and slid to other key, then released the finger. - // If the user cancels the sliding input, switching back to the previous keyboard - // mode is handled by {@link #onCancelInput}. - toggleAlphabetAndSymbols(); } break; case SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE: if (code == Constants.CODE_SHIFT) { // Detected only the shift key has been pressed on symbol layout, and then released. mSwitchState = SWITCH_STATE_SYMBOL_BEGIN; - } else if (isSinglePointer) { - // Switch back to the previous keyboard mode if the user pressed the shift key on - // symbol mode and slid to other key, then released the finger. - toggleShiftInSymbols(); - mSwitchState = SWITCH_STATE_SYMBOL; } break; case SWITCH_STATE_SYMBOL_BEGIN: @@ -650,6 +646,7 @@ public final class KeyboardState { case SWITCH_STATE_SYMBOL: return "SYMBOL"; case SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL: return "MOMENTARY-ALPHA-SYMBOL"; case SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE: return "MOMENTARY-SYMBOL-MORE"; + case SWITCH_STATE_MOMENTARY_ALPHA_SHIFT: return "MOMENTARY-ALPHA_SHIFT"; default: return null; } } diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 5dd42bf02..347a4c63a 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -90,7 +90,7 @@ import java.util.TreeSet; /** * Input method implementation for Qwerty'ish keyboard. */ -public final class LatinIME extends InputMethodService implements KeyboardActionListener, +public class LatinIME extends InputMethodService implements KeyboardActionListener, SuggestionStripView.Listener, TargetApplicationGetter.OnTargetApplicationKnownListener, Suggest.SuggestInitializationListener { private static final String TAG = LatinIME.class.getSimpleName(); @@ -188,6 +188,8 @@ public final class LatinIME extends InputMethodService implements KeyboardAction // Keeps track of most recently inserted text (multi-character key) for reverting private String mEnteredText; + // TODO: This boolean is persistent state and causes large side effects at unexpected times. + // Find a way to remove it for readability. private boolean mIsAutoCorrectionIndicatorOn; private AlertDialog mOptionsDialog; @@ -902,7 +904,12 @@ public final class LatinIME extends InputMethodService implements KeyboardAction // we know for sure the cursor moved while we were composing and we should reset // the state. final boolean noComposingSpan = composingSpanStart == -1 && composingSpanEnd == -1; - if (!mExpectingUpdateSelection + // If the keyboard is not visible, we don't need to do all the housekeeping work, as it + // will be reset when the keyboard shows up anyway. + // TODO: revisit this when LatinIME supports hardware keyboards. + // NOTE: the test harness subclasses LatinIME and overrides isInputViewShown(). + // TODO: find a better way to simulate actual execution. + if (isInputViewShown() && !mExpectingUpdateSelection && !mConnection.isBelatedExpectedUpdate(oldSelStart, newSelStart)) { // TAKE CARE: there is a race condition when we enter this test even when the user // did not explicitly move the cursor. This happens when typing fast, where two keys @@ -1752,9 +1759,16 @@ public final class LatinIME extends InputMethodService implements KeyboardAction // Called from PointerTracker through the KeyboardActionListener interface @Override + public void onFinishSlidingInput() { + // User finished sliding input. + mKeyboardSwitcher.onFinishSlidingInput(); + } + + // Called from PointerTracker through the KeyboardActionListener interface + @Override public void onCancelInput() { // User released a finger outside any key - mKeyboardSwitcher.onCancelInput(); + // Nothing to do so far. } @Override @@ -2102,25 +2116,16 @@ public final class LatinIME extends InputMethodService implements KeyboardAction } private boolean isSuggestionsStripVisible() { - final MainKeyboardView mainKeyboardView = mKeyboardSwitcher.getMainKeyboardView(); - if (null == mainKeyboardView || !mainKeyboardView.isShown()) { - return false; - } - if (mSuggestionStripView == null) { + if (mSuggestionStripView == null) return false; - } - if (mSuggestionStripView.isShowingAddToDictionaryHint()) { + if (mSuggestionStripView.isShowingAddToDictionaryHint()) return true; - } - if (null == mSettings.getCurrent()) { + if (null == mSettings.getCurrent()) return false; - } - if (!mSettings.getCurrent().isSuggestionStripVisibleInOrientation(mDisplayOrientation)) { + if (!mSettings.getCurrent().isSuggestionStripVisibleInOrientation(mDisplayOrientation)) return false; - } - if (mSettings.getCurrent().isApplicationSpecifiedCompletionsOn()) { + if (mSettings.getCurrent().isApplicationSpecifiedCompletionsOn()) return true; - } return mSettings.getCurrent().isSuggestionsRequested(mDisplayOrientation); } @@ -2509,7 +2514,10 @@ public final class LatinIME extends InputMethodService implements KeyboardAction // Note that it's very important here that suggestedWords.mWillAutoCorrect is false. // We never want to auto-correct on a resumed suggestion. Please refer to the three - // places above where suggestedWords is affected. + // places above where suggestedWords is affected. We also need to reset + // mIsAutoCorrectionIndicatorOn to avoid showSuggestionStrip touching the text to adapt it. + // TODO: remove mIsAutoCorrectionIndicator on (see comment on definition) + mIsAutoCorrectionIndicatorOn = false; showSuggestionStrip(suggestedWords, typedWord); } @@ -2621,8 +2629,8 @@ public final class LatinIME extends InputMethodService implements KeyboardAction // Callback called by PointerTracker through the KeyboardActionListener. This is called when a // key is depressed; release matching call is onReleaseKey below. @Override - public void onPressKey(final int primaryCode) { - mKeyboardSwitcher.onPressKey(primaryCode); + public void onPressKey(final int primaryCode, final boolean isSinglePointer) { + mKeyboardSwitcher.onPressKey(primaryCode, isSinglePointer); } // Callback by PointerTracker through the KeyboardActionListener. This is called when a key diff --git a/java/src/com/android/inputmethod/latin/setup/SetupWizardActivity.java b/java/src/com/android/inputmethod/latin/setup/SetupWizardActivity.java index 3406ecf34..78a6478c6 100644 --- a/java/src/com/android/inputmethod/latin/setup/SetupWizardActivity.java +++ b/java/src/com/android/inputmethod/latin/setup/SetupWizardActivity.java @@ -46,11 +46,14 @@ import java.util.ArrayList; public final class SetupWizardActivity extends Activity implements View.OnClickListener { static final String TAG = SetupWizardActivity.class.getSimpleName(); + private static final boolean ENABLE_WELCOME_VIDEO = true; + private View mSetupWizard; private View mWelcomeScreen; private View mSetupScreen; private Uri mWelcomeVideoUri; private VideoView mWelcomeVideoView; + private ImageView mWelcomeImageView; private View mActionStart; private View mActionNext; private TextView mStep1Bullet; @@ -58,6 +61,7 @@ public final class SetupWizardActivity extends Activity implements View.OnClickL private SetupStepGroup mSetupStepGroup; private static final String STATE_STEP = "step"; private int mStepNumber; + private boolean mNeedsToAdjustStepNumberToSystemState; private static final int STEP_WELCOME = 0; private static final int STEP_1 = 1; private static final int STEP_2 = 2; @@ -156,9 +160,7 @@ public final class SetupWizardActivity extends Activity implements View.OnClickL step2.setAction(new Runnable() { @Override public void run() { - // Invoke input method picker. - RichInputMethodManager.getInstance().getInputMethodManager() - .showInputMethodPicker(); + invokeInputMethodPicker(); } }); mSetupStepGroup.addStep(step2); @@ -191,18 +193,16 @@ public final class SetupWizardActivity extends Activity implements View.OnClickL mp.setLooping(true); } }); - final ImageView welcomeImageView = (ImageView)findViewById(R.id.setup_welcome_image); welcomeVideoView.setOnErrorListener(new MediaPlayer.OnErrorListener() { @Override public boolean onError(final MediaPlayer mp, final int what, final int extra) { Log.e(TAG, "Playing welcome video causes error: what=" + what + " extra=" + extra); - welcomeVideoView.setVisibility(View.GONE); - welcomeImageView.setImageResource(R.raw.setup_welcome_image); - welcomeImageView.setVisibility(View.VISIBLE); + hideWelcomeVideoAndShowWelcomeImage(); return true; } }); mWelcomeVideoView = welcomeVideoView; + mWelcomeImageView = (ImageView)findViewById(R.id.setup_welcome_image); mActionStart = findViewById(R.id.setup_start_label); mActionStart.setOnClickListener(this); @@ -244,6 +244,7 @@ public final class SetupWizardActivity extends Activity implements View.OnClickL | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); + mNeedsToAdjustStepNumberToSystemState = true; } private void invokeSettingsOfThisIme() { @@ -259,6 +260,14 @@ public final class SetupWizardActivity extends Activity implements View.OnClickL intent.setAction(Settings.ACTION_INPUT_METHOD_SETTINGS); intent.addCategory(Intent.CATEGORY_DEFAULT); startActivity(intent); + mNeedsToAdjustStepNumberToSystemState = true; + } + + void invokeInputMethodPicker() { + // Invoke input method picker. + RichInputMethodManager.getInstance().getInputMethodManager() + .showInputMethodPicker(); + mNeedsToAdjustStepNumberToSystemState = true; } void invokeSubtypeEnablerOfThisIme() { @@ -312,6 +321,9 @@ public final class SetupWizardActivity extends Activity implements View.OnClickL @Override protected void onRestart() { super.onRestart(); + // Probably the setup wizard has been invoked from "Recent" menu. The setup step number + // needs to be adjusted to system state, because the state (IME is enabled and/or current) + // may have been changed. if (isInSetupSteps(mStepNumber)) { mStepNumber = determineSetupStepNumber(); } @@ -344,21 +356,34 @@ public final class SetupWizardActivity extends Activity implements View.OnClickL super.onBackPressed(); } - private static void hideAndStopVideo(final VideoView videoView) { - videoView.stopPlayback(); - videoView.setVisibility(View.INVISIBLE); + void hideWelcomeVideoAndShowWelcomeImage() { + mWelcomeVideoView.setVisibility(View.GONE); + mWelcomeImageView.setImageResource(R.raw.setup_welcome_image); + mWelcomeImageView.setVisibility(View.VISIBLE); + } + + private void showAndStartWelcomeVideo() { + mWelcomeVideoView.setVisibility(View.VISIBLE); + mWelcomeVideoView.setVideoURI(mWelcomeVideoUri); + mWelcomeVideoView.start(); + } + + private void hideAndStopWelcomeVideo() { + mWelcomeVideoView.stopPlayback(); + mWelcomeVideoView.setVisibility(View.GONE); } @Override protected void onPause() { - hideAndStopVideo(mWelcomeVideoView); + hideAndStopWelcomeVideo(); super.onPause(); } @Override public void onWindowFocusChanged(final boolean hasFocus) { super.onWindowFocusChanged(hasFocus); - if (hasFocus && isInSetupSteps(mStepNumber)) { + if (hasFocus && mNeedsToAdjustStepNumberToSystemState) { + mNeedsToAdjustStepNumberToSystemState = false; mStepNumber = determineSetupStepNumber(); updateSetupStepView(); } @@ -370,12 +395,14 @@ public final class SetupWizardActivity extends Activity implements View.OnClickL mWelcomeScreen.setVisibility(welcomeScreen ? View.VISIBLE : View.GONE); mSetupScreen.setVisibility(welcomeScreen ? View.GONE : View.VISIBLE); if (welcomeScreen) { - mWelcomeVideoView.setVisibility(View.VISIBLE); - mWelcomeVideoView.setVideoURI(mWelcomeVideoUri); - mWelcomeVideoView.start(); + if (ENABLE_WELCOME_VIDEO) { + showAndStartWelcomeVideo(); + } else { + hideWelcomeVideoAndShowWelcomeImage(); + } return; } - hideAndStopVideo(mWelcomeVideoView); + hideAndStopWelcomeVideo(); final boolean isStepActionAlreadyDone = mStepNumber < determineSetupStepNumber(); mSetupStepGroup.enableStep(mStepNumber, isStepActionAlreadyDone); mActionNext.setVisibility(isStepActionAlreadyDone ? View.VISIBLE : View.GONE); diff --git a/java/src/com/android/inputmethod/research/ResearchLogger.java b/java/src/com/android/inputmethod/research/ResearchLogger.java index b3c0faf29..8b8ea21e9 100644 --- a/java/src/com/android/inputmethod/research/ResearchLogger.java +++ b/java/src/com/android/inputmethod/research/ResearchLogger.java @@ -156,11 +156,6 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang // LogUnits are queued in the LogBuffers and published to the ResearchLogs when words are // complete. /* package for test */ MainLogBuffer mMainLogBuffer; // always non-null after init() is called - // TODO: Remove the feedback log. The feedback log continuously captured user data in case the - // user wanted to submit it. We now use the mUserRecordingLogBuffer to allow the user to - // explicitly reproduce a problem. - private ResearchLog mFeedbackLog; - private LogBuffer mFeedbackLogBuffer; /* package */ ResearchLog mUserRecordingLog; /* package */ LogBuffer mUserRecordingLogBuffer; private File mUserRecordingFile = null; @@ -200,15 +195,6 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang private long mSavedDownEventTime; private Bundle mFeedbackDialogBundle = null; private boolean mInFeedbackDialog = false; - // The feedback dialog causes stop() to be called for the keyboard connected to the original - // window. This is because the feedback dialog must present its own EditText box that displays - // a keyboard. stop() normally causes mFeedbackLogBuffer, which contains the user's data, to be - // cleared, and causes mFeedbackLog, which is ready to collect information in case the user - // wants to upload, to be closed. This is good because we don't need to log information about - // what the user is typing in the feedback dialog, but bad because this data must be uploaded. - // Here we save the LogBuffer and Log so the feedback dialog can later access their data. - private LogBuffer mSavedFeedbackLogBuffer; - private ResearchLog mSavedFeedbackLog; private Handler mUserRecordingTimeoutHandler; private static final long USER_RECORDING_TIMEOUT_MS = 30L * DateUtils.SECOND_IN_MILLIS; @@ -280,10 +266,6 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang publishLogUnits(logUnits, mMainResearchLog, canIncludePrivateData); } }; - - mFeedbackLog = new ResearchLog(mResearchLogDirectory.getLogFilePath( - System.currentTimeMillis(), System.nanoTime()), mLatinIME); - mFeedbackLogBuffer = new FixedLogBuffer(FEEDBACK_WORD_BUFFER_SIZE); } private void cleanLogDirectoryIfNeeded(final ResearchLogDirectory researchLogDirectory, @@ -436,7 +418,6 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang Log.w(TAG, "IOException when publishing LogBuffer", e); } mMainResearchLog.blockingClose(RESEARCHLOG_CLOSE_TIMEOUT_IN_MS); - mFeedbackLog.blockingClose(RESEARCHLOG_CLOSE_TIMEOUT_IN_MS); resetLogBuffers(); } @@ -447,8 +428,6 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang } mMainLogBuffer.clear(); mMainResearchLog.blockingAbort(RESEARCHLOG_ABORT_TIMEOUT_IN_MS); - mFeedbackLogBuffer.clear(); - mFeedbackLog.blockingAbort(RESEARCHLOG_ABORT_TIMEOUT_IN_MS); resetLogBuffers(); } @@ -482,12 +461,6 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang saveRecording(); } mInFeedbackDialog = true; - mSavedFeedbackLogBuffer = mFeedbackLogBuffer; - mSavedFeedbackLog = mFeedbackLog; - // Set the non-saved versions to null so that the stop() caused by switching to the - // Feedback dialog will not close them. - mFeedbackLogBuffer = null; - mFeedbackLog = null; final Intent intent = new Intent(); intent.setClass(mLatinIME, FeedbackActivity.class); @@ -645,12 +618,6 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang new LogStatement("UserFeedback", false, false, "contents", "accountName", "recording"); public void sendFeedback(final String feedbackContents, final boolean includeHistory, final boolean isIncludingAccountName, final boolean isIncludingRecording) { - if (mSavedFeedbackLogBuffer == null) { - return; - } - if (!includeHistory) { - mSavedFeedbackLogBuffer.clear(); - } String recording = ""; if (isIncludingRecording) { // Try to read recording from recently written json file @@ -682,9 +649,13 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang final String accountName = isIncludingAccountName ? getAccountName() : ""; feedbackLogUnit.addLogStatement(LOGSTATEMENT_FEEDBACK, SystemClock.uptimeMillis(), feedbackContents, accountName, recording); - mFeedbackLogBuffer.shiftIn(feedbackLogUnit); - publishLogBuffer(mFeedbackLogBuffer, mSavedFeedbackLog, true /* isIncludingPrivateData */); - mSavedFeedbackLog.blockingClose(RESEARCHLOG_CLOSE_TIMEOUT_IN_MS); + + final ResearchLog feedbackLog = new ResearchLog(mResearchLogDirectory.getLogFilePath( + System.currentTimeMillis(), System.nanoTime()), mLatinIME); + final LogBuffer feedbackLogBuffer = new LogBuffer(); + feedbackLogBuffer.shiftIn(feedbackLogUnit); + publishLogBuffer(feedbackLogBuffer, feedbackLog, true /* isIncludingPrivateData */); + feedbackLog.blockingClose(RESEARCHLOG_CLOSE_TIMEOUT_IN_MS); uploadNow(); if (isIncludingRecording && DEBUG_REPLAY_AFTER_FEEDBACK) { @@ -836,9 +807,6 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang } if (!mCurrentLogUnit.isEmpty()) { mMainLogBuffer.shiftIn(mCurrentLogUnit); - if (mFeedbackLogBuffer != null) { - mFeedbackLogBuffer.shiftIn(mCurrentLogUnit); - } if (mUserRecordingLogBuffer != null) { mUserRecordingLogBuffer.shiftIn(mCurrentLogUnit); } @@ -884,9 +852,6 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang } else { mCurrentLogUnit = oldLogUnit; } - if (mFeedbackLogBuffer != null) { - mFeedbackLogBuffer.unshiftIn(); - } enqueueEvent(LOGSTATEMENT_UNCOMMIT_CURRENT_LOGUNIT); if (DEBUG) { Log.d(TAG, "uncommitCurrentLogUnit (dump=" + dumpCurrentLogUnit + ") back to " diff --git a/java/src/com/android/inputmethod/research/Uploader.java b/java/src/com/android/inputmethod/research/Uploader.java index ba05ec12b..c7ea3e69d 100644 --- a/java/src/com/android/inputmethod/research/Uploader.java +++ b/java/src/com/android/inputmethod/research/Uploader.java @@ -49,7 +49,7 @@ public final class Uploader { private static final boolean DEBUG = false && ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS_DEBUG; // Set IS_INHIBITING_AUTO_UPLOAD to true for local testing - private static final boolean IS_INHIBITING_AUTO_UPLOAD = false + private static final boolean IS_INHIBITING_UPLOAD = false && ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS_DEBUG; private static final int BUF_SIZE = 1024 * 8; @@ -76,7 +76,7 @@ public final class Uploader { } public boolean isPossibleToUpload() { - return hasUploadingPermission() && mUrl != null && !IS_INHIBITING_AUTO_UPLOAD; + return hasUploadingPermission() && mUrl != null && !IS_INHIBITING_UPLOAD; } private boolean hasUploadingPermission() { |