Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions java/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@
<!-- Search tags for the setting -->
<string name="auto_correction_tags">autocorrect</string>

<!-- Option to enable autocorrect in address bar inputs -->
<string name="auto_correct_address_bars">Auto-correct in address bars</string>
<!-- Description for "auto_correct_address_bars" -->
<string name="auto_correct_address_bars_summary">Auto-correction will apply when typing in address bars (URL, email address inputs)</string>

<!-- Option to enable using next word suggestions. After the user types a space, with this option on, the keyboard will try to predict the next word. -->
<string name="bigram_prediction">Next-word suggestions</string>
<!-- Description for "next word suggestion" option. This displays suggestions even when there is no input, based on the previous word. -->
Expand Down
14 changes: 9 additions & 5 deletions java/src/org/futo/inputmethod/latin/InputAttributes.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import androidx.annotation.Nullable;

import org.futo.inputmethod.latin.common.StringUtils;
import org.futo.inputmethod.latin.settings.Settings;
import org.futo.inputmethod.latin.utils.InputTypeUtils;

import java.util.ArrayList;
Expand Down Expand Up @@ -130,6 +131,9 @@ public InputAttributes(final EditorInfo editorInfo, final boolean isFullscreenMo
final boolean forceNoSuggestionsByPrivateFlag = editorInfo.privateImeOptions != null
&& editorInfo.privateImeOptions.contains("org.futo.inputmethod.latin.NoSuggestions=1");

final Settings settings = Settings.getInstance();
final boolean forceAutocorrectInAddressBars = settings.getCurrent().isAutoCorrectAddressBarsEnabled();

// TODO: Have a helper method in InputTypeUtils
// Make sure that passwords are not displayed in {@link SuggestionStripView}.
final boolean shouldSuppressSuggestions = mIsPasswordField
Expand All @@ -148,8 +152,8 @@ public InputAttributes(final EditorInfo editorInfo, final boolean isFullscreenMo
// TODO: This may need adjustment
mInputTypeNoAutoCorrect = shouldSuppressSuggestions
//|| (variation == InputType.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT && !flagAutoCorrect)
|| InputTypeUtils.isEmailVariation(variation)
|| InputType.TYPE_TEXT_VARIATION_URI == variation
|| (InputTypeUtils.isEmailVariation(variation) && !forceAutocorrectInAddressBars)
|| (InputType.TYPE_TEXT_VARIATION_URI == variation && !forceAutocorrectInAddressBars)
|| InputType.TYPE_TEXT_VARIATION_FILTER == variation
|| (flagNoSuggestions && !flagAutoCorrect && variation != InputType.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT)
|| mIsCodeField;
Expand All @@ -171,12 +175,12 @@ public InputAttributes(final EditorInfo editorInfo, final boolean isFullscreenMo
mApplicationSpecifiedCompletionOn = flagAutoComplete && isFullscreenMode;

// If we come here, inputClass is always TYPE_CLASS_TEXT
mIsGeneralTextInput = InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS != variation
mIsGeneralTextInput = (InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS != variation || forceAutocorrectInAddressBars)
&& InputType.TYPE_TEXT_VARIATION_PASSWORD != variation
&& InputType.TYPE_TEXT_VARIATION_PHONETIC != variation
&& InputType.TYPE_TEXT_VARIATION_URI != variation
&& (InputType.TYPE_TEXT_VARIATION_URI != variation || forceAutocorrectInAddressBars)
&& InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD != variation
&& InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS != variation
&& (InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS != variation || forceAutocorrectInAddressBars)
&& InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD != variation;

boolean noLearning = false;
Expand Down
1 change: 1 addition & 0 deletions java/src/org/futo/inputmethod/latin/settings/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
public static final String PREF_AUTO_CORRECTION_THRESHOLD_OBSOLETE =
"auto_correction_threshold";
public static final String PREF_AUTO_CORRECTION = "pref_key_auto_correction";
public static final String PREF_AUTO_CORRECT_ADDRESS_BARS = "auto_correct_address_bars";
// PREF_SHOW_SUGGESTIONS_SETTING_OBSOLETE is obsolete. Use PREF_SHOW_SUGGESTIONS instead.
public static final String PREF_SHOW_SUGGESTIONS_SETTING_OBSOLETE = "show_suggestions_setting";
public static final String PREF_SHOW_SUGGESTIONS = "show_suggestions";
Expand Down
10 changes: 10 additions & 0 deletions java/src/org/futo/inputmethod/latin/settings/SettingsValues.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public class SettingsValues {
public final float mPlausibilityThreshold;
public final boolean mAutoCorrectionEnabledPerUserSettings;
public final boolean mAutoCorrectionEnabledPerTextFieldSettings;
private final boolean mAutoCorrectAddressBarsEnabled;
private final boolean mSuggestionsEnabledPerUserSettings;
private final AsyncResultHolder<AppWorkaroundsUtils> mAppWorkarounds;

Expand Down Expand Up @@ -226,6 +227,7 @@ public SettingsValues(final Context context, final SharedPreferences prefs, fina
mAutoCorrectionEnabledPerUserSettings = mAutoCorrectEnabled
&& !mInputAttributes.mInputTypeNoAutoCorrect;
mAutoCorrectionEnabledPerTextFieldSettings = !mInputAttributes.mInputTypeNoAutoCorrect;
mAutoCorrectAddressBarsEnabled = readAutoCorrectAddressBarsEnabled(prefs);
mSuggestionsEnabledPerUserSettings = readSuggestionsEnabled(prefs);
mIsInternal = Settings.isInternal(prefs);
mHasCustomKeyPreviewAnimationParams = prefs.getBoolean(
Expand Down Expand Up @@ -279,6 +281,10 @@ public boolean needsToLookupSuggestions() {
&& (mAutoCorrectionEnabledPerUserSettings || isSuggestionsEnabledPerUserSettings());
}

public boolean isAutoCorrectAddressBarsEnabled() {
return mAutoCorrectAddressBarsEnabled;
}

public boolean isSuggestionsEnabledPerUserSettings() {
return mSuggestionsEnabledPerUserSettings;
}
Expand Down Expand Up @@ -363,6 +369,10 @@ public boolean isBrokenByRecorrection() {

private static final String SUGGESTIONS_VISIBILITY_HIDE_VALUE_OBSOLETE = "2";

private static boolean readAutoCorrectAddressBarsEnabled(final SharedPreferences prefs) {
return prefs.getBoolean(Settings.PREF_AUTO_CORRECT_ADDRESS_BARS, false);
}

private static boolean readSuggestionsEnabled(final SharedPreferences prefs) {
if (prefs.contains(Settings.PREF_SHOW_SUGGESTIONS_SETTING_OBSOLETE)) {
final boolean alwaysHide = SUGGESTIONS_VISIBILITY_HIDE_VALUE_OBSOLETE.equals(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ val PredictiveTextMenu = UserSettingsMenu(
}
).copy(searchTags = R.string.auto_correction_tags),

userSettingToggleSharedPrefs(
title = R.string.auto_correct_address_bars,
subtitle = R.string.auto_correct_address_bars_summary,
key = Settings.PREF_AUTO_CORRECT_ADDRESS_BARS,
default = {false}
),

userSettingToggleSharedPrefs(
title = R.string.prediction_settings_smart_keyhit_detection,
subtitle = R.string.prediction_settings_smart_keyhit_detection_subtitle,
Expand Down