Skip to content

feat: preserve operation state across screen rotation#73

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/keep-operation-state-on-rotate
Draft

feat: preserve operation state across screen rotation#73
Copilot wants to merge 2 commits intomainfrom
copilot/keep-operation-state-on-rotate

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 6, 2026

Summary

Rotating the phone no longer resets the active operation. All pending state (selected button, amounts, modes, NFC write recovery data, replay allowances) is preserved and correctly restored after the layout switches.

Changes

MainActivity.kt

  • onPause: Added isChangingConfigurations guard so resetToWaiting() is only called when actually navigating away from the activity, not on rotation.
  • onCreate: Gated NFC/VIEW intent handling with savedInstanceState == null to prevent re-processing the original launch intent on re-creation.
  • onSaveInstanceState: Saves all logical state (pendingAction, selectedButtonIndex, currentBalance, amounts, mode flags, pendingWrite byte arrays, replay allowances, dialog options, batteryOptimizationRequested) plus display-only view state (status/card-ID texts, before/after layout, transaction history rows, visibility flags).
  • onRestoreInstanceState: Defers restoration via a savedStateToRestore field.
  • onResume: Consumes savedStateToRestore at the very end — after checkNfcEnabled() and rebuildCustomButtons() — via the new restoreOperationState() helper.
  • restoreOperationState(Bundle): Restores all logical state, resets display views, re-applies button-selection styling on the freshly-built button grid, and re-schedules the auto-reset timer for FORMAT/RESET actions.
  • onDestroy: Cancels pending autoResetRunnable, buttonModeIdleRunnable, and FLASH_TOKEN callbacks when isChangingConfigurations, preventing stale-view updates from firing on the destroyed instance.

fastlane/metadata/android/en-US/changelogs/15.txt

  • Added entry: Fixed screen rotation resetting active operation

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.

2 participants