mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-09 07:16:04 -04:00
Upgraded the dagger version to 2.53.1.
* Upgraded the ksp version to `2.0.0-1.0.24`. * Upgraded the kotlin version to `2.0.0`. * Upgraded the objectbox version to `4.0.3`. * Removed the deprecated `runBlockingTest` from test cases which was giving compilation error because it is permanently removed in this version of kotlin. * Replaced some deprecated methods with new methods that is deprecated in latest version of gradle. * Fixed some string lint issues.
This commit is contained in:
parent
3423bbf671
commit
08c054586a
@ -25,7 +25,6 @@ import android.content.pm.PackageManager
|
|||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Environment
|
import android.os.Environment
|
||||||
import androidx.annotation.RequiresApi
|
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.test.core.app.canTakeScreenshot
|
import androidx.test.core.app.canTakeScreenshot
|
||||||
import androidx.test.core.app.takeScreenshot
|
import androidx.test.core.app.takeScreenshot
|
||||||
@ -91,10 +90,6 @@ object TestUtils {
|
|||||||
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||||
) == PackageManager.PERMISSION_GRANTED
|
) == PackageManager.PERMISSION_GRANTED
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.R)
|
|
||||||
private fun hasManageExternalStoragePermission(): Boolean =
|
|
||||||
Environment.isExternalStorageManager()
|
|
||||||
|
|
||||||
@JvmStatic fun hasStoragePermission() = Build.VERSION.SDK_INT > Build.VERSION_CODES.M &&
|
@JvmStatic fun hasStoragePermission() = Build.VERSION.SDK_INT > Build.VERSION_CODES.M &&
|
||||||
hasReadExternalStoragePermission() && hasWriteExternalStoragePermission()
|
hasReadExternalStoragePermission() && hasWriteExternalStoragePermission()
|
||||||
|
|
||||||
|
@ -51,6 +51,8 @@ import org.kiwix.kiwixmobile.core.utils.files.ScanningProgressListener
|
|||||||
import org.kiwix.kiwixmobile.core.zim_manager.ConnectivityBroadcastReceiver
|
import org.kiwix.kiwixmobile.core.zim_manager.ConnectivityBroadcastReceiver
|
||||||
import org.kiwix.kiwixmobile.core.zim_manager.Language
|
import org.kiwix.kiwixmobile.core.zim_manager.Language
|
||||||
import org.kiwix.kiwixmobile.core.zim_manager.NetworkState
|
import org.kiwix.kiwixmobile.core.zim_manager.NetworkState
|
||||||
|
import org.kiwix.kiwixmobile.core.zim_manager.NetworkState.CONNECTED
|
||||||
|
import org.kiwix.kiwixmobile.core.zim_manager.NetworkState.NOT_CONNECTED
|
||||||
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.SelectionMode.MULTI
|
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.SelectionMode.MULTI
|
||||||
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.SelectionMode.NORMAL
|
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.SelectionMode.NORMAL
|
||||||
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskListItem
|
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskListItem
|
||||||
@ -58,8 +60,6 @@ import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDis
|
|||||||
import org.kiwix.kiwixmobile.zimManager.Fat32Checker.FileSystemState
|
import org.kiwix.kiwixmobile.zimManager.Fat32Checker.FileSystemState
|
||||||
import org.kiwix.kiwixmobile.zimManager.Fat32Checker.FileSystemState.CanWrite4GbFile
|
import org.kiwix.kiwixmobile.zimManager.Fat32Checker.FileSystemState.CanWrite4GbFile
|
||||||
import org.kiwix.kiwixmobile.zimManager.Fat32Checker.FileSystemState.CannotWrite4GbFile
|
import org.kiwix.kiwixmobile.zimManager.Fat32Checker.FileSystemState.CannotWrite4GbFile
|
||||||
import org.kiwix.kiwixmobile.core.zim_manager.NetworkState.CONNECTED
|
|
||||||
import org.kiwix.kiwixmobile.core.zim_manager.NetworkState.NOT_CONNECTED
|
|
||||||
import org.kiwix.kiwixmobile.zimManager.ZimManageViewModel.FileSelectActions.MultiModeFinished
|
import org.kiwix.kiwixmobile.zimManager.ZimManageViewModel.FileSelectActions.MultiModeFinished
|
||||||
import org.kiwix.kiwixmobile.zimManager.ZimManageViewModel.FileSelectActions.RequestDeleteMultiSelection
|
import org.kiwix.kiwixmobile.zimManager.ZimManageViewModel.FileSelectActions.RequestDeleteMultiSelection
|
||||||
import org.kiwix.kiwixmobile.zimManager.ZimManageViewModel.FileSelectActions.RequestMultiSelection
|
import org.kiwix.kiwixmobile.zimManager.ZimManageViewModel.FileSelectActions.RequestMultiSelection
|
||||||
@ -139,7 +139,7 @@ class ZimManageViewModelTest {
|
|||||||
every { newLanguagesDao.languages() } returns languages
|
every { newLanguagesDao.languages() } returns languages
|
||||||
every { fat32Checker.fileSystemStates } returns fileSystemStates
|
every { fat32Checker.fileSystemStates } returns fileSystemStates
|
||||||
every { connectivityBroadcastReceiver.networkStates } returns networkStates
|
every { connectivityBroadcastReceiver.networkStates } returns networkStates
|
||||||
every { application.registerReceiver(any(), any()) } returns mockk()
|
every { application.registerReceiver(any(), any(), any()) } returns mockk()
|
||||||
every { dataSource.booksOnDiskAsListItems() } returns booksOnDiskListItems
|
every { dataSource.booksOnDiskAsListItems() } returns booksOnDiskListItems
|
||||||
every {
|
every {
|
||||||
connectivityManager.getNetworkCapabilities(connectivityManager.activeNetwork)
|
connectivityManager.getNetworkCapabilities(connectivityManager.activeNetwork)
|
||||||
@ -168,7 +168,7 @@ class ZimManageViewModelTest {
|
|||||||
@Test
|
@Test
|
||||||
fun `registers broadcastReceiver in init`() {
|
fun `registers broadcastReceiver in init`() {
|
||||||
verify {
|
verify {
|
||||||
application.registerReceiver(connectivityBroadcastReceiver, any())
|
application.registerReceiver(connectivityBroadcastReceiver, any(), any())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ repositories {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation("com.android.tools.build:gradle:8.4.0")
|
implementation("com.android.tools.build:gradle:8.4.0")
|
||||||
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:2.0.0")
|
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:2.0.0")
|
||||||
implementation("com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin:2.1.0-1.0.29")
|
implementation("com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin:2.0.0-1.0.24")
|
||||||
implementation("org.jacoco:org.jacoco.core:0.8.12")
|
implementation("org.jacoco:org.jacoco.core:0.8.12")
|
||||||
implementation("org.jlleitschuh.gradle:ktlint-gradle:10.3.0")
|
implementation("org.jlleitschuh.gradle:ktlint-gradle:10.3.0")
|
||||||
implementation("com.google.apis:google-api-services-androidpublisher:v3-rev20230406-2.0.0") {
|
implementation("com.google.apis:google-api-services-androidpublisher:v3-rev20230406-2.0.0") {
|
||||||
|
@ -28,7 +28,7 @@ object Versions {
|
|||||||
|
|
||||||
const val org_jetbrains_kotlin: String = "2.0.0"
|
const val org_jetbrains_kotlin: String = "2.0.0"
|
||||||
|
|
||||||
const val kotlin_ksp: String = "2.1.0-1.0.29"
|
const val kotlin_ksp: String = "2.0.0-1.0.24"
|
||||||
|
|
||||||
const val androidx_navigation: String = "2.5.3"
|
const val androidx_navigation: String = "2.5.3"
|
||||||
|
|
||||||
|
@ -217,8 +217,8 @@ class AllProjectConfigurer {
|
|||||||
compileOnly(Libs.javax_annotation_api)
|
compileOnly(Libs.javax_annotation_api)
|
||||||
implementation(Libs.dagger)
|
implementation(Libs.dagger)
|
||||||
implementation(Libs.dagger_android)
|
implementation(Libs.dagger_android)
|
||||||
annotationProcessor(Libs.dagger_compiler)
|
kapt(Libs.dagger_compiler)
|
||||||
annotationProcessor(Libs.dagger_android_processor)
|
kapt(Libs.dagger_android_processor)
|
||||||
implementation(Libs.core_ktx)
|
implementation(Libs.core_ktx)
|
||||||
implementation(Libs.fragment_ktx)
|
implementation(Libs.fragment_ktx)
|
||||||
implementation(Libs.collection_ktx)
|
implementation(Libs.collection_ktx)
|
||||||
@ -230,7 +230,7 @@ class AllProjectConfigurer {
|
|||||||
annotationProcessor(Libs.roomCompiler)
|
annotationProcessor(Libs.roomCompiler)
|
||||||
implementation(Libs.roomRuntime)
|
implementation(Libs.roomRuntime)
|
||||||
implementation(Libs.roomRxjava2)
|
implementation(Libs.roomRxjava2)
|
||||||
ksp(Libs.roomCompiler)
|
kapt(Libs.roomCompiler)
|
||||||
implementation(Libs.tracing)
|
implementation(Libs.tracing)
|
||||||
implementation(Libs.fetchOkhttp)
|
implementation(Libs.fetchOkhttp)
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import com.android.build.gradle.internal.utils.isKotlinKaptPluginApplied
|
|
||||||
import plugin.KiwixConfigurationPlugin
|
import plugin.KiwixConfigurationPlugin
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
|
@ -21,12 +21,10 @@ package eu.mhutti1.utils.storage
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.ContextWrapper
|
import android.content.ContextWrapper
|
||||||
import android.os.Environment
|
import android.os.Environment
|
||||||
import androidx.core.content.ContextCompat
|
|
||||||
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil
|
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileFilter
|
import java.io.FileFilter
|
||||||
import java.io.RandomAccessFile
|
import java.io.RandomAccessFile
|
||||||
import java.util.ArrayList
|
|
||||||
|
|
||||||
object StorageDeviceUtils {
|
object StorageDeviceUtils {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@ -63,7 +61,7 @@ object StorageDeviceUtils {
|
|||||||
private fun externalFilesDirsDevices(
|
private fun externalFilesDirsDevices(
|
||||||
context: Context,
|
context: Context,
|
||||||
writable: Boolean
|
writable: Boolean
|
||||||
) = ContextCompat.getExternalFilesDirs(context, "")
|
) = context.getExternalFilesDirs("")
|
||||||
.filterNotNull()
|
.filterNotNull()
|
||||||
.mapIndexed { index, dir -> StorageDevice(generalisePath(dir.path, writable), index == 0) }
|
.mapIndexed { index, dir -> StorageDevice(generalisePath(dir.path, writable), index == 0) }
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ class AdapterDelegateManager<T> {
|
|||||||
private fun getDelegateIndexFor(item: T): Int {
|
private fun getDelegateIndexFor(item: T): Int {
|
||||||
for (index in 0..delegates.size()) {
|
for (index in 0..delegates.size()) {
|
||||||
val valueAt = delegates.valueAt(index)
|
val valueAt = delegates.valueAt(index)
|
||||||
if (valueAt?.isFor(item) == true) {
|
if (valueAt.isFor(item) == true) {
|
||||||
return index
|
return index
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,6 @@ import android.os.Build
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Process
|
import android.os.Process
|
||||||
import androidx.activity.result.contract.ActivityResultContracts
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
import androidx.core.content.ContextCompat
|
|
||||||
import androidx.core.content.FileProvider
|
import androidx.core.content.FileProvider
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
@ -101,7 +100,7 @@ open class ErrorActivity : BaseActivity() {
|
|||||||
val targetedIntents = createEmailIntents(emailIntent, activities)
|
val targetedIntents = createEmailIntents(emailIntent, activities)
|
||||||
if (activities.isNotEmpty() && targetedIntents.isNotEmpty()) {
|
if (activities.isNotEmpty() && targetedIntents.isNotEmpty()) {
|
||||||
val chooserIntent =
|
val chooserIntent =
|
||||||
Intent.createChooser(targetedIntents.removeFirst(), "Send email...")
|
Intent.createChooser(targetedIntents.removeAt(0), "Send email...")
|
||||||
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetedIntents.toTypedArray())
|
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetedIntents.toTypedArray())
|
||||||
sendEmailLauncher.launch(chooserIntent)
|
sendEmailLauncher.launch(chooserIntent)
|
||||||
} else {
|
} else {
|
||||||
@ -245,7 +244,7 @@ open class ErrorActivity : BaseActivity() {
|
|||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
|
|
||||||
private fun externalFileDetails(): String =
|
private fun externalFileDetails(): String =
|
||||||
ContextCompat.getExternalFilesDirs(this, null).joinToString("\n") { it?.path ?: "null" }
|
getExternalFilesDirs(null).joinToString("\n") { it?.path ?: "null" }
|
||||||
|
|
||||||
private fun safeContains(extras: Bundle): Boolean {
|
private fun safeContains(extras: Bundle): Boolean {
|
||||||
return try {
|
return try {
|
||||||
@ -272,7 +271,7 @@ open class ErrorActivity : BaseActivity() {
|
|||||||
private val versionName: String
|
private val versionName: String
|
||||||
@SuppressLint("WrongConstant")
|
@SuppressLint("WrongConstant")
|
||||||
get() = packageManager
|
get() = packageManager
|
||||||
.getPackageInformation(packageName, ZERO).versionName
|
.getPackageInformation(packageName, ZERO).versionName.toString()
|
||||||
|
|
||||||
private fun toStackTraceString(exception: Throwable): String =
|
private fun toStackTraceString(exception: Throwable): String =
|
||||||
try {
|
try {
|
||||||
|
@ -1869,9 +1869,9 @@ abstract class CoreReaderFragment :
|
|||||||
}
|
}
|
||||||
reopenBook()
|
reopenBook()
|
||||||
showTabSwitcher()
|
showTabSwitcher()
|
||||||
setUpWithTextToSpeech(tempWebViewListForUndo.last())
|
setUpWithTextToSpeech(tempWebViewListForUndo[tempWebViewListForUndo.lastIndex])
|
||||||
updateBottomToolbarVisibility()
|
updateBottomToolbarVisibility()
|
||||||
safelyAddWebView(tempWebViewListForUndo.last())
|
safelyAddWebView(tempWebViewListForUndo[tempWebViewListForUndo.lastIndex])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,7 +229,7 @@ abstract class CorePrefsFragment :
|
|||||||
@Suppress("TooGenericExceptionThrown")
|
@Suppress("TooGenericExceptionThrown")
|
||||||
get() = try {
|
get() = try {
|
||||||
requireActivity().packageManager
|
requireActivity().packageManager
|
||||||
.getPackageInformation(requireActivity().packageName, 0).versionName
|
.getPackageInformation(requireActivity().packageName, 0).versionName.toString()
|
||||||
} catch (e: PackageManager.NameNotFoundException) {
|
} catch (e: PackageManager.NameNotFoundException) {
|
||||||
throw RuntimeException(e)
|
throw RuntimeException(e)
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ class SharedPreferenceUtil @Inject constructor(val context: Context) {
|
|||||||
get() = sharedPreferences.getInt(STORAGE_POSITION, 0)
|
get() = sharedPreferences.getInt(STORAGE_POSITION, 0)
|
||||||
|
|
||||||
fun defaultStorage(): String =
|
fun defaultStorage(): String =
|
||||||
getExternalFilesDirs(context, null)[0]?.path
|
context.getExternalFilesDirs(null)[0]?.path
|
||||||
?: context.filesDir.path // a workaround for emulators
|
?: context.filesDir.path // a workaround for emulators
|
||||||
|
|
||||||
fun defaultPublicStorage(): String =
|
fun defaultPublicStorage(): String =
|
||||||
|
@ -30,7 +30,6 @@ import android.os.storage.StorageManager
|
|||||||
import android.provider.DocumentsContract
|
import android.provider.DocumentsContract
|
||||||
import android.provider.MediaStore
|
import android.provider.MediaStore
|
||||||
import android.webkit.URLUtil
|
import android.webkit.URLUtil
|
||||||
import androidx.core.content.ContextCompat
|
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
@ -583,7 +582,7 @@ object FileUtils {
|
|||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun getDemoFilePathForCustomApp(context: Context) =
|
fun getDemoFilePathForCustomApp(context: Context) =
|
||||||
"${ContextCompat.getExternalFilesDirs(context, null)[0]}/demo.zim"
|
"${context.getExternalFilesDirs(null)[0]}/demo.zim"
|
||||||
|
|
||||||
@SuppressLint("Recycle")
|
@SuppressLint("Recycle")
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
|
@ -143,7 +143,7 @@
|
|||||||
<string name="help_11">This is a descriptive message explaining where the Zim files are located after downloading. It is showing on the help screen.</string>
|
<string name="help_11">This is a descriptive message explaining where the Zim files are located after downloading. It is showing on the help screen.</string>
|
||||||
<string name="pref_storage">{{Identical|Storage}}</string>
|
<string name="pref_storage">{{Identical|Storage}}</string>
|
||||||
<string name="pref_current_folder">This is showing on the preference settings screen, it shows the currently selected storage in which we are downloading the zim files, whether it is internal or external.</string>
|
<string name="pref_current_folder">This is showing on the preference settings screen, it shows the currently selected storage in which we are downloading the zim files, whether it is internal or external.</string>
|
||||||
<string name="pref_free_storage">This refers to free (unused) storage space, ’’not’’ to free as in free of charge.</string>
|
<string name="pref_free_storage">This refers to free (unused) storage space, ’’not’’ to free as in free of charge. Here %s will be replaced by the free space e.g. 20GB.</string>
|
||||||
<string name="delete_zim_failed">This message appears in the “Android Toast” as an error message. When there are some files that could not be deleted, due to some reason.</string>
|
<string name="delete_zim_failed">This message appears in the “Android Toast” as an error message. When there are some files that could not be deleted, due to some reason.</string>
|
||||||
<string name="tts_pause">{{identical|pause}}</string>
|
<string name="tts_pause">{{identical|pause}}</string>
|
||||||
<string name="tts_resume">{{identical|resume}}</string>
|
<string name="tts_resume">{{identical|resume}}</string>
|
||||||
|
@ -25,7 +25,7 @@ import io.objectbox.Box
|
|||||||
import io.objectbox.query.Query
|
import io.objectbox.query.Query
|
||||||
import io.objectbox.query.QueryBuilder
|
import io.objectbox.query.QueryBuilder
|
||||||
import kotlinx.coroutines.flow.flowOf
|
import kotlinx.coroutines.flow.flowOf
|
||||||
import kotlinx.coroutines.test.runBlockingTest
|
import kotlinx.coroutines.test.runTest
|
||||||
import org.junit.jupiter.api.Nested
|
import org.junit.jupiter.api.Nested
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.kiwix.kiwixmobile.core.dao.entities.RecentSearchEntity
|
import org.kiwix.kiwixmobile.core.dao.entities.RecentSearchEntity
|
||||||
@ -43,7 +43,7 @@ internal class NewRecentSearchDaoTest {
|
|||||||
@Nested
|
@Nested
|
||||||
inner class RecentSearchTests {
|
inner class RecentSearchTests {
|
||||||
@Test
|
@Test
|
||||||
fun `recentSearches searches by Id passed`() = runBlockingTest {
|
fun `recentSearches searches by Id passed`() = runTest {
|
||||||
val zimId = "id"
|
val zimId = "id"
|
||||||
val queryResult = listOf<RecentSearchEntity>(recentSearchEntity())
|
val queryResult = listOf<RecentSearchEntity>(recentSearchEntity())
|
||||||
expectFromRecentSearches(queryResult, zimId)
|
expectFromRecentSearches(queryResult, zimId)
|
||||||
@ -56,7 +56,7 @@ internal class NewRecentSearchDaoTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `recentSearches searches with blank Id if null passed`() = runBlockingTest {
|
fun `recentSearches searches with blank Id if null passed`() = runTest {
|
||||||
val queryResult = listOf<RecentSearchEntity>(recentSearchEntity())
|
val queryResult = listOf<RecentSearchEntity>(recentSearchEntity())
|
||||||
expectFromRecentSearches(queryResult, "")
|
expectFromRecentSearches(queryResult, "")
|
||||||
newRecentSearchDao.recentSearches(null)
|
newRecentSearchDao.recentSearches(null)
|
||||||
@ -68,7 +68,7 @@ internal class NewRecentSearchDaoTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `recentSearches searches returns distinct entities by searchTerm`() = runBlockingTest {
|
fun `recentSearches searches returns distinct entities by searchTerm`() = runTest {
|
||||||
val queryResult = listOf<RecentSearchEntity>(recentSearchEntity(), recentSearchEntity())
|
val queryResult = listOf<RecentSearchEntity>(recentSearchEntity(), recentSearchEntity())
|
||||||
expectFromRecentSearches(queryResult, "")
|
expectFromRecentSearches(queryResult, "")
|
||||||
newRecentSearchDao.recentSearches("")
|
newRecentSearchDao.recentSearches("")
|
||||||
@ -80,7 +80,7 @@ internal class NewRecentSearchDaoTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `recentSearches searches returns a limitedNumber of entities`() = runBlockingTest {
|
fun `recentSearches searches returns a limitedNumber of entities`() = runTest {
|
||||||
val searchResults: List<RecentSearchEntity> =
|
val searchResults: List<RecentSearchEntity> =
|
||||||
(0..200).map { recentSearchEntity(searchTerm = "$it") }
|
(0..200).map { recentSearchEntity(searchTerm = "$it") }
|
||||||
expectFromRecentSearches(searchResults, "")
|
expectFromRecentSearches(searchResults, "")
|
||||||
|
@ -33,11 +33,9 @@ import kotlinx.coroutines.flow.Flow
|
|||||||
import kotlinx.coroutines.flow.consumeAsFlow
|
import kotlinx.coroutines.flow.consumeAsFlow
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.sync.Mutex
|
import kotlinx.coroutines.sync.Mutex
|
||||||
import kotlinx.coroutines.test.TestCoroutineDispatcher
|
import kotlinx.coroutines.test.StandardTestDispatcher
|
||||||
import kotlinx.coroutines.test.TestCoroutineScope
|
|
||||||
import kotlinx.coroutines.test.TestScope
|
import kotlinx.coroutines.test.TestScope
|
||||||
import kotlinx.coroutines.test.resetMain
|
import kotlinx.coroutines.test.resetMain
|
||||||
import kotlinx.coroutines.test.runBlockingTest
|
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
import kotlinx.coroutines.test.setMain
|
import kotlinx.coroutines.test.setMain
|
||||||
import org.assertj.core.api.Assertions.assertThat
|
import org.assertj.core.api.Assertions.assertThat
|
||||||
@ -84,7 +82,7 @@ internal class SearchViewModelTest {
|
|||||||
private val zimReaderContainer: ZimReaderContainer = mockk()
|
private val zimReaderContainer: ZimReaderContainer = mockk()
|
||||||
private val searchResultGenerator: SearchResultGenerator = mockk()
|
private val searchResultGenerator: SearchResultGenerator = mockk()
|
||||||
private val zimFileReader: ZimFileReader = mockk()
|
private val zimFileReader: ZimFileReader = mockk()
|
||||||
private val testDispatcher = TestCoroutineDispatcher()
|
private val testDispatcher = StandardTestDispatcher()
|
||||||
private val searchMutex: Mutex = mockk()
|
private val searchMutex: Mutex = mockk()
|
||||||
|
|
||||||
lateinit var viewModel: SearchViewModel
|
lateinit var viewModel: SearchViewModel
|
||||||
@ -115,7 +113,7 @@ internal class SearchViewModelTest {
|
|||||||
@Nested
|
@Nested
|
||||||
inner class StateTests {
|
inner class StateTests {
|
||||||
@Test
|
@Test
|
||||||
fun `initial state is Initialising`() = runBlockingTest {
|
fun `initial state is Initialising`() = runTest {
|
||||||
viewModel.state.test(this).assertValue(
|
viewModel.state.test(this).assertValue(
|
||||||
SearchState("", SearchResultsWithTerm("", null, searchMutex), emptyList(), FromWebView)
|
SearchState("", SearchResultsWithTerm("", null, searchMutex), emptyList(), FromWebView)
|
||||||
).finish()
|
).finish()
|
||||||
@ -152,12 +150,12 @@ internal class SearchViewModelTest {
|
|||||||
inner class ActionMapping {
|
inner class ActionMapping {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `ExitedSearch offers PopFragmentBackstack`() = runBlockingTest {
|
fun `ExitedSearch offers PopFragmentBackstack`() = runTest {
|
||||||
actionResultsInEffects(ExitedSearch, PopFragmentBackstack)
|
actionResultsInEffects(ExitedSearch, PopFragmentBackstack)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `OnItemClick offers Saves and Opens`() = runBlockingTest {
|
fun `OnItemClick offers Saves and Opens`() = runTest {
|
||||||
val searchListItem = RecentSearchListItem("", "")
|
val searchListItem = RecentSearchListItem("", "")
|
||||||
actionResultsInEffects(
|
actionResultsInEffects(
|
||||||
OnItemClick(searchListItem),
|
OnItemClick(searchListItem),
|
||||||
@ -170,7 +168,7 @@ internal class SearchViewModelTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `OnOpenInNewTabClick offers Saves and Opens in new tab`() = runBlockingTest {
|
fun `OnOpenInNewTabClick offers Saves and Opens in new tab`() = runTest {
|
||||||
val searchListItem = RecentSearchListItem("", "")
|
val searchListItem = RecentSearchListItem("", "")
|
||||||
actionResultsInEffects(
|
actionResultsInEffects(
|
||||||
OnOpenInNewTabClick(searchListItem),
|
OnOpenInNewTabClick(searchListItem),
|
||||||
@ -183,7 +181,7 @@ internal class SearchViewModelTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `OnItemLongClick offers Saves and Opens`() = runBlockingTest {
|
fun `OnItemLongClick offers Saves and Opens`() = runTest {
|
||||||
val searchListItem = RecentSearchListItem("", "")
|
val searchListItem = RecentSearchListItem("", "")
|
||||||
actionResultsInEffects(
|
actionResultsInEffects(
|
||||||
OnItemLongClick(searchListItem),
|
OnItemLongClick(searchListItem),
|
||||||
@ -192,12 +190,12 @@ internal class SearchViewModelTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `ClickedSearchInText offers SearchInPreviousScreen`() = runBlockingTest {
|
fun `ClickedSearchInText offers SearchInPreviousScreen`() = runTest {
|
||||||
actionResultsInEffects(ClickedSearchInText, SearchInPreviousScreen(""))
|
actionResultsInEffects(ClickedSearchInText, SearchInPreviousScreen(""))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `ConfirmedDelete offers Delete and Toast`() = runBlockingTest {
|
fun `ConfirmedDelete offers Delete and Toast`() = runTest {
|
||||||
val searchListItem = RecentSearchListItem("", "")
|
val searchListItem = RecentSearchListItem("", "")
|
||||||
actionResultsInEffects(
|
actionResultsInEffects(
|
||||||
ConfirmedDelete(searchListItem),
|
ConfirmedDelete(searchListItem),
|
||||||
@ -207,7 +205,7 @@ internal class SearchViewModelTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `CreatedWithArguments offers SearchArgumentProcessing`() = runBlockingTest {
|
fun `CreatedWithArguments offers SearchArgumentProcessing`() = runTest {
|
||||||
val bundle = mockk<Bundle>()
|
val bundle = mockk<Bundle>()
|
||||||
actionResultsInEffects(
|
actionResultsInEffects(
|
||||||
CreatedWithArguments(bundle),
|
CreatedWithArguments(bundle),
|
||||||
@ -216,7 +214,7 @@ internal class SearchViewModelTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `ReceivedPromptForSpeechInput offers StartSpeechInput`() = runBlockingTest {
|
fun `ReceivedPromptForSpeechInput offers StartSpeechInput`() = runTest {
|
||||||
actionResultsInEffects(
|
actionResultsInEffects(
|
||||||
ReceivedPromptForSpeechInput,
|
ReceivedPromptForSpeechInput,
|
||||||
StartSpeechInput(viewModel.actions)
|
StartSpeechInput(viewModel.actions)
|
||||||
@ -224,7 +222,7 @@ internal class SearchViewModelTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `StartSpeechInputFailed offers ShowToast`() = runBlockingTest {
|
fun `StartSpeechInputFailed offers ShowToast`() = runTest {
|
||||||
actionResultsInEffects(
|
actionResultsInEffects(
|
||||||
StartSpeechInputFailed,
|
StartSpeechInputFailed,
|
||||||
ShowToast(string.speech_not_supported)
|
ShowToast(string.speech_not_supported)
|
||||||
@ -232,14 +230,14 @@ internal class SearchViewModelTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `ActivityResultReceived offers ProcessActivityResult`() = runBlockingTest {
|
fun `ActivityResultReceived offers ProcessActivityResult`() = runTest {
|
||||||
actionResultsInEffects(
|
actionResultsInEffects(
|
||||||
ActivityResultReceived(0, 1, null),
|
ActivityResultReceived(0, 1, null),
|
||||||
ProcessActivityResult(0, 1, null, viewModel.actions)
|
ProcessActivityResult(0, 1, null, viewModel.actions)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun TestCoroutineScope.actionResultsInEffects(
|
private fun TestScope.actionResultsInEffects(
|
||||||
action: Action,
|
action: Action,
|
||||||
vararg effects: SideEffect<*>
|
vararg effects: SideEffect<*>
|
||||||
) {
|
) {
|
||||||
|
@ -22,7 +22,6 @@ import android.content.Context
|
|||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.content.res.AssetFileDescriptor
|
import android.content.res.AssetFileDescriptor
|
||||||
import android.content.res.AssetManager
|
import android.content.res.AssetManager
|
||||||
import androidx.core.content.ContextCompat
|
|
||||||
import org.kiwix.kiwixmobile.core.utils.files.Log
|
import org.kiwix.kiwixmobile.core.utils.files.Log
|
||||||
import org.kiwix.kiwixmobile.custom.main.ValidationState.HasBothFiles
|
import org.kiwix.kiwixmobile.custom.main.ValidationState.HasBothFiles
|
||||||
import org.kiwix.kiwixmobile.custom.main.ValidationState.HasFile
|
import org.kiwix.kiwixmobile.custom.main.ValidationState.HasFile
|
||||||
@ -96,7 +95,7 @@ class CustomFileValidator @Inject constructor(private val context: Context) {
|
|||||||
|
|
||||||
private fun obbFiles() =
|
private fun obbFiles() =
|
||||||
scanDirs(
|
scanDirs(
|
||||||
ContextCompat.getObbDirs(context).filterNotNull().filter(File::exists).toTypedArray(),
|
context.obbDirs.filterNotNull().filter(File::exists).toTypedArray(),
|
||||||
"obb"
|
"obb"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -105,7 +104,7 @@ class CustomFileValidator @Inject constructor(private val context: Context) {
|
|||||||
val directoryList = mutableListOf<File>()
|
val directoryList = mutableListOf<File>()
|
||||||
|
|
||||||
// Get the external files directories for the app
|
// Get the external files directories for the app
|
||||||
ContextCompat.getExternalFilesDirs(context, null).filterNotNull()
|
context.getExternalFilesDirs(null).filterNotNull()
|
||||||
.filter(File::exists)
|
.filter(File::exists)
|
||||||
.forEach { dir ->
|
.forEach { dir ->
|
||||||
// Check if the directory's parent is not null
|
// Check if the directory's parent is not null
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<lint>
|
<lint>
|
||||||
<issue id="TypographyQuotes">
|
<issue id="TypographyQuotes" severity="warning">
|
||||||
<ignore path="**-qq/**.xml" />
|
<ignore path="**-qq/**.xml" />
|
||||||
<ignore path="**-iw/**.xml" />
|
<ignore path="**-iw/**.xml" />
|
||||||
</issue>
|
</issue>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user