mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Add option to undo slide deletion
This commit is contained in:
parent
740bd08e28
commit
474839f60b
@ -1002,9 +1002,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
|
||||
|
||||
if(mCursorMoved && currentKey.getCode() == Constants.CODE_DELETE) {
|
||||
sListener.onUpWithDeletePointerActive();
|
||||
}
|
||||
|
||||
if(mCursorMoved) {
|
||||
} else if(mCursorMoved) {
|
||||
sListener.onUpWithPointerActive();
|
||||
}
|
||||
|
||||
|
@ -1422,6 +1422,27 @@ public class LatinIMELegacy implements KeyboardActionListener,
|
||||
@Override
|
||||
public void onUpWithDeletePointerActive() {
|
||||
if (mInputLogic.mConnection.hasSelection()) {
|
||||
CharSequence selection = mInputLogic.mConnection.getSelectedText(0);
|
||||
if(selection != null) {
|
||||
ArrayList<SuggestedWordInfo> info = new ArrayList<>();
|
||||
info.add(new SuggestedWordInfo(
|
||||
selection.toString(),
|
||||
"",
|
||||
0,
|
||||
SuggestedWordInfo.KIND_UNDO,
|
||||
null,
|
||||
0,
|
||||
0));
|
||||
showSuggestionStrip(new SuggestedWords(info,
|
||||
null,
|
||||
null,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
0,
|
||||
0));
|
||||
((LatinIME)mInputMethodService).languageModelFacilitator.ignoreNextUpdate();
|
||||
}
|
||||
onCodeInput(
|
||||
Constants.CODE_DELETE,
|
||||
Constants.NOT_A_COORDINATE,
|
||||
|
@ -256,6 +256,7 @@ public class SuggestedWords {
|
||||
public static final int KIND_RESUMED = 9;
|
||||
public static final int KIND_OOV_CORRECTION = 10; // Most probable string correction
|
||||
public static final int KIND_EMOJI_SUGGESTION = 11;
|
||||
public static final int KIND_UNDO = 12;
|
||||
|
||||
public static final int KIND_FLAG_POSSIBLY_OFFENSIVE = 0x80000000;
|
||||
public static final int KIND_FLAG_EXACT_MATCH = 0x40000000;
|
||||
|
@ -303,6 +303,18 @@ public final class InputLogic {
|
||||
// Manual pick affects the contents of the editor, so we take note of this. It's important
|
||||
// for the sequence of language switching.
|
||||
inputTransaction.setDidAffectContents();
|
||||
|
||||
if(suggestionInfo.mKindAndFlags == SuggestedWordInfo.KIND_UNDO) {
|
||||
inputTransaction.setRequiresUpdateSuggestions();
|
||||
|
||||
mConnection.finishComposingText();
|
||||
mWordComposer.reset();
|
||||
|
||||
mConnection.commitText(suggestionInfo.mWord, 1);
|
||||
|
||||
return inputTransaction;
|
||||
}
|
||||
|
||||
mConnection.beginBatchEdit();
|
||||
if (SpaceState.PHANTOM == mSpaceState && suggestion.length() > 0
|
||||
// In the batch input mode, a manually picked suggested word should just replace
|
||||
|
@ -398,6 +398,9 @@ public class LanguageModelFacilitator(
|
||||
wordComposer, values.inputStyle, true, -1, locale, suggestionResults, settingsValues.mAutoCorrectionThreshold)
|
||||
|
||||
job.cancel()
|
||||
|
||||
// TODO
|
||||
if(values.sequenceId < currentSequenceId) return
|
||||
inputLogic.mSuggestionStripViewAccessor.showSuggestionStrip(suggestedWords)
|
||||
|
||||
if(values.composedData.mIsBatchMode) {
|
||||
@ -490,6 +493,11 @@ public class LanguageModelFacilitator(
|
||||
|
||||
if(!inputLogic.mConnection.isConnected) return
|
||||
|
||||
if(ignoringNextUpdate) {
|
||||
ignoringNextUpdate = false
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
val wordComposer = inputLogic.mWordComposer
|
||||
val ngramContext = inputLogic.getNgramContextFromNthPreviousWordForSuggestion(
|
||||
@ -621,5 +629,11 @@ public class LanguageModelFacilitator(
|
||||
public fun onStartInput() {
|
||||
transformerDisabled = false
|
||||
numConsecutiveTimeouts = 0
|
||||
ignoringNextUpdate = false
|
||||
}
|
||||
|
||||
var ignoringNextUpdate = false
|
||||
fun ignoreNextUpdate() {
|
||||
ignoringNextUpdate = true
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user