Skip to content

Implement smart delete#55

Merged
ricky9667 merged 13 commits intomasterfrom
smart-delete
Jul 24, 2025
Merged

Implement smart delete#55
ricky9667 merged 13 commits intomasterfrom
smart-delete

Conversation

@ricky9667
Copy link
Owner

Description

  • The backspace button normally deletes 1 character at a time.
  • Therefore, this PR implements smart delete to delete a cube notation instead of a character. The implementation does behind is to delete all the text before cursor until it deletes a main notation (R, U, F, x, M, etc.)
  • This feature be turned on in Settings page.

How to verify

  1. Smart delete can be turned on/off in settings page
  2. Smart delete can delete all text before cursor

Screenshots / Videos

@ricky9667 ricky9667 self-assigned this Jul 12, 2025
@ricky9667 ricky9667 added the feature Something new to develop label Jul 12, 2025
This was linked to issues Jul 12, 2025
@codecov
Copy link

codecov bot commented Jul 12, 2025

Codecov Report

Attention: Patch coverage is 26.31579% with 70 lines in your changes missing coverage. Please review.

Project coverage is 41.47%. Comparing base (5201743) to head (36e343f).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
.../com/rickyhu/hushkeyboard/utils/InputConnection.kt 0.00% 26 Missing ⚠️
.../rickyhu/hushkeyboard/keyboard/HushKeyboardView.kt 23.80% 15 Missing and 1 partial ⚠️
.../hushkeyboard/settings/ui/SmartDeleteSwitchItem.kt 31.81% 8 Missing and 7 partials ⚠️
...shkeyboard/keyboard/ui/rows/ControlKeyButtonRow.kt 37.50% 3 Missing and 2 partials ⚠️
.../java/com/rickyhu/hushkeyboard/data/AppSettings.kt 0.00% 3 Missing ⚠️
...rickyhu/hushkeyboard/settings/SettingsViewModel.kt 60.00% 2 Missing ⚠️
...om/rickyhu/hushkeyboard/data/SettingsRepository.kt 0.00% 1 Missing ⚠️
...in/java/com/rickyhu/hushkeyboard/model/Notation.kt 50.00% 1 Missing ⚠️
...om/rickyhu/hushkeyboard/settings/SettingsScreen.kt 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #55      +/-   ##
==========================================
- Coverage   43.17%   41.47%   -1.71%     
==========================================
  Files          38       39       +1     
  Lines         945     1020      +75     
  Branches      262      283      +21     
==========================================
+ Hits          408      423      +15     
- Misses        437      488      +51     
- Partials      100      109       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements a smart delete feature for a cube notation keyboard app, allowing users to delete entire cube notations (R, U, F, x, M, etc.) instead of single characters when using the backspace button. The feature can be toggled on/off in the settings.

  • Adds smart delete functionality that deletes text up to and including the previous main notation character
  • Creates a new settings toggle to control smart delete behavior
  • Updates the UI to show different backspace icons based on smart delete state

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
InputConnection.kt Implements core smart delete logic and adds logging
SmartDeleteSwitchItem.kt Creates new UI component for smart delete toggle
SettingsViewModel.kt Adds smart delete state management and reorders data class fields
SettingsScreen.kt Integrates smart delete toggle into settings UI
Notation.kt Adds companion object with helper method for notation characters
ControlKeyButtonRow.kt Updates delete button to show different icons based on smart delete state
KeyboardViewModel.kt Adds smart delete to keyboard state and reorders fields
HushKeyboardView.kt Integrates smart delete functionality and adds extensive logging
SettingsRepository.kt Adds repository method for updating smart delete setting
AppSettings.kt Adds smart delete field to data model and reorders fields
ic_backspace_*.xml Adds new drawable resources for backspace icons
SettingsScreenUiTest.kt Updates test to include smart delete callback

@Composable
fun SmartDeleteSwitchItemPreview() {
HushKeyboardTheme {
AddSpaceBetweenNotationSwitchItem(
Copy link

Copilot AI Jul 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The preview function is calling AddSpaceBetweenNotationSwitchItem instead of SmartDeleteSwitchItem. This will cause the preview to display the wrong component.

Suggested change
AddSpaceBetweenNotationSwitchItem(
SmartDeleteSwitchItem(

Copilot uses AI. Check for mistakes.
}
} else {
{
Log.d(TAG, "Smart delete button tapped")
Copy link

Copilot AI Jul 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The log message says "Smart delete button tapped" when this is actually the regular delete functionality (when smart delete is disabled). This should be "Delete button tapped" to match the actual functionality.

Suggested change
Log.d(TAG, "Smart delete button tapped")
Log.d(TAG, "Delete button tapped")

Copilot uses AI. Check for mistakes.
Comment on lines 12 to 13
val notationCharList = Notation.getCharList() + listOf('\n')

Copy link

Copilot AI Jul 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The inclusion of newline character ('\n') in the notation list seems inconsistent with the purpose of cube notations. Consider creating a separate constant or adding a comment explaining why newline is treated as a notation character for smart delete purposes.

Suggested change
val notationCharList = Notation.getCharList() + listOf('\n')
// Newline character is included to handle smart delete functionality, allowing deletion of line breaks.
private const val NEWLINE_CHAR = '\n'
val notationCharList = Notation.getCharList() + listOf(NEWLINE_CHAR)

Copilot uses AI. Check for mistakes.

beginBatchEdit()
try {
val scanWindow = 50
Copy link

Copilot AI Jul 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The magic number 50 for scan window size should be extracted to a named constant to improve code maintainability and make it easier to adjust if needed.

Suggested change
val scanWindow = 50
val scanWindow = SCAN_WINDOW_SIZE

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

@Xanonymous-GitHub Xanonymous-GitHub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@ricky9667 ricky9667 merged commit d57c20c into master Jul 24, 2025
3 checks passed
@ricky9667 ricky9667 deleted the smart-delete branch July 24, 2025 07:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Something new to develop

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Smart Delete Delete button works only by tapping

3 participants