trying to fix swipe cursor

This commit is contained in:
dslul 2020-09-08 12:38:04 +02:00
parent 5e2dbda4e0
commit c3276b943b

View file

@ -36,7 +36,6 @@ 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;
@ -1356,10 +1355,18 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
@Override
public void onMovePointer(int steps) {
for (; steps < 0; steps++)
mInputLogic.sendDownUpKeyEvent(KeyEvent.KEYCODE_DPAD_LEFT);
for (; steps > 0; steps--)
mInputLogic.sendDownUpKeyEvent(KeyEvent.KEYCODE_DPAD_RIGHT);
if (steps < 0) {
int availableCharacters = mInputLogic.mConnection.getTextBeforeCursor(64, 0).length();
steps = availableCharacters < -steps ? -availableCharacters : steps;
}
else if (steps > 0) {
int availableCharacters = mInputLogic.mConnection.getTextAfterCursor(64, 0).length();
steps = Math.min(availableCharacters, steps);
} else
return;
int newPosition = mInputLogic.mConnection.mExpectedSelStart + steps;
mInputLogic.mConnection.setSelection(newPosition, newPosition);
}
@Override
@ -1371,12 +1378,11 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
mInputLogic.mConnection.setSelection(start, end);
}
@Override
public void onUpWithDeletePointerActive() {
if (mInputLogic.mConnection.hasSelection()) {
mInputLogic.sendDownUpKeyEvent(KeyEvent.KEYCODE_DEL);
mInputLogic.sendDownUpKeyEvent(KeyEvent.KEYCODE_SHIFT_LEFT);
mInputLogic.finishInput();
onCodeInput(Constants.CODE_DELETE, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE, false);
}
}