mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-04-19 13:49:13 +00:00
Add more settings for autospace
fixes GH-1348 fixes GH-876
This commit is contained in:
parent
88a7f41038
commit
66a07eb8d2
7 changed files with 66 additions and 12 deletions
|
@ -474,6 +474,10 @@ public final class WordComposer {
|
|||
return mIsBatchMode;
|
||||
}
|
||||
|
||||
public void unsetBatchMode() {
|
||||
mIsBatchMode = false;
|
||||
}
|
||||
|
||||
public void setRejectedBatchModeSuggestion(final String rejectedSuggestion) {
|
||||
mRejectedBatchModeSuggestion = rejectedSuggestion;
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
) {
|
||||
|
|
|
@ -38,6 +38,8 @@
|
|||
<string name="settings_category_clipboard_history">Clipboard history</string>
|
||||
<!-- Settings category title for Text correction/Corrections -->
|
||||
<string name="settings_category_correction">Corrections</string>
|
||||
<!-- Settings category title for Text correction/Space -->
|
||||
<string name="settings_category_space">Space</string>
|
||||
<!-- Settings category title for Text correction/Suggestions -->
|
||||
<string name="settings_category_suggestions">Suggestions</string>
|
||||
<!-- Settings category title for Advanced/Experimental -->
|
||||
|
@ -209,10 +211,20 @@
|
|||
<string name="load_gesture_library_button_load">Load library</string>
|
||||
<!-- Button text for deleting gesture library -->
|
||||
<string name="load_gesture_library_button_delete">Delete library</string>
|
||||
<!-- Preferences item for enabling inserting more spaces key -->
|
||||
<!-- Preferences item for inserting space after punctuation -->
|
||||
<string name="autospace_after_punctuation">Autospace after punctuation</string>
|
||||
<!-- Description for "insert_more_spaces" option. -->
|
||||
<!-- Description for "autospace_after_punctuation" setting -->
|
||||
<string name="autospace_after_punctuation_summary">Automatically insert space after punctuation when typing a new word</string>
|
||||
<!-- Preferences item for inserting space after manualle picking a suggestion -->
|
||||
<string name="autospace_after_suggestion">Autospace after picking a suggestion</string>
|
||||
<!-- Preferences item for inserting space before entering a word using gesture typing -->
|
||||
<string name="autospace_before_gesture_typing">Autospace before gesture typing a word</string>
|
||||
<!-- Preferences item for inserting space after entering a word using gesture typing -->
|
||||
<string name="autospace_after_gesture_typing">Autospace after gesture typing a word</string>
|
||||
<!-- Preferences item for avoiding automatic space insertion by pressing shift -->
|
||||
<string name="shift_removes_autospace">No autospace when pressing shift</string>
|
||||
<!-- Description for "autospace_after_punctuation" setting -->
|
||||
<string name="shift_removes_autospace_summary">Shift removes pending autospace</string>
|
||||
<!-- Preferences item for showing popup keys in long-press popup -->
|
||||
<string name="show_popup_keys_title">Show more letters with diacritics in popup</string>
|
||||
<!-- Option for showing only letters defined in the current language file in long-press popup -->
|
||||
|
|
Loading…
Add table
Reference in a new issue