Merge pull request #564 from Helium314/patch-2

Add phantom space after characters usually followed by space
This commit is contained in:
Majeur 2022-03-21 15:16:34 +01:00 committed by GitHub
commit b96732ea22
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 0 deletions

View file

@ -996,6 +996,16 @@ public final class InputLogic {
// between swappers and strippers), so we should not stay in phantom space state if // between swappers and strippers), so we should not stay in phantom space state if
// the separator is a stripper. Hence the additional test above. // the separator is a stripper. Hence the additional test above.
mSpaceState = SpaceState.PHANTOM; mSpaceState = SpaceState.PHANTOM;
} 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.mAutospaceAfterPunctuationEnabled
&& settingsValues.isUsuallyFollowedBySpace(codePoint)) {
mSpaceState = SpaceState.PHANTOM;
} }
sendKeyCodePoint(settingsValues, codePoint); sendKeyCodePoint(settingsValues, codePoint);

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_KEYBOARD_HEIGHT_SCALE = "pref_keyboard_height_scale";
public static final String PREF_SPACE_TRACKPAD = "pref_space_trackpad"; 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_DELETE_SWIPE = "pref_delete_swipe";
public static final String PREF_AUTOSPACE_AFTER_PUNCTUATION = "pref_autospace_after_punctuation";
public static final String PREF_ALWAYS_INCOGNITO_MODE = public static final String PREF_ALWAYS_INCOGNITO_MODE =
"pref_always_incognito_mode"; "pref_always_incognito_mode";
public static final String PREF_BIGRAM_PREDICTIONS = "next_word_prediction"; 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); return prefs.getBoolean(PREF_DELETE_SWIPE, true);
} }
public static boolean readAutospaceAfterPunctuationEnabled(final SharedPreferences prefs) {
return prefs.getBoolean(PREF_AUTOSPACE_AFTER_PUNCTUATION, false);
}
public static boolean readUseFullscreenMode(final Resources res) { public static boolean readUseFullscreenMode(final Resources res) {
return res.getBoolean(R.bool.config_use_fullscreen_mode); 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 mBlockPotentiallyOffensive;
public final boolean mSpaceTrackpadEnabled; public final boolean mSpaceTrackpadEnabled;
public final boolean mDeleteSwipeEnabled; public final boolean mDeleteSwipeEnabled;
public final boolean mAutospaceAfterPunctuationEnabled;
public final boolean mClipboardHistoryEnabled; public final boolean mClipboardHistoryEnabled;
public final long mClipboardHistoryRetentionTime; public final long mClipboardHistoryRetentionTime;
public final boolean mOneHandedModeEnabled; public final boolean mOneHandedModeEnabled;
@ -237,6 +238,7 @@ public class SettingsValues {
} }
mSpaceTrackpadEnabled = Settings.readSpaceTrackpadEnabled(prefs); mSpaceTrackpadEnabled = Settings.readSpaceTrackpadEnabled(prefs);
mDeleteSwipeEnabled = Settings.readDeleteSwipeEnabled(prefs); mDeleteSwipeEnabled = Settings.readDeleteSwipeEnabled(prefs);
mAutospaceAfterPunctuationEnabled = Settings.readAutospaceAfterPunctuationEnabled(prefs);
mClipboardHistoryEnabled = Settings.readClipboardHistoryEnabled(prefs); mClipboardHistoryEnabled = Settings.readClipboardHistoryEnabled(prefs);
mClipboardHistoryRetentionTime = Settings.readClipboardHistoryRetentionTime(prefs, res); mClipboardHistoryRetentionTime = Settings.readClipboardHistoryRetentionTime(prefs, res);
mOneHandedModeEnabled = Settings.readOneHandedModeEnabled(prefs); mOneHandedModeEnabled = Settings.readOneHandedModeEnabled(prefs);

View file

@ -186,6 +186,10 @@
<string name="space_trackpad">Space bar trackpad</string> <string name="space_trackpad">Space bar trackpad</string>
<!-- Description for "space_trackpad" option. --> <!-- Description for "space_trackpad" option. -->
<string name="space_trackpad_summary">Swipe on the spacebar to move the cursor</string> <string name="space_trackpad_summary">Swipe on the spacebar to move the cursor</string>
<!-- Preferences item for enabling inserting more spaces key -->
<string name="autospace_after_punctuation">Autospace after punctuation</string>
<!-- Description for "insert_more_spaces" option. -->
<string name="autospace_after_punctuation_summary">Automatically insert space after punctuation when typing a new word</string>
<!-- Preferences item for disabling word learning --> <!-- Preferences item for disabling word learning -->
<string name="prefs_force_incognito_mode">Force incognito mode</string> <string name="prefs_force_incognito_mode">Force incognito mode</string>
<!-- Description for "prefs_force_incognito_mode" option. --> <!-- Description for "prefs_force_incognito_mode" option. -->

View file

@ -76,6 +76,12 @@
android:summary="@string/delete_swipe_summary" android:summary="@string/delete_swipe_summary"
android:defaultValue="true" /> android:defaultValue="true" />
<CheckBoxPreference
android:key="pref_autospace_after_punctuation"
android:title="@string/autospace_after_punctuation"
android:summary="@string/autospace_after_punctuation_summary"
android:defaultValue="false" />
</PreferenceCategory> </PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>