-
-
Notifications
You must be signed in to change notification settings - Fork 446
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
Saving and Restoring the Web View Navigation History Across Sessions #3996
base: main
Are you sure you want to change the base?
Conversation
Hello @MohitMaliFtechiz @kelson42 WhatsApp.Video.2024-09-19.at.11.05.05_9d0b7924.mp4But it has some cons.
On the bright side, the current approach makes sure everything is restored in order, so the navigation history stays consistent. Also, I’ve experimented with a few other approaches to reduce the restoration time, but none of them offered the same level of accuracy. It seems like there’s a trade-off between speed and ensuring the history is restored correctly. I’d appreciate your input on how we might address these challenges and any suggestions you have for further refinement of this approach |
@Saifuddin53 Thanks for your PR, and inputs. I will test and review your PR. I have fixed the detekt issue you were facing, Now, you can continue doing your work. The |
@MohitMaliDeveloper Any news? |
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.
@Saifuddin53 For the restoration timing issue, I am seeing the possible solution. In the meantime can you please make these review changes?
core/src/main/java/org/kiwix/kiwixmobile/core/dao/PageHistoryRoomDao.kt
Outdated
Show resolved
Hide resolved
core/src/main/java/org/kiwix/kiwixmobile/core/dao/entities/PageHistoryRoomEntity.kt
Outdated
Show resolved
Hide resolved
core/src/main/java/org/kiwix/kiwixmobile/core/data/DataSource.kt
Outdated
Show resolved
Hide resolved
core/src/main/java/org/kiwix/kiwixmobile/core/main/MainRepositoryActions.kt
Outdated
Show resolved
Hide resolved
core/src/main/java/org/kiwix/kiwixmobile/core/page/history/adapter/PageHistoryItem.kt
Outdated
Show resolved
Hide resolved
@Saifuddin53 Any news here? |
@kelson42 trying to optimize this algo. |
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.
@Saifuddin53 Please do these changes it will reduce the restoring time, and increase the overall performance and code quality.
core/src/main/java/org/kiwix/kiwixmobile/core/di/components/CoreComponent.kt
Outdated
Show resolved
Hide resolved
core/src/main/java/org/kiwix/kiwixmobile/core/di/modules/DatabaseModule.kt
Outdated
Show resolved
Hide resolved
core/src/main/java/org/kiwix/kiwixmobile/core/data/KiwixRoomDatabase.kt
Outdated
Show resolved
Hide resolved
core/src/main/java/org/kiwix/kiwixmobile/core/main/MainRepositoryActions.kt
Outdated
Show resolved
Hide resolved
core/src/main/java/org/kiwix/kiwixmobile/core/page/history/adapter/WebViewHistoryItem.kt
Outdated
Show resolved
Hide resolved
core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt
Outdated
Show resolved
Hide resolved
core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt
Outdated
Show resolved
Hide resolved
core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt
Outdated
Show resolved
Hide resolved
core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt
Outdated
Show resolved
Hide resolved
@Saifuddin53 What is the status on this PR? Do you need any help from me in completing the PR? |
@MohitMaliDeveloper, can you please help me with the restoration algorithm? As, when I try to load the pages using the onPageFinished callback, the pages load too quickly, or the asynchronous behavior of the WebView is not properly handled,so it sometimes skips some entries. |
@Saifuddin53 I will have a look at this after completing #4040. |
c0dba95
to
9f6b55d
Compare
9f6b55d
to
d8175e5
Compare
@Saifuddin53 The page history is restored when we open a page from a bookmark, history, etc. However, it should not restore the webView page history under these conditions(it should only restore the webView history when the application is restarted or we switch between pages). See the below video: IssueWhileRestoringWebViewHistory.mp4As in this condition, it should only open the page on which the user just clicked on the bookmark, history, etc. |
* Added new logic to save and restore WebView navigation history directly, without loading pages one by one. * Refactored Room database schema to support saving the history of all tabs instead of just one. * Applied changes to custom apps, currently working on integrating and testing with the Kiwix app. * Improved multi-tab restoration, ensuring history of all tabs is restored. * Improved the saving of WebView history by saving the list instead of saving each entry one by one, reducing database calls and saving time.
* Improved restoration of web view history after opening a searched article. * Refactored `restoreViewStateOnValidJSON` and `restoreViewStateOnInvalidJSON` methods to save and retrieve web view history from the Room database. * Added detailed comments to methods for better understanding, including guidance for developers to check subclass implementations before making modifications. * Fixed the `static analysis` errors.
3569070
to
b0750a9
Compare
* Created a common approach for both Kiwix and custom apps to open the searched item after restoring the tabs, ensuring smooth functionality in both applications and reducing the likelihood of future errors.
* Established a unified approach for both Kiwix and custom apps to trigger findInPage after restoring tabs, ensuring consistent functionality across both applications and minimizing potential future errors.
* Since tabs are now saved with proper WebView history on the IO thread, saving takes some time. As a result, when switching to the history, bookmarks, or notes screens, WebView history sometimes wasn't saved properly. To address this, we moved the tab-saving functionality from onPause to when the page is fully loaded in WebView, which ensures proper saving of tabs and reduces the chances of history loss. * This change fix the restoring the tabs when we switch to the bookmark, history, notes screens.
…after opening a page from the history, bookmarks, or notes screens in custom apps.
…es screen * Resolved the issue where the main page of the ZIM file was not loading when a note was opened from the notes screen, when a different ZIM file was set in the reader. Now, when opening notes, the application correctly sets the corresponding ZIM file in the reader, ensuring the main page is displayed as expected.
Fixes #398
Still in development
How It Works:
Screenshots