Removed all ObjectBox code from every variant except the Play Store version.

This commit is contained in:
MohitMaliFtechiz 2025-08-22 19:02:52 +05:30 committed by Kelson
parent 86fa171b50
commit 1d9633c6a4
44 changed files with 505 additions and 237 deletions

View File

@ -1,4 +1,3 @@
import com.android.build.gradle.internal.tasks.factory.dependsOn
import com.slack.keeper.optInToKeeper import com.slack.keeper.optInToKeeper
import org.w3c.dom.Element import org.w3c.dom.Element
import plugin.KiwixConfigurationPlugin import plugin.KiwixConfigurationPlugin

View File

@ -40,8 +40,6 @@ import org.junit.jupiter.api.Assertions.assertNotNull
import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Assertions.assertTrue
import org.kiwix.kiwixmobile.core.CoreApp import org.kiwix.kiwixmobile.core.CoreApp
import org.kiwix.kiwixmobile.core.dao.entities.BookOnDiskEntity import org.kiwix.kiwixmobile.core.dao.entities.BookOnDiskEntity
import org.kiwix.kiwixmobile.core.dao.entities.BookmarkEntity
import org.kiwix.kiwixmobile.core.data.remote.ObjectBoxToLibkiwixMigrator
import org.kiwix.kiwixmobile.core.di.modules.DatabaseModule import org.kiwix.kiwixmobile.core.di.modules.DatabaseModule
import org.kiwix.kiwixmobile.core.entity.LibkiwixBook import org.kiwix.kiwixmobile.core.entity.LibkiwixBook
import org.kiwix.kiwixmobile.core.page.bookmark.adapter.LibkiwixBookmarkItem import org.kiwix.kiwixmobile.core.page.bookmark.adapter.LibkiwixBookmarkItem

View File

@ -47,7 +47,6 @@ import org.kiwix.kiwixmobile.core.dao.entities.HistoryEntity
import org.kiwix.kiwixmobile.core.dao.entities.NotesEntity import org.kiwix.kiwixmobile.core.dao.entities.NotesEntity
import org.kiwix.kiwixmobile.core.dao.entities.RecentSearchEntity import org.kiwix.kiwixmobile.core.dao.entities.RecentSearchEntity
import org.kiwix.kiwixmobile.core.data.KiwixRoomDatabase import org.kiwix.kiwixmobile.core.data.KiwixRoomDatabase
import org.kiwix.kiwixmobile.core.data.remote.ObjectBoxToRoomMigrator
import org.kiwix.kiwixmobile.core.di.modules.DatabaseModule import org.kiwix.kiwixmobile.core.di.modules.DatabaseModule
import org.kiwix.kiwixmobile.core.page.notes.adapter.NoteListItem import org.kiwix.kiwixmobile.core.page.notes.adapter.NoteListItem
import org.kiwix.kiwixmobile.core.utils.LanguageUtils import org.kiwix.kiwixmobile.core.utils.LanguageUtils

View File

