fix(stats): recreate statistics and card info on rotation#21244
fix(stats): recreate statistics and card info on rotation#21244Ayush-Patel-56 wants to merge 1 commit into
Conversation
|
Thanks, but your video doesn't seem to demonstrate the fix. You need to tap on one of the bars in landscape mode to show the tooltip then rotate to portrait mode. Also, the bug is un-noticable when tapping on the bars on the left, so tap the right-mist bar. |
77f9b68 to
6f043e1
Compare
6f043e1 to
bb2c9c4
Compare
|
I changed the video, and now I think its the correct video as per the issue. btw thanks for tagging the issue. |
|
This now appears to reset scroll position on rotation |
|
Tried saving and restoring scroll position via @david-allison can you please help me with this ? |
|
Hello 👋, this PR has had no activity for more than 2 weeks and needs a reply from the author. If you think this is a mistake please comment and ping a maintainer to get this merged ASAP! Thanks for contributing! You have 7 days until this gets closed automatically |
|
Sorry but I can't help you @Ayush-Patel-56, I know nothing about this kind of coding. |
Purpose / Description
When viewing charts in the Statistics or Card Info screens, tapping on a bar opens a popup tooltip. If the device orientation changes while this popup is active, the popup remains on the screen and goes "out of bounds" instead of updating its position or being dismissed.
Fixes
Approach
Approach
Switched the hosting activity for
StatisticsandCardInfoFragmentdestinations fromSingleFragmentActivitytoConfigAwareSingleFragmentActivity. UnlikeSingleFragmentActivity,ConfigAwareSingleFragmentActivityrecreates on configuration changes (such as device rotation), ensuring the hosting Activity and Fragment are rebuilt and the WebView page is cleanly re-rendered to fit the new screen dimensions.Overrode
onCreateWebViewClientinStatisticsto re-apply the currently selected deck viachangeDeckonce the WebView finishes loading (usingonPageFinishedCallbacks) to preserve the user's selected deck across rotation.How Has This Been Tested?
Automated Tests
./gradlew :AnkiDroid:testPlayDebugUnitTest --tests "com.ichi2.anki.pages.StatisticsTest"(Tests pass successfully)
Manual Verification
new_video.mp4
Configuration: Tested using Robolectric and on an Android Emulator running SDK 33.
Checklist