Skip to content

Add swipe to delete, swipe to restore, and interactive onboarding tutorial #623

Open
prince-0408 wants to merge 3 commits into
scribe-org:mainfrom
prince-0408:swipe-gesture
Open

Add swipe to delete, swipe to restore, and interactive onboarding tutorial #623
prince-0408 wants to merge 3 commits into
scribe-org:mainfrom
prince-0408:swipe-gesture

Conversation

@prince-0408

Copy link
Copy Markdown
Contributor

Closes #622

Summary

Implements swipe-based text editing and a one-time interactive onboarding tutorial
for Scribe Keyboard. Users can now swipe left to delete and swipe right to restore
text, with haptic feedback on each step. First-time users are guided through both
gestures via a live practice overlay before it dismisses itself.


What's changed

Swipe left — delete

  • Swipe left anywhere on the keyboard to delete the previous word or character
  • Deletion mode (word vs. character) follows the user's existing backspace preference
  • Haptic tick fires on each 45px step of travel
  • Gesture registers after 80px horizontal threshold; aborts default key click

Swipe right — restore

  • Swipe right to restore the most recently deleted block from a stack, in sequence
  • Stack is cleared automatically on cursor movement or normal key input to prevent
    stale restoration context

Interactive onboarding tutorial

  • Shown once on first launch, controlled by swipe_tutorial_shown preference
  • Overlay is non-blocking — touches pass through so users practice on the real keyboard
  • "Scribe " is auto-inserted at tutorial start for immediate hands-on practice
  • Skip dismisses at any step; Got it! dismisses from the success screen
  • Both actions save the preference so the tutorial never reappears

Tutorial steps

Step Instruction Advances when
1 Swipe left to delete "Scribe " Word successfully deleted
2 Swipe right to restore "Scribe " Word successfully restored
Tap Got it! to finish Preference saved, overlay closed

Files changed

Logic

File Changes
KeyboardView.kt Added onSwipeLeft() and onSwipeRight() to the action listener interface. Tracks horizontal gesture travel in onModifiedTouchEvent(), aborts default click handling during swipe, fires haptic feedback.
BackspaceHandler.kt Introduced deletedChunksStack (java.util.Stack). Added performSwipeDelete() (push + delete) and performSwipeRestore() (pop + insert). Stack clears on cursor movement or direct key input.
GeneralKeyboardIME.kt Declares SwipeTutorialState enum (NOT_ACTIVE, SWIPE_LEFT_STEP, SWIPE_RIGHT_STEP, COMPLETED). Routes gesture events, drives tutorial step progression, auto-inserts "Scribe " at tutorial start.

Layout & assets

File Changes
input_method_view.xml Set android:clickable="false" and android:focusable="false" on the tutorial overlay for touch pass-through. Redesigned to show one instruction, one illustration, and one action button at a time.
ic_swipe_left.xml Updated — three-key outline with indigo/blue gesture trail.
ic_swipe_right.xml Updated — three-key outline with emerald green gesture trail.
ic_swipe_success.xml New — three-key outline with emerald green checkmark.

Tests

File Changes
BackspaceHandlerTest.kt JUnit/Robolectric tests covering stack push/pop behaviour, deletion offsets, character vs. word-by-word modes, and automatic stack clearing.

Testing

Automated

./gradlew testKeyboardsDebugUnitTest

Manual checklist

Start from a fresh install or clear the swipe_tutorial_shown preference.

  • Tutorial overlay appears on first launch with dark-slate translucent style
  • "Scribe " is pre-typed in the active text field
  • Keyboard keys respond to touch while the overlay is visible
  • Swiping left deletes "Scribe " word-by-word with haptic feedback, then advances to step 2
  • Swiping right restores "Scribe " with haptic feedback, then shows the success screen
  • Tapping Got it! dismisses the overlay; normal typing and swipes work correctly
  • Tapping Skip at any step dismisses the overlay and saves the preference
  • Tutorial does not reappear on subsequent launches
  • Swipe delete and restore work correctly outside the tutorial in normal use

Screenshots

Step 1 — Swipe left to delete Step 2 — Swipe right to restore Completion screen
Tutorial step 1 – swipe left to delete Tutorial step 2 – swipe right to restore Tutorial completion screen

@github-actions

Copy link
Copy Markdown

Thank you for the pull request! 💙🩵

The Scribe-Android team will do our best to address your contribution as soon as we can. The following are some important points:

  • Those interested in developing their skills and expanding their role in the community should read the mentorship and growth section of the contribution guide
  • If you're not already a member of our public Matrix community, please consider joining!
    • We'd suggest that you use the Element client as well as Element X for a mobile app
    • Join the General and Android rooms once you're in
  • Also consider attending our bi-weekly Saturday developer syncs!
    • Details are shared in the General room on Matrix each Wednesday before the sync
    • It would be great to meet you 😊

Note

Scribe uses Conventional Comments in reviews to make sure that communication is as clear as possible.

@github-actions

Copy link
Copy Markdown

Maintainer Checklist

The following is a checklist for maintainers to make sure this process goes as well as possible. Feel free to address the points below yourself in further commits if you realize that actions are needed :)

  • Tests for changes have been written and the unit test, linting and formatting workflows within the PR checks do not indicate new errors in the files changed

    • Tests may need to be reran as they're at times not deterministic
  • The CHANGELOG has been updated with a description of the changes for the upcoming release and the corresponding issue (if necessary)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Swipe to Delete, Swipe to Restore, and Interactive Gesture Onboarding Tutorial

1 participant