add comments and setting for auto-inserting more spaces

This commit is contained in:
Helium 2022-03-17 07:11:26 +01:00
parent 232c9892ae
commit 2197ffd4a5
5 changed files with 26 additions and 3 deletions

View file

@ -996,9 +996,15 @@ public final class InputLogic {
// between swappers and strippers), so we should not stay in phantom space state if
// the separator is a stripper. Hence the additional test above.
mSpaceState = SpaceState.PHANTOM;
}
if (mSpaceState == SpaceState.NONE && wasComposingWord && settingsValues.isUsuallyFollowedBySpace(codePoint)) {
} else
// mSpaceState is still SpaceState.NONE, but some characters should typically
// be followed by space. Set phantom space state for such characters if the user
// enabled the setting and was not composing a word. The latter avoids setting
// phantom space state when typing decimal numbers, with the drawback of not
// setting phantom space state after ending a sentence with a non-word.
if (wasComposingWord
&& settingsValues.mInsertMoreSpacesEnabled
&& settingsValues.isUsuallyFollowedBySpace(codePoint)) {
mSpaceState = SpaceState.PHANTOM;
}

View file

@ -94,6 +94,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
public static final String PREF_KEYBOARD_HEIGHT_SCALE = "pref_keyboard_height_scale";
public static final String PREF_SPACE_TRACKPAD = "pref_space_trackpad";
public static final String PREF_DELETE_SWIPE = "pref_delete_swipe";
public static final String PREF_INSERT_MORE_SPACES = "pref_insert_more_spaces";
public static final String PREF_ALWAYS_INCOGNITO_MODE =
"pref_always_incognito_mode";
public static final String PREF_BIGRAM_PREDICTIONS = "next_word_prediction";
@ -392,6 +393,10 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
return prefs.getBoolean(PREF_DELETE_SWIPE, true);
}
public static boolean readInsertMoreSpacesEnabled(final SharedPreferences prefs) {
return prefs.getBoolean(PREF_INSERT_MORE_SPACES, false);
}
public static boolean readUseFullscreenMode(final Resources res) {
return res.getBoolean(R.bool.config_use_fullscreen_mode);
}

View file

@ -80,6 +80,7 @@ public class SettingsValues {
public final boolean mBlockPotentiallyOffensive;
public final boolean mSpaceTrackpadEnabled;
public final boolean mDeleteSwipeEnabled;
public final boolean mInsertMoreSpacesEnabled;
public final boolean mClipboardHistoryEnabled;
public final long mClipboardHistoryRetentionTime;
public final boolean mOneHandedModeEnabled;
@ -237,6 +238,7 @@ public class SettingsValues {
}
mSpaceTrackpadEnabled = Settings.readSpaceTrackpadEnabled(prefs);
mDeleteSwipeEnabled = Settings.readDeleteSwipeEnabled(prefs);
mInsertMoreSpacesEnabled = Settings.readInsertMoreSpacesEnabled(prefs);
mClipboardHistoryEnabled = Settings.readClipboardHistoryEnabled(prefs);
mClipboardHistoryRetentionTime = Settings.readClipboardHistoryRetentionTime(prefs, res);
mOneHandedModeEnabled = Settings.readOneHandedModeEnabled(prefs);