@@ -292,6 +292,27 @@ public InputTransaction onTextInput(final SettingsValues settingsValues, final E
292
292
return inputTransaction ;
293
293
}
294
294
295
+ /** Only used when automatic spaces is set to NONE */
296
+ private void insertSuggestionAndKeepComposing (final SettingsValues settingsValues ,
297
+ final String word ,
298
+ final boolean updateSuggestions ) {
299
+ final boolean needToUpdateSuggestionStrip = updateSuggestions && word != mWordComposer .getTypedWord ();
300
+
301
+ if (word .indexOf (' ' ) != -1 || mWordComposer .isBatchMode ()) {
302
+ commitChosenWord (settingsValues , word , LastComposedWord .COMMIT_TYPE_MANUAL_PICK ,
303
+ LastComposedWord .NOT_A_SEPARATOR , 1 );
304
+ mLastComposedWord .deactivate ();
305
+ resetComposingWord (settingsValues , false );
306
+ } else {
307
+ final int [] codePoints = StringUtils .toCodePointArray (word );
308
+ mWordComposer .setComposingWord (codePoints ,
309
+ mImeHelper .getCodepointCoordinates (codePoints ));
310
+ setComposingTextInternal (word , 1 );
311
+ }
312
+
313
+ if (needToUpdateSuggestionStrip ) postUpdateSuggestionStrip (SuggestedWords .INPUT_STYLE_TYPING );
314
+ }
315
+
295
316
/**
296
317
* A suggestion was picked from the suggestion strip.
297
318
* @param settingsValues the current values of the settings.
@@ -365,6 +386,14 @@ public InputTransaction onPickSuggestionManually(final SettingsValues settingsVa
365
386
return inputTransaction ;
366
387
}
367
388
389
+ // The logic for no auto-spaces is a little different, we need to stay in composing
390
+ // state. If the suggestion has spaces in it, then we have to compose the final word.
391
+ if (settingsValues .mAltSpacesMode == Settings .SPACES_MODE_NONE ) {
392
+ insertSuggestionAndKeepComposing (settingsValues , suggestion , true );
393
+ mConnection .endBatchEdit ();
394
+ return inputTransaction ;
395
+ }
396
+
368
397
commitChosenWord (settingsValues , suggestion , LastComposedWord .COMMIT_TYPE_MANUAL_PICK ,
369
398
LastComposedWord .NOT_A_SEPARATOR , suggestionInfo .isKindOf (SuggestedWordInfo .KIND_TYPED ) ? 3 : 1 );
370
399
mConnection .endBatchEdit ();
@@ -621,7 +650,7 @@ public void onStartBatchInput(final SettingsValues settingsValues,
621
650
|| settingsValues .isUsuallyFollowedBySpace (codePointBeforeCursor )) {
622
651
final boolean autoShiftHasBeenOverriden = keyboardSwitcher .getKeyboardShiftMode () !=
623
652
getCurrentAutoCapsState (settingsValues );
624
- mSpaceState = SpaceState .PHANTOM ;
653
+ if ( settingsValues . mAltSpacesMode != Settings . SPACES_MODE_NONE ) mSpaceState = SpaceState .PHANTOM ;
625
654
if (!autoShiftHasBeenOverriden ) {
626
655
// When we change the space state, we need to update the shift state of the
627
656
// keyboard unless it has been overridden manually. This is happening for example
@@ -943,7 +972,7 @@ private void handleNonSeparatorEvent(final Event event, final SettingsValues set
943
972
insertAutomaticSpaceIfOptionsAndTextAllow (settingsValues );
944
973
}
945
974
946
- if (mWordComposer .isCursorFrontOrMiddleOfComposingWord ()) {
975
+ if (mWordComposer .isCursorFrontOrMiddleOfComposingWord () || mWordComposer . isBatchMode () ) {
947
976
// If we are in the middle of a recorrection, we need to commit the recorrection
948
977
// first so that we can insert the character at the current cursor position.
949
978
// We also need to unlearn the original word that is now being corrected.
@@ -2036,7 +2065,7 @@ private void revertCommit(final InputTransaction inputTransaction,
2036
2065
if (inputTransaction .mSettingsValues .mSpacingAndPunctuations .mCurrentLanguageHasSpaces ) {
2037
2066
mConnection .commitText (textToCommit , 1 );
2038
2067
if (usePhantomSpace ) {
2039
- mSpaceState = SpaceState .PHANTOM ;
2068
+ if ( settingsValues . mAltSpacesMode != Settings . SPACES_MODE_NONE ) mSpaceState = SpaceState .PHANTOM ;
2040
2069
}
2041
2070
} else {
2042
2071
// For languages without spaces, we revert the typed string but the cursor is flush
@@ -2353,7 +2382,7 @@ private void insertOrSetPhantomSpace(final SettingsValues settingsValues) {
2353
2382
2354
2383
mSpaceState = SpaceState .ANTIPHANTOM ;
2355
2384
sendKeyCodePoint (settingsValues , Constants .CODE_SPACE );
2356
- } else {
2385
+ } else if ( settingsValues . mAltSpacesMode != Settings . SPACES_MODE_NONE ) {
2357
2386
mSpaceState = SpaceState .PHANTOM ;
2358
2387
}
2359
2388
}
@@ -2378,7 +2407,7 @@ public void onUpdateTailBatchInputCompleted(final SettingsValues settingsValues,
2378
2407
setComposingTextInternal (batchInputText , 1 );
2379
2408
mConnection .endBatchEdit ();
2380
2409
// Space state must be updated before calling updateShiftState
2381
- mSpaceState = SpaceState .PHANTOM ;
2410
+ if ( settingsValues . mAltSpacesMode != Settings . SPACES_MODE_NONE ) mSpaceState = SpaceState .PHANTOM ;
2382
2411
keyboardSwitcher .requestUpdatingShiftState (getCurrentAutoCapsState (settingsValues ));
2383
2412
2384
2413
updateUiInputState ();
0 commit comments