@ -26,6 +26,7 @@ import org.kiwix.kiwixmobile.core.data.DataModule
import org.kiwix.kiwixmobile.core.di.modules.ApplicationModule import org.kiwix.kiwixmobile.core.di.modules.ApplicationModule
import org.kiwix.kiwixmobile.core.di.modules.CoreViewModelModule import org.kiwix.kiwixmobile.core.di.modules.CoreViewModelModule
import org.kiwix.kiwixmobile.core.di.modules.JNIModule import org.kiwix.kiwixmobile.core.di.modules.JNIModule
import org.kiwix.kiwixmobile.core.di.modules.MigrationModule
import org.kiwix.kiwixmobile.core.di.modules.MutexModule import org.kiwix.kiwixmobile.core.di.modules.MutexModule
import org.kiwix.kiwixmobile.core.di.modules.SearchModule import org.kiwix.kiwixmobile.core.di.modules.SearchModule
import org.kiwix.kiwixmobile.core.di.modules.TestNetworkModule import org.kiwix.kiwixmobile.core.di.modules.TestNetworkModule
@ -44,7 +45,8 @@ import javax.inject.Singleton
DataModule::class, DataModule::class,
CoreViewModelModule::class, CoreViewModelModule::class,
SearchModule::class, SearchModule::class,
MutexModule::class MutexModule::class,
MigrationModule::class
] ]
) )
interface TestComponent : CoreComponent { interface TestComponent : CoreComponent {

View File

@ -6,16 +6,11 @@ buildscript {
mavenCentral() mavenCentral()
maven { setUrl("https://jitpack.io") } maven { setUrl("https://jitpack.io") }
} }
dependencies {
classpath(Libs.objectbox_gradle_plugin)
}
} }
plugins { plugins {
`android-library` `android-library`
} }
plugins.apply(KiwixConfigurationPlugin::class) plugins.apply(KiwixConfigurationPlugin::class)
apply(plugin = "io.objectbox")
android { android {
defaultConfig { defaultConfig {
@ -62,7 +57,6 @@ dependencies {
debugImplementation(Libs.leakcanary_android) debugImplementation(Libs.leakcanary_android)
implementation(Libs.android_arch_lifecycle_extensions) implementation(Libs.android_arch_lifecycle_extensions)
implementation(Libs.objectbox_kotlin)
implementation(Libs.webkit) implementation(Libs.webkit)
testImplementation(Libs.kotlinx_coroutines_test) testImplementation(Libs.kotlinx_coroutines_test)
implementation(Libs.kotlinx_coroutines_android) implementation(Libs.kotlinx_coroutines_android)

View File

@ -1,54 +0,0 @@
/*
* Kiwix Android
* Copyright (c) 2019 Kiwix <android.kiwix.org>
* 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 <http://www.gnu.org/licenses/>.
*
*/
package org.kiwix.kiwixmobile.core.dao.entities
import io.objectbox.annotation.Convert
import io.objectbox.annotation.Entity
import io.objectbox.annotation.Id
import io.objectbox.converter.PropertyConverter
import org.kiwix.kiwixmobile.core.compat.CompatHelper.Companion.convertToLocal
import org.kiwix.kiwixmobile.core.zim_manager.Language
import java.util.Locale
@Entity
data class LanguageEntity(
@Id var id: Long = 0,
@Convert(converter = StringToLocaleConverter::class, dbType = String::class)
val locale: Locale = Locale.ENGLISH,
val active: Boolean = false,
val occurencesOfLanguage: Int = 0
) {
constructor(language: Language) : this(
0,
language.languageCode.convertToLocal(),
language.active,
language.occurencesOfLanguage
)
fun toLanguageModel() =
Language(locale, active, occurencesOfLanguage, id)
}
class StringToLocaleConverter : PropertyConverter<Locale, String> {
override fun convertToDatabaseValue(entityProperty: Locale?): String =
entityProperty?.isO3Language ?: Locale.ENGLISH.isO3Language
override fun convertToEntityProperty(databaseValue: String?): Locale =
databaseValue?.convertToLocal() ?: Locale.ENGLISH
}

View File

@ -0,0 +1,23 @@
/*
* Kiwix Android
* Copyright (c) 2025 Kiwix <android.kiwix.org>
* 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 <http://www.gnu.org/licenses/>.
*
*/
package org.kiwix.kiwixmobile.core.data
interface ObjectBoxDataMigrationHandler {
suspend fun migrate()
}

View File

@ -37,11 +37,10 @@ import org.kiwix.kiwixmobile.core.dao.WebViewHistoryRoomDao
import org.kiwix.kiwixmobile.core.data.DataModule import org.kiwix.kiwixmobile.core.data.DataModule
import org.kiwix.kiwixmobile.core.data.DataSource import org.kiwix.kiwixmobile.core.data.DataSource
import org.kiwix.kiwixmobile.core.data.remote.KiwixService import org.kiwix.kiwixmobile.core.data.remote.KiwixService
import org.kiwix.kiwixmobile.core.data.remote.ObjectBoxToLibkiwixMigrator
import org.kiwix.kiwixmobile.core.data.remote.ObjectBoxToRoomMigrator
import org.kiwix.kiwixmobile.core.di.modules.ApplicationModule import org.kiwix.kiwixmobile.core.di.modules.ApplicationModule
import org.kiwix.kiwixmobile.core.di.modules.CoreViewModelModule import org.kiwix.kiwixmobile.core.di.modules.CoreViewModelModule
import org.kiwix.kiwixmobile.core.di.modules.JNIModule import org.kiwix.kiwixmobile.core.di.modules.JNIModule
import org.kiwix.kiwixmobile.core.di.modules.MigrationModule
import org.kiwix.kiwixmobile.core.di.modules.MutexModule import org.kiwix.kiwixmobile.core.di.modules.MutexModule
import org.kiwix.kiwixmobile.core.di.modules.NetworkModule import org.kiwix.kiwixmobile.core.di.modules.NetworkModule
import org.kiwix.kiwixmobile.core.di.modules.SearchModule import org.kiwix.kiwixmobile.core.di.modules.SearchModule
@ -65,7 +64,8 @@ import javax.inject.Singleton
DataModule::class, DataModule::class,
CoreViewModelModule::class, CoreViewModelModule::class,
SearchModule::class, SearchModule::class,
MutexModule::class MutexModule::class,
MigrationModule::class
] ]
) )
interface CoreComponent { interface CoreComponent {
@ -88,14 +88,12 @@ interface CoreComponent {
fun dataSource(): DataSource fun dataSource(): DataSource
fun downloadRoomDao(): DownloadRoomDao fun downloadRoomDao(): DownloadRoomDao
fun connectivityManager(): ConnectivityManager fun connectivityManager(): ConnectivityManager
fun objectBoxToLibkiwixMigrator(): ObjectBoxToLibkiwixMigrator
fun libkiwixBookmarks(): LibkiwixBookmarks fun libkiwixBookmarks(): LibkiwixBookmarks
fun libkiwixBooks(): LibkiwixBookOnDisk fun libkiwixBooks(): LibkiwixBookOnDisk
fun recentSearchRoomDao(): RecentSearchRoomDao fun recentSearchRoomDao(): RecentSearchRoomDao
fun historyRoomDao(): HistoryRoomDao fun historyRoomDao(): HistoryRoomDao
fun webViewHistoryRoomDao(): WebViewHistoryRoomDao fun webViewHistoryRoomDao(): WebViewHistoryRoomDao
fun noteRoomDao(): NotesRoomDao fun noteRoomDao(): NotesRoomDao
fun objectBoxToRoomMigrator(): ObjectBoxToRoomMigrator
fun context(): Context fun context(): Context
fun downloader(): Downloader fun downloader(): Downloader
fun notificationManager(): NotificationManager fun notificationManager(): NotificationManager
@ -107,7 +105,5 @@ interface CoreComponent {
fun inject(kiwixWebView: KiwixWebView) fun inject(kiwixWebView: KiwixWebView)
fun inject(errorActivity: ErrorActivity) fun inject(errorActivity: ErrorActivity)
fun inject(objectBoxToLibkiwixMigrator: ObjectBoxToLibkiwixMigrator)
fun inject(objectBoxToRoomMigrator: ObjectBoxToRoomMigrator)
fun coreServiceComponent(): CoreServiceComponent.Builder fun coreServiceComponent(): CoreServiceComponent.Builder
} }

View File

@ -25,8 +25,6 @@ import android.os.storage.StorageManager
import dagger.Module import dagger.Module
import dagger.Provides import dagger.Provides
import org.kiwix.kiwixmobile.core.DarkModeConfig import org.kiwix.kiwixmobile.core.DarkModeConfig
import org.kiwix.kiwixmobile.core.data.remote.ObjectBoxToLibkiwixMigrator
import org.kiwix.kiwixmobile.core.data.remote.ObjectBoxToRoomMigrator
import org.kiwix.kiwixmobile.core.downloader.DownloadMonitor import org.kiwix.kiwixmobile.core.downloader.DownloadMonitor
import org.kiwix.kiwixmobile.core.downloader.downloadManager.DownloadManagerMonitor import org.kiwix.kiwixmobile.core.downloader.downloadManager.DownloadManagerMonitor
import org.kiwix.kiwixmobile.core.reader.ZimFileReader import org.kiwix.kiwixmobile.core.reader.ZimFileReader
@ -54,14 +52,6 @@ class ApplicationModule {
@Singleton @Singleton
internal fun provideBookUtils(): BookUtils = BookUtils() internal fun provideBookUtils(): BookUtils = BookUtils()
@Provides
@Singleton
fun provideObjectBoxToLibkiwixMigrator() = ObjectBoxToLibkiwixMigrator()
@Provides
@Singleton
fun provideObjectBoxToRoomMigrator() = ObjectBoxToRoomMigrator()
@Provides @Provides
@Singleton @Singleton
internal fun provideDownloadMonitor( internal fun provideDownloadMonitor(

View File

@ -20,27 +20,12 @@ package org.kiwix.kiwixmobile.core.di.modules
import android.content.Context import android.content.Context
import dagger.Module import dagger.Module
import dagger.Provides import dagger.Provides
import io.objectbox.BoxStore
import org.kiwix.kiwixmobile.core.dao.LibkiwixBookOnDisk import org.kiwix.kiwixmobile.core.dao.LibkiwixBookOnDisk
import org.kiwix.kiwixmobile.core.dao.entities.MyObjectBox
import org.kiwix.kiwixmobile.core.data.KiwixRoomDatabase import org.kiwix.kiwixmobile.core.data.KiwixRoomDatabase
import javax.inject.Singleton import javax.inject.Singleton
@Module @Module
open class DatabaseModule { open class DatabaseModule {
companion object {
var boxStore: BoxStore? = null
}
@Suppress("UnsafeCallOnNullableType")
// NOT RECOMMENDED TODO use custom runner to load TestApplication
@Provides @Singleton fun providesBoxStore(context: Context): BoxStore {
if (boxStore == null) {
boxStore = MyObjectBox.builder().androidContext(context).build()
}
return boxStore!!
}
@Singleton @Singleton
@Provides @Provides
fun provideYourDatabase( fun provideYourDatabase(

View File

@ -0,0 +1,24 @@
/*
* Kiwix Android
* Copyright (c) 2025 Kiwix <android.kiwix.org>
* 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 <http://www.gnu.org/licenses/>.
*
*/
package org.kiwix.kiwixmobile.core.di.modules
import dagger.Module
@Module
abstract class MigrationModule

View File

@ -47,8 +47,7 @@ import org.kiwix.kiwixmobile.core.CoreApp
import org.kiwix.kiwixmobile.core.R import org.kiwix.kiwixmobile.core.R
import org.kiwix.kiwixmobile.core.base.BaseActivity import org.kiwix.kiwixmobile.core.base.BaseActivity
import org.kiwix.kiwixmobile.core.base.FragmentActivityExtensions import org.kiwix.kiwixmobile.core.base.FragmentActivityExtensions
import org.kiwix.kiwixmobile.core.data.remote.ObjectBoxToLibkiwixMigrator import org.kiwix.kiwixmobile.core.data.ObjectBoxDataMigrationHandler
import org.kiwix.kiwixmobile.core.data.remote.ObjectBoxToRoomMigrator
import org.kiwix.kiwixmobile.core.di.components.CoreActivityComponent import org.kiwix.kiwixmobile.core.di.components.CoreActivityComponent
import org.kiwix.kiwixmobile.core.downloader.DownloadMonitor import org.kiwix.kiwixmobile.core.downloader.DownloadMonitor
import org.kiwix.kiwixmobile.core.downloader.downloadManager.APP_NAME_KEY import org.kiwix.kiwixmobile.core.downloader.downloadManager.APP_NAME_KEY
@ -165,9 +164,8 @@ abstract class CoreMainActivity : BaseActivity(), WebViewProvider {
abstract val mainActivity: AppCompatActivity abstract val mainActivity: AppCompatActivity
abstract val appName: String abstract val appName: String
@Inject lateinit var objectBoxToLibkiwixMigrator: ObjectBoxToLibkiwixMigrator @Inject
lateinit var objectBoxDataMigrationHandler: ObjectBoxDataMigrationHandler
@Inject lateinit var objectBoxToRoomMigrator: ObjectBoxToRoomMigrator
@Inject @Inject
lateinit var downloadMonitor: DownloadMonitor lateinit var downloadMonitor: DownloadMonitor
@ -194,11 +192,7 @@ abstract class CoreMainActivity : BaseActivity(), WebViewProvider {
setMainActivityToCoreApp() setMainActivityToCoreApp()
// run the migration on background thread to avoid any UI related issues. // run the migration on background thread to avoid any UI related issues.
CoroutineScope(Dispatchers.IO).launch { CoroutineScope(Dispatchers.IO).launch {
objectBoxToLibkiwixMigrator.migrateObjectBoxDataToLibkiwix() objectBoxDataMigrationHandler.migrate()
}
// run the migration on background thread to avoid any UI related issues.
CoroutineScope(Dispatchers.IO).launch {
objectBoxToRoomMigrator.migrateObjectBoxDataToRoom()
} }
lifecycleScope.launch(Dispatchers.IO) { lifecycleScope.launch(Dispatchers.IO) {
createApplicationShortcuts() createApplicationShortcuts()

View File

@ -18,7 +18,6 @@
package org.kiwix.kiwixmobile.core.page.bookmark.adapter package org.kiwix.kiwixmobile.core.page.bookmark.adapter
import org.kiwix.kiwixmobile.core.dao.entities.BookmarkEntity
import org.kiwix.kiwixmobile.core.page.adapter.Page import org.kiwix.kiwixmobile.core.page.adapter.Page
import org.kiwix.kiwixmobile.core.reader.ZimFileReader import org.kiwix.kiwixmobile.core.reader.ZimFileReader
import org.kiwix.kiwixmobile.core.reader.ZimReaderSource import org.kiwix.kiwixmobile.core.reader.ZimReaderSource
@ -35,16 +34,6 @@ data class BookmarkItem(
override val url: String = bookmarkUrl, override val url: String = bookmarkUrl,
override val id: Long = databaseId override val id: Long = databaseId
) : Page { ) : Page {
constructor(entity: BookmarkEntity) : this(
entity.id,
entity.zimId,
entity.zimName,
entity.zimReaderSource,
entity.bookmarkUrl,
entity.bookmarkTitle,
entity.favicon
)
constructor( constructor(
title: String, title: String,
url: String, url: String,

View File

@ -18,7 +18,6 @@
package org.kiwix.kiwixmobile.core.page.bookmark.adapter package org.kiwix.kiwixmobile.core.page.bookmark.adapter
import org.kiwix.kiwixmobile.core.dao.entities.BookmarkEntity
import org.kiwix.kiwixmobile.core.page.adapter.Page import org.kiwix.kiwixmobile.core.page.adapter.Page
import org.kiwix.kiwixmobile.core.reader.ZimFileReader import org.kiwix.kiwixmobile.core.reader.ZimFileReader
import org.kiwix.kiwixmobile.core.reader.ZimReaderSource import org.kiwix.kiwixmobile.core.reader.ZimReaderSource
@ -71,20 +70,6 @@ data class LibkiwixBookmarkItem(
libKiwixBook = libKiwixBook libKiwixBook = libKiwixBook
) )
constructor(
bookmarkEntity: BookmarkEntity,
libkiwixBook: Book?
) : this(
zimId = bookmarkEntity.zimId,
zimFilePath = bookmarkEntity.zimReaderSource?.toDatabase(),
zimReaderSource = bookmarkEntity.zimReaderSource,
zimName = bookmarkEntity.zimName,
bookmarkUrl = bookmarkEntity.bookmarkUrl,
title = bookmarkEntity.bookmarkTitle,
favicon = bookmarkEntity.favicon,
libKiwixBook = libkiwixBook
)
constructor( constructor(
zimId: String, zimId: String,
bookmarkUrl: String bookmarkUrl: String

View File

@ -17,7 +17,6 @@
*/ */
package org.kiwix.kiwixmobile.core.page.history.adapter package org.kiwix.kiwixmobile.core.page.history.adapter
import org.kiwix.kiwixmobile.core.dao.entities.HistoryEntity
import org.kiwix.kiwixmobile.core.dao.entities.HistoryRoomEntity import org.kiwix.kiwixmobile.core.dao.entities.HistoryRoomEntity
import org.kiwix.kiwixmobile.core.page.adapter.Page import org.kiwix.kiwixmobile.core.page.adapter.Page
import org.kiwix.kiwixmobile.core.page.adapter.PageRelated import org.kiwix.kiwixmobile.core.page.adapter.PageRelated
@ -56,19 +55,6 @@ sealed class HistoryListItem : PageRelated {
timeStamp = timeStamp timeStamp = timeStamp
) )
constructor(historyEntity: HistoryEntity) : this(
historyEntity.id,
historyEntity.zimId,
historyEntity.zimName,
historyEntity.zimReaderSource,
historyEntity.favicon,
historyEntity.historyUrl,
historyEntity.historyTitle,
historyEntity.dateString,
historyEntity.timeStamp,
false
)
constructor(historyRoomEntity: HistoryRoomEntity) : this( constructor(historyRoomEntity: HistoryRoomEntity) : this(
historyRoomEntity.id, historyRoomEntity.id,
historyRoomEntity.zimId, historyRoomEntity.zimId,

View File

@ -1,6 +1,5 @@
package org.kiwix.kiwixmobile.core.page.notes.adapter package org.kiwix.kiwixmobile.core.page.notes.adapter
import org.kiwix.kiwixmobile.core.dao.entities.NotesEntity
import org.kiwix.kiwixmobile.core.dao.entities.NotesRoomEntity import org.kiwix.kiwixmobile.core.dao.entities.NotesRoomEntity
import org.kiwix.kiwixmobile.core.page.adapter.Page import org.kiwix.kiwixmobile.core.page.adapter.Page
import org.kiwix.kiwixmobile.core.reader.ZimReaderSource import org.kiwix.kiwixmobile.core.reader.ZimReaderSource
@ -18,16 +17,6 @@ data class NoteListItem(
override val url: String = zimUrl, override val url: String = zimUrl,
override val id: Long = databaseId override val id: Long = databaseId
) : Page, Serializable { ) : Page, Serializable {
constructor(notesEntity: NotesEntity) : this(
notesEntity.id,
notesEntity.zimId,
notesEntity.noteTitle,
notesEntity.zimReaderSource,
notesEntity.zimUrl,
notesEntity.noteFilePath,
notesEntity.favicon
)
constructor( constructor(
zimId: String, zimId: String,
title: String, title: String,

View File

@ -19,7 +19,6 @@
package org.kiwix.kiwixmobile.core.zim_manager.fileselect_view package org.kiwix.kiwixmobile.core.zim_manager.fileselect_view
import org.kiwix.kiwixmobile.core.compat.CompatHelper.Companion.convertToLocal import org.kiwix.kiwixmobile.core.compat.CompatHelper.Companion.convertToLocal
import org.kiwix.kiwixmobile.core.dao.entities.BookOnDiskEntity
import org.kiwix.kiwixmobile.core.dao.entities.DownloadRoomEntity import org.kiwix.kiwixmobile.core.dao.entities.DownloadRoomEntity
import org.kiwix.kiwixmobile.core.entity.LibkiwixBook import org.kiwix.kiwixmobile.core.entity.LibkiwixBook
import org.kiwix.kiwixmobile.core.reader.ZimFileReader import org.kiwix.kiwixmobile.core.reader.ZimFileReader
@ -54,17 +53,6 @@ sealed class BooksOnDiskListItem {
book.language.convertToLocal() book.language.convertToLocal()
} }
@Deprecated(
"Now we are using the libkiwix to store and retrieve the local " +
"books so this constructor is no longer used."
)
constructor(bookOnDiskEntity: BookOnDiskEntity) : this(
databaseId = bookOnDiskEntity.id,
file = bookOnDiskEntity.file,
book = bookOnDiskEntity.toBook(),
zimReaderSource = bookOnDiskEntity.zimReaderSource
)
constructor(downloadRoomEntity: DownloadRoomEntity) : this( constructor(downloadRoomEntity: DownloadRoomEntity) : this(
book = downloadRoomEntity.toBook(), book = downloadRoomEntity.toBook(),
zimReaderSource = ZimReaderSource(File(downloadRoomEntity.file)) zimReaderSource = ZimReaderSource(File(downloadRoomEntity.file))

1
defaultMigration/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/build

View File

@ -0,0 +1,28 @@
import plugin.KiwixConfigurationPlugin
plugins {
id("com.android.library")
id("org.jetbrains.kotlin.android")
}
plugins.apply(KiwixConfigurationPlugin::class)
android {
namespace = "org.kiwix.kiwixmobile.defaultmigration"
defaultConfig {
minSdk = 25
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
}
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}
}
dependencies {
implementation(project(":core"))
}

View File

21
defaultMigration/proguard-rules.pro vendored Normal file
View File

@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>

View File

@ -1,6 +1,6 @@
/* /*
* Kiwix Android * Kiwix Android
* Copyright (c) 2019 Kiwix <android.kiwix.org> * Copyright (c) 2025 Kiwix <android.kiwix.org>
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
@ -16,16 +16,11 @@
* *
*/ */
package org.kiwix.kiwixmobile.core.base.adapter package org.kiwix.kiwixmobile.defaultmigration
import android.view.View import dagger.Component
import androidx.recyclerview.widget.RecyclerView.ViewHolder
import kotlinx.android.extensions.LayoutContainer
abstract class BaseViewHolder<in ITEM>(override val containerView: View) : @Component(modules = [DefaultMigrationModule::class])
ViewHolder( interface DefaultMigrationComponent {
containerView // Do nothing
),
LayoutContainer {
abstract fun bind(item: ITEM)
} }

View File

@ -0,0 +1,28 @@
/*
* Kiwix Android
* Copyright (c) 2025 Kiwix <android.kiwix.org>
* 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 <http://www.gnu.org/licenses/>.
*
*/
package org.kiwix.kiwixmobile.defaultmigration
import org.kiwix.kiwixmobile.core.data.ObjectBoxDataMigrationHandler
import javax.inject.Inject
class DefaultMigrationHandler @Inject constructor() : ObjectBoxDataMigrationHandler {
override suspend fun migrate() {
// Do nothing
}
}

View File

@ -0,0 +1,30 @@
/*
* Kiwix Android
* Copyright (c) 2025 Kiwix <android.kiwix.org>
* 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 <http://www.gnu.org/licenses/>.
*
*/
package org.kiwix.kiwixmobile.defaultmigration
import dagger.Module
import dagger.Provides
import org.kiwix.kiwixmobile.core.data.ObjectBoxDataMigrationHandler
@Module
class DefaultMigrationModule {
@Provides
fun provideMigrationHandler(): ObjectBoxDataMigrationHandler =
DefaultMigrationHandler()
}

1
objectboxmigration/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/build

View File

@ -0,0 +1,45 @@
import org.gradle.kotlin.dsl.apply
import plugin.KiwixConfigurationPlugin
plugins {
id("com.android.library")
id("org.jetbrains.kotlin.android")
}
buildscript {
repositories {
google()
mavenCentral()
maven { setUrl("https://jitpack.io") }
}
dependencies {
classpath(Libs.objectbox_gradle_plugin)
}
}
plugins.apply(KiwixConfigurationPlugin::class)
apply(plugin = "io.objectbox")
android {
namespace = "org.kiwix.kiwixmobile.objectboxmigration"
defaultConfig {
minSdk = 25
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
}
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}
}
dependencies {
implementation(Libs.objectbox_kotlin)
implementation(project(":core"))
}

View File

@ -98,35 +98,6 @@
], ],
"relations": [] "relations": []
}, },
{
"id": "4:6278838675135543734",
"lastPropertyId": "4:8812214350305159407",
"name": "LanguageEntity",
"properties": [
{
"id": "1:7795244654012809404",
"name": "id",
"type": 6,
"flags": 1
},
{
"id": "2:9116495537035444904",
"name": "locale",
"type": 9
},
{
"id": "3:452531964346972307",
"name": "active",
"type": 1
},
{
"id": "4:8812214350305159407",
"name": "occurencesOfLanguage",
"type": 5
}
],
"relations": []
},
{ {
"id": "5:3222423958972105425", "id": "5:3222423958972105425",
"lastPropertyId": "11:6493253695033019145", "lastPropertyId": "11:6493253695033019145",
@ -324,7 +295,8 @@
349148274283701276, 349148274283701276,
7257718270326155947, 7257718270326155947,
7394649290555378565, 7394649290555378565,
8093454424037540087 8093454424037540087,
6278838675135543734
], ],
"retiredIndexUids": [ "retiredIndexUids": [
1293695782925933448, 1293695782925933448,
@ -399,7 +371,11 @@
5555873126720275555, 5555873126720275555,
2724607601244650879, 2724607601244650879,
5485468735259326535, 5485468735259326535,
4272820830206771469 4272820830206771469,
7795244654012809404,
9116495537035444904,
452531964346972307,
8812214350305159407
], ],
"retiredRelationUids": [], "retiredRelationUids": [],
"version": 1 "version": 1

21
objectboxmigration/proguard-rules.pro vendored Normal file
View File

@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>

View File

@ -0,0 +1,34 @@
/*
* Kiwix Android
* Copyright (c) 2025 Kiwix <android.kiwix.org>
* 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 <http://www.gnu.org/licenses/>.
*
*/
package org.kiwix.kiwixmobile.objectboxmigration
import org.kiwix.kiwixmobile.core.data.ObjectBoxDataMigrationHandler
import org.kiwix.kiwixmobile.objectboxmigration.data.ObjectBoxToLibkiwixMigrator
import org.kiwix.kiwixmobile.objectboxmigration.data.ObjectBoxToRoomMigrator
import javax.inject.Inject
class ObjectBoxMigrationHandler @Inject constructor(
private val objectBoxToRoomMigrator: ObjectBoxToRoomMigrator,
private val objectBoxToLibkiwixMigrator: ObjectBoxToLibkiwixMigrator
) : ObjectBoxDataMigrationHandler {
override suspend fun migrate() {
objectBoxToRoomMigrator.migrateObjectBoxDataToRoom()
objectBoxToLibkiwixMigrator.migrateObjectBoxDataToLibkiwix()
}
}

View File

@ -16,23 +16,22 @@
* *
*/ */
package org.kiwix.kiwixmobile.core.data.remote package org.kiwix.kiwixmobile.objectboxmigration.data
import io.objectbox.Box import io.objectbox.Box
import io.objectbox.BoxStore import io.objectbox.BoxStore
import io.objectbox.kotlin.boxFor import io.objectbox.kotlin.boxFor
import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock import kotlinx.coroutines.sync.withLock
import org.kiwix.kiwixmobile.core.CoreApp
import org.kiwix.kiwixmobile.core.dao.LibkiwixBookOnDisk import org.kiwix.kiwixmobile.core.dao.LibkiwixBookOnDisk
import org.kiwix.kiwixmobile.core.dao.LibkiwixBookmarks import org.kiwix.kiwixmobile.core.dao.LibkiwixBookmarks
import org.kiwix.kiwixmobile.core.dao.entities.BookOnDiskEntity
import org.kiwix.kiwixmobile.core.dao.entities.BookmarkEntity
import org.kiwix.kiwixmobile.core.page.bookmark.adapter.LibkiwixBookmarkItem import org.kiwix.kiwixmobile.core.page.bookmark.adapter.LibkiwixBookmarkItem
import org.kiwix.kiwixmobile.core.reader.ZimReaderSource import org.kiwix.kiwixmobile.core.reader.ZimReaderSource
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil
import org.kiwix.kiwixmobile.core.utils.files.Log import org.kiwix.kiwixmobile.core.utils.files.Log
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.BooksOnDiskListItem.BookOnDisk import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.BooksOnDiskListItem.BookOnDisk
import org.kiwix.kiwixmobile.objectboxmigration.entities.BookOnDiskEntity
import org.kiwix.kiwixmobile.objectboxmigration.entities.BookmarkEntity
import org.kiwix.libkiwix.Book import org.kiwix.libkiwix.Book
import org.kiwix.libzim.Archive import org.kiwix.libzim.Archive
import java.io.File import java.io.File
@ -53,7 +52,7 @@ class ObjectBoxToLibkiwixMigrator {
private val migrationMutex = Mutex() private val migrationMutex = Mutex()
suspend fun migrateObjectBoxDataToLibkiwix() { suspend fun migrateObjectBoxDataToLibkiwix() {
CoreApp.coreComponent.inject(this) // CoreApp.coreComponent.inject(this)
if (!sharedPreferenceUtil.prefIsBookmarksMigrated) { if (!sharedPreferenceUtil.prefIsBookmarksMigrated) {
migrateBookMarks(boxStore.boxFor()) migrateBookMarks(boxStore.boxFor())
} }
@ -73,7 +72,12 @@ class ObjectBoxToLibkiwixMigrator {
bookOnDiskEntity.zimReaderSource = zimReaderSource bookOnDiskEntity.zimReaderSource = zimReaderSource
} }
} }
BookOnDisk(bookOnDiskEntity) BookOnDisk(
databaseId = bookOnDiskEntity.id,
file = bookOnDiskEntity.file,
book = bookOnDiskEntity.toBook(),
zimReaderSource = bookOnDiskEntity.zimReaderSource
)
} }
migrationMutex.withLock { migrationMutex.withLock {
runCatching { runCatching {
@ -118,13 +122,22 @@ class ObjectBoxToLibkiwixMigrator {
// to display them on the bookmark screen. // to display them on the bookmark screen.
null null
} }
} ?: kotlin.run { } ?: run {
// for migrating bookmarks for recent custom apps since in recent version of // for migrating bookmarks for recent custom apps since in recent version of
// custom app we are using the `assetFileDescriptor` which does not have the filePath. // custom app we are using the `assetFileDescriptor` which does not have the filePath.
null null
} }
libkiwixBookmarks.saveBookmark( libkiwixBookmarks.saveBookmark(
LibkiwixBookmarkItem(bookmarkEntity, libkiwixBook), LibkiwixBookmarkItem(
zimId = bookmarkEntity.zimId,
zimFilePath = bookmarkEntity.zimReaderSource?.toDatabase(),
zimReaderSource = bookmarkEntity.zimReaderSource,
zimName = bookmarkEntity.zimName,
bookmarkUrl = bookmarkEntity.bookmarkUrl,
title = bookmarkEntity.bookmarkTitle,
favicon = bookmarkEntity.favicon,
libKiwixBook = libkiwixBook
),
shouldWriteBookmarkToFile = index == bookMarksList.size - 1 shouldWriteBookmarkToFile = index == bookMarksList.size - 1
) )
archive?.dispose() archive?.dispose()

View File

@ -16,15 +16,14 @@
* *
*/ */
package org.kiwix.kiwixmobile.core.data.remote package org.kiwix.kiwixmobile.objectboxmigration.data
import io.objectbox.Box import io.objectbox.Box
import io.objectbox.BoxStore import io.objectbox.BoxStore
import io.objectbox.kotlin.boxFor import io.objectbox.kotlin.boxFor
import org.kiwix.kiwixmobile.core.CoreApp import org.kiwix.kiwixmobile.objectboxmigration.entities.HistoryEntity
import org.kiwix.kiwixmobile.core.dao.entities.HistoryEntity import org.kiwix.kiwixmobile.objectboxmigration.entities.NotesEntity
import org.kiwix.kiwixmobile.core.dao.entities.NotesEntity import org.kiwix.kiwixmobile.objectboxmigration.entities.RecentSearchEntity
import org.kiwix.kiwixmobile.core.dao.entities.RecentSearchEntity
import org.kiwix.kiwixmobile.core.data.KiwixRoomDatabase import org.kiwix.kiwixmobile.core.data.KiwixRoomDatabase
import org.kiwix.kiwixmobile.core.page.history.adapter.HistoryListItem import org.kiwix.kiwixmobile.core.page.history.adapter.HistoryListItem
import org.kiwix.kiwixmobile.core.page.notes.adapter.NoteListItem import org.kiwix.kiwixmobile.core.page.notes.adapter.NoteListItem
@ -39,7 +38,7 @@ class ObjectBoxToRoomMigrator {
@Inject lateinit var sharedPreferenceUtil: SharedPreferenceUtil @Inject lateinit var sharedPreferenceUtil: SharedPreferenceUtil
suspend fun migrateObjectBoxDataToRoom() { suspend fun migrateObjectBoxDataToRoom() {
CoreApp.coreComponent.inject(this) // CoreApp.coreComponent.inject(this)
if (!sharedPreferenceUtil.prefIsRecentSearchMigrated) { if (!sharedPreferenceUtil.prefIsRecentSearchMigrated) {
migrateRecentSearch(boxStore.boxFor()) migrateRecentSearch(boxStore.boxFor())
} }
@ -71,7 +70,20 @@ class ObjectBoxToRoomMigrator {
val historyEntityList = box.all val historyEntityList = box.all
historyEntityList.forEachIndexed { _, historyEntity -> historyEntityList.forEachIndexed { _, historyEntity ->
kiwixRoomDatabase.historyRoomDao() kiwixRoomDatabase.historyRoomDao()
.saveHistory(HistoryListItem.HistoryItem(historyEntity)) .saveHistory(
HistoryListItem.HistoryItem(
historyEntity.id,
historyEntity.zimId,
historyEntity.zimName,
historyEntity.zimReaderSource,
historyEntity.favicon,
historyEntity.historyUrl,
historyEntity.historyTitle,
historyEntity.dateString,
historyEntity.timeStamp,
false
)
)
// removing the single entity from the object box after migration. // removing the single entity from the object box after migration.
box.remove(historyEntity.id) box.remove(historyEntity.id)
} }
@ -81,7 +93,17 @@ class ObjectBoxToRoomMigrator {
suspend fun migrateNotes(box: Box<NotesEntity>) { suspend fun migrateNotes(box: Box<NotesEntity>) {
val notesEntityList = box.all val notesEntityList = box.all
notesEntityList.forEachIndexed { _, notesEntity -> notesEntityList.forEachIndexed { _, notesEntity ->
kiwixRoomDatabase.notesRoomDao().saveNote(NoteListItem(notesEntity)) kiwixRoomDatabase.notesRoomDao().saveNote(
NoteListItem(
notesEntity.id,
notesEntity.zimId,
notesEntity.noteTitle,
notesEntity.zimReaderSource,
notesEntity.zimUrl,
notesEntity.noteFilePath,
notesEntity.favicon
)
)
// removing the single entity from the object box after migration. // removing the single entity from the object box after migration.
box.remove(notesEntity.id) box.remove(notesEntity.id)
} }

View File

@ -0,0 +1,41 @@
/*
* Kiwix Android
* Copyright (c) 2025 Kiwix <android.kiwix.org>
* 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 <http://www.gnu.org/licenses/>.
*
*/
package org.kiwix.kiwixmobile.objectboxmigration.di
import dagger.Component
import org.kiwix.kiwixmobile.core.di.components.CoreComponent
import org.kiwix.kiwixmobile.objectboxmigration.data.ObjectBoxToLibkiwixMigrator
import org.kiwix.kiwixmobile.objectboxmigration.data.ObjectBoxToRoomMigrator
import org.kiwix.kiwixmobile.objectboxmigration.di.module.DatabaseModule
import org.kiwix.kiwixmobile.objectboxmigration.di.module.ObjectBoxMigrationModule
@MigrationScope
@Component(
dependencies = [CoreComponent::class],
modules = [ObjectBoxMigrationModule::class, DatabaseModule::class]
)
interface MigrationComponent {
fun objectBoxToRoomMigrator(): ObjectBoxToRoomMigrator
fun objectBoxToLibkiwixMigrator(): ObjectBoxToLibkiwixMigrator
@Component.Factory
interface Factory {
fun create(coreComponent: CoreComponent): MigrationComponent
}
}

View File

@ -0,0 +1,25 @@
/*
* Kiwix Android
* Copyright (c) 2025 Kiwix <android.kiwix.org>
* 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 <http://www.gnu.org/licenses/>.
*
*/
package org.kiwix.kiwixmobile.objectboxmigration.di
import javax.inject.Scope
@Scope
@Retention(AnnotationRetention.RUNTIME)
annotation class MigrationScope

View File

@ -0,0 +1,42 @@
/*
* Kiwix Android
* Copyright (c) 2025 Kiwix <android.kiwix.org>
* 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 <http://www.gnu.org/licenses/>.
*
*/
package org.kiwix.kiwixmobile.objectboxmigration.di.module
import android.content.Context
import dagger.Module
import dagger.Provides
import io.objectbox.BoxStore
import org.kiwix.kiwixmobile.objectboxmigration.entities.MyObjectBox
import javax.inject.Singleton
@Module
class DatabaseModule {
companion object {
var boxStore: BoxStore? = null
}
@Suppress("UnsafeCallOnNullableType")
// NOT RECOMMENDED TODO use custom runner to load TestApplication
@Provides @Singleton fun providesBoxStore(context: Context): BoxStore {
if (boxStore == null) {
boxStore = MyObjectBox.builder().androidContext(context).build()
}
return boxStore!!
}
}

View File

@ -0,0 +1,46 @@
/*
* Kiwix Android
* Copyright (c) 2025 Kiwix <android.kiwix.org>
* 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 <http://www.gnu.org/licenses/>.
*
*/
package org.kiwix.kiwixmobile.objectboxmigration.di.module
import dagger.Module
import dagger.Provides
import org.kiwix.kiwixmobile.core.data.ObjectBoxDataMigrationHandler
import org.kiwix.kiwixmobile.objectboxmigration.ObjectBoxMigrationHandler
import org.kiwix.kiwixmobile.objectboxmigration.data.ObjectBoxToLibkiwixMigrator
import org.kiwix.kiwixmobile.objectboxmigration.data.ObjectBoxToRoomMigrator
import org.kiwix.kiwixmobile.objectboxmigration.di.MigrationScope
@Module
class ObjectBoxMigrationModule {
@Provides
@MigrationScope
fun provideObjectBoxToLibkiwixMigrator() = ObjectBoxToLibkiwixMigrator()
@Provides
@MigrationScope
fun provideObjectBoxToRoomMigrator() = ObjectBoxToRoomMigrator()
@Provides
@MigrationScope
fun provideMigrationHandler(
objectBoxToRoomMigrator: ObjectBoxToRoomMigrator,
objectBoxToLibkiwixMigrator: ObjectBoxToLibkiwixMigrator
): ObjectBoxDataMigrationHandler =
ObjectBoxMigrationHandler(objectBoxToRoomMigrator, objectBoxToLibkiwixMigrator)
}

View File

@ -16,7 +16,7 @@
* *
*/ */
package org.kiwix.kiwixmobile.core.dao.entities package org.kiwix.kiwixmobile.objectboxmigration.entities
import io.objectbox.annotation.Convert import io.objectbox.annotation.Convert
import io.objectbox.annotation.Entity import io.objectbox.annotation.Entity

View File

@ -15,7 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
package org.kiwix.kiwixmobile.core.dao.entities package org.kiwix.kiwixmobile.objectboxmigration.entities
import io.objectbox.annotation.Convert import io.objectbox.annotation.Convert
import io.objectbox.annotation.Entity import io.objectbox.annotation.Entity

View File

@ -1,6 +1,6 @@
/* /*
* Kiwix Android * Kiwix Android
* Copyright (c) 2019 Kiwix <android.kiwix.org> * Copyright (c) 2025 Kiwix <android.kiwix.org>
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
@ -15,12 +15,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
package org.kiwix.kiwixmobile.core.dao.entities
package org.kiwix.kiwixmobile.objectboxmigration.entities
import io.objectbox.annotation.Convert import io.objectbox.annotation.Convert
import io.objectbox.annotation.Entity import io.objectbox.annotation.Entity
import io.objectbox.annotation.Id import io.objectbox.annotation.Id
import org.kiwix.kiwixmobile.core.page.history.adapter.HistoryListItem.HistoryItem import org.kiwix.kiwixmobile.core.page.history.adapter.HistoryListItem
import org.kiwix.kiwixmobile.core.reader.ZimReaderSource import org.kiwix.kiwixmobile.core.reader.ZimReaderSource
@Entity @Entity
@ -38,7 +39,7 @@ data class HistoryEntity(
val dateString: String, val dateString: String,
val timeStamp: Long val timeStamp: Long
) { ) {
constructor(historyItem: HistoryItem) : this( constructor(historyItem: HistoryListItem.HistoryItem) : this(
historyItem.databaseId, historyItem.databaseId,
historyItem.zimId, historyItem.zimId,
historyItem.zimName, historyItem.zimName,

View File

@ -16,7 +16,7 @@
* *
*/ */
package org.kiwix.kiwixmobile.core.dao.entities package org.kiwix.kiwixmobile.objectboxmigration.entities
import io.objectbox.annotation.Convert import io.objectbox.annotation.Convert
import io.objectbox.annotation.Entity import io.objectbox.annotation.Entity

View File

@ -15,7 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
package org.kiwix.kiwixmobile.core.dao.entities package org.kiwix.kiwixmobile.objectboxmigration.entities
import io.objectbox.annotation.Entity import io.objectbox.annotation.Entity
import io.objectbox.annotation.Id import io.objectbox.annotation.Id

View File

@ -2,6 +2,9 @@ include(
":core", ":core",
":app", ":app",
":custom", ":custom",
":install_time_asset" ":install_time_asset",
":objectboxmigration",
":defaultMigration"
) )
rootProject.name = "kiwix-android" rootProject.name = "kiwix-android"
include(":objectboxmigration2")