Skip to content

Commit a14f7ab

Browse files
sslater11dessalinesWadeWT
authored
Backspace swipe right to delete word and Slide gestures improvements (dessalines#439)
* Grouped together 'slide gestures checkbox' and 'slide sensitivity slider' in settings. * Enable/Disable 'Slide sensitivity' slider when the 'slide gestures' checkbox is ticked/unticked. * Better swipe selection toggle and better swipe delete toggle. * Made swiping right on backspace key delete a whole word to the right. * Swipe up or down to toggle slide gestures text selection. * Added a deadzone for slide gestures to allow normal swipes on spacebar and improved backspace deadzone * Added up and down swipes to spacebar to move cursor up and down. * Fixes dessalines#410 - Added cursor acceleration for slide gestures on the spacebar and backspace key. * Format kotlin * Fixing merge issue. * Fixed issue with selected text being deleted when we use the spacebar slide gesture * Copy/Cut actions now copy/cut all text if nothing is selected (dessalines#469) * Adding threshold acceleration * Added more cursor acceleration modes. * DB Migration: Added settings menu for slide gestures cursor acceleration and deadzone enable/disable. * Grouped all slide gesture settings together. * Added slide gestures Threshold Acceleration to the settings menu. --------- Co-authored-by: Dessalines <[email protected]> Co-authored-by: Dessalines <[email protected]> Co-authored-by: Wade <[email protected]>
1 parent 02f0bce commit a14f7ab

File tree

10 files changed

+545
-132
lines changed

10 files changed

+545
-132
lines changed

app/src/main/java/com/dessalines/thumbkey/db/AppDb.kt

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ const val DEFAULT_KEY_BORDERS = 1
4949
const val DEFAULT_SPACEBAR_MULTITAPS = 1
5050
const val DEFAULT_SLIDE_SENSITIVITY = 9
5151
const val DEFAULT_SLIDE_ENABLED = 0
52+
const val DEFAULT_SLIDE_CURSOR_MOVEMENT_MODE = 0
53+
const val DEFAULT_SLIDE_SPACEBAR_DEADZONE_ENABLED = 1
54+
const val DEFAULT_SLIDE_BACKSPACE_DEADZONE_ENABLED = 1
5255
const val DEFAULT_BACKDROP_ENABLED = 0
5356
const val DEFAULT_KEY_PADDING = 0
5457
const val DEFAULT_KEY_BORDER_WIDTH = 1
@@ -97,6 +100,21 @@ data class AppSettings(
97100
defaultValue = DEFAULT_SLIDE_ENABLED.toString(),
98101
)
99102
val slideEnabled: Int,
103+
@ColumnInfo(
104+
name = "slide_cursor_movement_mode",
105+
defaultValue = DEFAULT_SLIDE_CURSOR_MOVEMENT_MODE.toString(),
106+
)
107+
val slideCursorMovementMode: Int,
108+
@ColumnInfo(
109+
name = "slide_spacebar_deadzone_enabled",
110+
defaultValue = DEFAULT_SLIDE_SPACEBAR_DEADZONE_ENABLED.toString(),
111+
)
112+
val slideSpacebarDeadzoneEnabled: Int,
113+
@ColumnInfo(
114+
name = "slide_backspace_deadzone_enabled",
115+
defaultValue = DEFAULT_SLIDE_BACKSPACE_DEADZONE_ENABLED.toString(),
116+
)
117+
val slideBackspaceDeadzoneEnabled: Int,
100118
@ColumnInfo(
101119
name = "sound_on_tap",
102120
defaultValue = DEFAULT_SOUND_ON_TAP.toString(),
@@ -273,6 +291,12 @@ data class BehaviorUpdate(
273291
val slideSensitivity: Int,
274292
@ColumnInfo(name = "slide_enabled")
275293
val slideEnabled: Int,
294+
@ColumnInfo(name = "slide_cursor_movement_mode")
295+
val slideCursorMovementMode: Int,
296+
@ColumnInfo(name = "slide_spacebar_deadzone_enabled")
297+
val slideSpacebarDeadzoneEnabled: Int,
298+
@ColumnInfo(name = "slide_backspace_deadzone_enabled")
299+
val slideBackspaceDeadzoneEnabled: Int,
276300
@ColumnInfo(name = "auto_capitalize")
277301
val autoCapitalize: Int,
278302
@ColumnInfo(name = "spacebar_multitaps")
@@ -462,8 +486,22 @@ val MIGRATION_11_12 = object : Migration(11, 12) {
462486
}
463487
}
464488

489+
val MIGRATION_12_13 = object : Migration(12, 13) {
490+
override fun migrate(database: SupportSQLiteDatabase) {
491+
database.execSQL(
492+
"alter table AppSettings add column slide_spacebar_deadzone_enabled INTEGER NOT NULL default $DEFAULT_SLIDE_SPACEBAR_DEADZONE_ENABLED",
493+
)
494+
database.execSQL(
495+
"alter table AppSettings add column slide_backspace_deadzone_enabled INTEGER NOT NULL default $DEFAULT_SLIDE_BACKSPACE_DEADZONE_ENABLED",
496+
)
497+
database.execSQL(
498+
"alter table AppSettings add column slide_cursor_movement_mode INTEGER NOT NULL default $DEFAULT_SLIDE_CURSOR_MOVEMENT_MODE",
499+
)
500+
}
501+
}
502+
465503
@Database(
466-
version = 12,
504+
version = 13,
467505
entities = [AppSettings::class],
468506
exportSchema = true,
469507
)
@@ -498,6 +536,7 @@ abstract class AppDB : RoomDatabase() {
498536
MIGRATION_9_10,
499537
MIGRATION_10_11,
500538
MIGRATION_11_12,
539+
MIGRATION_12_13,
501540
)
502541
// Necessary because it can't insert data on creation
503542
.addCallback(object : Callback() {

app/src/main/java/com/dessalines/thumbkey/keyboards/CommonKeys.kt

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -144,20 +144,12 @@ val BACKSPACE_KEY_ITEM =
144144
slideType = SlideType.DELETE,
145145
swipes = mapOf(
146146
SwipeDirection.LEFT to KeyC(
147-
action = KeyAction.DeleteLastWord,
147+
action = KeyAction.DeleteWordBeforeCursor,
148148
display = null,
149149
),
150150
SwipeDirection.RIGHT to KeyC(
151-
action = KeyAction.SendEvent(
152-
KeyEvent(
153-
KeyEvent.ACTION_DOWN,
154-
KeyEvent
155-
.KEYCODE_FORWARD_DEL,
156-
),
157-
),
151+
action = KeyAction.DeleteWordAfterCursor,
158152
display = null,
159-
color = ColorVariant.MUTED,
160-
size = FontSizeVariant.SMALLEST,
161153
),
162154
),
163155
backgroundColor = ColorVariant.SURFACE_VARIANT,
@@ -169,9 +161,27 @@ val SPACEBAR_KEY_ITEM =
169161
display = KeyDisplay.TextDisplay(" "),
170162
action = KeyAction.CommitText(" "),
171163
),
172-
swipeType = SwipeNWay.TWO_WAY_HORIZONTAL,
164+
swipeType = SwipeNWay.FOUR_WAY_CROSS,
173165
slideType = SlideType.MOVE_CURSOR,
174166
swipes = mapOf(
167+
SwipeDirection.TOP to KeyC(
168+
action = KeyAction.SendEvent(
169+
KeyEvent(
170+
KeyEvent.ACTION_DOWN,
171+
KeyEvent.KEYCODE_DPAD_UP,
172+
),
173+
),
174+
display = null,
175+
),
176+
SwipeDirection.BOTTOM to KeyC(
177+
action = KeyAction.SendEvent(
178+
KeyEvent(
179+
KeyEvent.ACTION_DOWN,
180+
KeyEvent.KEYCODE_DPAD_DOWN,
181+
),
182+
),
183+
display = null,
184+
),
175185
SwipeDirection.LEFT to KeyC(
176186
action = KeyAction.SendEvent(
177187
KeyEvent(
@@ -463,20 +473,12 @@ val BACKSPACE_TYPESPLIT_KEY_ITEM =
463473
swipeType = SwipeNWay.FOUR_WAY_CROSS,
464474
swipes = mapOf(
465475
SwipeDirection.LEFT to KeyC(
466-
action = KeyAction.DeleteLastWord,
476+
action = KeyAction.DeleteWordBeforeCursor,
467477
display = null,
468478
),
469479
SwipeDirection.RIGHT to KeyC(
470-
action = KeyAction.SendEvent(
471-
KeyEvent(
472-
KeyEvent.ACTION_DOWN,
473-
KeyEvent
474-
.KEYCODE_FORWARD_DEL,
475-
),
476-
),
480+
action = KeyAction.DeleteWordAfterCursor,
477481
display = null,
478-
color = ColorVariant.MUTED,
479-
size = FontSizeVariant.SMALLEST,
480482
),
481483
SwipeDirection.TOP to KeyC(
482484
display = KeyDisplay.IconDisplay(Icons.Outlined.ArrowDropUp),
@@ -490,20 +492,12 @@ val BACKSPACE_TYPESPLIT_KEY_ITEM =
490492
val BACKSPACE_TYPESPLIT_SHIFTED_KEY_ITEM = BACKSPACE_TYPESPLIT_KEY_ITEM.copy(
491493
swipes = mapOf(
492494
SwipeDirection.LEFT to KeyC(
493-
action = KeyAction.DeleteLastWord,
495+
action = KeyAction.DeleteWordBeforeCursor,
494496
display = null,
495497
),
496498
SwipeDirection.RIGHT to KeyC(
497-
action = KeyAction.SendEvent(
498-
KeyEvent(
499-
KeyEvent.ACTION_DOWN,
500-
KeyEvent
501-
.KEYCODE_FORWARD_DEL,
502-
),
503-
),
499+
action = KeyAction.DeleteWordAfterCursor,
504500
display = null,
505-
color = ColorVariant.MUTED,
506-
size = FontSizeVariant.SMALLEST,
507501
),
508502
SwipeDirection.TOP to KeyC(
509503
display = KeyDisplay.IconDisplay(Icons.Outlined.KeyboardCapslock),

app/src/main/java/com/dessalines/thumbkey/keyboards/T9.kt

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -371,14 +371,8 @@ val KB_T9_MAIN = KeyboardC(
371371
color = ColorVariant.MUTED,
372372
),
373373
SwipeDirection.RIGHT to KeyC(
374-
display = KeyDisplay.TextDisplay(""),
375-
action = KeyAction.SendEvent(
376-
KeyEvent(
377-
KeyEvent.ACTION_DOWN,
378-
KeyEvent
379-
.KEYCODE_FORWARD_DEL,
380-
),
381-
),
374+
display = KeyDisplay.TextDisplay(""),
375+
action = KeyAction.DeleteWordAfterCursor,
382376
color = ColorVariant.MUTED,
383377
),
384378
SwipeDirection.BOTTOM to KeyC(
@@ -388,7 +382,7 @@ val KB_T9_MAIN = KeyboardC(
388382
),
389383
SwipeDirection.LEFT to KeyC(
390384
display = KeyDisplay.TextDisplay(""),
391-
action = KeyAction.DeleteLastWord,
385+
action = KeyAction.DeleteWordBeforeCursor,
392386
color = ColorVariant.MUTED,
393387
),
394388
),
@@ -924,14 +918,8 @@ val KB_T9_SHIFTED = KeyboardC(
924918
color = ColorVariant.MUTED,
925919
),
926920
SwipeDirection.RIGHT to KeyC(
927-
display = KeyDisplay.TextDisplay(""),
928-
action = KeyAction.SendEvent(
929-
KeyEvent(
930-
KeyEvent.ACTION_DOWN,
931-
KeyEvent
932-
.KEYCODE_FORWARD_DEL,
933-
),
934-
),
921+
display = KeyDisplay.TextDisplay(""),
922+
action = KeyAction.DeleteWordAfterCursor,
935923
color = ColorVariant.MUTED,
936924
),
937925
SwipeDirection.BOTTOM to KeyC(
@@ -941,7 +929,7 @@ val KB_T9_SHIFTED = KeyboardC(
941929
),
942930
SwipeDirection.LEFT to KeyC(
943931
display = KeyDisplay.TextDisplay(""),
944-
action = KeyAction.DeleteLastWord,
932+
action = KeyAction.DeleteWordBeforeCursor,
945933
color = ColorVariant.MUTED,
946934
),
947935
),

0 commit comments

Comments
 (0)