diff --git a/app/src/main/java/helium314/keyboard/latin/WordComposer.java b/app/src/main/java/helium314/keyboard/latin/WordComposer.java
index d67f50d7..203eb205 100644
--- a/app/src/main/java/helium314/keyboard/latin/WordComposer.java
+++ b/app/src/main/java/helium314/keyboard/latin/WordComposer.java
@@ -474,6 +474,10 @@ public final class WordComposer {
return mIsBatchMode;
}
+ public void unsetBatchMode() {
+ mIsBatchMode = false;
+ }
+
public void setRejectedBatchModeSuggestion(final String rejectedSuggestion) {
mRejectedBatchModeSuggestion = rejectedSuggestion;
}
diff --git a/app/src/main/java/helium314/keyboard/latin/inputlogic/InputLogic.java b/app/src/main/java/helium314/keyboard/latin/inputlogic/InputLogic.java
index 83d00864..b98906ef 100644
--- a/app/src/main/java/helium314/keyboard/latin/inputlogic/InputLogic.java
+++ b/app/src/main/java/helium314/keyboard/latin/inputlogic/InputLogic.java
@@ -323,7 +323,8 @@ public final class InputLogic {
// Don't allow cancellation of manual pick
mLastComposedWord.deactivate();
// Space state must be updated before calling updateShiftState
- mSpaceState = SpaceState.PHANTOM;
+ if (settingsValues.mAutospaceAfterSuggestion)
+ mSpaceState = SpaceState.PHANTOM;
inputTransaction.requireShiftUpdate(InputTransaction.SHIFT_UPDATE_NOW);
// If we're not showing the "Touch again to save", then update the suggestion strip.
@@ -546,7 +547,8 @@ public final class InputLogic {
|| settingsValues.isUsuallyFollowedBySpace(codePointBeforeCursor)) {
final boolean autoShiftHasBeenOverriden = keyboardSwitcher.getKeyboardShiftMode() !=
getCurrentAutoCapsState(settingsValues);
- mSpaceState = SpaceState.PHANTOM;
+ if (settingsValues.mAutospaceBeforeGestureTyping)
+ mSpaceState = SpaceState.PHANTOM;
if (!autoShiftHasBeenOverriden) {
// When we change the space state, we need to update the shift state of the
// keyboard unless it has been overridden manually. This is happening for example
@@ -686,10 +688,7 @@ public final class InputLogic {
if (mSuggestedWords.isPrediction()) {
inputTransaction.setRequiresUpdateSuggestions();
}
- // undo phantom space if it's because after punctuation
- // users who want to start a sentence with a lowercase letter may not like it
- if (mSpaceState == SpaceState.PHANTOM
- && inputTransaction.getMSettingsValues().isUsuallyFollowedBySpace(mConnection.getCodePointBeforeCursor()))
+ if (mSpaceState == SpaceState.PHANTOM && inputTransaction.getMSettingsValues().mShiftRemovesAutospace)
mSpaceState = SpaceState.NONE;
break;
case KeyCode.SETTINGS:
@@ -930,6 +929,7 @@ public final class InputLogic {
// handleNonSpecialCharacterEvent which has the same name as other handle* methods but is
// not the same.
boolean isComposingWord = mWordComposer.isComposingWord();
+ mWordComposer.unsetBatchMode(); // relevant in case we continue a batch word with normal typing
// if we continue directly after a sometimesWordConnector, restart suggestions for the whole word
// (only with URL detection and suggestions enabled)
@@ -1127,7 +1127,7 @@ public final class InputLogic {
// A double quote behaves like it's usually followed by space if we're inside
// a double quote.
if (wasComposingWord
- && settingsValues.mAutospaceAfterPunctuationEnabled
+ && settingsValues.mAutospaceAfterPunctuation
&& (settingsValues.isUsuallyFollowedBySpace(codePoint) || isInsideDoubleQuoteOrAfterDigit)) {
mSpaceState = SpaceState.PHANTOM;
}
@@ -2168,6 +2168,7 @@ public final class InputLogic {
&& !(mConnection.getCodePointBeforeCursor() == Constants.CODE_PERIOD && mConnection.wordBeforeCursorMayBeEmail())
) {
mConnection.commitCodePoint(Constants.CODE_SPACE);
+ // todo: why not remove phantom space state?
}
}
@@ -2202,12 +2203,14 @@ public final class InputLogic {
mConnection.beginBatchEdit();
if (SpaceState.PHANTOM == mSpaceState) {
insertAutomaticSpaceIfOptionsAndTextAllow(settingsValues);
+ mSpaceState = SpaceState.NONE;
}
mWordComposer.setBatchInputWord(batchInputText);
setComposingTextInternal(batchInputText, 1);
mConnection.endBatchEdit();
// Space state must be updated before calling updateShiftState
- mSpaceState = SpaceState.PHANTOM;
+ if (settingsValues.mAutospaceAfterGestureTyping)
+ mSpaceState = SpaceState.PHANTOM;
keyboardSwitcher.requestUpdatingShiftState(getCurrentAutoCapsState(settingsValues), getCurrentRecapitalizeState());
}
diff --git a/app/src/main/java/helium314/keyboard/latin/settings/Defaults.kt b/app/src/main/java/helium314/keyboard/latin/settings/Defaults.kt
index 58ef7939..08df4eac 100644
--- a/app/src/main/java/helium314/keyboard/latin/settings/Defaults.kt
+++ b/app/src/main/java/helium314/keyboard/latin/settings/Defaults.kt
@@ -92,6 +92,10 @@ object Defaults {
const val PREF_SPACE_VERTICAL_SWIPE = "none"
const val PREF_DELETE_SWIPE = true
const val PREF_AUTOSPACE_AFTER_PUNCTUATION = false
+ const val PREF_AUTOSPACE_AFTER_SUGGESTION = true
+ const val PREF_AUTOSPACE_AFTER_GESTURE_TYPING = true
+ const val PREF_AUTOSPACE_BEFORE_GESTURE_TYPING = true
+ const val PREF_SHIFT_REMOVES_AUTOSPACE = false
const val PREF_ALWAYS_INCOGNITO_MODE = false
const val PREF_BIGRAM_PREDICTIONS = true
const val PREF_SUGGEST_CLIPBOARD_CONTENT = true
diff --git a/app/src/main/java/helium314/keyboard/latin/settings/Settings.java b/app/src/main/java/helium314/keyboard/latin/settings/Settings.java
index bad339e5..08bf53b3 100644
--- a/app/src/main/java/helium314/keyboard/latin/settings/Settings.java
+++ b/app/src/main/java/helium314/keyboard/latin/settings/Settings.java
@@ -98,6 +98,10 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
public static final String PREF_SPACE_VERTICAL_SWIPE = "vertical_space_swipe";
public static final String PREF_DELETE_SWIPE = "delete_swipe";
public static final String PREF_AUTOSPACE_AFTER_PUNCTUATION = "autospace_after_punctuation";
+ public static final String PREF_AUTOSPACE_AFTER_SUGGESTION = "autospace_after_suggestion";
+ public static final String PREF_AUTOSPACE_AFTER_GESTURE_TYPING = "autospace_after_gesture_typing";
+ public static final String PREF_AUTOSPACE_BEFORE_GESTURE_TYPING = "autospace_before_gesture_typing";
+ public static final String PREF_SHIFT_REMOVES_AUTOSPACE = "shift_removes_autospace";
public static final String PREF_ALWAYS_INCOGNITO_MODE = "always_incognito_mode";
public static final String PREF_BIGRAM_PREDICTIONS = "next_word_prediction";
public static final String PREF_SUGGEST_CLIPBOARD_CONTENT = "suggest_clipboard_content";
diff --git a/app/src/main/java/helium314/keyboard/latin/settings/SettingsValues.java b/app/src/main/java/helium314/keyboard/latin/settings/SettingsValues.java
index 376c3668..3430ae04 100644
--- a/app/src/main/java/helium314/keyboard/latin/settings/SettingsValues.java
+++ b/app/src/main/java/helium314/keyboard/latin/settings/SettingsValues.java
@@ -77,7 +77,11 @@ public class SettingsValues {
public final int mSpaceSwipeVertical;
public final int mLanguageSwipeDistance;
public final boolean mDeleteSwipeEnabled;
- public final boolean mAutospaceAfterPunctuationEnabled;
+ public final boolean mAutospaceAfterPunctuation;
+ public final boolean mAutospaceAfterSuggestion;
+ public final boolean mAutospaceAfterGestureTyping;
+ public final boolean mAutospaceBeforeGestureTyping;
+ public final boolean mShiftRemovesAutospace;
public final boolean mClipboardHistoryEnabled;
public final long mClipboardHistoryRetentionTime;
public final boolean mOneHandedModeEnabled;
@@ -236,7 +240,11 @@ public class SettingsValues {
mSpaceSwipeVertical = Settings.readVerticalSpaceSwipe(prefs);
mLanguageSwipeDistance = prefs.getInt(Settings.PREF_LANGUAGE_SWIPE_DISTANCE, Defaults.PREF_LANGUAGE_SWIPE_DISTANCE);
mDeleteSwipeEnabled = prefs.getBoolean(Settings.PREF_DELETE_SWIPE, Defaults.PREF_DELETE_SWIPE);
- mAutospaceAfterPunctuationEnabled = prefs.getBoolean(Settings.PREF_AUTOSPACE_AFTER_PUNCTUATION, Defaults.PREF_AUTOSPACE_AFTER_PUNCTUATION);
+ mAutospaceAfterPunctuation = prefs.getBoolean(Settings.PREF_AUTOSPACE_AFTER_PUNCTUATION, Defaults.PREF_AUTOSPACE_AFTER_PUNCTUATION);
+ mAutospaceAfterSuggestion = prefs.getBoolean(Settings.PREF_AUTOSPACE_AFTER_SUGGESTION, Defaults.PREF_AUTOSPACE_AFTER_SUGGESTION);
+ mAutospaceAfterGestureTyping = prefs.getBoolean(Settings.PREF_AUTOSPACE_AFTER_GESTURE_TYPING, Defaults.PREF_AUTOSPACE_AFTER_GESTURE_TYPING);
+ mAutospaceBeforeGestureTyping = prefs.getBoolean(Settings.PREF_AUTOSPACE_BEFORE_GESTURE_TYPING, Defaults.PREF_AUTOSPACE_BEFORE_GESTURE_TYPING);
+ mShiftRemovesAutospace = prefs.getBoolean(Settings.PREF_SHIFT_REMOVES_AUTOSPACE, Defaults.PREF_SHIFT_REMOVES_AUTOSPACE);
mClipboardHistoryEnabled = prefs.getBoolean(Settings.PREF_ENABLE_CLIPBOARD_HISTORY, Defaults.PREF_ENABLE_CLIPBOARD_HISTORY);
mClipboardHistoryRetentionTime = prefs.getInt(Settings.PREF_CLIPBOARD_HISTORY_RETENTION_TIME, Defaults.PREF_CLIPBOARD_HISTORY_RETENTION_TIME);
diff --git a/app/src/main/java/helium314/keyboard/settings/screens/TextCorrectionScreen.kt b/app/src/main/java/helium314/keyboard/settings/screens/TextCorrectionScreen.kt
index f2d57048..f322e0f0 100644
--- a/app/src/main/java/helium314/keyboard/settings/screens/TextCorrectionScreen.kt
+++ b/app/src/main/java/helium314/keyboard/settings/screens/TextCorrectionScreen.kt
@@ -22,6 +22,7 @@ import helium314.keyboard.latin.R
import helium314.keyboard.latin.permissions.PermissionsUtil
import helium314.keyboard.latin.settings.Defaults
import helium314.keyboard.latin.settings.Settings
+import helium314.keyboard.latin.utils.JniUtils
import helium314.keyboard.latin.utils.Log
import helium314.keyboard.latin.utils.getActivity
import helium314.keyboard.latin.utils.prefs
@@ -49,6 +50,7 @@ fun TextCorrectionScreen(
Log.v("irrelevant", "stupid way to trigger recomposition on preference change")
val autocorrectEnabled = prefs.getBoolean(Settings.PREF_AUTO_CORRECTION, Defaults.PREF_AUTO_CORRECTION)
val suggestionsEnabled = prefs.getBoolean(Settings.PREF_SHOW_SUGGESTIONS, Defaults.PREF_SHOW_SUGGESTIONS)
+ val gestureEnabled = JniUtils.sHaveGestureLib && prefs.getBoolean(Settings.PREF_GESTURE_INPUT, Defaults.PREF_GESTURE_INPUT)
val items = listOf(
SettingsWithoutKey.EDIT_PERSONAL_DICTIONARY,
R.string.settings_category_correction,
@@ -58,8 +60,13 @@ fun TextCorrectionScreen(
if (autocorrectEnabled) Settings.PREF_AUTOCORRECT_SHORTCUTS else null,
if (autocorrectEnabled) Settings.PREF_AUTO_CORRECT_THRESHOLD else null,
Settings.PREF_AUTO_CAP,
+ R.string.settings_category_space,
Settings.PREF_KEY_USE_DOUBLE_SPACE_PERIOD,
Settings.PREF_AUTOSPACE_AFTER_PUNCTUATION,
+ Settings.PREF_AUTOSPACE_AFTER_SUGGESTION,
+ if (gestureEnabled) Settings.PREF_AUTOSPACE_BEFORE_GESTURE_TYPING else null,
+ if (gestureEnabled) Settings.PREF_AUTOSPACE_AFTER_GESTURE_TYPING else null,
+ Settings.PREF_SHIFT_REMOVES_AUTOSPACE,
R.string.settings_category_suggestions,
Settings.PREF_SHOW_SUGGESTIONS,
if (suggestionsEnabled) Settings.PREF_ALWAYS_SHOW_SUGGESTIONS else null,
@@ -131,6 +138,18 @@ fun createCorrectionSettings(context: Context) = listOf(
) {
SwitchPreference(it, Defaults.PREF_AUTOSPACE_AFTER_PUNCTUATION)
},
+ Setting(context, Settings.PREF_AUTOSPACE_AFTER_SUGGESTION, R.string.autospace_after_suggestion) {
+ SwitchPreference(it, Defaults.PREF_AUTOSPACE_AFTER_SUGGESTION)
+ },
+ Setting(context, Settings.PREF_AUTOSPACE_AFTER_GESTURE_TYPING, R.string.autospace_after_gesture_typing) {
+ SwitchPreference(it, Defaults.PREF_AUTOSPACE_AFTER_GESTURE_TYPING)
+ },
+ Setting(context, Settings.PREF_AUTOSPACE_BEFORE_GESTURE_TYPING, R.string.autospace_before_gesture_typing) {
+ SwitchPreference(it, Defaults.PREF_AUTOSPACE_BEFORE_GESTURE_TYPING)
+ },
+ Setting(context, Settings.PREF_SHIFT_REMOVES_AUTOSPACE, R.string.shift_removes_autospace, R.string.shift_removes_autospace_summary) {
+ SwitchPreference(it, Defaults.PREF_SHIFT_REMOVES_AUTOSPACE)
+ },
Setting(context, Settings.PREF_SHOW_SUGGESTIONS,
R.string.prefs_show_suggestions, R.string.prefs_show_suggestions_summary
) {
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 9873295b..aecf63b6 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -38,6 +38,8 @@
Clipboard history
Corrections
+
+ Space
Suggestions
@@ -209,10 +211,20 @@
Load library
Delete library
-
+
Autospace after punctuation
-
+
Automatically insert space after punctuation when typing a new word
+
+ Autospace after picking a suggestion
+
+ Autospace before gesture typing a word
+
+ Autospace after gesture typing a word
+
+ No autospace when pressing shift
+
+ Shift removes pending autospace
Show more letters with diacritics in popup