Skip to content

Conversation

@MohitMaliFtechiz
Copy link
Collaborator

@MohitMaliFtechiz MohitMaliFtechiz commented Jan 25, 2023

Fixes #3122
Fixes #3094
Fixes #3410
Fixes #3442
Fixes #2767
Fixes #2768
Fixes #3098
Fixes #3216
Fixes #2683.

  • We now have a new wrapper for java-libkiwix. This wrapper provides more direct access to libkiwix and libzim, enabling us to use the reader and searcher functionality through the natural methods of libzim and libkiwix. As a result, our wrapper introduces several new APIs, such as Archive and Searcher. To accommodate these changes in libkiwix, we have refactored our Android code to utilize the new java-libkiwix APIs.

  • As part of the update, java-libkiwix now compiles with Android 24 and above, making it incompatible with versions below Android 24. Consequently, we have raised the minimum SDK version of kiwix-android to 24 to ensure compatibility with java-libkiwix. For more information, refer to this link.

  • Introduced an endless suggestion list in search "Endless" suggestion list #3122.

    • With the integration of libkiwix12, we now receive full results based on the search term. Previously, we were loading the entire list, but we have now implemented pagination to enhance the search functionality.
    • The libkiwix provides us with a Search object, which enables us to obtain the suggestion list using start and end indices. Consequently, we have modified our ZimSearchResultGenerator code to return the Search object instead of a list.
    • To accommodate the changes, we have updated the return type of SearchResultGenerator to a nullable Search. This change is necessary because we initialize the SearchState when the search is initialized in SearchViewModel, and initially, we do not have the Search object available. The nullable return type allows us to pass the Search object when it becomes available.
    • We have modified our test cases for this change:
      Due to linking errors with libkiwix/libzim functions, direct testing usage was impossible. To address this, helper classes were created, similar to those in java-libkiwix, for testing the search functionality.

Since this pull request contains numerous changes, we have committed each small change with a detailed commit message. Please read the commit messages to understand the specific modifications made in this pull request.

This PR also fixes some other tickets of milestone 3.8.0 :

  1. Article opening after search page result leads to blank page on wikihow (Chinese) #3094
  2. Search results don't lead anywhere in Stack exchange Zims #3410 This issue is fixed in the latest wrapper.
  3. Can't open any zim files made with docker zimit, nautilus, zimwriterfs or warc2zim after 3.6.0 #3442 This issue is fixed in the latest wrapper.
  4. Random article function not working in wikiHow ZIMs #2767 This issue is fixed in the latest wrapper.
  5. Search results not retrievable in wikiHow ZIMs #2768 This issue is fixed in the latest wrapper.
  6. Custom created uptodate zim search not working on android (Works in Windows and kiwix-serve) #3098 This issue is fixed in the latest wrapper.
  7. 500 Error happens in Browser #2683 This issue is fixed in the latest wrapper.
  • Improved test cases and fixed memory leak in application.
    • Previously our test cases were launching the KiwixMainActivity twice (firstly it sets the values in preference and then relaunches the activity) before running the test case which was the cause of slow testing and sometimes it caused memory leak in some API levels so we have refactored our test cases to launch KiwixMainActivity once per test case.
    • IntroFragmentTest is failing on API level 24 due to a memory leak because after clicking on the get-started button it goes to the LocalLibrary page but somehow CoreReaderFragment's onStart and onStop methods are calling, which establish the serviceConnection, but it was happening very quickly. So before attaching the binder to the readAloudService unbindService method was called but at this point, the binder was not created, but creating was in progress so after going to the library screen it allocated memory to readAloudService, but ReaderFragment not visible to the user, that's why memory leak happened. We have fixed it by unbinding the service in the onDestroyView method.

@MohitMaliFtechiz MohitMaliFtechiz marked this pull request as draft January 25, 2023 13:18
@MohitMaliFtechiz MohitMaliFtechiz force-pushed the Issue#3216 branch 2 times, most recently from ac5a220 to 07bb13c Compare July 17, 2023 06:34
@kelson42
Copy link
Collaborator

@MohitMaliFtechiz Does this PR fixes other tickezs in 0.8 milestone? If "yes", which one exactly?

@MohitMaliFtechiz
Copy link
Collaborator Author

MohitMaliFtechiz commented Jul 17, 2023

@kelson42, Yes it seems to fix some other tickets of milestone 3.8.0.

  1. Article opening after search page result leads to blank page on wikihow (Chinese) #3094
  2. i) Search results don't lead anywhere in Stack exchange Zims #3410
    ii) Search results not retrievable in wikiHow ZIMs #2768 Once searching is start working we will test these issues.
  3. Can't open any zim files made with docker zimit, nautilus, zimwriterfs or warc2zim after 3.6.0 #3442 This issue is fixed in the latest wrapper.

