diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/download/DownloadTest.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/download/DownloadTest.kt index 853474bd64..f9533c500c 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/download/DownloadTest.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/download/DownloadTest.kt @@ -140,6 +140,8 @@ class DownloadTest : BaseActivityTest() { stopDownloadIfAlreadyStarted() downloadZimFile(smallestZimFileIndex) try { + // Scroll to the top because now the downloading ZIM files are showing on the top. + scrollToZimFileIndex(0) assertDownloadStart() pauseDownload() assertDownloadPaused() diff --git a/app/src/main/java/org/kiwix/kiwixmobile/zimManager/ZimManageViewModel.kt b/app/src/main/java/org/kiwix/kiwixmobile/zimManager/ZimManageViewModel.kt index c31a939fd4..c200e8178a 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/zimManager/ZimManageViewModel.kt +++ b/app/src/main/java/org/kiwix/kiwixmobile/zimManager/ZimManageViewModel.kt @@ -488,24 +488,35 @@ class ZimManageViewModel @Inject constructor( ): List { val activeLanguageCodes = allLanguages.filter(Language::active) .map(Language::languageCode) + val allBooks = libraryNetworkEntity.book!! - booksOnFileSystem.map(BookOnDisk::book).toSet() + val downloadingBooks = activeDownloads.mapNotNull { download -> + allBooks.firstOrNull { it.id == download.book.id } + } val booksUnfilteredByLanguage = applySearchFilter( - libraryNetworkEntity.book!! - booksOnFileSystem.map(BookOnDisk::book), + allBooks - downloadingBooks.toSet(), filter ) val booksWithActiveLanguages = booksUnfilteredByLanguage.filter { activeLanguageCodes.contains(it.language) } + val booksWithoutActiveLanguages = booksUnfilteredByLanguage - booksWithActiveLanguages.toSet() return createLibrarySection( - booksWithActiveLanguages, + downloadingBooks, activeDownloads, fileSystemState, - R.string.your_languages, + R.string.downloading, Long.MAX_VALUE + ) + createLibrarySection( + booksWithActiveLanguages, + emptyList(), + fileSystemState, + R.string.your_languages, + Long.MAX_VALUE - 1 ) + createLibrarySection( - booksUnfilteredByLanguage - booksWithActiveLanguages, - activeDownloads, + booksWithoutActiveLanguages, + emptyList(), fileSystemState, R.string.other_languages, Long.MIN_VALUE diff --git a/app/src/test/java/org/kiwix/kiwixmobile/zimManager/ZimManageViewModelTest.kt b/app/src/test/java/org/kiwix/kiwixmobile/zimManager/ZimManageViewModelTest.kt index 333c6b3156..02da4d6287 100644 --- a/app/src/test/java/org/kiwix/kiwixmobile/zimManager/ZimManageViewModelTest.kt +++ b/app/src/test/java/org/kiwix/kiwixmobile/zimManager/ZimManageViewModelTest.kt @@ -384,7 +384,7 @@ class ZimManageViewModelTest { url = "" ) val bookWithInactiveLanguage = book( - id = "3", + id = "4", language = "inactiveLanguage", url = "" ) @@ -415,10 +415,12 @@ class ZimManageViewModelTest { viewModel.libraryItems.test() .assertValue( listOf( - LibraryListItem.DividerItem(Long.MAX_VALUE, R.string.your_languages), + LibraryListItem.DividerItem(Long.MAX_VALUE, R.string.downloading), + LibraryListItem.LibraryDownloadItem(downloadModel(book = bookDownloading)), + LibraryListItem.DividerItem(Long.MAX_VALUE - 1, R.string.your_languages), LibraryListItem.BookItem(bookWithActiveLanguage, CanWrite4GbFile), LibraryListItem.DividerItem(Long.MIN_VALUE, R.string.other_languages), - LibraryListItem.LibraryDownloadItem(downloadModel(book = bookDownloading)) + LibraryListItem.BookItem(bookWithInactiveLanguage, CanWrite4GbFile) ) ) } diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index 4d1062acef..bfac610fd6 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -181,6 +181,7 @@ Do not ask anymore Selected languages: Other languages: + Downloading: No items available Well… This is Embarrassing It looks like we crashed.\n\nWould you mind helping us fix this problem by sending the following information?