feat: preserve operation state across screen rotation#73
Draft
feat: preserve operation state across screen rotation#73
Conversation
Agent-Logs-Url: https://github.com/duhow/nfc-coins/sessions/580e238e-74fe-4556-b294-a6e1c97a27c3 Co-authored-by: duhow <1145001+duhow@users.noreply.github.com>
…elog Agent-Logs-Url: https://github.com/duhow/nfc-coins/sessions/580e238e-74fe-4556-b294-a6e1c97a27c3 Co-authored-by: duhow <1145001+duhow@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
duhow
April 6, 2026 15:04
View session
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.
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.ktonPause: AddedisChangingConfigurationsguard soresetToWaiting()is only called when actually navigating away from the activity, not on rotation.onCreate: Gated NFC/VIEW intent handling withsavedInstanceState == nullto prevent re-processing the original launch intent on re-creation.onSaveInstanceState: Saves all logical state (pendingAction,selectedButtonIndex,currentBalance, amounts, mode flags,pendingWritebyte 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 asavedStateToRestorefield.onResume: ConsumessavedStateToRestoreat the very end — aftercheckNfcEnabled()andrebuildCustomButtons()— via the newrestoreOperationState()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 pendingautoResetRunnable,buttonModeIdleRunnable, andFLASH_TOKENcallbacks whenisChangingConfigurations, preventing stale-view updates from firing on the destroyed instance.fastlane/metadata/android/en-US/changelogs/15.txtFixed screen rotation resetting active operation