mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-06-07 15:17:42 +00:00
only ignore TYPE_TEXT_FLAG_NO_SUGGESTIONS when user explicitly wants it
This commit is contained in:
parent
9e94aa1143
commit
e8e4354600
7 changed files with 27 additions and 24 deletions
|
@ -89,7 +89,7 @@ public final class InputAttributes {
|
||||||
|
|
||||||
// TODO: Have a helper method in InputTypeUtils
|
// TODO: Have a helper method in InputTypeUtils
|
||||||
// Make sure that passwords are not displayed in {@link SuggestionStripView}.
|
// Make sure that passwords are not displayed in {@link SuggestionStripView}.
|
||||||
mShouldShowSuggestions = !mIsPasswordField;
|
mShouldShowSuggestions = !mIsPasswordField && !flagNoSuggestions;
|
||||||
|
|
||||||
mShouldInsertSpacesAutomatically = InputTypeUtils.isAutoSpaceFriendlyType(inputType);
|
mShouldInsertSpacesAutomatically = InputTypeUtils.isAutoSpaceFriendlyType(inputType);
|
||||||
|
|
||||||
|
|
|
@ -844,7 +844,7 @@ public final class InputLogic {
|
||||||
|| mWordComposer.isComposingWord() // emoji will be part of the word in this case, better do nothing
|
|| mWordComposer.isComposingWord() // emoji will be part of the word in this case, better do nothing
|
||||||
|| !settingsValues.mBigramPredictionEnabled // this is only for next word suggestions, so they need to be enabled
|
|| !settingsValues.mBigramPredictionEnabled // this is only for next word suggestions, so they need to be enabled
|
||||||
|| settingsValues.mIncognitoModeEnabled
|
|| settingsValues.mIncognitoModeEnabled
|
||||||
|| !settingsValues.mInputAttributes.mShouldShowSuggestions // see comment in performAdditionToUserHistoryDictionary
|
|| !settingsValues.isSuggestionsEnabledPerUserSettings() // see comment in performAdditionToUserHistoryDictionary
|
||||||
|| !StringUtilsKt.isEmoji(text)
|
|| !StringUtilsKt.isEmoji(text)
|
||||||
) return;
|
) return;
|
||||||
if (mConnection.hasSlowInputConnection()) {
|
if (mConnection.hasSlowInputConnection()) {
|
||||||
|
@ -1524,8 +1524,8 @@ public final class InputLogic {
|
||||||
// If correction is not enabled, we don't add words to the user history dictionary.
|
// 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
|
// That's to avoid unintended additions in some sensitive fields, or fields that
|
||||||
// expect to receive non-words.
|
// expect to receive non-words.
|
||||||
// mInputTypeNoAutoCorrect changed to !mShouldShowSuggestions because this was cancelling learning way too often
|
// mInputTypeNoAutoCorrect changed to !isSuggestionsEnabledPerUserSettings because this was cancelling learning way too often
|
||||||
if (!settingsValues.mInputAttributes.mShouldShowSuggestions || settingsValues.mIncognitoModeEnabled || TextUtils.isEmpty(suggestion))
|
if (!settingsValues.isSuggestionsEnabledPerUserSettings() || settingsValues.mIncognitoModeEnabled || TextUtils.isEmpty(suggestion))
|
||||||
return;
|
return;
|
||||||
final boolean wasAutoCapitalized = mWordComposer.wasAutoCapitalized() && !mWordComposer.isMostlyCaps();
|
final boolean wasAutoCapitalized = mWordComposer.wasAutoCapitalized() && !mWordComposer.isMostlyCaps();
|
||||||
final String word = stripWordSeparatorsFromEnd(suggestion, settingsValues);
|
final String word = stripWordSeparatorsFromEnd(suggestion, settingsValues);
|
||||||
|
|
|
@ -29,20 +29,6 @@ import org.dslul.openboard.inputmethod.latin.userdictionary.UserDictionarySettin
|
||||||
|
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
/**
|
|
||||||
* "Text correction" settings sub screen.
|
|
||||||
*
|
|
||||||
* This settings sub screen handles the following text correction preferences.
|
|
||||||
* - Personal dictionary
|
|
||||||
* - Add-on dictionaries
|
|
||||||
* - Block offensive words
|
|
||||||
* - Auto-correction
|
|
||||||
* - Auto-correction confidence
|
|
||||||
* - Show correction suggestions
|
|
||||||
* - Personalized suggestions
|
|
||||||
* - Suggest Contact names
|
|
||||||
* - Next-word suggestions
|
|
||||||
*/
|
|
||||||
public final class CorrectionSettingsFragment extends SubScreenFragment
|
public final class CorrectionSettingsFragment extends SubScreenFragment
|
||||||
implements SharedPreferences.OnSharedPreferenceChangeListener,
|
implements SharedPreferences.OnSharedPreferenceChangeListener,
|
||||||
PermissionsManager.PermissionsResultCallback {
|
PermissionsManager.PermissionsResultCallback {
|
||||||
|
@ -86,6 +72,8 @@ public final class CorrectionSettingsFragment extends SubScreenFragment
|
||||||
.setPositiveButton(android.R.string.ok, null)
|
.setPositiveButton(android.R.string.ok, null)
|
||||||
.setOnCancelListener(dialogInterface -> ((TwoStatePreference) findPreference(key)).setChecked(true))
|
.setOnCancelListener(dialogInterface -> ((TwoStatePreference) findPreference(key)).setChecked(true))
|
||||||
.show();
|
.show();
|
||||||
|
} else if (Settings.PREF_SHOW_SUGGESTIONS.equals(key) && !prefs.getBoolean(key, true)) {
|
||||||
|
((TwoStatePreference)findPreference(Settings.PREF_ALWAYS_SHOW_SUGGESTIONS)).setChecked(false);
|
||||||
}
|
}
|
||||||
refreshEnabledSettings();
|
refreshEnabledSettings();
|
||||||
}
|
}
|
||||||
|
@ -106,9 +94,9 @@ public final class CorrectionSettingsFragment extends SubScreenFragment
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshEnabledSettings() {
|
private void refreshEnabledSettings() {
|
||||||
setPreferenceVisible(Settings.PREF_AUTO_CORRECTION_CONFIDENCE,
|
setPreferenceVisible(Settings.PREF_AUTO_CORRECTION_CONFIDENCE, Settings.readAutoCorrectEnabled(getSharedPreferences()));
|
||||||
Settings.readAutoCorrectEnabled(getSharedPreferences()));
|
|
||||||
setPreferenceVisible(Settings.PREF_ADD_TO_PERSONAL_DICTIONARY, getSharedPreferences().getBoolean(Settings.PREF_KEY_USE_PERSONALIZED_DICTS, true));
|
setPreferenceVisible(Settings.PREF_ADD_TO_PERSONAL_DICTIONARY, getSharedPreferences().getBoolean(Settings.PREF_KEY_USE_PERSONALIZED_DICTS, true));
|
||||||
|
setPreferenceVisible(Settings.PREF_ALWAYS_SHOW_SUGGESTIONS, getSharedPreferences().getBoolean(Settings.PREF_SHOW_SUGGESTIONS, true));
|
||||||
turnOffLookupContactsIfNoPermission();
|
turnOffLookupContactsIfNoPermission();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,6 +83,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
|
||||||
public static final String PREF_AUTO_CORRECTION = "pref_key_auto_correction";
|
public static final String PREF_AUTO_CORRECTION = "pref_key_auto_correction";
|
||||||
public static final String PREF_AUTO_CORRECTION_CONFIDENCE = "pref_key_auto_correction_confidence";
|
public static final String PREF_AUTO_CORRECTION_CONFIDENCE = "pref_key_auto_correction_confidence";
|
||||||
public static final String PREF_SHOW_SUGGESTIONS = "show_suggestions";
|
public static final String PREF_SHOW_SUGGESTIONS = "show_suggestions";
|
||||||
|
public static final String PREF_ALWAYS_SHOW_SUGGESTIONS = "pref_always_show_suggestions";
|
||||||
public static final String PREF_KEY_USE_PERSONALIZED_DICTS = "pref_key_use_personalized_dicts";
|
public static final String PREF_KEY_USE_PERSONALIZED_DICTS = "pref_key_use_personalized_dicts";
|
||||||
public static final String PREF_KEY_USE_DOUBLE_SPACE_PERIOD = "pref_key_use_double_space_period";
|
public static final String PREF_KEY_USE_DOUBLE_SPACE_PERIOD = "pref_key_use_double_space_period";
|
||||||
public static final String PREF_BLOCK_POTENTIALLY_OFFENSIVE = "pref_key_block_potentially_offensive";
|
public static final String PREF_BLOCK_POTENTIALLY_OFFENSIVE = "pref_key_block_potentially_offensive";
|
||||||
|
|
|
@ -192,8 +192,8 @@ public class SettingsValues {
|
||||||
&& prefs.getBoolean(Settings.PREF_GESTURE_FLOATING_PREVIEW_TEXT, true);
|
&& prefs.getBoolean(Settings.PREF_GESTURE_FLOATING_PREVIEW_TEXT, true);
|
||||||
mAutoCorrectionEnabledPerUserSettings = mAutoCorrectEnabled;
|
mAutoCorrectionEnabledPerUserSettings = mAutoCorrectEnabled;
|
||||||
//&& !mInputAttributes.mInputTypeNoAutoCorrect; // follow that request or not?
|
//&& !mInputAttributes.mInputTypeNoAutoCorrect; // follow that request or not?
|
||||||
mSuggestionsEnabledPerUserSettings = !mInputAttributes.mIsPasswordField &&
|
mSuggestionsEnabledPerUserSettings = (mInputAttributes.mShouldShowSuggestions && readSuggestionsEnabled(prefs))
|
||||||
readSuggestionsEnabled(prefs);
|
|| (!mInputAttributes.mIsPasswordField && readSuggestionsOverrideEnabled(prefs));
|
||||||
mIncognitoModeEnabled = Settings.readAlwaysIncognitoMode(prefs) || mInputAttributes.mNoLearning
|
mIncognitoModeEnabled = Settings.readAlwaysIncognitoMode(prefs) || mInputAttributes.mNoLearning
|
||||||
|| mInputAttributes.mIsPasswordField;
|
|| mInputAttributes.mIsPasswordField;
|
||||||
mKeyboardHeightScale = prefs.getFloat(Settings.PREF_KEYBOARD_HEIGHT_SCALE, DEFAULT_SIZE_SCALE);
|
mKeyboardHeightScale = prefs.getFloat(Settings.PREF_KEYBOARD_HEIGHT_SCALE, DEFAULT_SIZE_SCALE);
|
||||||
|
@ -252,8 +252,7 @@ public class SettingsValues {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean needsToLookupSuggestions() {
|
public boolean needsToLookupSuggestions() {
|
||||||
return mInputAttributes.mShouldShowSuggestions
|
return mAutoCorrectionEnabledPerUserSettings || isSuggestionsEnabledPerUserSettings();
|
||||||
&& (mAutoCorrectionEnabledPerUserSettings || isSuggestionsEnabledPerUserSettings());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSuggestionsEnabledPerUserSettings() {
|
public boolean isSuggestionsEnabledPerUserSettings() {
|
||||||
|
@ -312,6 +311,10 @@ public class SettingsValues {
|
||||||
return prefs.getBoolean(Settings.PREF_SHOW_SUGGESTIONS, true);
|
return prefs.getBoolean(Settings.PREF_SHOW_SUGGESTIONS, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean readSuggestionsOverrideEnabled(final SharedPreferences prefs) {
|
||||||
|
return prefs.getBoolean(Settings.PREF_ALWAYS_SHOW_SUGGESTIONS, false);
|
||||||
|
}
|
||||||
|
|
||||||
private static boolean readBigramPredictionEnabled(final SharedPreferences prefs,
|
private static boolean readBigramPredictionEnabled(final SharedPreferences prefs,
|
||||||
final Resources res) {
|
final Resources res) {
|
||||||
return prefs.getBoolean(Settings.PREF_BIGRAM_PREDICTIONS, res.getBoolean(
|
return prefs.getBoolean(Settings.PREF_BIGRAM_PREDICTIONS, res.getBoolean(
|
||||||
|
|
|
@ -101,6 +101,10 @@
|
||||||
<string name="prefs_show_suggestions">Show correction suggestions</string>
|
<string name="prefs_show_suggestions">Show correction suggestions</string>
|
||||||
<!-- Description for show suggestions -->
|
<!-- Description for show suggestions -->
|
||||||
<string name="prefs_show_suggestions_summary">Display suggested words while typing</string>
|
<string name="prefs_show_suggestions_summary">Display suggested words while typing</string>
|
||||||
|
<!-- Option to override app flag to not show suggestions -->
|
||||||
|
<string name="prefs_always_show_suggestions">Always show suggestions</string>
|
||||||
|
<!-- Description for override app flag to not show suggestions -->
|
||||||
|
<string name="prefs_always_show_suggestions_summary">Ignore other apps’ request to disable suggestions</string>
|
||||||
<!-- Option to block potentially offensive words to be shown [CHAR_LIMIT=30] -->
|
<!-- Option to block potentially offensive words to be shown [CHAR_LIMIT=30] -->
|
||||||
<string name="prefs_block_potentially_offensive_title">Block offensive words</string>
|
<string name="prefs_block_potentially_offensive_title">Block offensive words</string>
|
||||||
<!-- Summary for option to block potentially offensive words to be shown [CHAR_LIMIT=80 (two lines) or 40 (fits on one line, preferable)] -->
|
<!-- Summary for option to block potentially offensive words to be shown [CHAR_LIMIT=80 (two lines) or 40 (fits on one line, preferable)] -->
|
||||||
|
|
|
@ -71,6 +71,13 @@
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
android:persistent="true" />
|
android:persistent="true" />
|
||||||
|
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
android:key="pref_always_show_suggestions"
|
||||||
|
android:title="@string/prefs_always_show_suggestions"
|
||||||
|
android:summary="@string/prefs_always_show_suggestions_summary"
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:persistent="true" />
|
||||||
|
|
||||||
<SwitchPreferenceCompat
|
<SwitchPreferenceCompat
|
||||||
android:key="pref_key_use_personalized_dicts"
|
android:key="pref_key_use_personalized_dicts"
|
||||||
android:title="@string/use_personalized_dicts"
|
android:title="@string/use_personalized_dicts"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue