Use CODE_DELETE instead of KEYCODE_DEL event for delete pointer

This commit is contained in:
Aleksandras Kostarevas 2024-03-18 15:06:13 -05:00
parent 12110e96aa
commit 9410e5a825
3 changed files with 21 additions and 3 deletions

View File

@ -1399,14 +1399,21 @@ public class LatinIMELegacy implements KeyboardActionListener,
mInputLogic.mConnection.setSelection(start, end); mInputLogic.mConnection.setSelection(start, end);
} else { } else {
for (; steps < 0; steps++) for (; steps < 0; steps++)
mInputLogic.sendDownUpKeyEvent(KeyEvent.KEYCODE_DEL, 0); onCodeInput(
Constants.CODE_DELETE,
Constants.NOT_A_COORDINATE,
Constants.NOT_A_COORDINATE, false);
} }
} }
@Override @Override
public void onUpWithDeletePointerActive() { public void onUpWithDeletePointerActive() {
if (mInputLogic.mConnection.hasSelection()) if (mInputLogic.mConnection.hasSelection()) {
mInputLogic.sendDownUpKeyEvent(KeyEvent.KEYCODE_DEL, 0); onCodeInput(
Constants.CODE_DELETE,
Constants.NOT_A_COORDINATE,
Constants.NOT_A_COORDINATE, false);
}
} }
@Override @Override

View File

@ -2429,6 +2429,9 @@ public final class InputLogic {
end = cursor; end = cursor;
} }
start = Math.max(0, start);
end = Math.max(0, end);
mConnection.setSelection(start, end); mConnection.setSelection(start, end);
} }

View File

@ -22,6 +22,14 @@ object EmojiTracker {
} }
} }
suspend fun Context.unuseEmoji(emoji: String) {
dataStore.edit {
val split = (it[lastUsedEmoji] ?: "").split("<|>")
val idxToRemove = split.indexOfFirst { v -> v == emoji }
it[lastUsedEmoji] = split.filterIndexed { i, _ -> i != idxToRemove}.joinToString("<|>")
}
}
suspend fun Context.getRecentEmojis(): List<String> { suspend fun Context.getRecentEmojis(): List<String> {
return getSetting(lastUsedEmoji, "") return getSetting(lastUsedEmoji, "")
.split("<|>") .split("<|>")