diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index 21466c0ae9..57236bb360 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -99,7 +99,6 @@ play {
}
dependencies {
- implementation(Libs.squidb)
androidTestImplementation(Libs.leakcanary_android_instrumentation)
}
task("generateVersionCodeAndName") {
diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/data/local/KiwixDatabaseTest.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/data/local/KiwixDatabaseTest.kt
deleted file mode 100644
index b724156f18..0000000000
--- a/app/src/androidTest/java/org/kiwix/kiwixmobile/data/local/KiwixDatabaseTest.kt
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Kiwix Android
- * Copyright (c) 2019 Kiwix
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-package org.kiwix.kiwixmobile.data.local
-
-import android.content.Context
-import androidx.test.ext.junit.runners.AndroidJUnit4
-import androidx.test.filters.SmallTest
-import androidx.test.platform.app.InstrumentationRegistry
-import com.yahoo.squidb.sql.Query
-import org.junit.Assert
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.kiwix.kiwixmobile.core.data.local.KiwixDatabase
-import org.kiwix.kiwixmobile.core.data.local.entity.Bookmark
-import java.io.BufferedWriter
-import java.io.File
-import java.io.FileOutputStream
-import java.io.IOException
-import java.io.OutputStreamWriter
-import java.io.Writer
-
-@RunWith(AndroidJUnit4::class)
-@SmallTest
-class KiwixDatabaseTest {
- private val context: Context = InstrumentationRegistry.getInstrumentation().targetContext
-
- @Test @Throws(IOException::class) // Standard charset throws exception on < API19
- fun testMigrateDatabase() {
- val kiwixDatabase = KiwixDatabase(
- context,
- null,
- null,
- null,
- null
- )
- kiwixDatabase.recreate()
- val testId = "8ce5775a-10a9-bbf3-178a-9df69f23263c"
- val testBookmarks = arrayOf("Test1", "Test2", "Test3")
- val fileName = context.filesDir.absolutePath + File.separator + testId + ".txt"
- val f = File(fileName)
- if (!f.createNewFile()) {
- throw IOException("Unable to create file for testing migration")
- }
- val writer: Writer = BufferedWriter(
- OutputStreamWriter(
- FileOutputStream(fileName),
- "UTF-8"
- )
- )
- for (bookmark in testBookmarks) {
- writer.write(
- """
- $bookmark
-
- """.trimIndent()
- )
- }
- writer.close()
- kiwixDatabase.migrateBookmarksVersion6()
- val bookmarkTitles = ArrayList()
- try {
- val bookmarkCursor = kiwixDatabase.query(
- Bookmark::class.java,
- Query.selectDistinct(Bookmark.BOOKMARK_TITLE)
- .where(
- Bookmark.ZIM_ID.eq(testId)
- .or(Bookmark.ZIM_NAME.eq(""))
- )
- .orderBy(Bookmark.BOOKMARK_TITLE.asc())
- )
- while (bookmarkCursor.moveToNext()) {
- bookmarkTitles.add(bookmarkCursor.get(Bookmark.BOOKMARK_TITLE))
- }
- } catch (exception: Exception) {
- exception.printStackTrace()
- }
- Assert.assertArrayEquals(testBookmarks, bookmarkTitles.toTypedArray())
-
- // TODO Add new migration test for version 16
- }
-}
diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/data/local/dao/BookDaoTest.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/data/local/dao/BookDaoTest.kt
deleted file mode 100644
index d94130a29f..0000000000
--- a/app/src/androidTest/java/org/kiwix/kiwixmobile/data/local/dao/BookDaoTest.kt
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * Kiwix Android
- * Copyright (c) 2019 Kiwix
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-package org.kiwix.kiwixmobile.data.local.dao
-
-import android.content.Context
-import androidx.test.InstrumentationRegistry
-import androidx.test.ext.junit.runners.AndroidJUnit4
-import io.mockk.every
-import io.mockk.mockk
-import io.mockk.verify
-import org.junit.After
-import org.junit.Before
-import org.junit.Test
-import org.junit.jupiter.api.fail
-import org.junit.runner.RunWith
-import org.kiwix.kiwixmobile.core.data.local.KiwixDatabase
-import org.kiwix.kiwixmobile.core.data.local.dao.BookDao
-import org.kiwix.kiwixmobile.core.data.local.entity.BookDatabaseEntity
-import org.kiwix.kiwixmobile.core.entity.LibraryNetworkEntity.Book
-import java.io.File
-import java.io.IOException
-import java.util.ArrayList
-
-@RunWith(AndroidJUnit4::class)
-class BookDaoTest {
- private var testDir: File? = null
-
- @Before
- fun executeBefore() {
- testDir = InstrumentationRegistry.getTargetContext().getDir("testDir", Context.MODE_PRIVATE)
- }
-
- // TODO : test books are saved after downloading the list of available zim files
- @Test @Throws(IOException::class)
- fun testGetBooks() { // Save the fake data to test
- val kiwixDatabase = mockk()
- val bookDao = BookDao(kiwixDatabase)
- val testId = "6qq5301d-2cr0-ebg5-474h-6db70j52864p"
- val fileName = testDir?.path + "/" + testId + "testFile"
- val booksToAdd = getFakeData(fileName)
- every { kiwixDatabase.deleteWhere(any(), any()) } returns 0
- val booksRetrieved =
- bookDao.filterBookResults(booksToAdd)
- if (!booksRetrieved.contains(booksToAdd[0])) fail()
- verify(exactly = 0) {
- kiwixDatabase.deleteWhere(
- BookDatabaseEntity::class.java,
- BookDatabaseEntity.URL.eq(booksToAdd[0].file?.path)
- )
- }
- if (booksRetrieved.contains(booksToAdd[1])) fail()
- verify(exactly = 0) {
- kiwixDatabase.deleteWhere(
- BookDatabaseEntity::class.java,
- BookDatabaseEntity.URL.eq(booksToAdd[1].file?.path)
- )
- }
- if (booksRetrieved.contains(booksToAdd[2])) fail()
- verify(exactly = 0) {
- kiwixDatabase.deleteWhere(
- BookDatabaseEntity::class.java,
- BookDatabaseEntity.URL.eq(booksToAdd[2].file?.path)
- )
- }
- if (booksRetrieved.contains(booksToAdd[3])) fail()
- verify {
- kiwixDatabase.deleteWhere(
- BookDatabaseEntity::class.java,
- BookDatabaseEntity.URL.eq(booksToAdd[3].file?.path)
- )
- }
- if (!booksRetrieved.contains(booksToAdd[4])) fail()
- verify(exactly = 0) {
- kiwixDatabase.deleteWhere(
- BookDatabaseEntity::class.java,
- BookDatabaseEntity.URL.eq(booksToAdd[4].file?.path)
- )
- }
- if (!booksRetrieved.contains(booksToAdd[5])) fail()
- verify(exactly = 0) {
- kiwixDatabase.deleteWhere(
- BookDatabaseEntity::class.java,
- BookDatabaseEntity.URL.eq(booksToAdd[5].file?.path)
- )
- }
- if (booksRetrieved.contains(booksToAdd[6])) fail()
- verify {
- kiwixDatabase.deleteWhere(
- BookDatabaseEntity::class.java,
- BookDatabaseEntity.URL.eq(booksToAdd[6].file?.path)
- )
- }
- if (!booksRetrieved.contains(booksToAdd[7])) fail()
- verify(exactly = 0) {
- kiwixDatabase.deleteWhere(
- BookDatabaseEntity::class.java,
- BookDatabaseEntity.URL.eq(booksToAdd[7].file?.path)
- )
- }
- if (booksRetrieved.contains(booksToAdd[8])) fail()
- verify {
- kiwixDatabase.deleteWhere(
- BookDatabaseEntity::class.java,
- BookDatabaseEntity.URL.eq(booksToAdd[8].file?.path)
- )
- }
- }
-
- private fun fail() {
- fail { "shouldn't happen" }
- }
-
- @Throws(IOException::class)
- private fun getFakeData(baseFileName: String): ArrayList {
- val books =
- ArrayList()
- for (i in 0..8) {
- val book = Book()
- book.bookName = "Test Copy $i"
- book.id = "Test ID $i"
- val fileName = baseFileName + i
- when (i) {
- 0 -> {
- book.file = File("$fileName.zim")
- book.file?.createNewFile()
- }
- 1 -> {
- book.file = File("$fileName.part")
- book.file?.createNewFile()
- }
- 2 -> {
- book.file = File("$fileName.zim")
- val t2 = File("$fileName.zim.part")
- t2.createNewFile()
- }
- 3 -> book.file = File("$fileName.zim")
- 4 -> {
- book.file = File("$fileName.zim")
- book.file?.createNewFile()
- val t4 = File("$fileName.zim.part")
- t4.createNewFile()
- }
- 5 -> {
- book.file = File("$fileName.zimdg")
- setupCase1(fileName)
- }
- 6 -> {
- book.file = File("$fileName.zimyr")
- setupCase2(fileName)
- }
- 7 -> {
- book.file = File("$fileName.zimdg")
- setupCase1(fileName)
- }
- 8 -> {
- book.file = File("$fileName.zimyr")
- setupCase2(fileName)
- }
- }
- books.add(book)
- }
- return books
- }
-
- @Throws(IOException::class)
- private fun setupCase1(fileName: String) {
- var char1 = 'a'
- while (char1 <= 'z') {
- var char2 = 'a'
- while (char2 <= 'z') {
- val file = File("$fileName.zim$char1$char2")
- file.createNewFile()
- if (char1 == 'd' && char2 == 'r') {
- break
- }
- char2++
- }
- if (char1 == 'd') {
- break
- }
- char1++
- }
- }
-
- @Throws(IOException::class)
- private fun setupCase2(fileName: String) {
- var char1 = 'a'
- while (char1 <= 'z') {
- var char2 = 'a'
- while (char2 <= 'z') {
- val file = File("$fileName.zim$char1$char2")
- file.createNewFile()
- if (char1 == 'd' && char2 == 'r') {
- break
- }
- char2++
- }
- if (char1 == 'd') {
- break
- }
- char1++
- }
- val t = File("$fileName.zimcp.part")
- }
-
- @After fun removeTestDirectory() {
- for (child in testDir?.listFiles() ?: emptyArray()) {
- child.delete()
- }
- testDir?.delete()
- }
-}
diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/data/local/dao/RecentSearchDaoTest.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/data/local/dao/RecentSearchDaoTest.kt
deleted file mode 100644
index 4fecbbb790..0000000000
--- a/app/src/androidTest/java/org/kiwix/kiwixmobile/data/local/dao/RecentSearchDaoTest.kt
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Kiwix Android
- * Copyright (c) 2019 Kiwix
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-package org.kiwix.kiwixmobile.data.local.dao
-
-import androidx.test.ext.junit.runners.AndroidJUnit4
-import com.yahoo.squidb.data.AbstractModel
-import com.yahoo.squidb.data.SquidCursor
-import io.mockk.every
-import io.mockk.mockk
-import io.mockk.verify
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.kiwix.kiwixmobile.core.data.local.KiwixDatabase
-import org.kiwix.kiwixmobile.core.data.local.dao.RecentSearchDao
-
-@RunWith(AndroidJUnit4::class)
-class RecentSearchDaoTest {
-
- @Test fun testGetRecentSearches() {
- val kiwixDatabase = mockk()
- every {
- kiwixDatabase.query(any>(), any())
- } returns mockk>(relaxed = true)
- RecentSearchDao(kiwixDatabase).getRecentSearches()
- verify { kiwixDatabase.query(any>(), any()) }
- }
-}
diff --git a/app/src/main/assets/credits.html b/app/src/main/assets/credits.html
index 5ccec14f47..cd0a10b109 100644
--- a/app/src/main/assets/credits.html
+++ b/app/src/main/assets/credits.html
@@ -102,11 +102,6 @@
Apache
Copyright 2015 RxAndroid Authors
-
- SquiDb
-
- Copyright 2013 Yahoo, Inc.
-
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/language/viewmodel/SaveLanguagesAndFinish.kt b/app/src/main/java/org/kiwix/kiwixmobile/language/viewmodel/SaveLanguagesAndFinish.kt
index 33a731d552..de904086c1 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/language/viewmodel/SaveLanguagesAndFinish.kt
+++ b/app/src/main/java/org/kiwix/kiwixmobile/language/viewmodel/SaveLanguagesAndFinish.kt
@@ -17,13 +17,16 @@
*/
package org.kiwix.kiwixmobile.language.viewmodel
+import android.annotation.SuppressLint
import androidx.appcompat.app.AppCompatActivity
import io.reactivex.Flowable
+import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import org.kiwix.kiwixmobile.core.base.SideEffect
import org.kiwix.kiwixmobile.core.dao.NewLanguagesDao
import org.kiwix.kiwixmobile.core.zim_manager.Language
+@SuppressLint("CheckResult")
data class SaveLanguagesAndFinish(
val languages: List,
val languageDao: NewLanguagesDao
@@ -32,6 +35,7 @@ data class SaveLanguagesAndFinish(
override fun invokeWith(activity: AppCompatActivity) {
Flowable.fromCallable { languageDao.insert(languages) }
.subscribeOn(Schedulers.io())
+ .observeOn(AndroidSchedulers.mainThread())
.subscribe({
activity.onBackPressed()
}, Throwable::printStackTrace)
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/LocalLibraryFragment.kt b/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/LocalLibraryFragment.kt
index 6588b1f914..00617025a9 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/LocalLibraryFragment.kt
+++ b/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/LocalLibraryFragment.kt
@@ -36,6 +36,7 @@ import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.view.ActionMode
import androidx.appcompat.widget.Toolbar
+import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.content.ContextCompat
import androidx.core.net.toUri
import androidx.fragment.app.FragmentActivity
@@ -43,6 +44,7 @@ import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
+import com.google.android.material.bottomnavigation.BottomNavigationView
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.CompositeDisposable
import org.kiwix.kiwixmobile.R
@@ -149,6 +151,12 @@ class LocalLibraryFragment : BaseFragment() {
.also {
coreMainActivity.navHostContainer
.setBottomMarginToFragmentContainerView(0)
+
+ val bottomNavigationView =
+ requireActivity().findViewById(R.id.bottom_nav_view)
+ bottomNavigationView?.let {
+ setBottomMarginToSwipeRefreshLayout(bottomNavigationView.measuredHeight)
+ }
}
disposable.add(sideEffects())
zimManageViewModel.deviceListIsRefreshing.observe(viewLifecycleOwner) {
@@ -164,6 +172,14 @@ class LocalLibraryFragment : BaseFragment() {
hideFilePickerButton()
}
+ private fun setBottomMarginToSwipeRefreshLayout(marginBottom: Int) {
+ fragmentDestinationLibraryBinding?.zimSwiperefresh?.apply {
+ val params = layoutParams as CoordinatorLayout.LayoutParams?
+ params?.bottomMargin = marginBottom
+ requestLayout()
+ }
+ }
+
private fun hideFilePickerButton() {
if (sharedPreferenceUtil.isPlayStoreBuild) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/OnlineLibraryFragment.kt b/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/OnlineLibraryFragment.kt
index 9243b46f0e..956ec3adcd 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/OnlineLibraryFragment.kt
+++ b/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/OnlineLibraryFragment.kt
@@ -177,7 +177,7 @@ class OnlineLibraryFragment : BaseFragment(), FragmentActivityExtensions {
viewLifecycleOwner
) {
if (it) {
- showInternetPermissionDialog()
+ showInternetAccessViaMobileNetworkDialog()
}
}
@@ -189,19 +189,14 @@ class OnlineLibraryFragment : BaseFragment(), FragmentActivityExtensions {
}
}
)
-
- fragmentDestinationDownloadBinding?.allowInternetPermissionButton?.setOnClickListener {
- showInternetPermissionDialog()
- }
}
- private fun showInternetPermissionDialog() {
+ private fun showInternetAccessViaMobileNetworkDialog() {
dialogShower.show(
WifiOnly,
{
onRefreshStateChange(true)
- fragmentDestinationDownloadBinding?.libraryErrorText?.visibility = View.GONE
- fragmentDestinationDownloadBinding?.allowInternetPermissionButton?.visibility = View.GONE
+ showRecyclerviewAndHideSwipeDownForLibraryErrorText()
sharedPreferenceUtil.putPrefWifiOnly(false)
zimManageViewModel.shouldShowWifiOnlyDialog.value = false
},
@@ -211,15 +206,28 @@ class OnlineLibraryFragment : BaseFragment(), FragmentActivityExtensions {
resources.getString(R.string.denied_internet_permission_message),
Toast.LENGTH_SHORT
)
- fragmentDestinationDownloadBinding?.libraryErrorText?.setText(
- R.string.allow_internet_permission_message
- )
- fragmentDestinationDownloadBinding?.libraryErrorText?.visibility = View.VISIBLE
- fragmentDestinationDownloadBinding?.allowInternetPermissionButton?.visibility = View.VISIBLE
+ hideRecyclerviewAndShowSwipeDownForLibraryErrorText()
}
)
}
+ private fun showRecyclerviewAndHideSwipeDownForLibraryErrorText() {
+ fragmentDestinationDownloadBinding?.apply {
+ libraryErrorText.visibility = View.GONE
+ libraryList.visibility = View.VISIBLE
+ }
+ }
+
+ private fun hideRecyclerviewAndShowSwipeDownForLibraryErrorText() {
+ fragmentDestinationDownloadBinding?.apply {
+ libraryErrorText.setText(
+ R.string.swipe_down_for_library
+ )
+ libraryErrorText.visibility = View.VISIBLE
+ libraryList.visibility = View.GONE
+ }
+ }
+
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
super.onCreateOptionsMenu(menu, inflater)
inflater.inflate(R.menu.menu_zim_manager, menu)
@@ -245,6 +253,7 @@ class OnlineLibraryFragment : BaseFragment(), FragmentActivityExtensions {
override fun onDestroyView() {
super.onDestroyView()
+ availableSpaceCalculator.dispose()
fragmentDestinationDownloadBinding?.libraryList?.adapter = null
fragmentDestinationDownloadBinding = null
}
@@ -261,6 +270,13 @@ class OnlineLibraryFragment : BaseFragment(), FragmentActivityExtensions {
private fun onNetworkStateChange(networkState: NetworkState?) {
when (networkState) {
NetworkState.CONNECTED -> {
+ if (NetworkUtils.isWiFi(requireContext())) {
+ onRefreshStateChange(true)
+ refreshFragment()
+ } else if (noWifiWithWifiOnlyPreferenceSet) {
+ onRefreshStateChange(false)
+ hideRecyclerviewAndShowSwipeDownForLibraryErrorText()
+ }
}
NetworkState.NOT_CONNECTED -> {
if (libraryAdapter.itemCount > 0) {
@@ -271,7 +287,6 @@ class OnlineLibraryFragment : BaseFragment(), FragmentActivityExtensions {
)
fragmentDestinationDownloadBinding?.libraryErrorText?.visibility = View.VISIBLE
}
- fragmentDestinationDownloadBinding?.allowInternetPermissionButton?.visibility = View.GONE
fragmentDestinationDownloadBinding?.librarySwipeRefresh?.isRefreshing = false
}
else -> {}
@@ -301,7 +316,6 @@ class OnlineLibraryFragment : BaseFragment(), FragmentActivityExtensions {
} else {
fragmentDestinationDownloadBinding?.libraryErrorText?.visibility = View.GONE
}
- fragmentDestinationDownloadBinding?.allowInternetPermissionButton?.visibility = View.GONE
}
private fun refreshFragment() {
@@ -310,6 +324,8 @@ class OnlineLibraryFragment : BaseFragment(), FragmentActivityExtensions {
} else {
zimManageViewModel.requestDownloadLibrary.onNext(Unit)
}
+ fragmentDestinationDownloadBinding?.libraryErrorText?.visibility = View.GONE
+ fragmentDestinationDownloadBinding?.libraryList?.visibility = View.VISIBLE
}
private fun downloadFile() {
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.kt b/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.kt
index 7ced19e691..09920833f6 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.kt
+++ b/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.kt
@@ -20,6 +20,7 @@ package org.kiwix.kiwixmobile.webserver
import android.util.Log
import io.reactivex.Flowable
import io.reactivex.android.schedulers.AndroidSchedulers
+import io.reactivex.disposables.Disposable
import org.kiwix.kiwixmobile.core.utils.DEFAULT_PORT
import org.kiwix.kiwixmobile.core.utils.ServerUtils
import org.kiwix.kiwixmobile.core.utils.ServerUtils.INVALID_IP
@@ -40,6 +41,7 @@ class WebServerHelper @Inject constructor(
) {
private var kiwixServer: KiwixServer? = null
private var isServerStarted = false
+ private var validIpAddressDisposable: Disposable? = null
fun startServerHelper(selectedBooksPath: ArrayList): Boolean {
val ip = getIpAddress()
@@ -79,7 +81,7 @@ class WebServerHelper @Inject constructor(
// If no ip is found after 15 seconds, dismisses the progress dialog
@Suppress("MagicNumber")
fun pollForValidIpAddress() {
- Flowable.interval(1, TimeUnit.SECONDS)
+ validIpAddressDisposable = Flowable.interval(1, TimeUnit.SECONDS)
.map { getIp() }
.filter { s: String? -> s != INVALID_IP }
.timeout(15, TimeUnit.SECONDS)
@@ -96,6 +98,10 @@ class WebServerHelper @Inject constructor(
}
}
+ fun dispose() {
+ validIpAddressDisposable?.dispose()
+ }
+
companion object {
private const val TAG = "WebServerHelper"
}
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/webserver/wifi_hotspot/HotspotService.kt b/app/src/main/java/org/kiwix/kiwixmobile/webserver/wifi_hotspot/HotspotService.kt
index fca38f16e9..50daf99610 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/webserver/wifi_hotspot/HotspotService.kt
+++ b/app/src/main/java/org/kiwix/kiwixmobile/webserver/wifi_hotspot/HotspotService.kt
@@ -64,6 +64,7 @@ class HotspotService :
}
override fun onDestroy() {
+ webServerHelper?.dispose()
hotspotStateReceiver?.let(this@HotspotService::unregisterReceiver)
super.onDestroy()
}
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/zimManager/Fat32Checker.kt b/app/src/main/java/org/kiwix/kiwixmobile/zimManager/Fat32Checker.kt
index 740081e7cd..1ced19f793 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/zimManager/Fat32Checker.kt
+++ b/app/src/main/java/org/kiwix/kiwixmobile/zimManager/Fat32Checker.kt
@@ -17,6 +17,7 @@
*/
package org.kiwix.kiwixmobile.zimManager
+import android.annotation.SuppressLint
import android.os.FileObserver
import io.reactivex.Flowable
import io.reactivex.functions.BiFunction
@@ -32,6 +33,7 @@ import org.kiwix.kiwixmobile.zimManager.FileSystemCapability.CAN_WRITE_4GB
import org.kiwix.kiwixmobile.zimManager.FileSystemCapability.INCONCLUSIVE
import java.io.File
+@SuppressLint("CheckResult")
class Fat32Checker constructor(
sharedPreferenceUtil: SharedPreferenceUtil,
private val fileSystemCheckers: List
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 a614c6c1c0..b447ee6617 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/zimManager/ZimManageViewModel.kt
+++ b/app/src/main/java/org/kiwix/kiwixmobile/zimManager/ZimManageViewModel.kt
@@ -246,12 +246,14 @@ class ZimManageViewModel @Inject constructor(
.observeOn(Schedulers.io())
.subscribe(
{
- kiwixService.library
- .retry(5)
- .subscribe(library::onNext) {
- it.printStackTrace()
- library.onNext(LibraryNetworkEntity().apply { book = LinkedList() })
- }
+ compositeDisposable?.add(
+ kiwixService.library
+ .retry(5)
+ .subscribe(library::onNext) {
+ it.printStackTrace()
+ library.onNext(LibraryNetworkEntity().apply { book = LinkedList() })
+ }
+ )
},
Throwable::printStackTrace
)
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/zimManager/libraryView/AvailableSpaceCalculator.kt b/app/src/main/java/org/kiwix/kiwixmobile/zimManager/libraryView/AvailableSpaceCalculator.kt
index 1c466ef14a..66647a0373 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/zimManager/libraryView/AvailableSpaceCalculator.kt
+++ b/app/src/main/java/org/kiwix/kiwixmobile/zimManager/libraryView/AvailableSpaceCalculator.kt
@@ -21,6 +21,7 @@ package org.kiwix.kiwixmobile.zimManager.libraryView
import eu.mhutti1.utils.storage.Bytes
import eu.mhutti1.utils.storage.Kb
import io.reactivex.android.schedulers.AndroidSchedulers
+import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
import org.kiwix.kiwixmobile.core.dao.FetchDownloadDao
import org.kiwix.kiwixmobile.core.downloader.model.DownloadModel
@@ -32,12 +33,13 @@ class AvailableSpaceCalculator @Inject constructor(
private val downloadDao: FetchDownloadDao,
private val storageCalculator: StorageCalculator
) {
+ private var availableSpaceCalculatorDisposable: Disposable? = null
fun hasAvailableSpaceFor(
bookItem: LibraryListItem.BookItem,
successAction: (LibraryListItem.BookItem) -> Unit,
failureAction: (String) -> Unit
) {
- downloadDao.allDownloads()
+ availableSpaceCalculatorDisposable = downloadDao.allDownloads()
.map { it.map(DownloadModel::bytesRemaining).sum() }
.map { bytesToBeDownloaded -> storageCalculator.availableBytes() - bytesToBeDownloaded }
.subscribeOn(Schedulers.io())
@@ -50,4 +52,8 @@ class AvailableSpaceCalculator @Inject constructor(
}
}
}
+
+ fun dispose() {
+ availableSpaceCalculatorDisposable?.dispose()
+ }
}
diff --git a/app/src/main/res/layout/fragment_destination_download.xml b/app/src/main/res/layout/fragment_destination_download.xml
index 9d71a38410..3a6c07d194 100644
--- a/app/src/main/res/layout/fragment_destination_download.xml
+++ b/app/src/main/res/layout/fragment_destination_download.xml
@@ -65,16 +65,4 @@
app:layout_constraintVertical_bias="0.45"
tools:ignore="RequiredSize" />
-
-
-
diff --git a/buildSrc/src/main/kotlin/Libs.kt b/buildSrc/src/main/kotlin/Libs.kt
index ba21570714..e95e40c388 100644
--- a/buildSrc/src/main/kotlin/Libs.kt
+++ b/buildSrc/src/main/kotlin/Libs.kt
@@ -161,11 +161,6 @@ object Libs {
const val dagger_compiler: String = "com.google.dagger:dagger-compiler:" +
Versions.com_google_dagger
- /**
- * https://jitpack.io/p/yahoo/squidb
- */
- const val squidb: String = "com.github.yahoo:squidb:" + Versions.com_yahoo_squidb
-
/**
* https://github.com/JakeWharton/butterknife/
*/
@@ -303,6 +298,9 @@ object Libs {
const val constraintlayout: String = "androidx.constraintlayout:constraintlayout:" +
Versions.constraintlayout
+ const val swipe_refresh_layout: String = "androidx.swiperefreshlayout:swiperefreshlayout:" +
+ Versions.swipe_refresh_layout
+
/**
* http://developer.android.com/tools/extras/support-library.html
*/
diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt
index bf14e8ded2..f5d25f5dca 100644
--- a/buildSrc/src/main/kotlin/Versions.kt
+++ b/buildSrc/src/main/kotlin/Versions.kt
@@ -32,8 +32,6 @@ object Versions {
const val com_google_dagger: String = "2.42"
- const val com_yahoo_squidb: String = "4.0.0-beta.2" // available: "3.2.3"
-
const val com_jakewharton: String = "10.2.3"
const val androidx_test: String = "1.5.1"
@@ -62,6 +60,8 @@ object Versions {
const val constraintlayout: String = "2.0.4"
+ const val swipe_refresh_layout: String = "1.1.0"
+
const val collection_ktx: String = "1.1.0"
const val preference_ktx: String = "1.1.1"
diff --git a/buildSrc/src/main/kotlin/plugin/AllProjectConfigurer.kt b/buildSrc/src/main/kotlin/plugin/AllProjectConfigurer.kt
index cb44bff582..3797516306 100644
--- a/buildSrc/src/main/kotlin/plugin/AllProjectConfigurer.kt
+++ b/buildSrc/src/main/kotlin/plugin/AllProjectConfigurer.kt
@@ -100,7 +100,6 @@ class AllProjectConfigurer {
"GoogleAppIndexingApiWarning",
"LockedOrientationActivity",
//TODO stop ignoring below this
- "CheckResult",
"LabelFor",
"LogConditional",
"ConvertToWebp",
@@ -172,6 +171,7 @@ class AllProjectConfigurer {
implementation(Libs.appcompat)
implementation(Libs.material)
implementation(Libs.constraintlayout)
+ implementation(Libs.swipe_refresh_layout)
implementation(Libs.multidex)
// navigation
implementation(Libs.navigation_fragment_ktx)
diff --git a/core/build.gradle.kts b/core/build.gradle.kts
index 40d9e7f7d6..f248bfed8d 100644
--- a/core/build.gradle.kts
+++ b/core/build.gradle.kts
@@ -67,9 +67,6 @@ dependencies {
api(fileTree(mapOf("include" to "*.aar", "dir" to "libs")))
}
- // SquiDB
- implementation(Libs.squidb)
-
// Document File
implementation(Libs.select_folder_document_file)
diff --git a/core/src/main/java/eu/mhutti1/utils/storage/StorageSelectDialog.kt b/core/src/main/java/eu/mhutti1/utils/storage/StorageSelectDialog.kt
index 5345199b2f..368ae14636 100644
--- a/core/src/main/java/eu/mhutti1/utils/storage/StorageSelectDialog.kt
+++ b/core/src/main/java/eu/mhutti1/utils/storage/StorageSelectDialog.kt
@@ -30,6 +30,7 @@ import eu.mhutti1.utils.storage.adapter.StorageAdapter
import eu.mhutti1.utils.storage.adapter.StorageDelegate
import io.reactivex.Flowable
import io.reactivex.android.schedulers.AndroidSchedulers
+import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
import org.kiwix.kiwixmobile.core.CoreApp
import org.kiwix.kiwixmobile.core.databinding.StorageSelectDialogBinding
@@ -44,6 +45,7 @@ class StorageSelectDialog : DialogFragment() {
@Inject lateinit var sharedPreferenceUtil: SharedPreferenceUtil
private var aTitle: String? = null
private var storageSelectDialogViewBinding: StorageSelectDialogBinding? = null
+ private var storageDisposable: Disposable? = null
private val storageAdapter: StorageAdapter by lazy {
StorageAdapter(
@@ -73,13 +75,14 @@ class StorageSelectDialog : DialogFragment() {
setHasFixedSize(true)
}
- Flowable.fromCallable { StorageDeviceUtils.getWritableStorage(requireActivity()) }
- .subscribeOn(Schedulers.io())
- .observeOn(AndroidSchedulers.mainThread())
- .subscribe(
- { storageAdapter.items = it },
- Throwable::printStackTrace
- )
+ storageDisposable =
+ Flowable.fromCallable { StorageDeviceUtils.getWritableStorage(requireActivity()) }
+ .subscribeOn(Schedulers.io())
+ .observeOn(AndroidSchedulers.mainThread())
+ .subscribe(
+ { storageAdapter.items = it },
+ Throwable::printStackTrace
+ )
}
override fun show(fm: FragmentManager, text: String?) {
@@ -89,6 +92,7 @@ class StorageSelectDialog : DialogFragment() {
override fun onDestroyView() {
super.onDestroyView()
+ storageDisposable?.dispose()
storageSelectDialogViewBinding = null
}
}
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/CoreApp.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/CoreApp.kt
index c99a56df00..e106fc0ec6 100644
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/CoreApp.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/CoreApp.kt
@@ -26,7 +26,6 @@ import android.os.StrictMode
import android.os.StrictMode.VmPolicy
import androidx.multidex.MultiDex
import com.jakewharton.threetenabp.AndroidThreeTen
-import org.kiwix.kiwixmobile.core.data.local.KiwixDatabase
import org.kiwix.kiwixmobile.core.di.components.CoreComponent
import org.kiwix.kiwixmobile.core.di.components.DaggerCoreComponent
import org.kiwix.kiwixmobile.core.downloader.DownloadMonitor
@@ -48,9 +47,6 @@ abstract class CoreApp : Application() {
@Inject
lateinit var nightModeConfig: NightModeConfig
- @Inject
- lateinit var kiwixDatabase: KiwixDatabase
-
/**
* The init of this class does the work of initializing,
* simply injecting it is all that there is to be done
@@ -83,7 +79,6 @@ abstract class CoreApp : Application() {
.build()
AndroidThreeTen.init(this)
coreComponent.inject(this)
- kiwixDatabase.forceMigration()
downloadMonitor.init()
nightModeConfig.init()
fileLogger.writeLogFile(this)
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/NightModeConfig.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/NightModeConfig.kt
index 669efaa115..c98c36c48f 100644
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/NightModeConfig.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/NightModeConfig.kt
@@ -17,6 +17,7 @@
*/
package org.kiwix.kiwixmobile.core
+import android.annotation.SuppressLint
import android.content.Context
import android.content.res.Configuration
import androidx.appcompat.app.AppCompatDelegate
@@ -24,6 +25,7 @@ import org.kiwix.kiwixmobile.core.NightModeConfig.Mode.SYSTEM
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil
import javax.inject.Inject
+@SuppressLint("CheckResult")
class NightModeConfig @Inject constructor(
val sharedPreferenceUtil: SharedPreferenceUtil,
val context: Context
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/dao/NewBookDao.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/dao/NewBookDao.kt
index 39e534174e..8e15a303a9 100644
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/dao/NewBookDao.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/dao/NewBookDao.kt
@@ -23,7 +23,6 @@ import io.objectbox.kotlin.query
import io.objectbox.query.QueryBuilder
import org.kiwix.kiwixmobile.core.dao.entities.BookOnDiskEntity
import org.kiwix.kiwixmobile.core.dao.entities.BookOnDiskEntity_
-import org.kiwix.kiwixmobile.core.data.local.entity.Bookmark
import org.kiwix.kiwixmobile.core.entity.LibraryNetworkEntity.Book
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskListItem.BookOnDisk
import javax.inject.Inject
@@ -88,13 +87,6 @@ class NewBookDao @Inject constructor(private val box: Box) {
box.remove(books)
}
- fun getFavIconAndZimFile(it: Bookmark): Pair {
- val bookOnDiskEntity = box.query {
- equal(BookOnDiskEntity_.bookId, it.zimId, QueryBuilder.StringOrder.CASE_INSENSITIVE)
- }.find().getOrNull(0)
- return bookOnDiskEntity?.let { it.favIcon to it.file.path } ?: null to null
- }
-
fun bookMatching(downloadTitle: String) = box.query {
endsWith(
BookOnDiskEntity_.file, downloadTitle,
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/dao/NewBookmarksDao.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/dao/NewBookmarksDao.kt
index a63d70ee67..03b2a890f8 100644
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/dao/NewBookmarksDao.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/dao/NewBookmarksDao.kt
@@ -24,7 +24,6 @@ import io.reactivex.Flowable
import io.reactivex.schedulers.Schedulers
import org.kiwix.kiwixmobile.core.dao.entities.BookmarkEntity
import org.kiwix.kiwixmobile.core.dao.entities.BookmarkEntity_
-import org.kiwix.kiwixmobile.core.data.local.entity.Bookmark
import org.kiwix.kiwixmobile.core.page.adapter.Page
import org.kiwix.kiwixmobile.core.page.bookmark.adapter.BookmarkItem
import org.kiwix.kiwixmobile.core.reader.ZimFileReader
@@ -91,11 +90,4 @@ class NewBookmarksDao @Inject constructor(val box: Box) : PageDa
)
}.remove()
}
-
- fun migrationInsert(
- bookmarks: MutableList,
- bookDao: NewBookDao
- ) {
- box.put(bookmarks.zip(bookmarks.map(bookDao::getFavIconAndZimFile)).map(::BookmarkEntity))
- }
}
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/dao/NewRecentSearchDao.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/dao/NewRecentSearchDao.kt
index cd3a8411d8..7010f12b6d 100644
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/dao/NewRecentSearchDao.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/dao/NewRecentSearchDao.kt
@@ -23,7 +23,6 @@ import io.objectbox.query.QueryBuilder
import kotlinx.coroutines.flow.map
import org.kiwix.kiwixmobile.core.dao.entities.RecentSearchEntity
import org.kiwix.kiwixmobile.core.dao.entities.RecentSearchEntity_
-import org.kiwix.kiwixmobile.core.data.local.entity.RecentSearch
import org.kiwix.kiwixmobile.core.search.adapter.SearchListItem.RecentSearchListItem
import javax.inject.Inject
@@ -66,10 +65,6 @@ class NewRecentSearchDao @Inject constructor(
box.removeAll()
}
- fun migrationInsert(recentSearches: MutableList) {
- box.put(recentSearches.map(::RecentSearchEntity))
- }
-
companion object {
private const val NUM_RECENT_RESULTS = 100
}
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/dao/entities/BookmarkEntity.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/dao/entities/BookmarkEntity.kt
index 5f751bdb81..9d29d0735a 100644
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/dao/entities/BookmarkEntity.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/dao/entities/BookmarkEntity.kt
@@ -19,7 +19,6 @@ package org.kiwix.kiwixmobile.core.dao.entities
import io.objectbox.annotation.Entity
import io.objectbox.annotation.Id
-import org.kiwix.kiwixmobile.core.data.local.entity.Bookmark
import org.kiwix.kiwixmobile.core.page.bookmark.adapter.BookmarkItem
@Entity
@@ -41,20 +40,4 @@ data class BookmarkEntity(
item.title,
item.favicon
)
-
- private constructor(bookmark: Bookmark, zimFilePath: String?, favicon: String?) : this(
- 0,
- bookmark.zimId,
- bookmark.zimName,
- zimFilePath,
- bookmark.bookmarkUrl,
- bookmark.bookmarkTitle,
- favicon
- )
-
- constructor(bookmarkWithFavIconAndFile: Pair>) : this(
- bookmarkWithFavIconAndFile.first,
- bookmarkWithFavIconAndFile.second.first,
- bookmarkWithFavIconAndFile.second.second
- )
}
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/dao/entities/RecentSearchEntity.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/dao/entities/RecentSearchEntity.kt
index 55c5719bad..f27e8d12b2 100644
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/dao/entities/RecentSearchEntity.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/dao/entities/RecentSearchEntity.kt
@@ -19,17 +19,10 @@ package org.kiwix.kiwixmobile.core.dao.entities
import io.objectbox.annotation.Entity
import io.objectbox.annotation.Id
-import org.kiwix.kiwixmobile.core.data.local.entity.RecentSearch
@Entity
data class RecentSearchEntity(
@Id var id: Long = 0L,
val searchTerm: String,
val zimId: String
-) {
- constructor(recentSearch: RecentSearch) : this(
- 0,
- recentSearch.searchString,
- recentSearch.zimID
- )
-}
+)
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/data/local/KiwixDatabase.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/data/local/KiwixDatabase.kt
deleted file mode 100644
index 81a4feda3a..0000000000
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/data/local/KiwixDatabase.kt
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * Kiwix Android
- * Copyright (c) 2019 Kiwix
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-package org.kiwix.kiwixmobile.core.data.local
-
-import android.content.Context
-import android.util.Log
-import com.yahoo.squidb.android.AndroidOpenHelper
-import com.yahoo.squidb.data.ISQLiteDatabase
-import com.yahoo.squidb.data.ISQLiteOpenHelper
-import com.yahoo.squidb.data.SquidDatabase
-import com.yahoo.squidb.sql.Table
-import org.kiwix.kiwixmobile.core.dao.NewBookDao
-import org.kiwix.kiwixmobile.core.dao.NewBookmarksDao
-import org.kiwix.kiwixmobile.core.dao.NewLanguagesDao
-import org.kiwix.kiwixmobile.core.dao.NewRecentSearchDao
-import org.kiwix.kiwixmobile.core.data.local.dao.BookDao
-import org.kiwix.kiwixmobile.core.data.local.dao.BookmarksDao
-import org.kiwix.kiwixmobile.core.data.local.dao.NetworkLanguageDao
-import org.kiwix.kiwixmobile.core.data.local.dao.RecentSearchDao
-import org.kiwix.kiwixmobile.core.data.local.entity.BookDatabaseEntity
-import org.kiwix.kiwixmobile.core.data.local.entity.Bookmark
-import org.kiwix.kiwixmobile.core.data.local.entity.LibraryDatabaseEntity
-import org.kiwix.kiwixmobile.core.data.local.entity.NetworkLanguageDatabaseEntity
-import org.kiwix.kiwixmobile.core.data.local.entity.RecentSearch
-import org.kiwix.kiwixmobile.core.utils.TAG_KIWIX
-import org.kiwix.kiwixmobile.core.utils.UpdateUtils
-import java.io.BufferedReader
-import java.io.FileNotFoundException
-import java.io.IOException
-import java.io.InputStream
-import java.io.InputStreamReader
-import javax.inject.Inject
-import javax.inject.Singleton
-
-@Singleton
-@Deprecated("") // delete once migrations are no longer needed
-open class KiwixDatabase @Inject constructor(
- private val context: Context,
- private val bookDao: NewBookDao?,
- private val languagesDao: NewLanguagesDao?,
- private val bookmarksDao: NewBookmarksDao?,
- private val recentSearchDao: NewRecentSearchDao?
-) : SquidDatabase() {
-
- override fun getName(): String = "Kiwix.db"
-
- override fun getTables(): Array
=
- arrayOf(
- RecentSearch.TABLE,
- Bookmark.TABLE,
- BookDatabaseEntity.TABLE,
- NetworkLanguageDatabaseEntity.TABLE
- )
-
- override fun createOpenHelper(
- databaseName: String,
- delegate: OpenHelperDelegate,
- version: Int
- ): ISQLiteOpenHelper = AndroidOpenHelper(context, databaseName, delegate, version)
-
- @Suppress(
- "LongMethod",
- "ComplexMethod",
- "NestedBlockDepth",
- "TooGenericExceptionCaught",
- "MagicNumber"
- )
- override fun onUpgrade(db: ISQLiteDatabase, oldVersion: Int, newVersion: Int): Boolean {
- Log.e("UPGRADE", "oldversion: $oldVersion newVersion: $newVersion")
- when (oldVersion) {
- 1, 2 -> {
- db.execSQL("DROP TABLE IF EXISTS recents")
- db.execSQL("DROP TABLE IF EXISTS recentsearches")
- tryCreateTable(RecentSearch.TABLE)
- }
- 3 -> {
- tryCreateTable(Bookmark.TABLE)
- }
- 4 -> {
- db.execSQL("DROP TABLE IF EXISTS book")
- tryCreateTable(BookDatabaseEntity.TABLE)
- }
- 5 -> {
- db.execSQL("DROP TABLE IF EXISTS Bookmarks")
- tryCreateTable(Bookmark.TABLE)
- migrateBookmarksVersion6()
- }
- 6 -> {
- db.execSQL("DROP TABLE IF EXISTS recents")
- db.execSQL("DROP TABLE IF EXISTS recentsearches")
- tryCreateTable(RecentSearch.TABLE)
- }
- 7 -> {
- db.execSQL("DROP TABLE IF EXISTS recents")
- db.execSQL("DROP TABLE IF EXISTS recentsearches")
- tryCreateTable(RecentSearch.TABLE)
- }
- 8 -> {
- db.execSQL("DROP TABLE IF EXISTS book")
- tryCreateTable(BookDatabaseEntity.TABLE)
- }
- 9 -> {
- tryCreateTable(NetworkLanguageDatabaseEntity.TABLE)
- }
- 10 -> {
- db.execSQL("DROP TABLE IF EXISTS recentSearches")
- tryCreateTable(RecentSearch.TABLE)
- }
- 11 -> {
- tryAddColumn(BookDatabaseEntity.REMOTE_URL)
- }
- 12 -> {
- tryAddColumn(BookDatabaseEntity.NAME)
- tryAddColumn(Bookmark.ZIM_NAME)
- }
- 13 -> {
- tryDropTable(BookDatabaseEntity.TABLE)
- tryCreateTable(BookDatabaseEntity.TABLE)
- }
- 14, 15 -> {
- try {
- bookDao?.migrationInsert(BookDao(this).books)
- } catch (e: java.lang.Exception) {
- e.printStackTrace()
- }
- try {
- languagesDao?.insert(NetworkLanguageDao(this).filteredLanguages)
- } catch (e: java.lang.Exception) {
- e.printStackTrace()
- }
- tryDropTable(BookDatabaseEntity.TABLE)
- tryDropTable(NetworkLanguageDatabaseEntity.TABLE)
- tryDropTable(LibraryDatabaseEntity.TABLE)
- }
- TWO_POINT_FIVE_POINT_THREE -> {
- try {
- val oldBookmarksDao = BookmarksDao(this)
- val stringOperationImpl: BookmarksDao.StringOperation =
- object : BookmarksDao.StringOperation {
- override fun apply(string: String?): String? =
- string?.let(UpdateUtils::reformatProviderUrl)
- }
- oldBookmarksDao.processBookmark(stringOperationImpl)
- bookDao?.let {
- bookmarksDao?.migrationInsert(oldBookmarksDao.bookmarks.toMutableList(), it)
- }
- } catch (e: Exception) {
- e.printStackTrace()
- }
- tryDropTable(Bookmark.TABLE)
- try {
- recentSearchDao?.migrationInsert(RecentSearchDao(this).getRecentSearches())
- } catch (e: Exception) {
- e.printStackTrace()
- }
- tryDropTable(RecentSearch.TABLE)
- }
- }
- return true
- }
-
- override fun getVersion(): Int = FINAL
-
- @Suppress("NestedBlockDepth", "MagicNumber")
- fun migrateBookmarksVersion6() {
- context.fileList()
- .asSequence()
- .filter { it.length == 40 && it.endsWith(".txt") }
- .forEach { id ->
- try {
- val idName = id.substring(0, id.length - 4)
- val stream: InputStream? = context.openFileInput(id)
- var bookMarkTitle: String?
- if (stream != null) {
- val read = BufferedReader(InputStreamReader(stream))
- while (read.readLine().also { bookMarkTitle = it } != null) {
- val bookmark = Bookmark()
- bookmark.setBookmarkUrl("null")
- .setBookmarkTitle(bookMarkTitle!!)
- .setZimId(idName).zimName = idName
- persist(bookmark)
- }
- context.deleteFile(id)
- }
- } catch (e: FileNotFoundException) {
- Log.e(TAG_KIWIX, "Bookmark File ( $id ) not found", e)
- // Surface to user
- } catch (e: IOException) {
- Log.e(TAG_KIWIX, "Can not read file $id", e)
- // Surface to user
- }
- }
- }
-
- /* Now that the database is no longer used
- * we need to make a migration happen with an explicit call
- */
- fun forceMigration() {
- beginTransaction()
- endTransaction()
- }
-
- companion object {
- private const val TWO_POINT_FIVE_POINT_THREE = 16
- private const val FINAL = 17 // 3.0.0
- }
-}
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/data/local/dao/BookDao.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/data/local/dao/BookDao.kt
deleted file mode 100644
index bb99d26a3f..0000000000
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/data/local/dao/BookDao.kt
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Kiwix Android
- * Copyright (c) 2019 Kiwix
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-package org.kiwix.kiwixmobile.core.data.local.dao
-
-import com.yahoo.squidb.data.SquidCursor
-import com.yahoo.squidb.sql.Query
-import org.kiwix.kiwixmobile.core.data.local.KiwixDatabase
-import org.kiwix.kiwixmobile.core.data.local.entity.BookDatabaseEntity
-import org.kiwix.kiwixmobile.core.entity.LibraryNetworkEntity
-import org.kiwix.kiwixmobile.core.utils.files.FileUtils.hasPart
-import java.io.File
-import javax.inject.Inject
-
-/**
- * Dao class for books
- */
-@Deprecated("")
-class BookDao @Inject constructor(private val kiwixDatabase: KiwixDatabase) {
- private fun setBookDetails(
- book: LibraryNetworkEntity.Book,
- bookCursor: SquidCursor
- ) {
- book.id = bookCursor.get(BookDatabaseEntity.BOOK_ID)!!
- book.title = bookCursor.get(BookDatabaseEntity.TITLE)!!
- book.description = bookCursor.get(BookDatabaseEntity.DESCRIPTION)
- book.language = bookCursor.get(BookDatabaseEntity.LANGUAGE)!!
- book.creator = bookCursor.get(BookDatabaseEntity.BOOK_CREATOR)!!
- book.publisher = bookCursor.get(BookDatabaseEntity.PUBLISHER)!!
- book.date = bookCursor.get(BookDatabaseEntity.DATE)!!
- book.file = bookCursor.get(BookDatabaseEntity.URL)?.let(::File)
- book.articleCount = bookCursor.get(BookDatabaseEntity.ARTICLE_COUNT)
- book.mediaCount = bookCursor.get(BookDatabaseEntity.MEDIA_COUNT)
- book.size = bookCursor.get(BookDatabaseEntity.SIZE)!!
- book.favicon = bookCursor.get(BookDatabaseEntity.FAVICON)!!
- book.bookName = bookCursor.get(BookDatabaseEntity.NAME)
- }
-
- val books: ArrayList
- @Suppress("TooGenericExceptionCaught")
- get() {
- val books = ArrayList()
- try {
- val bookCursor = kiwixDatabase.query(
- BookDatabaseEntity::class.java,
- Query.select()
- )
- while (bookCursor.moveToNext()) {
- val book = LibraryNetworkEntity.Book()
- setBookDetails(book, bookCursor)
- books.add(book)
- }
- } catch (exception: Exception) {
- exception.printStackTrace()
- }
- return filterBookResults(books)
- }
-
- fun filterBookResults(
- books: ArrayList
- ): ArrayList {
- val filteredBookList = ArrayList()
- books
- .asSequence()
- .filterNot { it.file?.let(::hasPart) == true }
- .forEach {
- if (it.file?.exists() == true) {
- filteredBookList.add(it)
- } else {
- kiwixDatabase.deleteWhere(
- BookDatabaseEntity::class.java,
- BookDatabaseEntity.URL.eq(it.file?.path)
- )
- }
- }
- return filteredBookList
- }
-}
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/data/local/dao/BookmarksDao.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/data/local/dao/BookmarksDao.kt
deleted file mode 100644
index 278b7c0e2e..0000000000
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/data/local/dao/BookmarksDao.kt
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Kiwix Android
- * Copyright (c) 2019 Kiwix
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-package org.kiwix.kiwixmobile.core.data.local.dao
-
-import com.yahoo.squidb.sql.Query
-import com.yahoo.squidb.sql.Update
-import org.kiwix.kiwixmobile.core.data.local.KiwixDatabase
-import org.kiwix.kiwixmobile.core.data.local.entity.Bookmark
-import javax.inject.Inject
-
-/**
- * Dao class for bookmarks.
- */
-@Deprecated("")
-class BookmarksDao @Inject constructor(private val kiwixDatabase: KiwixDatabase) {
- val bookmarks: List
- @Suppress("TooGenericExceptionCaught")
- get() {
- val bookmarks = ArrayList()
- val query = Query.select()
- try {
- val squidCursor = kiwixDatabase
- .query(Bookmark::class.java, query.orderBy(Bookmark.BOOKMARK_TITLE.asc()))
- while (squidCursor.moveToNext()) {
- val bookmark = Bookmark()
- bookmark.zimId = squidCursor.get(Bookmark.ZIM_ID)!!
- bookmark.zimName = squidCursor.get(Bookmark.ZIM_NAME)!!
- bookmark.bookmarkTitle = squidCursor.get(Bookmark.BOOKMARK_TITLE)!!
- bookmark.bookmarkUrl = squidCursor.get(Bookmark.BOOKMARK_URL)!!
- bookmarks.add(bookmark)
- }
- } catch (exception: Exception) {
- exception.printStackTrace()
- }
- return bookmarks
- }
-
- @Suppress("TooGenericExceptionCaught")
- fun processBookmark(operation: StringOperation) {
- try {
- val bookmarkCursor = kiwixDatabase.query(
- Bookmark::class.java,
- Query.select(Bookmark.ROWID, Bookmark.BOOKMARK_URL)
- )
- while (bookmarkCursor.moveToNext()) {
- operation.apply(bookmarkCursor.get(Bookmark.BOOKMARK_URL))?.let { bookmarkUrl ->
- kiwixDatabase.update(
- Update.table(Bookmark.TABLE)
- .where(Bookmark.ROWID.eq(bookmarkCursor.get(Bookmark.ROWID)))
- .set(Bookmark.BOOKMARK_URL, bookmarkUrl)
- )
- }
- }
- } catch (exception: Exception) {
- exception.printStackTrace()
- }
- }
-
- interface StringOperation {
- fun apply(string: String?): String?
- }
-}
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/data/local/dao/NetworkLanguageDao.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/data/local/dao/NetworkLanguageDao.kt
deleted file mode 100644
index 539333bf43..0000000000
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/data/local/dao/NetworkLanguageDao.kt
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Kiwix Android
- * Copyright (c) 2019 Kiwix
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-package org.kiwix.kiwixmobile.core.data.local.dao
-
-import org.kiwix.kiwixmobile.core.data.local.KiwixDatabase
-import com.yahoo.squidb.sql.Query
-import org.kiwix.kiwixmobile.core.data.local.entity.NetworkLanguageDatabaseEntity
-import org.kiwix.kiwixmobile.core.zim_manager.Language
-import java.lang.Exception
-import java.util.ArrayList
-import javax.inject.Inject
-
-@Deprecated("")
-class NetworkLanguageDao @Inject constructor(private val mDb: KiwixDatabase) {
- val filteredLanguages: ArrayList
- @Suppress("TooGenericExceptionCaught")
- get() {
- val result = ArrayList()
- try {
- val languageCursor = mDb.query(
- NetworkLanguageDatabaseEntity::class.java,
- Query.select()
- )
- while (languageCursor.moveToNext()) {
- val languageCode =
- languageCursor.get(NetworkLanguageDatabaseEntity.LANGUAGE_I_S_O_3) ?: ""
- val enabled = languageCursor.get(NetworkLanguageDatabaseEntity.ENABLED) ?: false
- result.add(Language(languageCode, enabled, 0))
- }
- } catch (exception: Exception) {
- exception.printStackTrace()
- }
- return result
- }
-}
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/data/local/dao/RecentSearchDao.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/data/local/dao/RecentSearchDao.kt
deleted file mode 100644
index 82d211e88f..0000000000
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/data/local/dao/RecentSearchDao.kt
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Kiwix Android
- * Copyright (c) 2019 Kiwix
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-package org.kiwix.kiwixmobile.core.data.local.dao
-
-import android.database.sqlite.SQLiteException
-import com.yahoo.squidb.sql.Query
-import org.kiwix.kiwixmobile.core.data.local.KiwixDatabase
-import org.kiwix.kiwixmobile.core.data.local.entity.RecentSearch
-import javax.inject.Inject
-
-/**
- * Dao class for recent searches.
- */
-class RecentSearchDao @Inject constructor(private val mDb: KiwixDatabase) {
-
- fun getRecentSearches(): MutableList {
- val result: MutableList = ArrayList()
- try {
- val searchCursor = mDb.query(
- RecentSearch::class.java, Query.select()
- )
- while (searchCursor.moveToNext()) {
- result.add(RecentSearch(searchCursor))
- }
- } catch (exception: SQLiteException) {
- exception.printStackTrace()
- }
-
- return result
- }
-}
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/data/local/entity/BookDataSource.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/data/local/entity/BookDataSource.kt
deleted file mode 100644
index 40141cfacf..0000000000
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/data/local/entity/BookDataSource.kt
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Kiwix Android
- * Copyright (c) 2019 Kiwix
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-package org.kiwix.kiwixmobile.core.data.local.entity
-
-import com.yahoo.squidb.annotations.TableModelSpec
-
-@TableModelSpec(className = "BookDatabaseEntity", tableName = "book")
-class BookDataSource {
- var bookId: String? = null
- var title: String? = null
- var description: String? = null
- var language: String? = null
- var bookCreator: String? = null
- var publisher: String? = null
- var date: String? = null
- var url: String? = null
- var remoteUrl: String? = null
- var articleCount: String? = null
- var mediaCount: String? = null
- var size: String? = null
- var favicon: String? = null
- var name: String? = null
-}
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/data/local/entity/BookmarksSpec.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/data/local/entity/BookmarksSpec.kt
deleted file mode 100644
index 3d5318e4a0..0000000000
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/data/local/entity/BookmarksSpec.kt
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Kiwix Android
- * Copyright (c) 2019 Kiwix
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-package org.kiwix.kiwixmobile.core.data.local.entity
-
-import com.yahoo.squidb.annotations.TableModelSpec
-import com.yahoo.squidb.annotations.tables.constraints.NotNull
-
-/**
- * Squidb spec for saved bookmarks.
- */
-@Suppress("VariableNaming")
-@TableModelSpec(className = "Bookmark", tableName = "Bookmarks")
-class BookmarksSpec {
- @NotNull
- lateinit var ZimId: String
-
- @NotNull
- lateinit var ZimName: String
-
- @NotNull
- lateinit var bookmarkUrl: String
-
- @NotNull
- lateinit var bookmarkTitle: String
-}
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/data/local/entity/LibraryDataSource.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/data/local/entity/LibraryDataSource.kt
deleted file mode 100644
index e9863aca7f..0000000000
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/data/local/entity/LibraryDataSource.kt
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Kiwix Android
- * Copyright (c) 2019 Kiwix
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-package org.kiwix.kiwixmobile.core.data.local.entity
-
-import com.yahoo.squidb.annotations.TableModelSpec
-
-@TableModelSpec(className = "LibraryDatabaseEntity", tableName = "library")
-class LibraryDataSource {
- var libraryVersion: String? = null
-}
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/data/local/entity/NetworkLanguageSpec.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/data/local/entity/NetworkLanguageSpec.kt
deleted file mode 100644
index 0f49a4a2b3..0000000000
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/data/local/entity/NetworkLanguageSpec.kt
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Kiwix Android
- * Copyright (c) 2019 Kiwix
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-package org.kiwix.kiwixmobile.core.data.local.entity
-
-import com.yahoo.squidb.annotations.TableModelSpec
-
-@TableModelSpec(className = "NetworkLanguageDatabaseEntity", tableName = "networkLanguages")
-class NetworkLanguageSpec {
- var languageISO3: String? = null
- var enabled = false
- var numberOfOccurences = 0
-}
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/data/local/entity/RecentSearchSpec.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/data/local/entity/RecentSearchSpec.kt
deleted file mode 100644
index bb428d5e1b..0000000000
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/data/local/entity/RecentSearchSpec.kt
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Kiwix Android
- * Copyright (c) 2019 Kiwix
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-package org.kiwix.kiwixmobile.core.data.local.entity
-
-import com.yahoo.squidb.annotations.TableModelSpec
-import com.yahoo.squidb.annotations.tables.constraints.NotNull
-
-/**
- * Squidb spec for recent searches.
- */
-@TableModelSpec(className = "RecentSearch", tableName = "recentSearches")
-class RecentSearchSpec {
- @NotNull
- lateinit var searchString: String
-
- @NotNull
- lateinit var zimID: String
-}
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/di/components/CoreComponent.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/di/components/CoreComponent.kt
index 8edb9a8ab4..81c2528cac 100644
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/di/components/CoreComponent.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/di/components/CoreComponent.kt
@@ -35,8 +35,6 @@ import org.kiwix.kiwixmobile.core.dao.NewNoteDao
import org.kiwix.kiwixmobile.core.dao.NewRecentSearchDao
import org.kiwix.kiwixmobile.core.data.DataModule
import org.kiwix.kiwixmobile.core.data.DataSource
-import org.kiwix.kiwixmobile.core.data.local.dao.BookDao
-import org.kiwix.kiwixmobile.core.data.local.dao.BookmarksDao
import org.kiwix.kiwixmobile.core.data.remote.KiwixService
import org.kiwix.kiwixmobile.core.di.modules.ApplicationModule
import org.kiwix.kiwixmobile.core.di.modules.CoreViewModelModule
@@ -95,8 +93,6 @@ interface CoreComponent {
fun connectivityManager(): ConnectivityManager
fun context(): Context
fun downloader(): Downloader
- fun bookDao(): BookDao
- fun bookmarksDao(): BookmarksDao
fun notificationManager(): NotificationManager
fun searchResultGenerator(): SearchResultGenerator
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/downloader/DownloaderImpl.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/downloader/DownloaderImpl.kt
index 908b91817b..e272ca6d99 100644
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/downloader/DownloaderImpl.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/downloader/DownloaderImpl.kt
@@ -18,6 +18,7 @@
package org.kiwix.kiwixmobile.core.downloader
+import android.annotation.SuppressLint
import io.reactivex.Observable
import org.kiwix.kiwixmobile.core.dao.FetchDownloadDao
import org.kiwix.kiwixmobile.core.data.remote.KiwixService
@@ -31,6 +32,7 @@ class DownloaderImpl @Inject constructor(
private val kiwixService: KiwixService
) : Downloader {
+ @SuppressLint("CheckResult")
override fun download(book: LibraryNetworkEntity.Book) {
urlProvider(book)
.take(1)
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/downloader/fetch/FetchDownloadMonitor.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/downloader/fetch/FetchDownloadMonitor.kt
index 1bf34b1fab..eef4bf97d8 100644
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/downloader/fetch/FetchDownloadMonitor.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/downloader/fetch/FetchDownloadMonitor.kt
@@ -17,6 +17,7 @@
*/
package org.kiwix.kiwixmobile.core.downloader.fetch
+import android.annotation.SuppressLint
import com.tonyodev.fetch2.Download
import com.tonyodev.fetch2.Error
import com.tonyodev.fetch2.Fetch
@@ -28,6 +29,7 @@ import org.kiwix.kiwixmobile.core.dao.FetchDownloadDao
import org.kiwix.kiwixmobile.core.downloader.DownloadMonitor
import javax.inject.Inject
+@SuppressLint("CheckResult")
class FetchDownloadMonitor @Inject constructor(fetch: Fetch, fetchDownloadDao: FetchDownloadDao) :
DownloadMonitor {
private val updater = PublishSubject.create<() -> Unit>()
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/main/AddNoteDialog.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/main/AddNoteDialog.kt
index 0ffa0dab3a..08bf576f04 100644
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/main/AddNoteDialog.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/main/AddNoteDialog.kt
@@ -439,6 +439,7 @@ class AddNoteDialog : DialogFragment() {
override fun onDestroyView() {
super.onDestroyView()
+ mainRepositoryActions.dispose()
dialogNoteAddNoteBinding = null
}
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt
index 0a484441cc..bcd81eed4c 100644
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt
@@ -802,6 +802,7 @@ abstract class CoreReaderFragment :
val activity = requireActivity() as AppCompatActivity?
activity?.setSupportActionBar(null)
}
+ repositoryActions?.dispose()
safeDispose()
tabCallback = null
hideBackToTopTimer?.cancel()
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/main/KiwixTextToSpeech.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/main/KiwixTextToSpeech.kt
index 58960c94fc..3a4608809a 100644
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/main/KiwixTextToSpeech.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/main/KiwixTextToSpeech.kt
@@ -117,7 +117,8 @@ class KiwixTextToSpeech internal constructor(
} else {
tts.language = locale
if (getFeatures(tts).contains(Engine.KEY_FEATURE_NOT_INSTALLED)) {
- context.toast(R.string.tts_lang_not_supported, Toast.LENGTH_LONG)
+ val activity = context as CoreMainActivity?
+ activity?.externalLinkOpener?.showTTSLanguageDownloadDialog()
} else if (requestAudioFocus()) {
loadURL(webView)
}
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/main/MainRepositoryActions.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/main/MainRepositoryActions.kt
index 9c417d846a..4f6a440cc9 100644
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/main/MainRepositoryActions.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/main/MainRepositoryActions.kt
@@ -18,6 +18,7 @@
package org.kiwix.kiwixmobile.core.main
import android.util.Log
+import io.reactivex.disposables.Disposable
import org.kiwix.kiwixmobile.core.data.DataSource
import org.kiwix.kiwixmobile.core.di.ActivityScope
import org.kiwix.kiwixmobile.core.page.bookmark.adapter.BookmarkItem
@@ -29,14 +30,18 @@ private const val TAG = "MainPresenter"
@ActivityScope
class MainRepositoryActions @Inject constructor(private val dataSource: DataSource) {
+ private var saveHistoryDisposable: Disposable? = null
+ private var saveBookmarkDisposable: Disposable? = null
+ private var saveNoteDisposable: Disposable? = null
+ private var deleteNoteDisposable: Disposable? = null
fun saveHistory(history: HistoryItem) {
- dataSource.saveHistory(history)
+ saveHistoryDisposable = dataSource.saveHistory(history)
.subscribe({}, { e -> Log.e(TAG, "Unable to save history", e) })
}
fun saveBookmark(bookmark: BookmarkItem) {
- dataSource.saveBookmark(bookmark)
+ saveBookmarkDisposable = dataSource.saveBookmark(bookmark)
.subscribe({}, { e -> Log.e(TAG, "Unable to save bookmark", e) })
}
@@ -47,12 +52,19 @@ class MainRepositoryActions @Inject constructor(private val dataSource: DataSour
}
fun saveNote(note: NoteListItem) {
- dataSource.saveNote(note)
+ saveNoteDisposable = dataSource.saveNote(note)
.subscribe({}, { e -> Log.e(TAG, "Unable to save note", e) })
}
fun deleteNote(noteUniqueKey: String) {
- dataSource.deleteNote(noteUniqueKey)
+ deleteNoteDisposable = dataSource.deleteNote(noteUniqueKey)
.subscribe({}, { e -> Log.e(TAG, "Unable to delete note", e) })
}
+
+ fun dispose() {
+ saveHistoryDisposable?.dispose()
+ saveBookmarkDisposable?.dispose()
+ saveNoteDisposable?.dispose()
+ deleteNoteDisposable?.dispose()
+ }
}
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/reader/ZimFileReader.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/reader/ZimFileReader.kt
index 60ebe0a61d..1b811614d4 100644
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/reader/ZimFileReader.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/reader/ZimFileReader.kt
@@ -17,6 +17,7 @@
*/
package org.kiwix.kiwixmobile.core.reader
+import android.annotation.SuppressLint
import android.content.res.AssetFileDescriptor
import android.net.Uri
import android.os.ParcelFileDescriptor
@@ -173,6 +174,7 @@ class ZimFileReader constructor(
private fun getContent(url: String) = getContentAndMimeType(url).let { (content, _) -> content }
+ @SuppressLint("CheckResult")
private fun streamZimContentToPipe(uri: String, outputStream: OutputStream) {
Completable.fromAction {
try {
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/settings/CorePrefsFragment.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/settings/CorePrefsFragment.kt
index 13a11e5225..07ad1ec09c 100644
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/settings/CorePrefsFragment.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/settings/CorePrefsFragment.kt
@@ -127,6 +127,11 @@ abstract class CorePrefsFragment :
.unregisterOnSharedPreferenceChangeListener(this)
}
+ override fun onDestroyView() {
+ presenter?.dispose()
+ super.onDestroyView()
+ }
+
private fun setUpSettings() {
setAppVersionNumber()
}
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/settings/SettingsPresenter.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/settings/SettingsPresenter.kt
index 3f4653e6b7..d4b26446c3 100644
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/settings/SettingsPresenter.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/settings/SettingsPresenter.kt
@@ -18,6 +18,7 @@
package org.kiwix.kiwixmobile.core.settings
import android.util.Log
+import io.reactivex.disposables.Disposable
import org.kiwix.kiwixmobile.core.base.BasePresenter
import org.kiwix.kiwixmobile.core.data.DataSource
import org.kiwix.kiwixmobile.core.settings.SettingsContract.Presenter
@@ -26,12 +27,17 @@ import javax.inject.Inject
internal class SettingsPresenter @Inject constructor(private val dataSource: DataSource) :
BasePresenter(), Presenter {
+ private var dataSourceDisposable: Disposable? = null
override fun clearHistory() {
- dataSource.clearHistory()
+ dataSourceDisposable = dataSource.clearHistory()
.subscribe({
// TODO
}, { e ->
Log.e("SettingsPresenter", e.message, e)
})
}
+
+ fun dispose() {
+ dataSourceDisposable?.dispose()
+ }
}
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/utils/ExternalLinkOpener.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/utils/ExternalLinkOpener.kt
index a7341d6602..c0ea13c1de 100644
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/utils/ExternalLinkOpener.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/utils/ExternalLinkOpener.kt
@@ -20,6 +20,7 @@ package org.kiwix.kiwixmobile.core.utils
import android.app.Activity
import android.content.Intent
+import android.speech.tts.TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA
import org.kiwix.kiwixmobile.core.R
import org.kiwix.kiwixmobile.core.extensions.toast
import org.kiwix.kiwixmobile.core.utils.dialog.AlertDialogShower
@@ -63,4 +64,17 @@ class ExternalLinkOpener @Inject constructor(
url = URL(intent.data.toString())
)
}
+
+ fun showTTSLanguageDownloadDialog() {
+ alertDialogShower.show(
+ KiwixDialog.DownloadTTSLanguage,
+ {
+ activity.startActivity(
+ Intent().apply {
+ action = ACTION_INSTALL_TTS_DATA
+ }
+ )
+ }
+ )
+ }
}
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/utils/dialog/KiwixDialog.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/utils/dialog/KiwixDialog.kt
index 81ff47f0cd..4aae4bc648 100644
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/utils/dialog/KiwixDialog.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/utils/dialog/KiwixDialog.kt
@@ -221,6 +221,13 @@ sealed class KiwixDialog(
android.R.string.cancel
)
+ object DownloadTTSLanguage : KiwixDialog(
+ R.string.download_tts_language_title,
+ R.string.download_tts_language_message,
+ R.string.download,
+ android.R.string.cancel
+ )
+
open class YesNoDialog(
title: Int?,
message: Int
diff --git a/core/src/main/res/values-ar/strings.xml b/core/src/main/res/values-ar/strings.xml
index d810c19576..86d97ffc9d 100644
--- a/core/src/main/res/values-ar/strings.xml
+++ b/core/src/main/res/values-ar/strings.xml
@@ -303,7 +303,6 @@
الرجاء تحديد مجلد للتخزين الخارجي.النظام غير قادر على منح الإذن!السماح
- يرجى السماح بإذن الإنترنت لتنزيل المحتوىلا توجد ملاحظاتعرض الملاحظات من جميع الكتبملاحظات البحث
diff --git a/core/src/main/res/values-cs/strings.xml b/core/src/main/res/values-cs/strings.xml
index 949bdd66fd..6d6a11bbd3 100644
--- a/core/src/main/res/values-cs/strings.xml
+++ b/core/src/main/res/values-cs/strings.xml
@@ -304,7 +304,6 @@
Vyberte složku pro externí úložiště.Systém nemůže udělit oprávnění!Povolit
- Povolte prosím internetové povolení ke stahování obsahuŽádné poznámkyZobrazit poznámky ze všech knihHledat poznámky
diff --git a/core/src/main/res/values-de/strings.xml b/core/src/main/res/values-de/strings.xml
index 739a9fa3b1..7457210fa2 100644
--- a/core/src/main/res/values-de/strings.xml
+++ b/core/src/main/res/values-de/strings.xml
@@ -309,5 +309,4 @@
Bitte einen Ordner für externe Speicherung auswählen.System kann keine Berechtigung erteilen!Erlauben
- Bitte erteile die Internet-Erlaubnis, um Inhalte herunterzuladen
diff --git a/core/src/main/res/values-fr/strings.xml b/core/src/main/res/values-fr/strings.xml
index b4e3b35bca..035f4af98c 100644
--- a/core/src/main/res/values-fr/strings.xml
+++ b/core/src/main/res/values-fr/strings.xml
@@ -309,7 +309,6 @@
Veuillez sélectionner un dossier pour le stockage externe.Le système n’a pas pu accorder le droit d’accès !Autoriser
- Veuillez autoriser le droit sur Internet de télécharger le contenu.Aucune noteAfficher les notes de tous les livresRechercher des notes
diff --git a/core/src/main/res/values-hi/strings.xml b/core/src/main/res/values-hi/strings.xml
index ebd235d88a..f3977ef4a9 100644
--- a/core/src/main/res/values-hi/strings.xml
+++ b/core/src/main/res/values-hi/strings.xml
@@ -132,5 +132,4 @@
चालूबंदअनुमति दें
- कृपया कंटैट डाउनलोड करने के लिए इंटरनेट की अनुमति दें
diff --git a/core/src/main/res/values-it/strings.xml b/core/src/main/res/values-it/strings.xml
index b95b18c85c..8f1b9e284d 100644
--- a/core/src/main/res/values-it/strings.xml
+++ b/core/src/main/res/values-it/strings.xml
@@ -304,7 +304,6 @@
Seleziona una cartella per l\'archiviazione esterna.Il sistema non è in grado di concedere l\'autorizzazione!Consenti
- Si prega di consentire l\'autorizzazione a Internet per scaricare i contenutiNessuna notaVisualizza le note di tutti i libriCerca note
diff --git a/core/src/main/res/values-iw/strings.xml b/core/src/main/res/values-iw/strings.xml
index 440fe81b1f..f46e4aca37 100644
--- a/core/src/main/res/values-iw/strings.xml
+++ b/core/src/main/res/values-iw/strings.xml
@@ -301,7 +301,6 @@
נא לבחור תיקייה לאחסון חיצוני.המערכת אינה יכולה לתת הרשאה!לאפשר
- נא לאפשר הרשאת אינטרנט כדי להוריד תוכןאין הערותהצגת הערות מכל הספריםחיפוש בהערות
diff --git a/core/src/main/res/values-ku/strings.xml b/core/src/main/res/values-ku/strings.xml
index 7072b7fcbc..396645d1e9 100644
--- a/core/src/main/res/values-ku/strings.xml
+++ b/core/src/main/res/values-ku/strings.xml
@@ -297,7 +297,6 @@
Ji kerema xwe peldankekê bibijêre ji bo depokirina xaricî.Sîstem nikare destûrê werbigire!Destûr bide
- Ji kerema xwe destûra înternetê bide da ku karibe naverokê daxîneNot tineNotan Bibîne Ji Hemû KitêbanLi notan bigere
diff --git a/core/src/main/res/values-mk/strings.xml b/core/src/main/res/values-mk/strings.xml
index 0a0b21d344..e0d7395a45 100644
--- a/core/src/main/res/values-mk/strings.xml
+++ b/core/src/main/res/values-mk/strings.xml
@@ -293,7 +293,6 @@
Изберете ја папката за надворешно складирање.Системот не може да ја даде дозволата!Дозволи
- Дајте дозвола за семрежен пристап за преземање на содржинитеНема белешкиПогл. белешки од сите книгиПребарај белешки
diff --git a/core/src/main/res/values-nqo/strings.xml b/core/src/main/res/values-nqo/strings.xml
index a892b42fc4..ee3a9c8a83 100644
--- a/core/src/main/res/values-nqo/strings.xml
+++ b/core/src/main/res/values-nqo/strings.xml
@@ -295,7 +295,6 @@
ߞߎ߲ߓߍ߲ ߘߏ߫ ߛߎߥߊ߲ߘߌ߫ ߖߊ߰ߣߌ߲߫ ߞߣߐߘߐ ߟߊ߬ߡߙߊ߬ߦߙߐ߬ ߞߏ ߘߐ߫.ߘߌ߬ߢߍ߬ ߞߍߣߍ߲߫ ߣߍ߫ ߞߊ߲ߞߋ ߢߍ߫ ߖߡߊ߬ߙߌ߬ߟߌ ߘߐ߫߹ߊ߬ ߟߊߘߌ߬ߢߍ߬
- ߓߟߐߟߐ ߖߡߊ߬ߙߌ߬ߦߊ ߟߊߘߌ߬ߢߍ߫ ߖߊ߰ߣߌ߲߫ ߞߊ߬ ߛߋ߫ ߞߣߐߘߐ ߡߊߞߍ߫ ߟߴߌ ߞߎ߲߬ߦߟߌߣߐ߫ ߕߴߦߋ߲߬ߦߟߌߣߐ ߘߐߜߍ߫ ߞߊ߬ ߝߘߊ߫ ߞߊ߬ߝߊ ߟߎ߬ ߓߍ߯ ߟߊ߫ߞߐߕߐ߮ ߟߎ߬ ߢߌߣߌ߲߫
diff --git a/core/src/main/res/values-ru/strings.xml b/core/src/main/res/values-ru/strings.xml
index 523e4dd068..648bba0c7a 100644
--- a/core/src/main/res/values-ru/strings.xml
+++ b/core/src/main/res/values-ru/strings.xml
@@ -314,7 +314,6 @@
Выберите папку для внешнего хранилища.Система не может предоставить разрешение!Разрешить
- Пожалуйста разрешите доступ в интернет для загрузки контентаНет заметокПросмотр заметок из всех книгИскать заметки
diff --git a/core/src/main/res/values-sc/strings.xml b/core/src/main/res/values-sc/strings.xml
index 2efedd6008..3118072283 100644
--- a/core/src/main/res/values-sc/strings.xml
+++ b/core/src/main/res/values-sc/strings.xml
@@ -294,7 +294,6 @@
Pro praghere seletziona una cartella pro sa memòria esterna.Su sistema no est in gradu de frunire su permissu!Permite
- Pro praghere fruni su permissu pro sa retze ìnternet pro iscarrigare cuntenutosPeruna notaPòmpia sas notas de totu sos librosChirca notas
diff --git a/core/src/main/res/values-sk/strings.xml b/core/src/main/res/values-sk/strings.xml
index 9bb51e8f3f..a7a9f2caf4 100644
--- a/core/src/main/res/values-sk/strings.xml
+++ b/core/src/main/res/values-sk/strings.xml
@@ -293,7 +293,6 @@
Prosím vyberte priečinok pre externé úložisko.Systému sa nedarí udeliť povolenie!Povoliť
- Povoľte internetové povolenie na sťahovanie obsahuŽiadne poznámkyZobraziť poznámky zo všetkých kníhHľadať v poznámkach
diff --git a/core/src/main/res/values-sv/strings.xml b/core/src/main/res/values-sv/strings.xml
index 054723ca64..764a9fa337 100644
--- a/core/src/main/res/values-sv/strings.xml
+++ b/core/src/main/res/values-sv/strings.xml
@@ -298,7 +298,6 @@
Välj mapp för extern lagring.Systemet kunde inte ge tillstånd!Tillåt
- Tillåt internetbehörigheter för att ladda ner innehållInga anteckningarVisa anteckningar från alla böckerSök i anteckningar
diff --git a/core/src/main/res/values-ta/strings.xml b/core/src/main/res/values-ta/strings.xml
index 5187298c93..8e25f08948 100644
--- a/core/src/main/res/values-ta/strings.xml
+++ b/core/src/main/res/values-ta/strings.xml
@@ -296,7 +296,6 @@
வெளிப்புற சேமிப்பகத்திற்கான கோப்புறையைத் தேர்ந்தெடுக்கவும்.அமைப்பு அனுமதி வழங்க முடியவில்லை!அனுமதிக்கவும்
- உள்ளடக்கத்தைப் பதிவிறக்க இணைய அனுமதியை அனுமதிக்கவும்குறிப்புகள் இல்லைஎல்லா புத்தகங்களிலிருந்தும் குறிப்புகளைப் பார்க்கவும்குறிப்புகளைத் தேடு
diff --git a/core/src/main/res/values-tr/strings.xml b/core/src/main/res/values-tr/strings.xml
index 7b7728fad1..5589583b5f 100644
--- a/core/src/main/res/values-tr/strings.xml
+++ b/core/src/main/res/values-tr/strings.xml
@@ -307,7 +307,6 @@
Lütfen harici depolama için bir klasör seçin.Sistem izin veremiyor!İzin ver
- Lütfen içeriği indirmek için internet iznine izin verinNot YokTüm Kitaplardan Notları GörüntüleNotları Ara
diff --git a/core/src/main/res/values-zh-rTW/strings.xml b/core/src/main/res/values-zh-rTW/strings.xml
index 7b812976af..ce7b718fa5 100644
--- a/core/src/main/res/values-zh-rTW/strings.xml
+++ b/core/src/main/res/values-zh-rTW/strings.xml
@@ -299,7 +299,6 @@
請選取用於外部儲存的資料夾。系統無法授予權限!允許
- 請允許網路權限來下載內容沒有註釋檢視來自所有書籍的註釋搜尋註釋
diff --git a/core/src/main/res/values-zh/strings.xml b/core/src/main/res/values-zh/strings.xml
index e203fd9a26..6d3afd546d 100644
--- a/core/src/main/res/values-zh/strings.xml
+++ b/core/src/main/res/values-zh/strings.xml
@@ -311,7 +311,6 @@
请选择用于外部存储的文件夹。系统无法授予权限!允许
- 请允许联网权限来下载内容没有注释查看来自所有书籍的注释搜索注释
diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml
index 55068aa0d3..c51646367b 100644
--- a/core/src/main/res/values/strings.xml
+++ b/core/src/main/res/values/strings.xml
@@ -60,7 +60,7 @@
Choose a languageContributors and LicensesCredits
- The language of this page is not supported, or appropriate language data was not installed. The article may not be properly read.
+ The language of this page is not supported. The article may not be properly read.Could not find an installed application for this type of fileNo Content Headers FoundTo access offline content we need access to your storage
@@ -304,7 +304,7 @@
Please select a folder for external storage.System unable to grant permission!Allow
- Please allow internet permission to download content
+ Swipe Down for Library@string/on@string/off
@@ -324,4 +324,6 @@
Note: Notes are not deleted from your storageDelete Selected Notes?External Link Copied to Clipboard
+ Download this language for read aloud feature
+ Please click the Download button. It will automatically download the required language.
diff --git a/core/src/test/java/org/kiwix/kiwixmobile/core/dao/NewBookDaoTest.kt b/core/src/test/java/org/kiwix/kiwixmobile/core/dao/NewBookDaoTest.kt
index dc55beced5..dabbcf2f4a 100644
--- a/core/src/test/java/org/kiwix/kiwixmobile/core/dao/NewBookDaoTest.kt
+++ b/core/src/test/java/org/kiwix/kiwixmobile/core/dao/NewBookDaoTest.kt
@@ -18,6 +18,7 @@
package org.kiwix.kiwixmobile.core.dao
+import android.annotation.SuppressLint
import io.mockk.CapturingSlot
import io.mockk.clearAllMocks
import io.mockk.every
@@ -36,7 +37,6 @@ import org.junit.jupiter.api.Nested
import org.junit.jupiter.api.Test
import org.kiwix.kiwixmobile.core.dao.entities.BookOnDiskEntity
import org.kiwix.kiwixmobile.core.dao.entities.BookOnDiskEntity_
-import org.kiwix.kiwixmobile.core.data.local.entity.Bookmark
import org.kiwix.kiwixmobile.core.entity.LibraryNetworkEntity
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskListItem.BookOnDisk
import org.kiwix.sharedFunctions.book
@@ -63,6 +63,7 @@ internal class NewBookDaoTest {
newBookDao.books().test().assertValues(listOf(BookOnDisk(expectedEntity)))
}
+ @SuppressLint("CheckResult")
@Test
fun `books deletes entities whose file does not exist`() {
val (_, deletedEntity) = expectEmissionOfExistingAndNotExistingBook()
@@ -190,42 +191,6 @@ internal class NewBookDaoTest {
verify { box.put(listOf(BookOnDiskEntity(BookOnDisk(book = book, file = book.file!!)))) }
}
- @Test
- fun `getFavIconAndZimFile with no result returns pair with null values`() {
- val bookmark: Bookmark = mockk()
- expectGetFavIconAndZimFileWith(bookmark, listOf())
- assertThat(newBookDao.getFavIconAndZimFile(bookmark)).isEqualTo(Pair(null, null))
- }
-
- @Test
- fun `getFavIconAndZimFile with result returns valid pair`() {
- val bookmark: Bookmark = mockk()
- val bookOnDiskEntity: BookOnDiskEntity = bookOnDiskEntity()
- expectGetFavIconAndZimFileWith(bookmark, listOf(bookOnDiskEntity))
- assertThat(newBookDao.getFavIconAndZimFile(bookmark))
- .isEqualTo(Pair(bookOnDiskEntity.favIcon, bookOnDiskEntity.file.path))
- }
-
- private fun expectGetFavIconAndZimFileWith(
- bookmark: Bookmark,
- queryResult: List
- ) {
- val expectedZimId = "zimId"
- every { bookmark.zimId } returns expectedZimId
- val queryBuilder: QueryBuilder = mockk()
- every { box.query() } returns queryBuilder
- every {
- queryBuilder.equal(
- BookOnDiskEntity_.bookId,
- expectedZimId,
- QueryBuilder.StringOrder.CASE_INSENSITIVE
- )
- } returns queryBuilder
- val query: Query = mockk()
- every { queryBuilder.build() } returns query
- every { query.find() } returns queryResult
- }
-
@Test
fun `bookMatching queries file by title`() {
val downloadTitle = "title"
diff --git a/core/src/test/java/org/kiwix/kiwixmobile/core/dao/NewRecentSearchDaoTest.kt b/core/src/test/java/org/kiwix/kiwixmobile/core/dao/NewRecentSearchDaoTest.kt
index c424f6dcc9..70e78806e0 100644
--- a/core/src/test/java/org/kiwix/kiwixmobile/core/dao/NewRecentSearchDaoTest.kt
+++ b/core/src/test/java/org/kiwix/kiwixmobile/core/dao/NewRecentSearchDaoTest.kt
@@ -30,7 +30,6 @@ import org.junit.jupiter.api.Nested
import org.junit.jupiter.api.Test
import org.kiwix.kiwixmobile.core.dao.entities.RecentSearchEntity
import org.kiwix.kiwixmobile.core.dao.entities.RecentSearchEntity_
-import org.kiwix.kiwixmobile.core.data.local.entity.RecentSearch
import org.kiwix.kiwixmobile.core.search.adapter.SearchListItem.RecentSearchListItem
import org.kiwix.kiwixmobile.core.search.viewmodel.test
import org.kiwix.sharedFunctions.recentSearchEntity
@@ -137,15 +136,4 @@ internal class NewRecentSearchDaoTest {
newRecentSearchDao.deleteSearchHistory()
verify { box.removeAll() }
}
-
- @Test
- fun `migrationInsert adds old items to box`() {
- val id = "zimId"
- val term = "searchString"
- val recentSearch: RecentSearch = mockk()
- every { recentSearch.searchString } returns term
- every { recentSearch.zimID } returns id
- newRecentSearchDao.migrationInsert(mutableListOf(recentSearch))
- verify { box.put(listOf(recentSearchEntity(searchTerm = term, zimId = id))) }
- }
}
diff --git a/custom/src/main/assets/credits.html b/custom/src/main/assets/credits.html
index bdc4c7bf53..f5c3c70de7 100644
--- a/custom/src/main/assets/credits.html
+++ b/custom/src/main/assets/credits.html
@@ -103,11 +103,6 @@