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

Unverified Commit 05f7fefa authored by Oliver Scott's avatar Oliver Scott Committed by Michael Bestas
Browse files

fixup! LatinIME: support for incognito mode

The original commit does not offer word suggestions in incognito but
it still learns words while being in incognito, which is exactly the
opposite of what this feature should do.

Issue: calyxos#3077
Change-Id: If80faa519aab29e5e094d51de4b83f068a341b05
parent 36ec7d9b
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ public final class InputAttributes {
    final public boolean mApplicationSpecifiedCompletionOn;
    final public boolean mShouldInsertSpacesAutomatically;
    final public boolean mShouldShowVoiceInputKey;
    final public boolean mNoLearning;
    final public boolean mNoPersonalizedLearning;
    /**
     * Whether the floating gesture preview should be disabled. If true, this should override the
     * corresponding keyboard settings preference, always suppressing the floating preview text.
@@ -87,7 +87,7 @@ public final class InputAttributes {
            mShouldShowVoiceInputKey = false;
            mDisableGestureFloatingPreviewText = false;
            mIsGeneralTextInput = false;
            mNoLearning = false;
            mNoPersonalizedLearning = false;
            return;
        }
        // inputClass == InputType.TYPE_CLASS_TEXT
@@ -142,7 +142,8 @@ public final class InputAttributes {
                && InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS != variation
                && InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD != variation;

        mNoLearning = (editorInfo.imeOptions & EditorInfo.IME_FLAG_NO_PERSONALIZED_LEARNING) != 0;
        mNoPersonalizedLearning =
                (editorInfo.imeOptions & EditorInfo.IME_FLAG_NO_PERSONALIZED_LEARNING) != 0;
    }

    public boolean isTypeNull() {
+2 −1
Original line number Diff line number Diff line
@@ -1438,7 +1438,8 @@ public final class InputLogic {
        // If correction is not enabled, we don't add words to the user history dictionary.
        // That's to avoid unintended additions in some sensitive fields, or fields that
        // expect to receive non-words.
        if (!settingsValues.mAutoCorrectionEnabledPerUserSettings) return;
        if (!settingsValues.mAutoCorrectionEnabledPerUserSettings ||
                !settingsValues.isPersonalizedLearningEnabled()) return;
        if (mConnection.hasSlowInputConnection()) {
            // Since we don't unlearn when the user backspaces on a slow InputConnection,
            // turn off learning to guard against adding typos that the user later deletes.
+5 −2
Original line number Diff line number Diff line
@@ -190,8 +190,7 @@ public class SettingsValues {
                && prefs.getBoolean(Settings.PREF_GESTURE_FLOATING_PREVIEW_TEXT, true);
        mAutoCorrectionEnabledPerUserSettings = mAutoCorrectEnabled
                && !mInputAttributes.mInputTypeNoAutoCorrect;
        mSuggestionsEnabledPerUserSettings = !mInputAttributes.mNoLearning &&
                readSuggestionsEnabled(prefs);
        mSuggestionsEnabledPerUserSettings = readSuggestionsEnabled(prefs);
        mIsInternal = Settings.isInternal(prefs);
        mHasCustomKeyPreviewAnimationParams = prefs.getBoolean(
                DebugSettings.PREF_HAS_CUSTOM_KEY_PREVIEW_ANIMATION_PARAMS, false);
@@ -308,6 +307,10 @@ public class SettingsValues {
        return null == appWorkaroundUtils ? false : appWorkaroundUtils.isBrokenByRecorrection();
    }

    public boolean isPersonalizedLearningEnabled() {
        return !mInputAttributes.mNoPersonalizedLearning;
    }

    private static final String SUGGESTIONS_VISIBILITY_HIDE_VALUE_OBSOLETE = "2";

    private static boolean readSuggestionsEnabled(final SharedPreferences prefs) {