Skip to content

fix: keep confirmations working after recreation - #22886

Draft
criticalAY wants to merge 3 commits into
ankidroid:mainfrom
criticalAY:fix/card-template-confirmation-recreation
Draft

criticalAY wants to merge 3 commits into
ankidroid:mainfrom
criticalAY:fix/card-template-confirmation-recreation

Conversation

@criticalAY

Copy link
Copy Markdown
Contributor

Note

Assisted-by: Opus 5.5

Purpose / Description

After a night mode switch, confirming Add or Delete card type, or the full sync warning, did nothing. Cancelling the warning brought the previous confirmation back.

Fixes

Approach

Each card type page now gets its confirmations as fragment results. The full sync warning replaces the confirmation instead of opening on top of it, so Back on it now closes it too.

How Has This Been Tested?

test (fails without this change) and some more tests :)

Learning (optional, can help others)

NA

Checklist

Please, go through these checks before submitting the PR.

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

The field editor forgot which field was tapped when it was recreated,
for example by a night mode switch. An open field menu then acted on
the first field, so Delete could remove the wrong one.

Part of 22714

Assisted-by: Claude Opus 5.5
@criticalAY criticalAY added Blocked by dependency Currently blocked by some other dependent / related change and removed Needs Review labels Oct 31, 2026

@mikehardy mikehardy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Assisted-by: Grok 4.7

Thank you — the card-type and field editor recreation fix looks solid, and the new Robolectric tests are a nice touch.

Rebased locally onto current main (clean replay; no force-push). Ran lint (lintAll, ktlintCheck, lint-rules:test), jacocoUnitTestReport, and emulator tests (TEST_RELEASE_BUILD=true via run_emulator_tests.py on emulator-5556 / API35_GAPI); all passed.

ConfirmationDialog now stores requestKey and a result Bundle in arguments so the positive button survives recreation via setFragmentResult, while still running any in-memory confirm when set. On the card template page, add/delete/reposition confirmations register fragment-result listeners on the activity’s FragmentManager; executeWithSyncCheck applies the bundle, and full-sync warnings reuse the same bundle through the dialog back stack. Field editor add/delete/reposition/sort follow the same pattern with saved currentPos. New recreation tests configuration-change to night mode before clicking confirm so a no-op restored button would fail.

some acceptable findings, no action required, just leaving for posterity: rename’s full-sync confirm is still an in-memory Runnable (recreation during rename can still drop it); ConfirmationDialog KDoc still mentions setArgs/setConfirm rather than newInstance; full-sync confirm for card-type add/delete does not reload the previewer (same as the old Runnable path).

@mikehardy mikehardy added the Needs Second Approval Has one approval, one more approval to merge label Nov 2, 2026
@criticalAY
criticalAY force-pushed the fix/card-template-confirmation-recreation branch 2 times, most recently from 28507b9 to 470806e Compare November 2, 2026 19:50
david-allison

This comment was marked as resolved.

@david-allison david-allison added the Needs Author Reply Waiting for a reply from the original author label Nov 2, 2026
@david-allison
david-allison marked this pull request as draft November 2, 2026 21:06
@criticalAY

Copy link
Copy Markdown
Contributor Author

Leaving it for now until parent is merged

ConfirmationDialog kept its action in memory, so after a night mode
switch tapping Delete did nothing and the field menu came back. It can
now send a fragment result, which the field editor uses to add, delete,
reposition and sort fields.

Part of 22714

Assisted-by: Claude Opus 5.5
After a night mode switch, confirming Add or Delete card type, or the
full sync warning, did nothing, and cancelling the warning brought the
previous confirmation back. The card type page now receives these as
fragment results.

Part of 22714

Assisted-by: Claude Opus 5.5
@criticalAY
criticalAY force-pushed the fix/card-template-confirmation-recreation branch from 470806e to 5630578 Compare November 2, 2026 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Blocked by dependency Currently blocked by some other dependent / related change Needs Author Reply Waiting for a reply from the original author Needs Second Approval Has one approval, one more approval to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants