Skip to content

Commit

Permalink
Backspace swipe right to delete word and Slide gestures improvements (#…
Browse files Browse the repository at this point in the history
…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 #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 (#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 <dessalines@users.noreply.github.com>
Co-authored-by: Dessalines <tyhou13@gmx.com>
Co-authored-by: Wade <wadewtaylor@live.co.uk>
  • Loading branch information
4 people committed Oct 20, 2023
1 parent 02f0bce commit a14f7ab
Show file tree
Hide file tree
Showing 10 changed files with 545 additions and 132 deletions.
41 changes: 40 additions & 1 deletion app/src/main/java/com/dessalines/thumbkey/db/AppDb.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ const val DEFAULT_KEY_BORDERS = 1
const val DEFAULT_SPACEBAR_MULTITAPS = 1
const val DEFAULT_SLIDE_SENSITIVITY = 9
const val DEFAULT_SLIDE_ENABLED = 0
const val DEFAULT_SLIDE_CURSOR_MOVEMENT_MODE = 0
const val DEFAULT_SLIDE_SPACEBAR_DEADZONE_ENABLED = 1
const val DEFAULT_SLIDE_BACKSPACE_DEADZONE_ENABLED = 1
const val DEFAULT_BACKDROP_ENABLED = 0
const val DEFAULT_KEY_PADDING = 0
const val DEFAULT_KEY_BORDER_WIDTH = 1
Expand Down Expand Up @@ -97,6 +100,21 @@ data class AppSettings(
defaultValue = DEFAULT_SLIDE_ENABLED.toString(),
)
val slideEnabled: Int,
@ColumnInfo(
name = "slide_cursor_movement_mode",
defaultValue = DEFAULT_SLIDE_CURSOR_MOVEMENT_MODE.toString(),
)
val slideCursorMovementMode: Int,
@ColumnInfo(
name = "slide_spacebar_deadzone_enabled",
defaultValue = DEFAULT_SLIDE_SPACEBAR_DEADZONE_ENABLED.toString(),
)
val slideSpacebarDeadzoneEnabled: Int,
@ColumnInfo(
name = "slide_backspace_deadzone_enabled",
defaultValue = DEFAULT_SLIDE_BACKSPACE_DEADZONE_ENABLED.toString(),
)
val slideBackspaceDeadzoneEnabled: Int,
@ColumnInfo(
name = "sound_on_tap",
defaultValue = DEFAULT_SOUND_ON_TAP.toString(),
Expand Down Expand Up @@ -273,6 +291,12 @@ data class BehaviorUpdate(
val slideSensitivity: Int,
@ColumnInfo(name = "slide_enabled")
val slideEnabled: Int,
@ColumnInfo(name = "slide_cursor_movement_mode")
val slideCursorMovementMode: Int,
@ColumnInfo(name = "slide_spacebar_deadzone_enabled")
val slideSpacebarDeadzoneEnabled: Int,
@ColumnInfo(name = "slide_backspace_deadzone_enabled")
val slideBackspaceDeadzoneEnabled: Int,
@ColumnInfo(name = "auto_capitalize")
val autoCapitalize: Int,
@ColumnInfo(name = "spacebar_multitaps")
Expand Down Expand Up @@ -462,8 +486,22 @@ val MIGRATION_11_12 = object : Migration(11, 12) {
}
}

val MIGRATION_12_13 = object : Migration(12, 13) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL(
"alter table AppSettings add column slide_spacebar_deadzone_enabled INTEGER NOT NULL default $DEFAULT_SLIDE_SPACEBAR_DEADZONE_ENABLED",
)
database.execSQL(
"alter table AppSettings add column slide_backspace_deadzone_enabled INTEGER NOT NULL default $DEFAULT_SLIDE_BACKSPACE_DEADZONE_ENABLED",
)
database.execSQL(
"alter table AppSettings add column slide_cursor_movement_mode INTEGER NOT NULL default $DEFAULT_SLIDE_CURSOR_MOVEMENT_MODE",
)
}
}

