Repository navigation
Keep the translation scroll position after sharing an ayah - #4054
Open
marouanebatrone wants to merge 1 commit into
Open
marouanebatrone wants to merge 1 commit into
marouanebatrone wants to merge 1 commit into
Conversation
TranslationFragment only saves its scroll position in onSaveInstanceState, but TranslationPresenter restored that saved position after every refresh. The fragment refreshes whenever it resumes, so coming back from something that only pauses the activity, such as the share sheet, scrolled the list back to the stale saved position (the top of the page unless the page was recreated). Only restore the saved position the first time the verses are shown, so later refreshes keep the position the reader scrolled to. Rotation still restores the position, since it creates a new fragment and presenter. Fixes quran#2248. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Assalamu alaikum,
Fixes #2248.
What
In translation mode, sharing an ayah (long-press → Share → text) and then closing the share sheet scrolled the translation list back to the top of the page, so the reader lost their place. This happens in single-page translation mode; dual-page translation on tablets already kept its place.
How
TranslationFragmentsaves its scroll position only inonSaveInstanceState, butTranslationPresenter.refresh()restored that saved position after every refresh, and the fragment refreshes whenever it resumes. While the share sheet is open,PagerActivityis only paused, so no state is saved. When the reader comes back, the stale value is applied again: that's the top of the page unless the page was recreated.TranslationPresenternow restores the saved position only the first time the verses are shown. Later refreshes leave the list where the reader scrolled it.@QuranPageScopepresenter are new.Tests
TranslationPresenterTest(Robolectric, using the existing fakes plus a smallFakeTranslationScreen):refreshing again keeps the position the reader scrolled tofails onmain(expected: 1,but was: 2restores) and passes with this change.assembleMadaniDebuglintMadaniDebugverifySqlDelightMigrationtestMadaniDebug testReleaseUnitTest -PdisableFirebasemain(280bf44) and this branch with the same scripted steps: page 2, translation mode, scroll so 2:3 is at the top, long-press an ayah, Share → text, Back.mainjumps back to 2:1; this branch stays on 2:3.main.mainand on this branch.Screenshots
After scrolling to 2:3, sharing an ayah's text and closing the share sheet:
main)