Skip to content

Commit 05f7fef

Browse files
UldiniadmikeNG
authored andcommitted
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
1 parent 36ec7d9 commit 05f7fef

3 files changed

Lines changed: 11 additions & 6 deletions

File tree

java/src/com/android/inputmethod/latin/InputAttributes.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public final class InputAttributes {
4343
final public boolean mApplicationSpecifiedCompletionOn;
4444
final public boolean mShouldInsertSpacesAutomatically;
4545
final public boolean mShouldShowVoiceInputKey;
46-
final public boolean mNoLearning;
46+
final public boolean mNoPersonalizedLearning;
4747
/**
4848
* Whether the floating gesture preview should be disabled. If true, this should override the
4949
* corresponding keyboard settings preference, always suppressing the floating preview text.
@@ -87,7 +87,7 @@ public InputAttributes(final EditorInfo editorInfo, final boolean isFullscreenMo
8787
mShouldShowVoiceInputKey = false;
8888
mDisableGestureFloatingPreviewText = false;
8989
mIsGeneralTextInput = false;
90-
mNoLearning = false;
90+
mNoPersonalizedLearning = false;
9191
return;
9292
}
9393
// inputClass == InputType.TYPE_CLASS_TEXT
@@ -142,7 +142,8 @@ public InputAttributes(final EditorInfo editorInfo, final boolean isFullscreenMo
142142
&& InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS != variation
143143
&& InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD != variation;
144144

145-
mNoLearning = (editorInfo.imeOptions & EditorInfo.IME_FLAG_NO_PERSONALIZED_LEARNING) != 0;
145+
mNoPersonalizedLearning =
146+
(editorInfo.imeOptions & EditorInfo.IME_FLAG_NO_PERSONALIZED_LEARNING) != 0;
146147
}
147148

148149
public boolean isTypeNull() {

java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1438,7 +1438,8 @@ private void performAdditionToUserHistoryDictionary(final SettingsValues setting
14381438
// If correction is not enabled, we don't add words to the user history dictionary.
14391439
// That's to avoid unintended additions in some sensitive fields, or fields that
14401440
// expect to receive non-words.
1441-
if (!settingsValues.mAutoCorrectionEnabledPerUserSettings) return;
1441+
if (!settingsValues.mAutoCorrectionEnabledPerUserSettings ||
1442+
!settingsValues.isPersonalizedLearningEnabled()) return;
14421443
if (mConnection.hasSlowInputConnection()) {
14431444
// Since we don't unlearn when the user backspaces on a slow InputConnection,
14441445
// turn off learning to guard against adding typos that the user later deletes.

java/src/com/android/inputmethod/latin/settings/SettingsValues.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,7 @@ public SettingsValues(final Context context, final SharedPreferences prefs, fina
190190
&& prefs.getBoolean(Settings.PREF_GESTURE_FLOATING_PREVIEW_TEXT, true);
191191
mAutoCorrectionEnabledPerUserSettings = mAutoCorrectEnabled
192192
&& !mInputAttributes.mInputTypeNoAutoCorrect;
193-
mSuggestionsEnabledPerUserSettings = !mInputAttributes.mNoLearning &&
194-
readSuggestionsEnabled(prefs);
193+
mSuggestionsEnabledPerUserSettings = readSuggestionsEnabled(prefs);
195194
mIsInternal = Settings.isInternal(prefs);
196195
mHasCustomKeyPreviewAnimationParams = prefs.getBoolean(
197196
DebugSettings.PREF_HAS_CUSTOM_KEY_PREVIEW_ANIMATION_PARAMS, false);
@@ -308,6 +307,10 @@ public boolean isBrokenByRecorrection() {
308307
return null == appWorkaroundUtils ? false : appWorkaroundUtils.isBrokenByRecorrection();
309308
}
310309

310+
public boolean isPersonalizedLearningEnabled() {
311+
return !mInputAttributes.mNoPersonalizedLearning;
312+
}
313+
311314
private static final String SUGGESTIONS_VISIBILITY_HIDE_VALUE_OBSOLETE = "2";
312315

313316
private static boolean readSuggestionsEnabled(final SharedPreferences prefs) {

0 commit comments

Comments
 (0)