change swipe cursor behaviour to use left/right keys

This commit is contained in:
dslul 2020-09-04 19:46:06 +02:00
parent 8e4c01941e
commit 48b9ac9967

View file

@ -36,6 +36,7 @@ import android.os.IBinder;
import android.os.Message;
import android.preference.PreferenceManager;
import android.text.InputType;
import android.text.TextUtils;
import android.util.Log;
import android.util.PrintWriterPrinter;
import android.util.Printer;
@ -1355,17 +1356,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
@Override
public void onMovePointer(int steps) {
if (steps < 0) {
int availableCharacters = getCurrentInputConnection().getTextBeforeCursor(64, 0).length();
steps = availableCharacters < -steps ? -availableCharacters : steps;
}
else if (steps > 0) {
int availableCharacters = getCurrentInputConnection().getTextAfterCursor(64, 0).length();
steps = availableCharacters < steps ? availableCharacters : steps;
} else return;
int newPosition = mInputLogic.mConnection.mExpectedSelStart + steps;
getCurrentInputConnection().setSelection(newPosition, newPosition);
for (; steps < 0; steps++)
mInputLogic.sendDownUpKeyEvent(KeyEvent.KEYCODE_DPAD_LEFT);
for (; steps > 0; steps--)
mInputLogic.sendDownUpKeyEvent(KeyEvent.KEYCODE_DPAD_RIGHT);
}
@Override
@ -1377,6 +1371,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
mInputLogic.mConnection.setSelection(start, end);
}
@Override
public void onUpWithDeletePointerActive() {
if (mInputLogic.mConnection.hasSelection()) {