Skip to content

Conversation

@MohitMaliFtechiz
Copy link
Collaborator

@MohitMaliFtechiz MohitMaliFtechiz commented Oct 3, 2025

Fixes #41

  • Introduced similarly spelled suggestions results.
  • Fixed: SearchStateTest that was failing.
  • Refactored our UI to support showing multiple suggestedItems returns by libkiwix.
  • Refactored the code to use the libkiwix's SpellingsDB.
  • Configured custom apps to display spell-checked suggestions in search based on configuration. See Introduced the show_search_suggestions_spellchecked key in the info.json file. kiwix-android-custom#252.
  • The SpellingsDB is initilized inside the application's cache dir.
  • Assets are now loaded inside the AssetLoadingCachedDir subdirectory within the cache directory, instead of directly in the cache root. This ensures that when the asset cache is cleared, the SpellingsDB remains preserved in storage.
  • Upgraded the libkiwix version to 2.4.0 to use the new bindings.
  • Refactored the UI to show spelling correction suggestions in the same way as search suggestion items.

Important

At the first start, it will not show anything untill the DB is fully created, it takes time in creating the DB at first launch. However, it starts showing the spelled correction suggestions after the DB is initilazed(In the meanwhile user can use the application normally). After the first launch(when DB created) then it immedadtly shows the spelling correction suggestions. See in below video.

DWDS_Spelling_correction.mp4

@MohitMaliFtechiz MohitMaliFtechiz marked this pull request as draft October 3, 2025 16:09
@kelson42
Copy link
Collaborator

kelson42 commented Nov 5, 2025

@MohitMaliFtechiz Are we reqdy to merge here? Please carrefuly issue/PR on Apple to ensure you are at the level kiwix/kiwix-apple#1326. We shoukd be ready ASAP to merge and publish release for dwds.

Please update with screencast PR description

@MohitMaliFtechiz
Copy link
Collaborator Author

@MohitMaliFtechiz Are we reqdy to merge here?

No yet, depeneds on kiwix/java-libkiwix#130.

Please carrefuly issue/PR on Apple to ensure you are at the level kiwix/kiwix-apple#1326. We shoukd be ready ASAP to merge and publish release for dwds.

Sure, i am on it.

@codecov
Copy link

codecov bot commented Nov 5, 2025

Codecov Report

❌ Patch coverage is 37.11340% with 122 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.32%. Comparing base (5142ea1) to head (ee50d4e).

Files with missing lines Patch % Lines
.../org/kiwix/kiwixmobile/core/search/SearchScreen.kt 37.11% 56 Missing and 5 partials ⚠️
...org/kiwix/kiwixmobile/core/reader/ZimFileReader.kt 12.50% 23 Missing and 5 partials ⚠️
...g/kiwix/kiwixmobile/core/reader/ZimReaderSource.kt 17.64% 10 Missing and 4 partials ⚠️
...rg/kiwix/kiwixmobile/core/utils/files/FileUtils.kt 25.00% 11 Missing and 1 partial ⚠️
...rg/kiwix/kiwixmobile/core/search/SearchFragment.kt 73.68% 5 Missing ⚠️
...kiwixmobile/core/main/reader/CoreReaderFragment.kt 66.66% 0 Missing and 1 partial ⚠️
...wixmobile/core/search/viewmodel/SearchViewModel.kt 0.00% 0 Missing and 1 partial ⚠️

