Re-run OCR immediately when the OCR source changes - #84
Open
bee-san wants to merge 1 commit into
Open
Conversation
Changing the reader OCR source (e.g. Automatic -> Google Lens) updated the stored preference and cleared the scan state, but nothing kicked off a new scan. The chapter-wide OCR pass only restarted on the next page change, so the source switch appeared to do nothing until the user swiped. setOcrSource() now restarts the scan for the current page right away when the OCR overlay is enabled. Also fixes the ReaderOcrSourceTest call to availableSources(), which was left with the old single-argument signature and does not compile.
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.
Follow-up to #81.
Problem
Changing the OCR source from the long-press menu on the reader OCR action didn't visibly do anything.
setOcrSource()stored the preference, cancelled the in-flight scan and clearedocrScannedChapterIds, but nothing started a new scan — the chapter-wide OCR pass only restarts fromonPageSelected -> scanOcrPages(). So picking Google Lens while sitting on a page left the reader idle until the user swiped.Fix
setOcrSource()now restarts the scan for the currently selected page right away, when the OCR overlay is enabled:This mirrors what the existing
ocrOverlayEnabled().changes()collector already does when OCR is toggled on.Note the visible page was already being re-OCR'd by the
setOcrEnabled(false)/setOcrEnabled(true)dance inReaderActivity.selectOcrSourceFromReader. What was missing is the chapter-wide background rescan under the new source (and its progress HUD), which is what this restores. No duplicate network work: both paths go throughgetOcrBlocks(), which dedupes concurrent fetches viaocrInFlightkeyed on(chapterId, pageIndex, ocrSource).Drive-by
ReaderOcrSourceTest.availableSources()was still calling the old single-argument signature and doesn't compile onmain— #81 added themokuroAvailableparameter toReaderOcrSource.availableSources()but didn't update the test. One call site, two arguments. Without thistestReleaseUnitTestfails to compile, so it's included here rather than left broken.Verification
./gradlew testReleaseUnitTest— passes (fails to compile onmainwithout the test fix above)