mirror of
https://github.com/null2264/yokai.git
synced 2025-06-20 18:24:42 +00:00
refactor: Replace Requery's SQLite with AndroidX's new KMP SQLite
This reverts commit abbe606473
.
This commit is contained in:
parent
abbe606473
commit
fa26270c6e
5 changed files with 38 additions and 60 deletions
|
@ -49,6 +49,7 @@ The format is simplified version of [Keep a Changelog](https://keepachangelog.co
|
|||
- Refactor Library to store LibraryMap instead of flatten list of LibraryItem
|
||||
- LibraryItem abstraction to make it easier to manage
|
||||
- LibraryManga no longer extend MangaImpl
|
||||
- Replace Requery's SQLite with AndroidX's new KMP SQLite
|
||||
- Update dependency gradle to v8.12
|
||||
- Update user agent (@Hiirbaf)
|
||||
- Update serialization to v1.8.1
|
||||
|
@ -65,8 +66,7 @@ The format is simplified version of [Keep a Changelog](https://keepachangelog.co
|
|||
- Update dependency com.getkeepsafe.taptargetview:taptargetview to v1.15.0
|
||||
- Update dependency androidx.window:window to v1.4.0
|
||||
- Update dependency androidx.webkit:webkit to v1.13.0
|
||||
- Update dependency androidx.sqlite:sqlite-ktx to v2.5.1
|
||||
- Update dependency androidx.sqlite:sqlite to v2.5.1
|
||||
- Update androidxSqlite to v2.5.1
|
||||
- Update dependency androidx.recyclerview:recyclerview to v1.4.0
|
||||
- Update dependency androidx.core:core-ktx to v1.16.0
|
||||
- Update dependency androidx.compose:compose-bom to v2025.05.01
|
||||
|
|
|
@ -200,7 +200,6 @@ dependencies {
|
|||
implementation(libs.play.services.gcm)
|
||||
|
||||
// Database
|
||||
implementation(libs.sqlite.android)
|
||||
implementation(libs.bundles.sqlite)
|
||||
|
||||
// Model View Presenter
|
||||
|
|
|
@ -2,12 +2,19 @@ package yokai.core.di
|
|||
|
||||
import android.app.Application
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.sqlite.db.SupportSQLiteDatabase
|
||||
import androidx.sqlite.driver.bundled.BundledSQLiteDriver
|
||||
import androidx.sqlite.driver.bundled.SQLITE_OPEN_CREATE
|
||||
import androidx.sqlite.driver.bundled.SQLITE_OPEN_READWRITE
|
||||
import app.cash.sqldelight.db.SqlDriver
|
||||
import app.cash.sqldelight.driver.android.AndroidSqliteDriver
|
||||
import co.touchlab.kermit.Logger
|
||||
import com.chuckerteam.chucker.api.ChuckerCollector
|
||||
import com.chuckerteam.chucker.api.ChuckerInterceptor
|
||||
import com.eygraber.sqldelight.androidx.driver.AndroidxSqliteConfiguration
|
||||
import com.eygraber.sqldelight.androidx.driver.AndroidxSqliteDatabaseType
|
||||
import com.eygraber.sqldelight.androidx.driver.AndroidxSqliteDriver
|
||||
import com.eygraber.sqldelight.androidx.driver.File
|
||||
import com.eygraber.sqldelight.androidx.driver.SqliteJournalMode
|
||||
import com.eygraber.sqldelight.androidx.driver.SqliteSync
|
||||
import eu.kanade.tachiyomi.BuildConfig
|
||||
import eu.kanade.tachiyomi.core.storage.AndroidStorageFolderProvider
|
||||
import eu.kanade.tachiyomi.data.cache.ChapterCache
|
||||
|
@ -23,7 +30,6 @@ import eu.kanade.tachiyomi.network.NetworkHelper
|
|||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.util.chapter.ChapterFilter
|
||||
import eu.kanade.tachiyomi.util.manga.MangaShortcutManager
|
||||
import io.requery.android.database.sqlite.RequerySQLiteOpenHelperFactory
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.protobuf.ProtoBuf
|
||||
import nl.adaptivity.xmlutil.XmlDeclMode
|
||||
|
@ -42,46 +48,23 @@ fun appModule(app: Application) = module {
|
|||
single { app }
|
||||
|
||||
single<SqlDriver> {
|
||||
AndroidSqliteDriver(
|
||||
AndroidxSqliteDriver(
|
||||
createConnection = { name ->
|
||||
BundledSQLiteDriver().open(name, SQLITE_OPEN_READWRITE or SQLITE_OPEN_CREATE)
|
||||
},
|
||||
databaseType = AndroidxSqliteDatabaseType.File(app, "tachiyomi.db"),
|
||||
configuration = AndroidxSqliteConfiguration().apply {
|
||||
isForeignKeyConstraintsEnabled = true
|
||||
journalMode = SqliteJournalMode.WAL
|
||||
sync = SqliteSync.Normal
|
||||
},
|
||||
schema = Database.Schema,
|
||||
context = app,
|
||||
name = "tachiyomi.db",
|
||||
// factory = if (BuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
// // Support database inspector in Android Studio
|
||||
// FrameworkSQLiteOpenHelperFactory()
|
||||
// } else {
|
||||
// RequerySQLiteOpenHelperFactory()
|
||||
// },
|
||||
factory = RequerySQLiteOpenHelperFactory(),
|
||||
callback = object : AndroidSqliteDriver.Callback(Database.Schema) {
|
||||
override fun onOpen(db: SupportSQLiteDatabase) {
|
||||
super.onOpen(db)
|
||||
setPragma(db, "foreign_keys = ON")
|
||||
setPragma(db, "journal_mode = WAL")
|
||||
setPragma(db, "synchronous = NORMAL")
|
||||
}
|
||||
|
||||
private fun setPragma(db: SupportSQLiteDatabase, pragma: String) {
|
||||
val cursor = db.query("PRAGMA $pragma")
|
||||
cursor.moveToFirst()
|
||||
cursor.close()
|
||||
}
|
||||
|
||||
// Not sure if this is still needed, but just in case
|
||||
override fun onConfigure(db: SupportSQLiteDatabase) {
|
||||
db.setForeignKeyConstraintsEnabled(true)
|
||||
}
|
||||
|
||||
override fun onCreate(db: SupportSQLiteDatabase) {
|
||||
Logger.d { "Creating new database..." }
|
||||
super.onCreate(db)
|
||||
}
|
||||
|
||||
override fun onUpgrade(db: SupportSQLiteDatabase, oldVersion: Int, newVersion: Int) {
|
||||
if (oldVersion < newVersion) {
|
||||
Logger.d { "Upgrading database from $oldVersion to $newVersion" }
|
||||
super.onUpgrade(db, oldVersion, newVersion)
|
||||
}
|
||||
onCreate = {
|
||||
Logger.d { "Creating new database..." }
|
||||
},
|
||||
onUpdate = { oldVersion, newVersion ->
|
||||
if (oldVersion < newVersion) {
|
||||
Logger.d { "Upgrading database from $oldVersion to $newVersion" }
|
||||
}
|
||||
},
|
||||
)
|
||||
|
|
|
@ -28,7 +28,6 @@ multidex = { module = "androidx.multidex:multidex", version = "2.0.1" }
|
|||
palette = { module = "androidx.palette:palette", version = "1.0.0" }
|
||||
preference = { module = "androidx.preference:preference-ktx", version = "1.2.1" }
|
||||
recyclerview = { module = "androidx.recyclerview:recyclerview", version = "1.4.0" }
|
||||
sqlite = { module = "androidx.sqlite:sqlite", version = "2.5.1" }
|
||||
webkit = { module = "androidx.webkit:webkit", version = "1.13.0" }
|
||||
work = { module = "androidx.work:work-runtime-ktx", version = "2.10.1" }
|
||||
window = { module = "androidx.window:window", version = "1.4.0" }
|
||||
|
@ -38,7 +37,7 @@ androidx = [
|
|||
"activity", "activity-compose", "annotation", "appcompat", "browser", "biometric", "cardview", "core",
|
||||
"core-splashscreen", "layout-constraint", "glance-appwidget", "lifecycle-common", "lifecycle-livedata",
|
||||
"lifecycle-process", "lifecycle-runtime", "lifecycle-viewmodel", "lifecycle-viewmodel-compose", "multidex",
|
||||
"palette", "preference", "recyclerview", "sqlite", "layout-swiperefresh", "webkit", "work", "window"
|
||||
"palette", "preference", "recyclerview", "layout-swiperefresh", "webkit", "work", "window"
|
||||
]
|
||||
|
||||
[plugins]
|
||||
|
|
|
@ -6,9 +6,9 @@ fast_adapter = "5.7.0"
|
|||
moko = "0.24.5"
|
||||
okhttp = "5.0.0-alpha.16"
|
||||
shizuku = "13.1.5"
|
||||
# FIXME: Uncomment once SQLDelight support KMP AndroidX SQLiteDriver
|
||||
#sqlite = "2.5.0-alpha04"
|
||||
sqlite = "2.5.1"
|
||||
androidxSqlite = "2.5.1"
|
||||
# FIXME: Stay at 2.0.2 until 2.1.1 released because dialect is borked
|
||||
# REF: https://github.com/sqldelight/sqldelight/issues/5758
|
||||
sqldelight = "2.0.2"
|
||||
junit = "5.11.3"
|
||||
kermit = "2.0.5"
|
||||
|
@ -82,13 +82,12 @@ rxjava = { module = "io.reactivex:rxjava", version = "1.3.8" }
|
|||
rxandroid = { module = "io.reactivex:rxandroid", version = "1.2.1" }
|
||||
slice = { module = "com.github.mthli:Slice", version = "v1.2" }
|
||||
|
||||
# FIXME: Uncomment once SQLDelight support KMP AndroidX SQLiteDriver
|
||||
#sqlite = { module = "androidx.sqlite:sqlite-bundled", version.ref = "sqlite" }
|
||||
sqlite-ktx = { module = "androidx.sqlite:sqlite-ktx", version.ref = "sqlite" }
|
||||
sqlite-android = { module = "com.github.requery:sqlite-android", version = "3.49.0" }
|
||||
# SQLite interface
|
||||
sqlite = { module = "androidx.sqlite:sqlite", version.ref = "androidxSqlite" }
|
||||
sqlite-bundled = { module = "androidx.sqlite:sqlite-bundled", version.ref = "androidxSqlite" }
|
||||
|
||||
sqldelight-coroutines = { module = "app.cash.sqldelight:coroutines-extensions", version.ref = "sqldelight" }
|
||||
sqldelight-android-driver = { module = "app.cash.sqldelight:android-driver", version.ref = "sqldelight" }
|
||||
sqldelight-androidx-driver = { module = "com.eygraber:sqldelight-androidx-driver", version = "0.0.12" }
|
||||
sqldelight-android-paging = { module = "app.cash.sqldelight:androidx-paging3-extensions", version.ref = "sqldelight" }
|
||||
sqldelight-dialects-sql = { module = "app.cash.sqldelight:sqlite-3-38-dialect", version.ref = "sqldelight" }
|
||||
|
||||
|
@ -114,13 +113,11 @@ moko = { id = "dev.icerock.mobile.multiplatform-resources", version.ref = "moko"
|
|||
sqldelight = { id = "app.cash.sqldelight", version.ref = "sqldelight" }
|
||||
|
||||
[bundles]
|
||||
db = [ "sqldelight-coroutines" ]
|
||||
db-android = [ "sqldelight-android-driver", "sqldelight-android-paging" ]
|
||||
db = [ "sqldelight-coroutines", "sqldelight-androidx-driver" ]
|
||||
db-android = [ "sqldelight-android-paging" ]
|
||||
coil = [ "coil3", "coil3-svg", "coil3-gif", "coil3-okhttp" ]
|
||||
logging = [ "kermit" ]
|
||||
# FIXME: Uncomment once SQLDelight support KMP AndroidX SQLiteDriver
|
||||
#sqlite = [ "sqlite", "sqlite-ktx" ]
|
||||
sqlite = [ "sqlite-ktx" ]
|
||||
sqlite = [ "sqlite", "sqlite-bundled" ]
|
||||
test = [ "junit-api", "kotest-assertions", "mockk" ]
|
||||
test-android = [ "junit-android" ]
|
||||
test-runtime = [ "junit-engine" ]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue