Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ef3936bc authored by Kurt Partridge's avatar Kurt Partridge
Browse files

[Rlog59c] More detailed logging of backspace

- Normal delete events are recorded
- Includes number of characters deleted for both batch and normal delete

Change-Id: I422da3ddc94fa0ccd6c7586eaacf14c62dd16679
parent 343a852c
Loading
Loading
Loading
Loading
+12 −3
Original line number Original line Diff line number Diff line
@@ -1667,7 +1667,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
                if (mWordComposer.isBatchMode()) {
                if (mWordComposer.isBatchMode()) {
                    if (ProductionFlag.IS_EXPERIMENTAL) {
                    if (ProductionFlag.IS_EXPERIMENTAL) {
                        final String word = mWordComposer.getTypedWord();
                        final String word = mWordComposer.getTypedWord();
                        ResearchLogger.latinIME_handleBackspace_batch(word);
                        ResearchLogger.latinIME_handleBackspace_batch(word, 1);
                        ResearchLogger.getInstance().uncommitCurrentLogUnit(
                        ResearchLogger.getInstance().uncommitCurrentLogUnit(
                                word, false /* dumpCurrentLogUnit */);
                                word, false /* dumpCurrentLogUnit */);
                    }
                    }
@@ -1718,14 +1718,17 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
            // We should backspace one char and restart suggestion if at the end of a word.
            // We should backspace one char and restart suggestion if at the end of a word.
            if (mLastSelectionStart != mLastSelectionEnd) {
            if (mLastSelectionStart != mLastSelectionEnd) {
                // If there is a selection, remove it.
                // If there is a selection, remove it.
                final int lengthToDelete = mLastSelectionEnd - mLastSelectionStart;
                final int numCharsDeleted = mLastSelectionEnd - mLastSelectionStart;
                mConnection.setSelection(mLastSelectionEnd, mLastSelectionEnd);
                mConnection.setSelection(mLastSelectionEnd, mLastSelectionEnd);
                // Reset mLastSelectionEnd to mLastSelectionStart. This is what is supposed to
                // Reset mLastSelectionEnd to mLastSelectionStart. This is what is supposed to
                // happen, and if it's wrong, the next call to onUpdateSelection will correct it,
                // happen, and if it's wrong, the next call to onUpdateSelection will correct it,
                // but we want to set it right away to avoid it being used with the wrong values
                // but we want to set it right away to avoid it being used with the wrong values
                // later (typically, in a subsequent press on backspace).
                // later (typically, in a subsequent press on backspace).
                mLastSelectionEnd = mLastSelectionStart;
                mLastSelectionEnd = mLastSelectionStart;
                mConnection.deleteSurroundingText(lengthToDelete, 0);
                mConnection.deleteSurroundingText(numCharsDeleted, 0);
                if (ProductionFlag.IS_EXPERIMENTAL) {
                    ResearchLogger.latinIME_handleBackspace(numCharsDeleted);
                }
            } else {
            } else {
                // There is no selection, just delete one character.
                // There is no selection, just delete one character.
                if (NOT_A_CURSOR_POSITION == mLastSelectionEnd) {
                if (NOT_A_CURSOR_POSITION == mLastSelectionEnd) {
@@ -1742,8 +1745,14 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
                } else {
                } else {
                    mConnection.deleteSurroundingText(1, 0);
                    mConnection.deleteSurroundingText(1, 0);
                }
                }
                if (ProductionFlag.IS_EXPERIMENTAL) {
                    ResearchLogger.latinIME_handleBackspace(1);
                }
                if (mDeleteCount > DELETE_ACCELERATE_AT) {
                if (mDeleteCount > DELETE_ACCELERATE_AT) {
                    mConnection.deleteSurroundingText(1, 0);
                    mConnection.deleteSurroundingText(1, 0);
                    if (ProductionFlag.IS_EXPERIMENTAL) {
                        ResearchLogger.latinIME_handleBackspace(1);
                    }
                }
                }
            }
            }
            if (mSettings.getCurrent().isSuggestionsRequested(mDisplayOrientation)) {
            if (mSettings.getCurrent().isSuggestionsRequested(mDisplayOrientation)) {
+20 −4
Original line number Original line Diff line number Diff line
@@ -1647,15 +1647,31 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
    }
    }


    /**
    /**
     * Log a call to LatinIME.handleBackspace().
     * Log a call to LatinIME.handleBackspace() that is not a batch delete.
     *
     * UserInput: The user is deleting one or more characters by hitting the backspace key once.
     * The covers single character deletes as well as deleting selections.
     */
    private static final LogStatement LOGSTATEMENT_LATINIME_HANDLEBACKSPACE =
            new LogStatement("LatinIMEHandleBackspace", true, false, "numCharacters");
    public static void latinIME_handleBackspace(final int numCharacters) {
        final ResearchLogger researchLogger = getInstance();
        researchLogger.enqueueEvent(LOGSTATEMENT_LATINIME_HANDLEBACKSPACE, numCharacters);
    }

    /**
     * Log a call to LatinIME.handleBackspace() that is a batch delete.
     *
     *
     * UserInput: The user is deleting a gestured word by hitting the backspace key once.
     * UserInput: The user is deleting a gestured word by hitting the backspace key once.
     */
     */
    private static final LogStatement LOGSTATEMENT_LATINIME_HANDLEBACKSPACE_BATCH =
    private static final LogStatement LOGSTATEMENT_LATINIME_HANDLEBACKSPACE_BATCH =
            new LogStatement("LatinIMEHandleBackspaceBatch", true, false, "deletedText");
            new LogStatement("LatinIMEHandleBackspaceBatch", true, false, "deletedText",
    public static void latinIME_handleBackspace_batch(final CharSequence deletedText) {
                    "numCharacters");
    public static void latinIME_handleBackspace_batch(final CharSequence deletedText,
            final int numCharacters) {
        final ResearchLogger researchLogger = getInstance();
        final ResearchLogger researchLogger = getInstance();
        researchLogger.enqueueEvent(LOGSTATEMENT_LATINIME_HANDLEBACKSPACE_BATCH, deletedText);
        researchLogger.enqueueEvent(LOGSTATEMENT_LATINIME_HANDLEBACKSPACE_BATCH, deletedText,
                numCharacters);
        researchLogger.mStatistics.recordGestureDelete(deletedText.length(),
        researchLogger.mStatistics.recordGestureDelete(deletedText.length(),
                SystemClock.uptimeMillis());
                SystemClock.uptimeMillis());
    }
    }