Some tickets may be fixed by this PR, but not tested yet.

  1. Random article function not working in wikiHow ZIMs #2767

@kelson42
Copy link
Collaborator

kelson42 commented Jul 17, 2023

So why they are not in description? Maybe just because you are not over... but please put them when you are so far.

@codecov
Copy link

codecov bot commented Jul 28, 2023

Codecov Report

Patch coverage: 53.61% and project coverage change: +0.45% 🎉

Comparison is base (f29c206) 48.86% compared to head (6530539) 49.31%.
Report is 1 commits behind head on develop.

❗ Current head 6530539 differs from pull request most recent head 9ff91ba. Consider uploading reports for the commit 9ff91ba to get more accurate results

Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #3217      +/-   ##
=============================================
+ Coverage      48.86%   49.31%   +0.45%     
- Complexity      1018     1027       +9     
=============================================
  Files            285      284       -1     
  Lines          10136    10189      +53     
  Branches        1353     1356       +3     
=============================================
+ Hits            4953     5025      +72     
+ Misses          4399     4356      -43     
- Partials         784      808      +24     
Files Changed Coverage Δ
...ava/org/kiwix/kiwixmobile/webserver/KiwixServer.kt 5.55% <0.00%> (-2.14%) ⬇️
...bserver/wifi_hotspot/HotspotNotificationManager.kt 7.69% <0.00%> (+0.37%) ⬆️
...wixmobile/webserver/wifi_hotspot/HotspotService.kt 36.50% <0.00%> (+0.57%) ⬆️
...a/org/kiwix/kiwixmobile/zimManager/Fat32Checker.kt 67.50% <0.00%> (+7.50%) ⬆️
...le/zimManager/fileselectView/effects/ShareFiles.kt 0.00% <0.00%> (ø)
.../java/org/kiwix/kiwixmobile/core/JNIInitialiser.kt 47.36% <ø> (ø)
...wixmobile/core/base/adapter/BaseDelegateAdapter.kt 81.81% <0.00%> (-18.19%) ⬇️
...ava/org/kiwix/kiwixmobile/core/compat/CompatV33.kt 0.00% <0.00%> (ø)
...org/kiwix/kiwixmobile/core/di/modules/JNIModule.kt 100.00% <ø> (+57.14%) ⬆️
...a/org/kiwix/kiwixmobile/core/main/AddNoteDialog.kt 0.00% <0.00%> (ø)
... and 18 more

... and 19 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MohitMaliFtechiz
Copy link
Collaborator Author

MohitMaliFtechiz commented Aug 15, 2023

@kelson42, @gouri-panda, This PR is ready for review now. But here we have fixed SuggestionSearch in java-libkiwix kiwix/java-libkiwix#61. So once we will publish the new version of java-libkiwix on Maven then we upgrade the version of libkiwix and we can merge this PR meanwhile you can start reviewing this PR since it is a big PR.

@gouri-panda
Copy link
Collaborator

@MohitMaliDeveloper Ok, but it'll take some time to review the code since I'm not quite familiar with this end of the code and the PR is large and it also touches breakable changes. I want to make things right :)

@kelson42
Copy link
Collaborator

kelson42 commented Aug 16, 2023

@MohitMaliFtechiz we need anyway to republish the binding with the right name first. please prepare everything for the release in a pr (see release ticket in java-libkiwix). So this pr depends on kiwix/java-libkiwix#42

@kelson42
Copy link
Collaborator

kelson42 commented Aug 27, 2023

@gouri-panda Any news here? We really need your expert approval here to move forward! Can you please check if it fixes #3118 as well?

@kelson42
Copy link
Collaborator

org.kiwix/libkiwix has been released on Maven. Please update PR to use it and review with PRIO0.