@Database(
version = 12,
version = 13,
entities = [AppSettings::class],
exportSchema = true,
)
Expand Down Expand Up @@ -498,6 +536,7 @@ abstract class AppDB : RoomDatabase() {
MIGRATION_9_10,
MIGRATION_10_11,
MIGRATION_11_12,
MIGRATION_12_13,
)
// Necessary because it can't insert data on creation
.addCallback(object : Callback() {
Expand Down
56 changes: 25 additions & 31 deletions app/src/main/java/com/dessalines/thumbkey/keyboards/CommonKeys.kt
Original file line number Diff line number Diff line change
Expand Up @@ -144,20 +144,12 @@ val BACKSPACE_KEY_ITEM =
slideType = SlideType.DELETE,
swipes = mapOf(
SwipeDirection.LEFT to KeyC(
action = KeyAction.DeleteLastWord,
action = KeyAction.DeleteWordBeforeCursor,
display = null,
),
SwipeDirection.RIGHT to KeyC(
action = KeyAction.SendEvent(
KeyEvent(
KeyEvent.ACTION_DOWN,
KeyEvent
.KEYCODE_FORWARD_DEL,
),
),
action = KeyAction.DeleteWordAfterCursor,
display = null,
color = ColorVariant.MUTED,
size = FontSizeVariant.SMALLEST,
),
),
backgroundColor = ColorVariant.SURFACE_VARIANT,
Expand All @@ -169,9 +161,27 @@ val SPACEBAR_KEY_ITEM =
display = KeyDisplay.TextDisplay(" "),
action = KeyAction.CommitText(" "),
),
swipeType = SwipeNWay.TWO_WAY_HORIZONTAL,
swipeType = SwipeNWay.FOUR_WAY_CROSS,
slideType = SlideType.MOVE_CURSOR,
swipes = mapOf(
SwipeDirection.TOP to KeyC(
action = KeyAction.SendEvent(
KeyEvent(
KeyEvent.ACTION_DOWN,
KeyEvent.KEYCODE_DPAD_UP,
),
),
display = null,
),
SwipeDirection.BOTTOM to KeyC(
action = KeyAction.SendEvent(
KeyEvent(
KeyEvent.ACTION_DOWN,
KeyEvent.KEYCODE_DPAD_DOWN,
),
),
display = null,
),
SwipeDirection.LEFT to KeyC(
action = KeyAction.SendEvent(
KeyEvent(
Expand Down Expand Up @@ -463,20 +473,12 @@ val BACKSPACE_TYPESPLIT_KEY_ITEM =
swipeType = SwipeNWay.FOUR_WAY_CROSS,
swipes = mapOf(
SwipeDirection.LEFT to KeyC(
action = KeyAction.DeleteLastWord,
action = KeyAction.DeleteWordBeforeCursor,
display = null,
),
SwipeDirection.RIGHT to KeyC(
action = KeyAction.SendEvent(
KeyEvent(
KeyEvent.ACTION_DOWN,
KeyEvent
.KEYCODE_FORWARD_DEL,
),
),
action = KeyAction.DeleteWordAfterCursor,
display = null,
color = ColorVariant.MUTED,
size = FontSizeVariant.SMALLEST,
),
SwipeDirection.TOP to KeyC(
display = KeyDisplay.IconDisplay(Icons.Outlined.ArrowDropUp),
Expand All @@ -490,20 +492,12 @@ val BACKSPACE_TYPESPLIT_KEY_ITEM =
val BACKSPACE_TYPESPLIT_SHIFTED_KEY_ITEM = BACKSPACE_TYPESPLIT_KEY_ITEM.copy(
swipes = mapOf(
SwipeDirection.LEFT to KeyC(
action = KeyAction.DeleteLastWord,
action = KeyAction.DeleteWordBeforeCursor,
display = null,
),
SwipeDirection.RIGHT to KeyC(
action = KeyAction.SendEvent(
KeyEvent(
KeyEvent.ACTION_DOWN,
KeyEvent
.KEYCODE_FORWARD_DEL,
),
),
action = KeyAction.DeleteWordAfterCursor,
display = null,
color = ColorVariant.MUTED,
size = FontSizeVariant.SMALLEST,
),
SwipeDirection.TOP to KeyC(
display = KeyDisplay.IconDisplay(Icons.Outlined.KeyboardCapslock),
Expand Down
24 changes: 6 additions & 18 deletions app/src/main/java/com/dessalines/thumbkey/keyboards/T9.kt
Original file line number Diff line number Diff line change
Expand Up @@ -371,14 +371,8 @@ val KB_T9_MAIN = KeyboardC(
color = ColorVariant.MUTED,
),
SwipeDirection.RIGHT to KeyC(
display = KeyDisplay.TextDisplay(""),
action = KeyAction.SendEvent(
KeyEvent(
KeyEvent.ACTION_DOWN,
KeyEvent
.KEYCODE_FORWARD_DEL,
),
),
display = KeyDisplay.TextDisplay(""),
action = KeyAction.DeleteWordAfterCursor,
color = ColorVariant.MUTED,
),
SwipeDirection.BOTTOM to KeyC(
Expand All @@ -388,7 +382,7 @@ val KB_T9_MAIN = KeyboardC(
),
SwipeDirection.LEFT to KeyC(
display = KeyDisplay.TextDisplay(""),
action = KeyAction.DeleteLastWord,
action = KeyAction.DeleteWordBeforeCursor,
color = ColorVariant.MUTED,
),
),
Expand Down Expand Up @@ -924,14 +918,8 @@ val KB_T9_SHIFTED = KeyboardC(
color = ColorVariant.MUTED,
),
SwipeDirection.RIGHT to KeyC(
display = KeyDisplay.TextDisplay(""),
action = KeyAction.SendEvent(
KeyEvent(
KeyEvent.ACTION_DOWN,
KeyEvent
.KEYCODE_FORWARD_DEL,
),
),
display = KeyDisplay.TextDisplay(""),
action = KeyAction.DeleteWordAfterCursor,
color = ColorVariant.MUTED,
),
SwipeDirection.BOTTOM to KeyC(
Expand All @@ -941,7 +929,7 @@ val KB_T9_SHIFTED = KeyboardC(
),
SwipeDirection.LEFT to KeyC(
display = KeyDisplay.TextDisplay(""),
action = KeyAction.DeleteLastWord,
action = KeyAction.DeleteWordBeforeCursor,
color = ColorVariant.MUTED,
),
),
Expand Down
Loading

0 comments on commit a14f7ab

Please sign in to comment.