Skip to content

Commit

Permalink
Fixed: Mul file not recognized as such and listing pretty much all la…
Browse files Browse the repository at this point in the history
…nguages.

* ZIM files that have multiple languages are represented as a single string with comma-separated values (e.g., "eng,fra,vie,ita,ara,por"). We have modified the code to check for these cases and ensure that any ZIM file containing more than one language is shown under the "Multiple languages" section.
  • Loading branch information
MohitMaliDeveloper authored and kelson42 committed Jul 1, 2024
1 parent 3c0397d commit 0f8b593
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion core/src/main/java/org/kiwix/kiwixmobile/core/data/Repository.kt
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,22 @@ class Repository @Inject internal constructor(
.observeOn(mainThread)

override fun booksOnDiskAsListItems(): Flowable<List<BooksOnDiskListItem>> = bookDao.books()
.map { it.sortedBy { bookOnDisk -> bookOnDisk.book.language + bookOnDisk.book.title } }
.map {
it.map { bookOnDisk ->
// If the book contains more than one language, it comes in a single string with commas.
// e.g., "eng,fra,vie,ita,ara,por". Check if the language contains a comma,
// then move this book to the "Multiple languages" section.
if (bookOnDisk.book.language.contains(',')) {
bookOnDisk.copy().apply {

Check warning on line 77 in core/src/main/java/org/kiwix/kiwixmobile/core/data/Repository.kt

View check run for this annotation

Codecov / codecov/patch

core/src/main/java/org/kiwix/kiwixmobile/core/data/Repository.kt#L77

Added line #L77 was not covered by tests
// Set the language to "mul" for the book so that it is shown
// in the "Multiple languages" section.
book.language = "mul"
}

Check warning on line 81 in core/src/main/java/org/kiwix/kiwixmobile/core/data/Repository.kt

View check run for this annotation

Codecov / codecov/patch

core/src/main/java/org/kiwix/kiwixmobile/core/data/Repository.kt#L80-L81

Added lines #L80 - L81 were not covered by tests
} else {
bookOnDisk
}
}.sortedBy { bookOnDisk -> bookOnDisk.book.language + bookOnDisk.book.title }
}.map {
HeaderizableList<BooksOnDiskListItem, BookOnDisk, LanguageItem>(it).foldOverAddingHeaders(
{ bookOnDisk -> LanguageItem(bookOnDisk.locale) },
{ current, next -> current.locale.displayName != next.locale.displayName }
Expand Down

0 comments on commit 0f8b593

Please sign in to comment.