Repository navigation
Conversation
- Store last customized timebox limit in Android preferences. - Restore custom limit on toggle re-enable and screen reload. Fixes ankidroid#22720 Assisted-by: Gemini Flash
david-allison
left a comment
There was a problem hiding this comment.
The domain logic feels a little too mixed up with the ViewModel, let's split it out
|
Hi @david-allison thanks for the review
|
|
Could you have another round at the abstraction work, to start things off:
Look to see what else you find |
bd3d180 to
ed66c5f
Compare
|
Had another round at the abstraction work:
|
|
Sorry, this is only a partial review |
ed66c5f to
e5da4a3
Compare
david-allison
left a comment
There was a problem hiding this comment.
LGTM, optional thoughts on the domain. Cheers!
… desktop limits - Extract TimeboxTimeLimit domain type with INPUT_RANGE (1..9999) matching Anki Desktop - Provide TimeboxTimeLimit.fromMinutes returning null on invalid input - Provide canIncrement, canDecrement, and orElse helper methods on TimeboxTimeLimit - Provide resolveDisplayLimit extension to sync custom limit - Add Duration.toTimeboxTimeLimit() and TimeboxTimeLimit.toDuration() extensions - Type ViewModel UI state with TimeboxTimeLimit - Document Desktop source links alongside values - Add TimeboxPersistenceReviewTest and domain unit tests Fixes ankidroid#22720
e5da4a3 to
43a7b71
Compare
mikehardy
left a comment
There was a problem hiding this comment.
Assisted-by: Grok 4.7
Thank you — the TimeboxTimeLimit split and custom-prefs round-trip keep desktop limits intact without clamping surprises in the UI.
Locally I rebased onto main without force-pushing (prep stayed at the PR tip). I ran lint (lintAll, ktlintCheck, lint-rules:test), unit tests (jacocoUnitTestReport), and release emulator tests (TEST_RELEASE_BUILD=true via run_emulator_tests.py on emulator-5556 / API35_GAPI); all passed.
Reviewed TimeboxTimeLimit validation with null on bad input, extension mapping to prefs/collection, ViewModel load/save preserving values above 999 minutes, and Compose settings wired from the fragment.
some acceptable findings, no action required, just leaving for posterity: long refactor commit title; unused helpers; stepper can snap sub-9999 desktop values on first decrement.
Note
Assisted-by: Gemini Flash
Purpose / Description
When disabling the review timebox toggle, the collection timebox limit is set to 0. Previously, when re-enabling the toggle or leaving and re-entering the screen while disabled, the duration defaulted back to 20 minutes (
DEFAULT_TIMEBOX_MINUTES), losing any custom duration (e.g. 45 minutes) the user had configured.This PR persists the user's customized timebox limit in Android preferences (
Prefs.customTimeboxLimit), so that:Fixes
Approach
custom_timebox_limit_keyinpreferences.xml.customTimeboxLimitproperty delegate inPrefs.ktwith a default of 20 (DEFAULT_TIMEBOX_MINUTES).TimeboxSettingsViewModel:PrefsRepository = Prefs.loadSettings(): if disabled, initialize withprefs.customTimeboxLimit; if enabled, record the limit inprefs.customTimeboxLimit.setMinutes(): updateprefs.customTimeboxLimit.toggleEnabled(): restore_uiState.value.minuteswhen enabled, or set 0 to collection when disabled while keeping the minutes in state/prefs.TimeboxSettingsViewModelTest.How Has This Been Tested?
:AnkiDroid:testPlayDebugUnitTest --tests "com.ichi2.anki.preferences.TimeboxSettingsViewModelTest"(all passed).:AnkiDroid:testPlayDebugUnitTest --tests "com.ichi2.anki.settings.Prefs*"(all passed).:AnkiDroid:ktlintCheck(passed).Checklist