❌ Your patch check has failed because the patch coverage (37.11%) is below the target coverage (70.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #4445      +/-   ##
============================================
- Coverage     58.49%   58.32%   -0.18%     
- Complexity     1464     1477      +13     
============================================
  Files           327      327              
  Lines         17057    17204     +147     
  Branches       2115     2147      +32     
============================================
+ Hits           9978    10034      +56     
- Misses         5676     5754      +78     
- Partials       1403     1416      +13     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…by libkiwix.

* Refactored the code to use the libkiwix's `SpellingsDB`.
…ts initialization is time-consuming. Creating it together with the reader was increasing the load time and affecting the user experience. Since this object is only needed during search, we can safely initialize it in the background while allowing the user to read the ZIM file.
@MohitMaliFtechiz
Copy link
Collaborator Author

Currently, CI failing due to we do not have the new bindings of java-libkiwix. See kiwix/java-libkiwix#128, and kiwix/java-libkiwix#130.

> Task :core:compileDebugKotlin FAILED
e: file:///home/runner/work/kiwix-android/kiwix-android/core/src/main/java/org/kiwix/kiwixmobile/core/reader/ZimFileReader.kt:42:27 Unresolved reference 'SpellingsDB'.
e: file:///home/runner/work/kiwix-android/kiwix-android/core/src/main/java/org/kiwix/kiwixmobile/core/reader/ZimFileReader.kt:115:28 Unresolved reference 'SpellingsDB'.
e: file:///home/runner/work/kiwix-android/kiwix-android/core/src/main/java/org/kiwix/kiwixmobile/core/reader/ZimFileReader.kt:198:21 Unresolved reference 'SpellingsDB'.
e: file:///home/runner/work/kiwix-android/kiwix-android/core/src/main/java/org/kiwix/kiwixmobile/core/reader/ZimFileReader.kt:217:5 Return type mismatch: expected 'kotlin.collections.List<kotlin.String>', actual 'kotlin.Any'.
e: file:///home/runner/work/kiwix-android/kiwix-android/core/src/main/java/org/kiwix/kiwixmobile/core/reader/ZimFileReader.kt:218:20 Unresolved reference 'getSpellingCorrections'.
e: file:///home/runner/work/kiwix-android/kiwix-android/core/src/main/java/org/kiwix/kiwixmobile/core/reader/ZimFileReader.kt:225:20 Not enough information to infer type argument for 'T'.
e: file:///home/runner/work/kiwix-android/kiwix-android/core/src/main/java/org/kiwix/kiwixmobile/core/reader/ZimFileReader.kt:440:18 Unresolved reference 'dispose'.

… based on configuration.

* The database is initialized on the first launch and reused throughout the app’s lifecycle.
* Improved the comparison logic in `ZimReaderSource`.
* Assets are now loaded inside the `AssetLoadingCachedDir` subdirectory within the `cache` directory, instead of directly in the `cache` root. This ensures that when the asset cache is cleared, the `SpellingsDB` remains preserved in storage.
@MohitMaliFtechiz
Copy link
Collaborator Author

The code refactoring has been completed for this PR. The last change is left in this PR is using the new java-libkiwix.

@kelson42
Copy link
Collaborator

kelson42 commented Nov 10, 2025

@MohitMaliFtechiz We have a bit evolved on the topic how to display spellchecker suggestions since the beginning. Can you please do it in a way you can display many suggestions? This means displaying the spell suggestionS exactly like the normal suggestion, the only difference, is that just on the top you write "Do you mean:".

Please also show us how looks the first start of the app (the one where the index is created). Is that fully transparent?

@kelson42
Copy link
Collaborator

Currently, CI failing due to we do not have the new bindings of java-libkiwix. See kiwix/java-libkiwix#128, and kiwix/java-libkiwix#130.

Please do the PR to make the release of java-libkiwix asap.

* Refactored the UI to show spelling correction suggestions in the same way as search suggestion items, consistent with the iOS app.
@MohitMaliFtechiz
Copy link
Collaborator Author

@MohitMaliFtechiz We have a bit evolved on the topic how to display spellchecker suggestions since the beginning. Can you please do it in a way you can display many suggestions? This means displaying the spell suggestionS exactly like the normal suggestion, the only difference, is that just on the top you write "Do you mean:".

@kelson42 I have made the changes see the below-video.

DWDS_Spelling_correction.mp4

Please also show us how looks the first start of the app (the one where the index is created). Is that fully transparent?

It works like in the above video. Also, i have updated the PR description for this.

Please do the PR to make the release of java-libkiwix asap.

Released the java-libkiwix on maven, and updated our code to use the latest bindings.

@kelson42
Copy link
Collaborator

kelson42 commented Nov 11, 2025

@MohitMaliFtechiz Why the video starts at 30s? What happens if someone start to search an index is still no here?

Other small detail, the "Do you mean:" is well positioned but can almost be confused with a result. We have no way to improve the situation? Maybe we could have a background behind each resukt item slightly more visible (darker)? Or change somehow a bit the font of the string "Do you mean:"?

@MohitMaliFtechiz
Copy link
Collaborator Author

MohitMaliFtechiz commented Nov 12, 2025

@MohitMaliFtechiz Why the video starts at 30s?

@kelson42 The application is building at this time, i was running the application via Android studio so it took time in building and running the application.

What happens if someone start to search an index is still no here?

If user start for search, and the DB is not still fully created. Then it will not show any result instead it will work like normal search:

  • If no result found for that search term: It shows the "No result" text.
  • If no result found for that search term, and previously opened items are avialable in our android DB: It shows the those items.

But after the DB is fully created it starts showing the "Spelled correction suggestions".

Maybe we could have a background behind each resukt item slightly more visible (darker)? Or change somehow a bit the font of the string "Do you mean:"?

Here are both UI.

With background in dark mode With background in day mode With font
Screenshot_20251112-135536 Screenshot_20251112-135526 Screenshot_20251112-134035

To separate the suggestion items, I think the font-based version works better. Changing the background would make it look inconsistent with the normal search suggestions. @kelson42 What do you think?

@MohitMaliFtechiz MohitMaliFtechiz marked this pull request as draft November 12, 2025 12:38
* Fixed a native crash that occurred when the `SpellingsDB` creation was incomplete and the user closed the application. In such cases, a temporary folder (.tmp) remained, causing a `DatabaseCreateError` during the next initialization.
* Improved the font of "Do you mean:" text so that it could be show different from our suggestion items.
@MohitMaliFtechiz
Copy link
Collaborator Author

MohitMaliFtechiz commented Nov 12, 2025

@kelson42 I have made the changes in font size of "Do you mean:" as shown in the above screenshot. If do you want any change in it do let me know.

@MohitMaliFtechiz MohitMaliFtechiz marked this pull request as ready for review November 12, 2025 14:06
@kelson42
Copy link
Collaborator

@MohitMaliFtechiz Thx for the explanations and fint changes. All good IMO.

Can you please change the item bacground as well... everywhere (rmember: suggestion AND spelled suggestions shoukd display the same!)?

@MohitMaliFtechiz
Copy link
Collaborator Author

Can you please change the item bacground as well... everywhere (rmember: suggestion AND spelled suggestions shoukd display the same!)?

@kelson42 Sure. Doing the changes.

@MohitMaliFtechiz
Copy link
Collaborator Author

I have made the changes the UI look like this(in day and night theme):

SpellingAndSearchSuggestionsWithBackground.mp4

@kelson42
Copy link
Collaborator

kelson42 commented Nov 13, 2025

@MohitMaliFtechiz Better, but you should have the same kind of spacing/margin left, right, too, bottom between the result item!..l and they should not be too big, currently the ratio font size, item size, space between two item is really not beautiful.

I will provide you a mockup

@MohitMaliFtechiz
Copy link
Collaborator Author

@kelson42 What do you think about this UI?

Normal suggestions Spelled corrections suggestions
Screenshot_20251113-220036 Screenshot_20251113-220041
NewSearchUI.mp4

@MohitMaliFtechiz MohitMaliFtechiz marked this pull request as draft November 13, 2025 16:51
@kelson42
Copy link
Collaborator

This is a lot better, here few suggestions:

  • Can we reduce the height of item (only a few pixels)?
  • Reduce the spacing left, roght, ... of one or two pixels
  • slightly reduce the radius of cirners

@MohitMaliFtechiz
Copy link
Collaborator Author

MohitMaliFtechiz commented Nov 13, 2025

Can we reduce the height of item (only a few pixels)?

@kelson42 We can only reduce the height of the item a little bit like shown in the below images: We could not reduce the more height otherwise it will give the "Touch target" issue for the "Open in new tab" icon.

Reduce the spacing left, roght, ... of one or two pixels

I have reduced it by 2 pixel.

Reduced height (With 10dp radius) Reduced height (With 8dp radius)
Screenshot_20251114-010045 Screenshot_20251114-011335
Screenshot_20251114-010051 Screenshot_20251114-010436

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Suggest similarly spelled suggestions results

4 participants