Repository navigation
Dice Lock - #81
Merged
Merged
Dice Lock#81
Conversation
Each die tile gains a small lock button in its top-end corner. A locked die keeps its value and is skipped by both Roll All and the tap-to-roll gesture on its own tile, so "hold some, reroll the rest" no longer means rerolling each unwanted die by hand. Lock state lives in SavedStateHandle for the session only. Persisting it would be incoherent today, because DicePrefsDataSource stores faces but not values, so a restored "locked" die would show a face-count placeholder rather than the value that was locked. Behaviour details: - Tapping a locked tile shakes it instead of rolling. The card keeps a selectableItemBackground foreground and ripples on touch regardless, so a silent no-op would read as a bug. - Locked tiles do not play the roll animation during Roll All. - Roll All suppresses its haptic and summary bounce when nothing is rollable. This also covers an empty board, which previously buzzed and bounced a total that could not change. - Locked tiles take a 2dp stroke in the luminance-derived contrast colour the adapter already computes, not colorPrimary, which would disappear against neighbouring diceColors entries. - An Unlock All app-bar item appears only while at least one die is locked. There is no Lock All: its only outcome is a dead Roll All. - Lock does not block delete, and the summary chips and total are unchanged. Adds isLocked to the DiffUtil contents check, or lock icons would not refresh when nothing else about a die changed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DvVWNNqvJ3zwwWbA18Uvvq
Three defects in the lock toggle, all cases where a control did something invisible or nothing at all. The locked-tile shake used raw pixels. setTranslationX takes pixels, not dp, so the 6f nudge was about 2dp on a 3x-density screen. Since the locked path also returns before any haptic fires, tapping a locked tile produced a ripple and no other feedback, which is exactly the "reads as a bug" outcome the shake existed to prevent. Now scaled by display density, matching how the same class already computes the locked stroke width. The lock button swallowed long presses. A clickable child consumes the touch stream, and the button is not long-clickable, so a long press in the top-end corner never reached the card's delete handler: the gesture deleted the die everywhere on the tile except a 44dp square. The button now forwards long presses to the same handler. Roll All stayed enabled while inert. When nothing is rollable the action suppressed its haptic, animation and roll, but still looked available. onPrepareMenu now disables it, so the dead state is visible rather than silent. This also required invalidating the menu when the rollable flag changes on its own, not just the locked flag; otherwise Roll All stayed disabled after adding the first die to an empty board. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DvVWNNqvJ3zwwWbA18Uvvq
Owner
|
Sorry for the delay, checking the UI |
Owner
|
Thanks! this looks great |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces the ability to lock and unlock dice in the dice-rolling UI, enhancing user interaction and control. The changes span UI updates, state management, and persistence to support the new locking feature. Additionally, debug build configuration improvements were made to facilitate parallel installation and clearer identification.
Dice Locking Feature
DiceAdapter.java,DiceFragment.java) [1] [2] [3] [4]DiceAdapter.java)DiceAdapter.java,DiceFragment.java) [1] [2] [3] [4]State and Persistence Enhancements
DiceUiStateandDiceViewModelto track and expose which dice are locked and which are rollable, enabling UI and menu updates based on current state. (DiceUiState.java,DiceViewModel.java) [1] [2] [3] [4]DiceAdapter.java)Menu and Action Improvements
DiceFragment.java)DiceFragment.java) [1] [2]Debug Build Improvements
app/build.gradle,strings.xml) [1] [2]User Feedback
DiceFragment.java)These changes together provide a more interactive and user-friendly dice-rolling experience, with robust state management and improved development workflow.