Fix sustain key state lost after opening preferences#14
Conversation
The sustain key state was being reset when navigating to the preferences menu because onPause calls cleanStates(), which stops all keys, including the sustain key (which resets the global sustain state). This commit modifies Play.java to: 1. Save the global sustain state (HexKeyboard.mSustain) in onPause before calling cleanStates(). 2. Restore the sustain state in onResume. 3. Manually update the visual state of the SustainKey in onResume if the keyboard was not reloaded (i.e., if no preferences were changed), ensuring the UI reflects the restored state. Co-authored-by: lrq3000 <1118942+lrq3000@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📝 WalkthroughWalkthroughAdds sustain state persistence to the Play activity by introducing two static boolean fields ( Changes
Sequence DiagramsequenceDiagram
participant Play as Play Activity
participant HexKeyboard as HexKeyboard
participant SustainKey as SustainKey
rect rgba(100, 150, 200, 0.5)
Note over Play: onPause() called
Play->>Play: Save current sustain state<br/>to savedSustainState
Play->>Play: Set hasSavedSustainState = true
end
rect rgba(150, 200, 100, 0.5)
Note over Play: onResume() called
Play->>HexKeyboard: Apply saved sustain state
Play->>SustainKey: Re-press SustainKey<br/>(if conditions met)
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Previously, opening preferences or pausing the app would call `cleanStates()`, which stopped all keys including modifier keys, resetting their state. This commit introduces `HexKeyboard.stopAllNotes()` which stops sound-producing keys but preserves the state of `ModifierKey`s (like Sustain). `Play.cleanStates()` now calls `stopAllNotes()` instead of `stopAll()`. This allows the sustain key to remain active when returning from the preferences menu, leveraging the existing persistence of the static `mKeys` array. Co-authored-by: lrq3000 <1118942+lrq3000@users.noreply.github.com>
Fixes an issue where the sustain key modifier's state was lost when opening the preferences menu and returning. The state is now saved in
onPauseand restored inonResume. Additionally, the visual state of the sustain key is updated if the keyboard is not fully reloaded.PR created automatically by Jules for task 3338882354673970821 started by @lrq3000
Summary by CodeRabbit
Bug Fixes