diff --git a/app/lint-baseline.xml b/app/lint-baseline.xml
index 06946ce3b..3f75b5561 100644
--- a/app/lint-baseline.xml
+++ b/app/lint-baseline.xml
@@ -158,26 +158,15 @@
file="..\..\..\.gradle\caches\modules-2\files-2.1\org.simpleframework\simple-xml\2.7.1\dd91fb744c2ff921407475cb29a1e3fee397d411\simple-xml-2.7.1.jar"/>
-
-
-
-
+ errorLine1=" filePath = String.format("/data/data/%s/lib/%s", BuildConfig.APPLICATION_ID,"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~">
+ line="1932"
+ column="36"/>
+ errorLine1=" android:networkSecurityConfig="@xml/network_security_config""
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ line="21"
+ column="5"/>
@@ -352,7 +341,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
@@ -411,7 +400,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
@@ -422,7 +411,7 @@
errorLine2=" ~~~~~~~~">
@@ -433,7 +422,7 @@
errorLine2=" ~~~~~~~~~~~">
@@ -444,7 +433,7 @@
errorLine2=" ^">
@@ -580,6 +569,34 @@
column="10"/>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
@@ -1384,51 +2140,51 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
-
-
+
+
-
+
@@ -1525,12 +2281,34 @@
message="The resource `R.string.no_items_msg` appears to be unused"
errorLine1=" <string name="no_items_msg">No items available</string>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -2704,7 +3625,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~">
@@ -2715,7 +3636,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~">
@@ -2726,7 +3647,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~">
@@ -2737,7 +3658,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~">
@@ -2748,7 +3669,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~">
@@ -2759,7 +3680,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~">
@@ -2770,7 +3691,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~">
@@ -2781,7 +3702,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~">
@@ -2792,7 +3713,7 @@
errorLine2=" ~~~~~~~~~~~~~~~">
@@ -2803,7 +3724,7 @@
errorLine2=" ~~~~~~~~~">
@@ -2814,7 +3735,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
@@ -2825,7 +3746,7 @@
errorLine2=" ~~~~~~~~">
@@ -2836,7 +3757,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~">
@@ -2847,7 +3768,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~">
@@ -2858,7 +3779,7 @@
errorLine2=" ~~~~~~~~~~">
@@ -2869,7 +3790,7 @@
errorLine2=" ~~~~">
@@ -2880,7 +3801,7 @@
errorLine2=" ~~~~~~~~~~~~~~">
@@ -2891,7 +3812,7 @@
errorLine2=" ~~~~~~~~~~">
@@ -2902,7 +3823,7 @@
errorLine2=" ~~~~">
@@ -2913,32 +3834,10 @@
errorLine2=" ~~~~~~~~~~~~~~">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -3056,7 +3988,7 @@
errorLine2=" ^">
@@ -3095,6 +4027,24 @@
file="src\main\res\drawable-xhdpi"/>
+
+
+
+
+
+
+
+
@@ -3146,19 +4096,30 @@
errorLine2=" ~~~~~~~~">
+ errorLine1=" <TextView"
+ errorLine2=" ~~~~~~~~">
+ line="59"
+ column="8"/>
+
+
+
+
@@ -3366,7 +4327,7 @@
errorLine2=" ~~~~~~~~~~~~">
@@ -3377,7 +4338,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~">
@@ -3399,7 +4360,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~">
@@ -3410,7 +4371,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~">
@@ -3421,7 +4382,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~">
@@ -3491,7 +4452,7 @@
errorLine2=" ~~~~~~~~~">
@@ -3502,7 +4463,7 @@
errorLine2=" ~~~~~~~~~">
@@ -3586,12 +4547,12 @@
+ errorLine1=" android:layout_marginRight="@dimen/favicon_margin_right""
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ line="17"
+ column="5"/>
-
-
-
-
@@ -3964,7 +4914,7 @@
errorLine2=" ~~~~~~~~~~~~">
@@ -3975,7 +4925,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
@@ -3986,18 +4936,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
-
-
-
-
@@ -4008,7 +4947,7 @@
errorLine2=" ~~~~~~~~~">
@@ -4019,7 +4958,7 @@
errorLine2=" ~~~~~~~~~">
@@ -4030,7 +4969,7 @@
errorLine2=" ~~~~~~~~~">
@@ -4118,7 +5057,7 @@
errorLine2=" ~~~~~~~~~~~~~~~">
@@ -5130,7 +6069,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
@@ -5141,7 +6080,7 @@
errorLine2=" ~~~~~~~~~~~">
@@ -5152,7 +6091,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
@@ -5163,7 +6102,7 @@
errorLine2=" ~~~~~~~~~~~">
@@ -5174,7 +6113,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
@@ -5185,7 +6124,7 @@
errorLine2=" ~~~~~~~~~~~">
@@ -5196,7 +6135,7 @@
errorLine2=" ~~~~~~~~~~~~~~">
@@ -5207,7 +6146,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
@@ -5218,7 +6157,7 @@
errorLine2=" ~~~~~~~~~~~">
@@ -5229,7 +6168,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~">
@@ -5240,7 +6179,7 @@
errorLine2=" ~~~~~~~~~~~">
@@ -5251,7 +6190,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~">
@@ -5262,7 +6201,7 @@
errorLine2=" ~~~~~~~~~~~">
@@ -5273,7 +6212,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~">
@@ -5284,7 +6223,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~">
@@ -5295,7 +6234,7 @@
errorLine2=" ~~~~~~~~~~~">
@@ -5306,7 +6245,7 @@
errorLine2=" ~~~~~~~~~~~~">
@@ -5317,7 +6256,7 @@
errorLine2=" ~~~~~~~~~~~">
@@ -5328,29 +6267,29 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~">
+ errorLine1=" Completable deleteBookmark(String bookmarkUrl);"
+ errorLine2=" ~~~~~~">
@@ -5361,7 +6300,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
@@ -5431,149 +6370,6 @@
column="39"/>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
@@ -5878,7 +6663,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~">
@@ -5889,7 +6674,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~">
@@ -5900,7 +6685,7 @@
errorLine2=" ~~~~~~~">
@@ -5911,7 +6696,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~">
@@ -6017,12 +6802,12 @@
+ errorLine1=" @GET(LIBRARY_NETWORK_PATH) Single<LibraryNetworkEntity> getLibrary();"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ line="36"
+ column="30"/>
@@ -6043,7 +6828,7 @@
errorLine2=" ~~~~~~">
@@ -6054,7 +6839,7 @@
errorLine2=" ~~~~~~~~~~~~">
@@ -6065,7 +6850,7 @@
errorLine2=" ~~~~~~~~~~~~">
@@ -6076,7 +6861,7 @@
errorLine2=" ~~~~~~">
@@ -6146,17 +6931,6 @@
column="9"/>
-
-
-
-
@@ -6351,7 +7125,7 @@
errorLine2=" ~~~~~~">
@@ -6362,7 +7136,7 @@
errorLine2=" ~~~~~~~">
@@ -6373,7 +7147,7 @@
errorLine2=" ~~~~~~">
@@ -6384,7 +7158,7 @@
errorLine2=" ~~~~~~">
@@ -6395,7 +7169,7 @@
errorLine2=" ~~~~~~~">
@@ -6406,7 +7180,7 @@
errorLine2=" ~~~~~~">
@@ -7154,7 +7928,7 @@
errorLine2=" ~~~~~~~~~~">
@@ -7165,7 +7939,7 @@
errorLine2=" ~~~~~~~~~~">
@@ -7176,7 +7950,7 @@
errorLine2=" ~~~~~~">
@@ -7187,7 +7961,7 @@
errorLine2=" ~~~~~~~~">
@@ -7198,7 +7972,7 @@
errorLine2=" ~~~~~~">
@@ -7209,7 +7983,7 @@
errorLine2=" ~~~~~~~~">
@@ -7220,7 +7994,7 @@
errorLine2=" ~~~~~~">
@@ -7231,7 +8005,7 @@
errorLine2=" ~~~~~~~~~~~~">
@@ -7242,7 +8016,7 @@
errorLine2=" ~~~~~~~~~~~~~">
@@ -7253,7 +8027,7 @@
errorLine2=" ~~~~~~">
@@ -7264,7 +8038,7 @@
errorLine2=" ~~~~">
@@ -7275,7 +8049,7 @@
errorLine2=" ~~~~">
@@ -7286,7 +8060,7 @@
errorLine2=" ~~~~~~">
@@ -7297,7 +8071,7 @@
errorLine2=" ~~~~~~">
@@ -7308,7 +8082,7 @@
errorLine2=" ~~~~~~">
@@ -7319,7 +8093,7 @@
errorLine2=" ~~~~">
@@ -7330,7 +8104,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
@@ -7341,7 +8115,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~">
@@ -7352,10 +8126,21 @@
errorLine2=" ~~~~">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -7836,7 +8709,7 @@
errorLine2=" ~~~~~~">
@@ -7847,7 +8720,7 @@
errorLine2=" ~~~~~~">
@@ -7858,7 +8731,7 @@
errorLine2=" ~~~~~~">
@@ -7869,7 +8742,7 @@
errorLine2=" ~~~~~~">
@@ -7880,7 +8753,7 @@
errorLine2=" ~~~~~~">
@@ -7891,7 +8764,7 @@
errorLine2=" ~~~~~~">
@@ -7902,18 +8775,18 @@
errorLine2=" ~~~~~~">
@@ -8082,215 +8955,6 @@
column="27"/>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
@@ -9057,7 +9732,7 @@
errorLine2=" ~~~">
@@ -9068,7 +9743,7 @@
errorLine2=" ~~~~~~">
@@ -9079,7 +9754,7 @@
errorLine2=" ~~~~~~">
@@ -9090,7 +9765,7 @@
errorLine2=" ~~~">
@@ -9101,7 +9776,7 @@
errorLine2=" ~~~~~~~~">
@@ -9112,7 +9787,7 @@
errorLine2=" ~~~~~~">
@@ -9123,7 +9798,7 @@
errorLine2=" ~~~~~~~~">
@@ -9134,7 +9809,7 @@
errorLine2=" ~~~~~~">
@@ -9145,7 +9820,7 @@
errorLine2=" ~~~">
@@ -9156,7 +9831,7 @@
errorLine2=" ~~~">
@@ -9167,7 +9842,7 @@
errorLine2=" ~~~~~~~~~~~~~">
@@ -9178,7 +9853,7 @@
errorLine2=" ~~~">
@@ -9189,7 +9864,7 @@
errorLine2=" ~~~~~~~~~~~~~">
@@ -9200,7 +9875,7 @@
errorLine2=" ~~~~~~">
@@ -9211,7 +9886,7 @@
errorLine2=" ~~~~~~~~">
@@ -9222,7 +9897,7 @@
errorLine2=" ~~~">
@@ -9233,7 +9908,7 @@
errorLine2=" ~~~~~~">
@@ -9244,7 +9919,7 @@
errorLine2=" ~~~~~~~~">
diff --git a/app/objectbox-models/default.json.bak b/app/objectbox-models/default.json.bak
index 667cdafb9..9ed3079c0 100644
--- a/app/objectbox-models/default.json.bak
+++ b/app/objectbox-models/default.json.bak
@@ -3,74 +3,6 @@
"_note2": "ObjectBox manages crucial IDs for your object model. See docs for details.",
"_note3": "If you have VCS merge conflicts, you must resolve them according to ObjectBox docs.",
"entities": [
- {
- "id": "1:7257718270326155947",
- "lastPropertyId": "17:8085320504542486236",
- "name": "DownloadEntity",
- "properties": [
- {
- "id": "1:2266566996008201697",
- "name": "id"
- },
- {
- "id": "2:1953917250527765737",
- "name": "downloadId"
- },
- {
- "id": "5:6575412958851693470",
- "name": "bookId"
- },
- {
- "id": "6:1075612111256674117",
- "name": "title"
- },
- {
- "id": "7:2831524841121029990",
- "name": "description"
- },
- {
- "id": "8:2334902404590133038",
- "name": "language"
- },
- {
- "id": "9:5087250349738158996",
- "name": "creator"
- },
- {
- "id": "10:6128960350043895299",
- "name": "publisher"
- },
- {
- "id": "11:3850323036475883785",
- "name": "date"
- },
- {
- "id": "12:5288623325038033644",
- "name": "url"
- },
- {
- "id": "13:2501711400901908648",
- "name": "articleCount"
- },
- {
- "id": "14:3550975911715416030",
- "name": "mediaCount"
- },
- {
- "id": "15:8949996430663588693",
- "name": "size"
- },
- {
- "id": "16:7554483297276446029",
- "name": "name"
- },
- {
- "id": "17:8085320504542486236",
- "name": "favIcon"
- }
- ],
- "relations": []
- },
{
"id": "3:5536749840871435068",
"lastPropertyId": "16:6142333908132117423",
@@ -367,7 +299,8 @@
"modelVersion": 4,
"modelVersionParserMinimum": 4,
"retiredEntityUids": [
- 349148274283701276
+ 349148274283701276,
+ 7257718270326155947
],
"retiredIndexUids": [
1293695782925933448,
@@ -394,7 +327,22 @@
7273406943564025911,
428251106490095982,
5162677841083528491,
- 7886541039889727771
+ 7886541039889727771,
+ 2266566996008201697,
+ 1953917250527765737,
+ 6575412958851693470,
+ 1075612111256674117,
+ 2831524841121029990,
+ 2334902404590133038,
+ 5087250349738158996,
+ 6128960350043895299,
+ 3850323036475883785,
+ 5288623325038033644,
+ 2501711400901908648,
+ 3550975911715416030,
+ 8949996430663588693,
+ 7554483297276446029,
+ 8085320504542486236
],
"retiredRelationUids": [],
"version": 1
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/downloader/DownloadViewHolder.kt b/app/src/main/java/org/kiwix/kiwixmobile/downloader/DownloadViewHolder.kt
index ebcad6933..28f1330f4 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/downloader/DownloadViewHolder.kt
+++ b/app/src/main/java/org/kiwix/kiwixmobile/downloader/DownloadViewHolder.kt
@@ -51,9 +51,7 @@ class DownloadViewHolder(override val containerView: View) : RecyclerView.ViewHo
stop.setOnClickListener {
itemClickListener.invoke(downloadItem)
}
- downloadState.text = toReadableState(
- downloadItem.downloadState, containerView.context
- )
+ downloadState.text = toReadableState(downloadItem.downloadState, containerView.context)
eta.text = downloadItem.eta.takeIf { it.seconds > 0L }?.toHumanReadableTime() ?: ""
}
diff --git a/app/src/test/java/org/kiwix/kiwixmobile/utils/files/FileSearchTest.kt b/app/src/test/java/org/kiwix/kiwixmobile/utils/files/FileSearchTest.kt
index 8dd40bec5..8e9f2394e 100644
--- a/app/src/test/java/org/kiwix/kiwixmobile/utils/files/FileSearchTest.kt
+++ b/app/src/test/java/org/kiwix/kiwixmobile/utils/files/FileSearchTest.kt
@@ -61,7 +61,7 @@ class FileSearchTest {
every { Environment.getExternalStorageDirectory() } returns externalStorageDirectory
every { externalStorageDirectory.absolutePath } returns "/externalStorageDirectory"
every { context.contentResolver } returns contentResolver
- every { StorageDeviceUtils.getReadableStorage(context, false) } returns arrayListOf(
+ every { StorageDeviceUtils.getReadableStorage(context) } returns arrayListOf(
storageDevice
)
every { storageDevice.name } returns "/deviceDir"
@@ -80,7 +80,7 @@ class FileSearchTest {
@Test
fun `scan of directory that doesn't exist returns nothing`() {
every { contentResolver.query(any(), any(), any(), any(), any()) } returns null
- fileSearch.scan("doesNotExist")
+ fileSearch.scan()
.test()
.assertValue(listOf())
}
@@ -91,7 +91,8 @@ class FileSearchTest {
val zimaaFile = File.createTempFile("fileToFind2", ".zimaa")
File.createTempFile("willNotFind", ".txt")
every { contentResolver.query(any(), any(), any(), any(), any()) } returns null
- val fileList = fileSearch.scan(zimFile.parent)
+ every { storageDevice.name } returns zimFile.parent
+ val fileList = fileSearch.scan()
.test()
.values()[0]
assertThat(fileList).containsExactlyInAnyOrder(zimFile, zimaaFile)
@@ -106,7 +107,8 @@ class FileSearchTest {
".zim",
File("$tempRoot${File.separator}dir").apply { mkdirs() })
every { contentResolver.query(any(), any(), any(), any(), any()) } returns null
- val fileList = fileSearch.scan(zimFile.parentFile.parent)
+ every { storageDevice.name } returns tempRoot
+ val fileList = fileSearch.scan()
.test()
.values()[0]
assertThat(fileList).containsExactlyInAnyOrder(zimFile)
@@ -120,7 +122,7 @@ class FileSearchTest {
fun `scan media store, if files are readable they are returned`() {
val fileToFind = File.createTempFile("fileToFind", ".zim")
expectFromMediaStore(fileToFind)
- fileSearch.scan("")
+ fileSearch.scan()
.test()
.assertValue(listOf(fileToFind))
}
@@ -130,7 +132,7 @@ class FileSearchTest {
val unreadableFile = File.createTempFile("fileToFind", ".zim")
expectFromMediaStore(unreadableFile)
unreadableFile.delete()
- fileSearch.scan("")
+ fileSearch.scan()
.test()
.assertValue(listOf())
}
diff --git a/app/src/test/java/org/kiwix/kiwixmobile/zim_manager/ZimManageViewModelTest.kt b/app/src/test/java/org/kiwix/kiwixmobile/zim_manager/ZimManageViewModelTest.kt
index ede3385c1..6b44358a0 100644
--- a/app/src/test/java/org/kiwix/kiwixmobile/zim_manager/ZimManageViewModelTest.kt
+++ b/app/src/test/java/org/kiwix/kiwixmobile/zim_manager/ZimManageViewModelTest.kt
@@ -25,6 +25,7 @@ import io.mockk.every
import io.mockk.mockk
import io.mockk.verify
import io.reactivex.Single
+import io.reactivex.processors.BehaviorProcessor
import io.reactivex.processors.PublishProcessor
import io.reactivex.schedulers.TestScheduler
import org.junit.jupiter.api.AfterAll
@@ -38,17 +39,12 @@ import org.kiwix.kiwixmobile.book
import org.kiwix.kiwixmobile.bookOnDisk
import org.kiwix.kiwixmobile.data.DataSource
import org.kiwix.kiwixmobile.data.remote.KiwixService
+import org.kiwix.kiwixmobile.database.newdb.dao.FetchDownloadDao
import org.kiwix.kiwixmobile.database.newdb.dao.NewBookDao
-import org.kiwix.kiwixmobile.database.newdb.dao.NewDownloadDao
import org.kiwix.kiwixmobile.database.newdb.dao.NewLanguagesDao
+import org.kiwix.kiwixmobile.downloadItem
import org.kiwix.kiwixmobile.downloadModel
-import org.kiwix.kiwixmobile.downloadStatus
-import org.kiwix.kiwixmobile.downloader.Downloader
-import org.kiwix.kiwixmobile.downloader.model.DownloadItem
import org.kiwix.kiwixmobile.downloader.model.DownloadModel
-import org.kiwix.kiwixmobile.downloader.model.DownloadState
-import org.kiwix.kiwixmobile.downloader.model.DownloadStatus
-import org.kiwix.kiwixmobile.downloader.model.UriToFileConverter
import org.kiwix.kiwixmobile.language
import org.kiwix.kiwixmobile.library.entity.LibraryNetworkEntity.Book
import org.kiwix.kiwixmobile.libraryNetworkEntity
@@ -65,7 +61,6 @@ import org.kiwix.kiwixmobile.zim_manager.fileselect_view.StorageObserver
import org.kiwix.kiwixmobile.zim_manager.fileselect_view.adapter.BooksOnDiskListItem
import org.kiwix.kiwixmobile.zim_manager.fileselect_view.adapter.BooksOnDiskListItem.BookOnDisk
import org.kiwix.kiwixmobile.zim_manager.library_view.adapter.LibraryListItem
-import java.io.File
import java.util.Locale
import java.util.concurrent.TimeUnit.MILLISECONDS
import java.util.concurrent.TimeUnit.SECONDS
@@ -73,17 +68,15 @@ import java.util.concurrent.TimeUnit.SECONDS
@ExtendWith(InstantExecutorExtension::class)
class ZimManageViewModelTest {
- private val newDownloadDao: NewDownloadDao = mockk()
+ private val downloadDao: FetchDownloadDao = mockk()
private val newBookDao: NewBookDao = mockk()
private val newLanguagesDao: NewLanguagesDao = mockk()
- private val downloader: Downloader = mockk()
private val storageObserver: StorageObserver = mockk()
private val kiwixService: KiwixService = mockk()
private val application: Application = mockk()
private val connectivityBroadcastReceiver: ConnectivityBroadcastReceiver = mockk()
private val bookUtils: BookUtils = mockk()
private val fat32Checker: Fat32Checker = mockk()
- private val uriToFileConverter: UriToFileConverter = mockk()
private val defaultLanguageProvider: DefaultLanguageProvider = mockk()
private val dataSource: DataSource = mockk()
lateinit var viewModel: ZimManageViewModel
@@ -92,7 +85,7 @@ class ZimManageViewModelTest {
private val booksOnFileSystem: PublishProcessor> = PublishProcessor.create()
private val books: PublishProcessor> = PublishProcessor.create()
private val languages: PublishProcessor> = PublishProcessor.create()
- private val fileSystemStates: PublishProcessor = PublishProcessor.create()
+ private val fileSystemStates: BehaviorProcessor = BehaviorProcessor.create()
private val networkStates: PublishProcessor = PublishProcessor.create()
private val booksOnDiskListItems: PublishProcessor> =
PublishProcessor.create()
@@ -112,7 +105,7 @@ class ZimManageViewModelTest {
fun init() {
clearAllMocks()
every { connectivityBroadcastReceiver.action } returns "test"
- every { newDownloadDao.downloads() } returns downloads
+ every { downloadDao.downloads() } returns downloads
every { newBookDao.books() } returns books
every { storageObserver.booksOnFileSystem } returns booksOnFileSystem
every { newLanguagesDao.languages() } returns languages
@@ -121,9 +114,17 @@ class ZimManageViewModelTest {
every { application.registerReceiver(any(), any()) } returns mockk()
every { dataSource.booksOnDiskAsListItems() } returns booksOnDiskListItems
viewModel = ZimManageViewModel(
- newDownloadDao, newBookDao, newLanguagesDao, downloader,
- storageObserver, kiwixService, application, connectivityBroadcastReceiver, bookUtils,
- fat32Checker, uriToFileConverter, defaultLanguageProvider, dataSource
+ downloadDao,
+ newBookDao,
+ newLanguagesDao,
+ storageObserver,
+ kiwixService,
+ application,
+ connectivityBroadcastReceiver,
+ bookUtils,
+ fat32Checker,
+ defaultLanguageProvider,
+ dataSource
)
testScheduler.triggerActions()
}
@@ -150,63 +151,19 @@ class ZimManageViewModelTest {
@Nested
inner class Downloads {
@Test
- fun `on emission from database query and render downloads`() {
- val expectedStatus = downloadStatus()
- expectStatusWith(listOf(expectedStatus))
+ fun `on emission from database render downloads`() {
+ expectDownloads()
viewModel.downloadItems
.test()
- .assertValue(listOf(DownloadItem(expectedStatus)))
+ .assertValue(listOf(downloadItem()))
}
- @Test
- fun `on emission of successful status create a book and delete the download`() {
- every { uriToFileConverter.convert(any()) } returns File("test")
- val expectedStatus = downloadStatus(
- downloadId = 10L,
- downloadState = DownloadState.Successful
- )
- expectStatusWith(listOf(expectedStatus))
- val element = expectedStatus.toBookOnDisk(uriToFileConverter)
- verify {
- newBookDao.insert(listOf(element))
- newDownloadDao.delete(10L)
- }
- }
-
- @Test
- fun `if statuses don't have a matching Id for download in db over 3 secs then delete`() {
- expectStatusWith(
- listOf(downloadStatus(downloadId = 1)),
- listOf(downloadModel(downloadId = 1), downloadModel(downloadId = 3))
- )
- testScheduler.advanceTimeBy(3, SECONDS)
- testScheduler.triggerActions()
- verify {
- newDownloadDao.delete(3)
- }
- }
-
- @Test
- fun `if statuses do have a matching Id for download in db over 3 secs then don't delete`() {
- expectStatusWith(
- listOf(downloadStatus(downloadId = 1)),
- listOf(downloadModel(downloadId = 1))
- )
- testScheduler.advanceTimeBy(3, SECONDS)
- testScheduler.triggerActions()
- verify(exactly = 0) {
- newDownloadDao.delete(any())
- }
- }
-
- private fun expectStatusWith(
- expectedStatuses: List,
+ private fun expectDownloads(
expectedDownloads: List = listOf(
downloadModel()
)
) {
every { application.getString(any()) } returns ""
- every { downloader.queryStatus(expectedDownloads) } returns expectedStatuses
downloads.offer(expectedDownloads)
testScheduler.triggerActions()
testScheduler.advanceTimeBy(1, SECONDS)
@@ -387,7 +344,6 @@ class ZimManageViewModelTest {
@Test
fun `library update removes from sources`() {
- every { downloader.queryStatus(any()) } returns emptyList()
every { application.getString(R.string.your_languages) } returns "1"
every { application.getString(R.string.other_languages) } returns "2"
val bookAlreadyOnDisk = book(
diff --git a/app/src/test/java/org/kiwix/kiwixmobile/zim_manager/fileselect_view/StorageObserverTest.kt b/app/src/test/java/org/kiwix/kiwixmobile/zim_manager/fileselect_view/StorageObserverTest.kt
index 1b36f0156..9a6cf236e 100644
--- a/app/src/test/java/org/kiwix/kiwixmobile/zim_manager/fileselect_view/StorageObserverTest.kt
+++ b/app/src/test/java/org/kiwix/kiwixmobile/zim_manager/fileselect_view/StorageObserverTest.kt
@@ -32,7 +32,7 @@ import org.junit.jupiter.api.Test
import org.kiwix.kiwixmobile.book
import org.kiwix.kiwixmobile.bookOnDisk
import org.kiwix.kiwixmobile.data.ZimContentProvider
-import org.kiwix.kiwixmobile.database.newdb.dao.NewDownloadDao
+import org.kiwix.kiwixmobile.database.newdb.dao.FetchDownloadDao
import org.kiwix.kiwixmobile.downloader.model.DownloadModel
import org.kiwix.kiwixmobile.library.entity.LibraryNetworkEntity.Book
import org.kiwix.kiwixmobile.resetSchedulers
@@ -44,7 +44,7 @@ import java.io.File
class StorageObserverTest {
private val sharedPreferenceUtil: SharedPreferenceUtil = mockk()
- private val newDownloadDao: NewDownloadDao = mockk()
+ private val downloadDao: FetchDownloadDao = mockk()
private val fileSearch: FileSearch = mockk()
private val downloadModel = mockk()
private val file = mockk()
@@ -66,9 +66,9 @@ class StorageObserverTest {
@BeforeEach fun init() {
clearAllMocks()
every { sharedPreferenceUtil.prefStorage } returns "a"
- every { fileSearch.scan("a") } returns files
- every { newDownloadDao.downloads() } returns downloads
- storageObserver = StorageObserver(newDownloadDao, fileSearch)
+ every { fileSearch.scan() } returns files
+ every { downloadDao.downloads() } returns downloads
+ storageObserver = StorageObserver(downloadDao, fileSearch)
}
@Test
diff --git a/app/src/testShared/org/kiwix/kiwixmobile/TestModelFunctions.kt b/app/src/testShared/org/kiwix/kiwixmobile/TestModelFunctions.kt
index 2f521aeeb..e5790b345 100644
--- a/app/src/testShared/org/kiwix/kiwixmobile/TestModelFunctions.kt
+++ b/app/src/testShared/org/kiwix/kiwixmobile/TestModelFunctions.kt
@@ -17,10 +17,15 @@
*/
package org.kiwix.kiwixmobile
+import com.tonyodev.fetch2.Error
+import com.tonyodev.fetch2.Status
+import com.tonyodev.fetch2.Status.NONE
+import org.kiwix.kiwixmobile.downloader.model.Base64String
+import org.kiwix.kiwixmobile.downloader.model.DownloadItem
import org.kiwix.kiwixmobile.downloader.model.DownloadModel
import org.kiwix.kiwixmobile.downloader.model.DownloadState
import org.kiwix.kiwixmobile.downloader.model.DownloadState.Pending
-import org.kiwix.kiwixmobile.downloader.model.DownloadStatus
+import org.kiwix.kiwixmobile.downloader.model.Seconds
import org.kiwix.kiwixmobile.language.adapter.LanguageListItem.LanguageItem
import org.kiwix.kiwixmobile.library.entity.LibraryNetworkEntity
import org.kiwix.kiwixmobile.library.entity.LibraryNetworkEntity.Book
@@ -39,29 +44,37 @@ fun bookOnDisk(
file: File = File("")
) = BookOnDisk(databaseId, book, file)
-fun downloadStatus(
- downloadId: Long = 0L,
- title: String = "",
- description: String = "",
- downloadState: DownloadState = Pending,
- bytesDownloadedSoFar: Long = 0L,
- totalSizeBytes: Long = 0L,
- lastModified: String = "",
- localUri: String? = null,
- mediaProviderUri: String? = null,
- mediaType: String? = null,
- uri: String? = null,
+fun downloadModel(
+ databaseId: Long = 1L,
+ downloadId: Long = 1L,
+ file: String = "",
+ etaInMilliSeconds: Long = 0L,
+ bytesDownloaded: Long = 1L,
+ totalSizeOfDownload: Long = 1L,
+ status: Status = NONE,
+ error: Error = Error.NONE,
+ progress: Int = 1,
book: Book = book()
-) = DownloadStatus(
- downloadId, title, description, downloadState, bytesDownloadedSoFar,
- totalSizeBytes, lastModified, localUri, mediaProviderUri, mediaType, uri, book
+) = DownloadModel(
+ databaseId, downloadId, file, etaInMilliSeconds, bytesDownloaded, totalSizeOfDownload,
+ status, error, progress, book
)
-fun downloadModel(
- databaseId: Long? = 1L,
+fun downloadItem(
downloadId: Long = 1L,
- book: Book = book()
-) = DownloadModel(databaseId, downloadId, book)
+ favIcon: Base64String = Base64String("favIcon"),
+ title: String = "title",
+ description: String = "description",
+ bytesDownloaded: Long = 1L,
+ totalSizeBytes: Long = 1L,
+ progress: Int = 1,
+ eta: Seconds = Seconds(0),
+ state: DownloadState = Pending
+) =
+ DownloadItem(
+ downloadId, favIcon, title, description, bytesDownloaded,
+ totalSizeBytes, progress, eta, state
+ )
fun language(
id: Long = 0,