Skip to content

Commit 0109899

Browse files
committed
Removing the "off" value from the auto_correction_threshold_values array. Making required code changes to auto correct threshold code based on this change.
1 parent 0ae6040 commit 0109899

2 files changed

Lines changed: 9 additions & 12 deletions

File tree

app/src/main/java/org/dslul/openboard/inputmethod/latin/settings/SettingsValues.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public class SettingsValues {
5353
private static final String FLOAT_NEGATIVE_INFINITY_MARKER_STRING = "floatNegativeInfinity";
5454
private static final int TIMEOUT_TO_GET_TARGET_PACKAGE = 5; // seconds
5555
public static final float DEFAULT_SIZE_SCALE = 1.0f; // 100%
56+
public static final float AUTO_CORRECTION_DISABLED_THRESHOLD = Float.MAX_VALUE;
5657

5758
// From resources:
5859
public final SpacingAndPunctuations mSpacingAndPunctuations;
@@ -163,9 +164,9 @@ public SettingsValues(final Context context, final SharedPreferences prefs, fina
163164
&& inputAttributes.mIsGeneralTextInput;
164165
mBlockPotentiallyOffensive = Settings.readBlockPotentiallyOffensive(prefs, res);
165166
mAutoCorrectEnabled = Settings.readAutoCorrectEnabled(prefs, res);
166-
final String autoCorrectionThresholdRawValue = mAutoCorrectEnabled
167-
? Settings.readAutoCorrectConfidence(prefs, res)
168-
: res.getString(R.string.auto_correction_threshold_mode_index_off);
167+
mAutoCorrectionThreshold = mAutoCorrectEnabled
168+
? readAutoCorrectionThreshold(res, prefs)
169+
: AUTO_CORRECTION_DISABLED_THRESHOLD;
169170
mBigramPredictionEnabled = readBigramPredictionEnabled(prefs, res);
170171
mDoubleSpacePeriodTimeout = res.getInteger(R.integer.config_double_space_period_timeout);
171172
mHasHardwareKeyboard = Settings.readHasHardwareKeyboard(res.getConfiguration());
@@ -183,8 +184,6 @@ public SettingsValues(final Context context, final SharedPreferences prefs, fina
183184
Settings.PREF_ENABLE_EMOJI_ALT_PHYSICAL_KEY, true);
184185
mShowAppIcon = Settings.readShowSetupWizardIcon(prefs, context);
185186
mIsShowAppIconSettingInPreferences = prefs.contains(Settings.PREF_SHOW_SETUP_WIZARD_ICON);
186-
mAutoCorrectionThreshold = readAutoCorrectionThreshold(res,
187-
autoCorrectionThresholdRawValue);
188187
mPlausibilityThreshold = Settings.readPlausibilityThreshold(res);
189188
mGestureInputEnabled = Settings.readGestureInputEnabled(prefs, res);
190189
mGestureTrailEnabled = prefs.getBoolean(Settings.PREF_GESTURE_PREVIEW_TRAIL, true);
@@ -331,7 +330,8 @@ private static boolean readBigramPredictionEnabled(final SharedPreferences prefs
331330
}
332331

333332
private static float readAutoCorrectionThreshold(final Resources res,
334-
final String currentAutoCorrectionSetting) {
333+
final SharedPreferences prefs) {
334+
final String currentAutoCorrectionSetting = Settings.readAutoCorrectConfidence(prefs, res);
335335
final String[] autoCorrectionThresholdValues = res.getStringArray(
336336
R.array.auto_correction_threshold_values);
337337
// When autoCorrectionThreshold is greater than 1.0, it's like auto correction is off.

app/src/main/res/values/config-auto-correction-thresholds.xml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
<resources>
2222
<!-- The array of auto correction threshold values. -->
2323
<string-array name="auto_correction_threshold_values" translatable="false">
24-
<!-- Off, When auto correction setting is Off, this value is not used. -->
25-
<item>floatMaxValue</item>
2624
<!-- Modest : Suggestion whose normalized score is greater than this value
2725
will be subject to auto-correction. -->
2826
<item>0.185</item>
@@ -41,10 +39,9 @@
4139
<string name="plausibility_threshold" translatable="false">0.065</string>
4240

4341
<!-- The index of the auto correction threshold values array. -->
44-
<string name="auto_correction_threshold_mode_index_off" translatable="false">0</string>
45-
<string name="auto_correction_threshold_mode_index_modest" translatable="false">1</string>
46-
<string name="auto_correction_threshold_mode_index_aggressive" translatable="false">2</string>
47-
<string name="auto_correction_threshold_mode_index_very_aggressive" translatable="false">3</string>
42+
<string name="auto_correction_threshold_mode_index_modest" translatable="false">0</string>
43+
<string name="auto_correction_threshold_mode_index_aggressive" translatable="false">1</string>
44+
<string name="auto_correction_threshold_mode_index_very_aggressive" translatable="false">2</string>
4845

4946
<!-- The array of the auto correction threshold settings values. -->
5047
<string-array name="auto_correction_threshold_mode_indexes" translatable="false">

0 commit comments

Comments
 (0)