Skip to content

Commit ec1de5f

Browse files
committed
feat: tune double-tap shift timing and keep llamacpp proguard
1 parent 82033c7 commit ec1de5f

4 files changed

Lines changed: 13 additions & 3 deletions

File tree

app/proguard-rules.pro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727

2828
# Keep java-llama.cpp classes
2929
-keep class de.kherud.llama.** { *; }
30+
-keep class org.nehuatl.llamacpp.** { *; }
31+
3032

3133

3234
# Fix correct service name

app/src/main/java/helium314/keyboard/keyboard/KeyboardSwitcher.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ private void setMainKeyboardFrame(
366366
}
367367
mHandwritingView.setVisibility(View.GONE);
368368
}
369+
369370

370371
if (PointerTracker.sPersistentTouchpadModeActive) {
371372
if (mTouchpadView != null) {

app/src/main/java/helium314/keyboard/keyboard/internal/KeyboardState.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ class KeyboardState(private val switchActions: SwitchActions) {
7373
// For handling double tap.
7474
private var isInAlphabetUnshiftedFromShifted = false
7575
private var isInDoubleTapShiftKey = false
76+
private var lastShiftPressTime = 0L
77+
7678

7779
private val savedKeyboardState = SavedKeyboardState()
7880

@@ -515,8 +517,11 @@ class KeyboardState(private val switchActions: SwitchActions) {
515517
shiftKeyState.onPress()
516518
return
517519
}
518-
isInDoubleTapShiftKey = switchActions.isInDoubleTapShiftKeyTimeout
520+
val now = android.os.SystemClock.uptimeMillis()
521+
isInDoubleTapShiftKey = switchActions.isInDoubleTapShiftKeyTimeout && (now - lastShiftPressTime > 100)
522+
lastShiftPressTime = now
519523
if (isInDoubleTapShiftKey) {
524+
520525
if (alphabetShiftState.isManualShifted || isInAlphabetUnshiftedFromShifted) {
521526
// Shift key has been double tapped while in manual shifted or automatic shifted state.
522527
setShiftLocked(true)

app/src/main/java/helium314/keyboard/keyboard/internal/TimerHandler.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,10 @@ public boolean isTypingState() {
163163

164164
@Override
165165
public void startDoubleTapShiftKeyTimer() {
166-
sendMessageDelayed(obtainMessage(MSG_DOUBLE_TAP_SHIFT_KEY),
167-
ViewConfiguration.getDoubleTapTimeout());
166+
sendMessageDelayed(obtainMessage(MSG_DOUBLE_TAP_SHIFT_KEY), 300);
168167
}
169168

169+
170170
@Override
171171
public void cancelDoubleTapShiftKeyTimer() {
172172
removeMessages(MSG_DOUBLE_TAP_SHIFT_KEY);
@@ -218,8 +218,10 @@ public void postDismissGestureFloatingPreviewText(final long delay) {
218218

219219
public void cancelAllMessages() {
220220
cancelAllKeyTimers();
221+
cancelDoubleTapShiftKeyTimer();
221222
cancelAllUpdateBatchInputTimers();
222223
removeMessages(MSG_DISMISS_KEY_PREVIEW);
223224
removeMessages(MSG_DISMISS_GESTURE_FLOATING_PREVIEW_TEXT);
224225
}
225226
}
227+

0 commit comments

Comments
 (0)