Skip to content

feat: implement auto-spacing after punctuation and double-tap space period (#669) - #670

Open
prince-0408 wants to merge 12 commits into
scribe-org:mainfrom
prince-0408:feature/auto-space-double-tap-period-669
Open

feat: implement auto-spacing after punctuation and double-tap space period (#669)#670
prince-0408 wants to merge 12 commits into
scribe-org:mainfrom
prince-0408:feature/auto-space-double-tap-period-669

Conversation

@prince-0408

@prince-0408 prince-0408 commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Description

This PR implements two standard soft-keyboard usability features as requested in #669 by adding automatic punctuation spacing and refining double-tap space for period behavior to align with modern keyboard standards (such as Gboard and SwiftKey).

Key Changes

Double-Tap Space for Period (. ):

  • Updated SpaceKeyProcessor.kt so that pressing the spacebar twice after a word converts the trailing space to a period and space (. ).
  • Automatically activates single-character shift state (SHIFT_ON_ONE_CHAR) on period conversion to capitalize the first letter of the next sentence.
  • Removed outdated helper functions to simplify and streamline spacebar event handling.

Auto-Spacing After Punctuation:

  • Updated KeyHandler.kt to intercept punctuation keys (., ,, !, ?) and automatically append a trailing space when typed after a word.
  • Handled edge cases to gracefully remove auto-inserted spaces if a consecutive punctuation mark (e.g. ... or ?!) or backspace is typed.

Settings & Preferences Integration:

  • Added AUTO_SPACE_AFTER_PUNCTUATION constant, getter, and setter in PreferencesHelper.kt.
  • Defaulted both "Double-space for period" and "Auto-space after punctuation" settings to enabled (true).
  • Added a new toggle switch for "Auto-space after punctuation" under Keyboard Settings > Functionality in LanguageSettingsScreen.kt.
  • Added string resources in en-US/string.xml.

Unit Tests & Linter Cleanliness:

  • Added new test coverage in SpaceKeyProcessorTest.kt for spacebar event processing and period commits.
  • Formatted all Kotlin sources via ./gradlew formatKotlin to ensure clean compliance with ktlint and detekt.

Visual Demonstration

Double-Tap Space Period Feature Auto-Space Settings Toggle

Related Issue

Closes #669

…eriod (scribe-org#669)

- Add auto-space after punctuation (. , ! ?) setting and key handling
- Refine double-tap space for period conversion and auto-capitalization
- Default auto-spacing and double-tap period preferences to enabled
- Add unit tests for SpaceKeyProcessor
@andrewtavis

Copy link
Copy Markdown
Member

Thanks for the PR, @prince-0408! Could we do one quick PR to Scribe-i18n to add in the needed strings for this menu option? Then we can merge that and rebase this PR?

@prince-0408

Copy link
Copy Markdown
Collaborator Author

Thanks for the PR, @prince-0408! Could we do one quick PR to Scribe-i18n to add in the needed strings for this menu option? Then we can merge that and rebase this PR?

Hi @andrewtavis! 👋

I have opened the PR to Scribe-i18n with the required string keys here:
👉 scribe-org/Scribe-i18n#122

CI Status & Fallback Implementation:

  • Temporary Fallback Strings: Added the string definitions directly into app/src/main/res/values/strings.xml (plural) as a fallback. Since moveFromi18n only overwrites singular string.xml during Gradle preBuild, adding them to strings.xml ensures AAPT2 merges the resources and keeps all 6 Android CI checks 100% green while #122 is being reviewed.
  • Upstream Sync: Updated this branch with the latest changes from scribe-org/main.

Once Scribe-i18n#122 is merged into main, I will update the app/src/main/assets/i18n submodule pointer to the new commit and clean up the fallback entries from strings.xml.

@andrewtavis

Copy link
Copy Markdown
Member

Thanks, @prince-0408! See my comment here asking if we want to expand this a bit :) I'm happy to finalize the changes to Scribe-i18n if you verify that it makes sense, and from there we can bring those strings in and finish this up too 😊

@andrewtavis

andrewtavis commented Aug 14, 2026

Copy link
Copy Markdown
Member

Scribe-i18n has been updated now, @prince-0408, so feel free to sync this and I'll look further 😊

@prince-0408

Copy link
Copy Markdown
Collaborator Author

Scribe-i18n has been updated now, @prince-0408, so feel free to sync this and I'll look further 😊

Hi @andrewtavis

I have synced the i18n submodule to point to the merged scribe-org/Scribe-i18n:main commit!

I also cleaned up the temporary fallback entries from strings.xml to prevent AAPT resource duplication issues during build.

All checks are running and ready for your review whenever you have a moment. Thanks! 😊

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.

Implement Auto-Spacing After Punctuation & Double-Tap Space for Period

2 participants