-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Retain previous selection for Reset Progress #17615
Merged
Merged
+14
−0
Conversation
This file contains 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
@Arthur-Milchior Please Review this. |
AnkiDroid/src/main/java/com/ichi2/anki/scheduling/ForgetCardsDialog.kt
Outdated
Show resolved
Hide resolved
AnkiDroid/src/main/java/com/ichi2/anki/scheduling/ForgetCardsDialog.kt
Outdated
Show resolved
Hide resolved
AnkiDroid/src/main/java/com/ichi2/anki/scheduling/ForgetCardsDialog.kt
Outdated
Show resolved
Hide resolved
AnkiDroid/src/main/java/com/ichi2/anki/scheduling/ForgetCardsDialog.kt
Outdated
Show resolved
Hide resolved
AnkiDroid/src/main/java/com/ichi2/anki/scheduling/ForgetCardsDialog.kt
Outdated
Show resolved
Hide resolved
david-allison
requested changes
Dec 18, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! One last change
Index: AnkiDroid/src/main/java/com/ichi2/anki/scheduling/ForgetCardsDialog.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/scheduling/ForgetCardsDialog.kt b/AnkiDroid/src/main/java/com/ichi2/anki/scheduling/ForgetCardsDialog.kt
--- a/AnkiDroid/src/main/java/com/ichi2/anki/scheduling/ForgetCardsDialog.kt (revision 4bdf08fcb784c14749fe5bf0ce0fd41c78120839)
+++ b/AnkiDroid/src/main/java/com/ichi2/anki/scheduling/ForgetCardsDialog.kt (date 1734493627020)
@@ -29,6 +29,7 @@
import com.ichi2.anki.CollectionManager.TR
import com.ichi2.anki.R
import com.ichi2.anki.launchCatchingTask
+import com.ichi2.anki.preferences.sharedPrefs
import com.ichi2.anki.snackbar.showSnackbar
import com.ichi2.anki.utils.openUrl
import com.ichi2.anki.withProgress
@@ -81,14 +82,15 @@
}
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
- val sharedPrefs = requireContext().getSharedPreferences("dialog_prefs", 0)
if (savedInstanceState != null) {
restoreOriginalPositionIfPossible = savedInstanceState.getBoolean(ARG_RESTORE_ORIGINAL, true)
resetRepetitionAndLapseCounts = savedInstanceState.getBoolean(ARG_RESET_REPETITION, false)
} else {
// If no saved instance state, load the last saved preferences for restore position and reset counts.
- restoreOriginalPositionIfPossible = sharedPrefs.getBoolean(ARG_RESTORE_ORIGINAL, true)
- resetRepetitionAndLapseCounts = sharedPrefs.getBoolean(ARG_RESET_REPETITION, false)
+ with (requireContext().sharedPrefs()) {
+ restoreOriginalPositionIfPossible = getBoolean(ARG_RESTORE_ORIGINAL, true)
+ resetRepetitionAndLapseCounts = getBoolean(ARG_RESET_REPETITION, false)
+ }
}
val contentView =
layoutInflater.inflate(R.layout.dialog_forget_cards, null).apply {
david-allison
approved these changes
Dec 18, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cheers!
Optional request for a @NeedsTest
here
david-allison
added
the
Needs Second Approval
Has one approval, one more approval to merge
label
Dec 18, 2024
BrayanDSO
approved these changes
Dec 18, 2024
BrayanDSO
added
Pending Merge
Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc)
and removed
Needs Second Approval
Has one approval, one more approval to merge
labels
Dec 18, 2024
github-actions
bot
removed
the
Pending Merge
Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc)
label
Dec 18, 2024
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
The issue was that the settings for "Reset Progress" were not retaining the user's previous selection. This change addresses that by saving the selected options in shared preferences.
Fixes
Approach
The solution involves saving the user’s selection (whether to reset repetition and lapse counts) in shared preferences. When the dialog is reopened, the saved preferences are loaded to restore the previous settings.
How Has This Been Tested?
Tested by opening the "Reset Progress" dialog, selecting various options, and verifying that the settings are retained even after reopening the dialog. Tested on a physical device running Android 12.
Checklist
Please, go through these checks before submitting the PR.