mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 18:56:44 -04:00
Merge pull request #4211 from kiwix/Fixes#4206
Keeping the downloading books always at the top.
This commit is contained in:
commit
549bb5afb0
@ -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()
|
||||
|
@ -488,24 +488,35 @@ class ZimManageViewModel @Inject constructor(
|
||||
): List<LibraryListItem> {
|
||||
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
|
||||
|
@ -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)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
@ -181,6 +181,7 @@
|
||||
<string name="do_not_ask_anymore">Do not ask anymore</string>
|
||||
<string name="your_languages" tools:keep="@string/your_languages">Selected languages:</string>
|
||||
<string name="other_languages" tools:keep="@string/other_languages">Other languages:</string>
|
||||
<string name="downloading" tools:keep="@string/no_items_msg">Downloading:</string>
|
||||
<string name="no_items_msg" tools:keep="@string/no_items_msg">No items available</string>
|
||||
<string name="crash_title">Well… This is Embarrassing</string>
|
||||
<string name="crash_description">It looks like we crashed.\n\nWould you mind helping us fix this problem by sending the following information?</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user