Repository navigation
fix: field deletion confirmation after recreation - #22767
Closed
Ranjan-3105 wants to merge 1 commit into
Closed
Ranjan-3105 wants to merge 1 commit into
Ranjan-3105 wants to merge 1 commit into
Conversation
Member
|
Please read our AI policy: https://github.com/ankidroid/Anki-Android/blob/main/AI_POLICY.md |
Contributor
Author
|
I am sorry, I should have read the AI policy beforehand. Also in the PR description I atleast should have disclosed. I was frustrated with the errors I was going through so decided to use AI. I understand the workflow but am new to android development. I have now read the AI policy and will abide by it from this point on, please direct me with the appropriate next step I should take. |
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.
Purpose / Description
Deleting a field in the note-type field editor could silently fail if the activity was recreated while the confirmation dialog was open.
ConfirmationDialogstored its confirmation action as an in-memoryRunnable. When the activity was recreated, for example, after switching to night mode, the dialog was restored but theRunnablewas not. Consequently, confirming the deletion could do nothing, leaving the field options menu visible without deleting the field.Fixes
ConfirmationDialogloses callbacks on activity recreation #22714Approach
ConfirmationDialog. The request key is stored in the dialog's arguments, allowing the confirmation result to be delivered after activity recreation.setConfirm()andsetCancel()behavior for other callers.NoteTypeFieldEditorto handle the deletion confirmation through a Fragment Result listener registered inonCreate.How Has This Been Tested?
Unit tests (JVM / Robolectric):
NoteTypeFieldEditorRecreationTest, which opens the deletion confirmation, recreates the activity, confirms the deletion, and verifies that the intended field is deleted.NoteTypeFieldEditorTest: 10 tests passed.:AnkiDroid:testPlayDebugUnitTesttask completed successfully.ktlintand pre-commit hooks completed successfully.Commands used:
Learning (optional, can help others)
In-memory callbacks belong to a fragment instance and are not automatically restored when that fragment is recreated. Fragment arguments and saved state, however, can survive recreation.
Using fragment arguments together with the Fragment Result API allows the dialog to return a confirmation result to a listener registered by the recreated activity.
See the Android Fragment communication guide.
Checklist