MohitMaliDeveloper and others added 27 commits September 18, 2023 19:13
* As we can not search in that zim file which is not contains the FT Xapian index and testzim.zim file is not contain it so we have improved our test case.
* Now we are downloading the `off the grid` zim file and performing the search functionality inside it.
* Fixed search unit test cases.
* Improved the search functionality to perform the unit test case for search.
… been upgraded (as mentioned in kiwix/kiwix-build#544). However, to make this upgrade compatible, the minimum SDK version had to be updated to 24 since the NDK version is not compatible with Android API levels below 24. The README.md file has been updated to reflect the new minimum Android support version, which is now Android 7, due to the change in the minimum SDK version. Since the project's minimum SDK version is now 24, some conditions related to Android 23 and 24 have become unused. These unused conditions have been removed, and along with that, the drawable-night-23 and drawable-23 launch_screen.xml files, which were no longer in use, have also been removed.
* Now our minimum SDK version is 24 and we are using some conditions placed on behalf of this api level which are unused now, so we have removed those conditions.
* Removed `CompatV21` file as now it is unused.
* Renamed `CompatV23` to `CompatV24` and refactored the code to support our new minimum api level.
* Refactored `NetworkUtilsTest` to support api level 24.
* Since our minimum API level is now 24, we have updated our CI configuration to run on API level 24, which aligns with the minimum API level required for our project.
* With the integration of libkiwix12, we now receive full results based on the search term. Previously, we were loading the entire list, but we have now implemented pagination to enhance the search functionality.
* The libkiwix provides us with a Search object, which enables us to obtain the suggestion list using start and end indices. Consequently, we have modified our `ZimSearchResultGenerator` code to return the `Search` object instead of a list.
* To accommodate the changes, we have updated the return type of `SearchResultGenerator` to a nullable Search. This change is necessary because we initialize the `SearchState` when the search is initialized in `SearchViewModel`, and initially, we do not have the Search object available. The nullable return type allows us to pass the Search object when it becomes available.
* Due to linking errors with libkiwix/libzim functions, direct usage in testing was not possible. To address this, helper classes were created, similar to those in `java-libkiwix`, for testing the search functionality.
…at the end of list and there is no data available to show
* We are previously checking `hasEntryByPath`, `hasEntryByTitle`, `mainEntry.isRedirect` which are internally calling the same function as we are calling after checking this condition so it would be better to directly use those function to avoid calling same function twice see more details kiwix/java-libkiwix#60.
* Updated proguard file to keep the `libkiwix/libzim` classes in release variant.
…ality.

* Since `Search` is not compatible with those zim files which does not have Xapian index but `SuggestionSearch` have this functionality to search inside those zim files so we have used this.
* Update test cases for test new search functionality.
After addressing the issue documented in kiwix/java-libkiwix#61, we now have the ability to search within zim files that do not have a Xapian index. As a result, we have enhanced our test to utilize pre-existing zim files. This improvement leads to reduced time consumption, improved memory efficiency, and minimized network usage impact.
* Added a loading progress bar at the end of the RecyclerView when loading more search results as the user scrolls to the bottom. This indicator informs users that additional results are being loaded. The progress bar appears if there are more results available for the search term, providing users with visibility into ongoing loading.
* Enhanced the search loading process for larger ZIM files by introducing coroutines. This background threading approach prevents the UI thread from being impacted and ensures a smooth scrolling experience for users.
* A bug was introduced after enhancing the search functionality to align with the new `java-libkiwix` wrapper. Initially, when searching for any article in the ZIM file, the loading progress bar was not being displayed. This commit resolves this issue.
* While searching within large ZIM files, the application used to freeze momentarily due to fetching data from the `libkiwix` on the UI thread. We have improved this functionality to provide a seamless user experience.
* Previously our test cases were launching the `KiwixMainActivity` twice (firstly it sets the values in preference and then relaunch the activity) before running the test case which was the cause of slow testing and sometimes it caused to memory leak in some api levels so we have refactored our test cases to launch `KiwixMainTest` once per test case.
* `IntroFragmentTest` is failing on api level 24 due to a memory leak because after clicking on getStarted button is going to the LocalLibrary page but somehow `onStart` and `onStop` methods are calling of the `CoreReaderFragment` which stablish the `serviceConnection` but it was happening very quickly so before attaching the binder to `readAloudService` unbindService method called but at this point service was not created but creating was in progress so after going to library screen it allocate memory to `readAloudService` but `ReaderFragment` is no more visible to the user that's why memory leak happened. We have fixed it by unbinding the service in `onDestroyView` method.
…ral other enhancements:

* Added logging for cases where the `ZimFileReader` failed to find an entry, failed to load an asset, and more.
* Significantly improved the "load more" functionality: Now, if the user is near the end of the list, we start loading new search results. This enhancement enhances the user experience by reducing wait times for new search results.
* Added references in the `KiwixServer` class to help developers understand why we are keeping the library object.
* Implemented test cases to thoroughly test the `getMimeTypeFromUrl()` function in the ZimFileReader class.
* Enhanced the search functionality by consolidating the use of a single viewModelScope instead of multiple coroutines, reducing the potential for future issues.
…t in the `SearchFragment`. We are now directly obtaining additional search data from the `SearchViewModel`, which already contains the `SearchState`.
@kelson42 kelson42 merged commit 27215b0 into develop Sep 18, 2023
@kelson42 kelson42 deleted the Issue#3216 branch September 18, 2023 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment