Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -988,12 +988,21 @@ private void enterCombiningMode(final SettingsValues settingsValues, final boole
final int graceMs = baseGraceMs + Math.max(0, settingsValues.mCombiningTapExtraMs);
cancelCombiningTimerOnly();
mInCombiningMode = true;
// #14 "only auto-finish swiped words": still ENTER combining mode (so a following swipe
// can extend this word), but DON'T arm the auto-commit timer for a pure tap word — it
// stays open until the user commits. A tap-then-swipe still arms: the gesture re-enters
// here with fromTap=false and the fragment present, so it arms then.
final boolean armTimer = !(fromTap && settingsValues.mCombiningGraceOnlyAfterGesture
&& !mCombiningWordHasGestureFragment && !mWordComposer.isBatchMode());
final long startTime = SystemClock.uptimeMillis();
mPendingCombiningCommit = () -> onCombiningGraceExpired();
mCombiningHandler.postDelayed(mPendingCombiningCommit, graceMs);
if (armTimer) {
mPendingCombiningCommit = () -> onCombiningGraceExpired();
mCombiningHandler.postDelayed(mPendingCombiningCommit, graceMs);
}
final MainKeyboardView kv = KeyboardSwitcher.getInstance().getMainKeyboardView();
if (kv != null) {
final boolean showAutospaceIndicator = settingsValues.shouldInsertSpacesAutomatically()
final boolean showAutospaceIndicator = armTimer
&& settingsValues.shouldInsertSpacesAutomatically()
&& settingsValues.mSpacingAndPunctuations.mCurrentLanguageHasSpaces
&& (!settingsValues.mCombiningAutospaceOnlyAfterGesture
|| mCombiningWordHasGestureFragment)
Expand Down Expand Up @@ -1309,6 +1318,12 @@ private void onCombiningGraceExpired() {
mBackspaceUnits.setCommitted(writtenChars, committedFragments);
}
// "keep_alternatives" — fall through, do nothing.
// #14 bug fix: this commit ran on the async grace timer, OFF the normal onCodeInput path
// that refreshes the shift state after a commit. Without this, the next word's auto-caps
// is stale — auto-caps gets dropped after a grace auto-commit and capitalization comes out
// erratic. Mirror the gesture-commit path's requestUpdatingShiftState.
KeyboardSwitcher.getInstance().requestUpdatingShiftState(
getCurrentAutoCapsState(sv), getCurrentRecapitalizeState());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ object Defaults {
const val PREF_COMBINING_TAP_EXTRA_MS = 250
const val PREF_COMBINING_AUTOSPACE_ONLY_AFTER_GESTURE = false
const val PREF_SPACING_DEFER_GRACE_SPACE = false
const val PREF_COMBINING_GRACE_ONLY_AFTER_GESTURE = true // default on: tapped words shouldn't auto-finish
const val PREF_COMBINING_AUTOSPACE_SUGGESTIONS = "alternatives_then_next_word"
const val PREF_COMBINING_BACKSPACE_DELETES_GESTURE_WORD = true
const val PREF_COMBINING_BACKSPACE_DELETES_COMPOSING_TEXT = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
// #23: route the two-thumb grace-mode auto-commit space through the deferred PHANTOM
// mechanism (like the default gesture path) instead of writing it eagerly. Experimental.
public static final String PREF_SPACING_DEFER_GRACE_SPACE = "spacing_defer_grace_space";
// #14: when on, the combining grace timer only auto-commits words that include a swipe —
// pure tap-typed words are never auto-finished by the timer. Experimental, default off.
public static final String PREF_COMBINING_GRACE_ONLY_AFTER_GESTURE = "combining_grace_only_after_gesture";
// What the suggestion strip shows after the combining grace timer auto-commits a word.
// Values: "keep_alternatives" (1) | "next_word" (2, default) | "alternatives_then_next_word" (3).
public static final String PREF_COMBINING_AUTOSPACE_SUGGESTIONS = "combining_autospace_suggestions";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public class SettingsValues {
public final int mCombiningTapExtraMs;
public final boolean mCombiningAutospaceOnlyAfterGesture;
public final boolean mSpacingDeferGraceSpace;
public final boolean mCombiningGraceOnlyAfterGesture;
// Raw string value: "keep_alternatives" | "next_word" | "alternatives_then_next_word"
public final String mCombiningAutospaceSuggestions;
public final boolean mCombiningBackspaceDeletesGestureWord;
Expand Down Expand Up @@ -386,6 +387,9 @@ public SettingsValues(final Context context, final SharedPreferences prefs, fina
mSpacingDeferGraceSpace = prefs.getBoolean(
Settings.PREF_SPACING_DEFER_GRACE_SPACE,
Defaults.PREF_SPACING_DEFER_GRACE_SPACE);
mCombiningGraceOnlyAfterGesture = prefs.getBoolean(
Settings.PREF_COMBINING_GRACE_ONLY_AFTER_GESTURE,
Defaults.PREF_COMBINING_GRACE_ONLY_AFTER_GESTURE);
mCombiningAutospaceSuggestions = prefs.getString(Settings.PREF_COMBINING_AUTOSPACE_SUGGESTIONS,
Defaults.PREF_COMBINING_AUTOSPACE_SUGGESTIONS);
final boolean nonNormalTwoThumbSpacing = mGestureManualSpacing || mCombiningGraceMs > 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ fun TwoThumbTypingScreen(
add(Settings.PREF_COMBINING_AUTOCORRECT_ON_AUTOSPACE)
add(Settings.PREF_COMBINING_AUTOSPACE_SUGGESTIONS)
add(Settings.PREF_SPACING_DEFER_GRACE_SPACE)
add(Settings.PREF_COMBINING_GRACE_ONLY_AFTER_GESTURE)
}
if (nonNormalSpacing) {
add(Settings.PREF_MULTIPART_FULL_WORD_SUGGESTIONS)
Expand Down Expand Up @@ -152,6 +153,11 @@ fun createTwoThumbTypingSettings(context: Context) = listOf(
R.string.spacing_defer_grace_space_summary) {
SwitchPreference(it, Defaults.PREF_SPACING_DEFER_GRACE_SPACE)
},
Setting(context, Settings.PREF_COMBINING_GRACE_ONLY_AFTER_GESTURE,
R.string.combining_grace_only_after_gesture,
R.string.combining_grace_only_after_gesture_summary) {
SwitchPreference(it, Defaults.PREF_COMBINING_GRACE_ONLY_AFTER_GESTURE)
},
Setting(context, Settings.PREF_COMBINING_AUTOSPACE_SUGGESTIONS,
R.string.combining_autospace_suggestions, R.string.combining_autospace_suggestions_summary) { def ->
val items = listOf(
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,15 @@
<string name="two_thumb_tap_autospace_grace">Extra autospace delay after taps</string>
<string name="two_thumb_tap_autospace_grace_summary">Add this much extra time when the last input was a tapped letter, so tap-then-swipe combinations are easier to continue.</string>
<string name="combining_autospace_only_after_gesture">Only auto-space after swipes</string>
<string name="combining_autospace_only_after_gesture_summary">When enabled, tap-only words are committed without an automatic space. Words that include a swipe still auto-space.</string>
<string name="combining_autospace_only_after_gesture_summary">Controls the automatic space only \u2014 not whether a word commits. When on, a tap-only word still commits but without an auto-space; swiped words still get one.</string>
<!-- Title of the experimental toggle that defers the two-thumb grace auto-commit space. -->
<string name="spacing_defer_grace_space">Defer grace space (experimental)</string>
<!-- Description for spacing_defer_grace_space. -->
<string name="spacing_defer_grace_space_summary">Route the two-thumb grace auto-commit space through the deferred mechanism (like the default swipe path) instead of writing it immediately. The space appears on your next input and stays backspace-reversible.</string>
<!-- Title of the toggle that limits the grace auto-commit timer to swiped words. -->
<string name="combining_grace_only_after_gesture">Only auto-finish swiped words</string>
<!-- Description for combining_grace_only_after_gesture. -->
<string name="combining_grace_only_after_gesture_summary">The pause timer auto-commits a word only when it includes a swipe. Words you tap out stay open until you press space or pick a suggestion, so tapped shortcuts and corrections won\'t fire early. On by default \u2014 this controls whether the word commits (the auto-space option above only controls the trailing space).</string>
<!-- Title of the toggle that makes the first backspace after a gesture delete the whole word. -->
<string name="combining_backspace_deletes_gesture_word">Backspace deletes last swipe</string>
<!-- Description for combining_backspace_deletes_gesture_word. -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ class SettingsContainerTest {
container[Settings.PREF_SPACING_DEFER_GRACE_SPACE]?.key)
}

@Test
fun combiningGraceOnlyAfterGestureSettingIsRegistered() {
assertEquals(Settings.PREF_COMBINING_GRACE_ONLY_AFTER_GESTURE,
container[Settings.PREF_COMBINING_GRACE_ONLY_AFTER_GESTURE]?.key)
}

@Test
fun twoThumbLowLevelBackspaceSettingIsHiddenFromSearchRegistry() {
assertNull(container[Settings.PREF_COMBINING_BACKSPACE_DELETES_GESTURE_WORD])
Expand Down
Loading