Move SQLDelight to data module (#8954)

And use tachiyomi instead of eu.kanade.tachiyomi for package names in the module
This commit is contained in:
Andreas 2023-01-21 16:37:07 +01:00 committed by GitHub
parent 2b5d9fd76b
commit 823749fc1e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
60 changed files with 90 additions and 48 deletions

View file

@ -7,7 +7,6 @@ plugins {
kotlin("android")
kotlin("plugin.serialization")
id("com.github.zellius.shortcut-helper")
id("com.squareup.sqldelight")
}
if (gradle.startParameter.taskRequests.toString().contains("Standard")) {
@ -136,19 +135,13 @@ android {
composeOptions {
kotlinCompilerExtensionVersion = compose.versions.compiler.get()
}
sqldelight {
database("Database") {
packageName = "eu.kanade.tachiyomi"
dialect = "sqlite:3.24"
}
}
}
dependencies {
implementation(project(":i18n"))
implementation(project(":core"))
implementation(project(":source-api"))
implementation(project(":data"))
// Compose
implementation(platform(compose.bom))
@ -171,9 +164,6 @@ dependencies {
implementation(androidx.paging.compose)
implementation(libs.bundles.sqlite)
implementation(libs.sqldelight.android.driver)
implementation(libs.sqldelight.coroutines)
implementation(libs.sqldelight.android.paging)
implementation(kotlinx.reflect)

View file

@ -1,11 +1,11 @@
package eu.kanade.data.category
import eu.kanade.data.DatabaseHandler
import eu.kanade.domain.category.model.Category
import eu.kanade.domain.category.model.CategoryUpdate
import eu.kanade.domain.category.repository.CategoryRepository
import eu.kanade.tachiyomi.Database
import kotlinx.coroutines.flow.Flow
import tachiyomi.data.Database
import tachiyomi.data.DatabaseHandler
class CategoryRepositoryImpl(
private val handler: DatabaseHandler,

View file

@ -1,6 +1,5 @@
package eu.kanade.data.chapter
import eu.kanade.data.DatabaseHandler
import eu.kanade.domain.chapter.model.Chapter
import eu.kanade.domain.chapter.model.ChapterUpdate
import eu.kanade.domain.chapter.repository.ChapterRepository
@ -8,6 +7,7 @@ import eu.kanade.tachiyomi.util.system.logcat
import eu.kanade.tachiyomi.util.system.toLong
import kotlinx.coroutines.flow.Flow
import logcat.LogPriority
import tachiyomi.data.DatabaseHandler
class ChapterRepositoryImpl(
private val handler: DatabaseHandler,

View file

@ -1,12 +1,12 @@
package eu.kanade.data.history
import eu.kanade.data.DatabaseHandler
import eu.kanade.domain.history.model.HistoryUpdate
import eu.kanade.domain.history.model.HistoryWithRelations
import eu.kanade.domain.history.repository.HistoryRepository
import eu.kanade.tachiyomi.util.system.logcat
import kotlinx.coroutines.flow.Flow
import logcat.LogPriority
import tachiyomi.data.DatabaseHandler
class HistoryRepositoryImpl(
private val handler: DatabaseHandler,

View file

@ -1,8 +1,5 @@
package eu.kanade.data.manga
import eu.kanade.data.DatabaseHandler
import eu.kanade.data.listOfStringsAdapter
import eu.kanade.data.updateStrategyAdapter
import eu.kanade.domain.library.model.LibraryManga
import eu.kanade.domain.manga.model.Manga
import eu.kanade.domain.manga.model.MangaUpdate
@ -11,6 +8,9 @@ import eu.kanade.tachiyomi.util.system.logcat
import eu.kanade.tachiyomi.util.system.toLong
import kotlinx.coroutines.flow.Flow
import logcat.LogPriority
import tachiyomi.data.DatabaseHandler
import tachiyomi.data.listOfStringsAdapter
import tachiyomi.data.updateStrategyAdapter
class MangaRepositoryImpl(
private val handler: DatabaseHandler,

View file

@ -1,9 +1,9 @@
package eu.kanade.data.source
import eu.kanade.data.DatabaseHandler
import eu.kanade.domain.source.model.SourceData
import eu.kanade.domain.source.repository.SourceDataRepository
import kotlinx.coroutines.flow.Flow
import tachiyomi.data.DatabaseHandler
class SourceDataRepositoryImpl(
private val handler: DatabaseHandler,

View file

@ -1,6 +1,5 @@
package eu.kanade.data.source
import eu.kanade.data.DatabaseHandler
import eu.kanade.domain.source.model.Source
import eu.kanade.domain.source.model.SourcePagingSourceType
import eu.kanade.domain.source.model.SourceWithCount
@ -11,6 +10,7 @@ import eu.kanade.tachiyomi.source.SourceManager
import eu.kanade.tachiyomi.source.model.FilterList
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map
import tachiyomi.data.DatabaseHandler
class SourceRepositoryImpl(
private val sourceManager: SourceManager,

View file

@ -1,9 +1,9 @@
package eu.kanade.data.track
import eu.kanade.data.DatabaseHandler
import eu.kanade.domain.track.model.Track
import eu.kanade.domain.track.repository.TrackRepository
import kotlinx.coroutines.flow.Flow
import tachiyomi.data.DatabaseHandler
class TrackRepositoryImpl(
private val handler: DatabaseHandler,

View file

@ -1,9 +1,9 @@
package eu.kanade.data.updates
import eu.kanade.data.DatabaseHandler
import eu.kanade.domain.updates.model.UpdatesWithRelations
import eu.kanade.domain.updates.repository.UpdatesRepository
import kotlinx.coroutines.flow.Flow
import tachiyomi.data.DatabaseHandler
class UpdatesRepositoryImpl(
val databaseHandler: DatabaseHandler,

View file

@ -46,7 +46,6 @@ import eu.kanade.presentation.components.FastScrollLazyColumn
import eu.kanade.presentation.components.LoadingScreen
import eu.kanade.presentation.components.Scaffold
import eu.kanade.presentation.util.selectedBackground
import eu.kanade.tachiyomi.Database
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.util.lang.launchIO
import eu.kanade.tachiyomi.util.lang.launchUI
@ -54,6 +53,7 @@ import eu.kanade.tachiyomi.util.lang.withNonCancellableContext
import eu.kanade.tachiyomi.util.system.toast
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.update
import tachiyomi.data.Database
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get

View file

@ -24,7 +24,6 @@ import coil.decode.GifDecoder
import coil.decode.ImageDecoderDecoder
import coil.disk.DiskCache
import coil.util.DebugLogger
import eu.kanade.data.DatabaseHandler
import eu.kanade.domain.DomainModule
import eu.kanade.domain.base.BasePreferences
import eu.kanade.domain.ui.UiPreferences
@ -59,6 +58,7 @@ import org.acra.config.httpSender
import org.acra.ktx.initAcra
import org.acra.sender.HttpSender
import org.conscrypt.Conscrypt
import tachiyomi.data.DatabaseHandler
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import uy.kohesive.injekt.injectLazy

View file

@ -7,13 +7,6 @@ import androidx.sqlite.db.SupportSQLiteDatabase
import androidx.sqlite.db.framework.FrameworkSQLiteOpenHelperFactory
import com.squareup.sqldelight.android.AndroidSqliteDriver
import com.squareup.sqldelight.db.SqlDriver
import data.History
import data.Mangas
import eu.kanade.data.AndroidDatabaseHandler
import eu.kanade.data.DatabaseHandler
import eu.kanade.data.dateAdapter
import eu.kanade.data.listOfStringsAdapter
import eu.kanade.data.updateStrategyAdapter
import eu.kanade.domain.backup.service.BackupPreferences
import eu.kanade.domain.base.BasePreferences
import eu.kanade.domain.download.service.DownloadPreferences
@ -47,6 +40,14 @@ import nl.adaptivity.xmlutil.XmlDeclMode
import nl.adaptivity.xmlutil.core.XmlVersion
import nl.adaptivity.xmlutil.serialization.UnknownChildHandler
import nl.adaptivity.xmlutil.serialization.XML
import tachiyomi.data.AndroidDatabaseHandler
import tachiyomi.data.Database
import tachiyomi.data.DatabaseHandler
import tachiyomi.data.History
import tachiyomi.data.Mangas
import tachiyomi.data.dateAdapter
import tachiyomi.data.listOfStringsAdapter
import tachiyomi.data.updateStrategyAdapter
import uy.kohesive.injekt.api.InjektModule
import uy.kohesive.injekt.api.InjektRegistrar
import uy.kohesive.injekt.api.addSingleton

View file

@ -4,10 +4,6 @@ import android.Manifest
import android.content.Context
import android.net.Uri
import com.hippo.unifile.UniFile
import data.Manga_sync
import data.Mangas
import eu.kanade.data.DatabaseHandler
import eu.kanade.data.updateStrategyAdapter
import eu.kanade.domain.backup.service.BackupPreferences
import eu.kanade.domain.category.interactor.GetCategories
import eu.kanade.domain.category.model.Category
@ -45,6 +41,10 @@ import logcat.LogPriority
import okio.buffer
import okio.gzip
import okio.sink
import tachiyomi.data.DatabaseHandler
import tachiyomi.data.Manga_sync
import tachiyomi.data.Mangas
import tachiyomi.data.updateStrategyAdapter
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import java.io.FileOutputStream

View file

@ -43,7 +43,6 @@ import coil.request.ImageRequest
import coil.size.Precision
import coil.size.Scale
import coil.transform.RoundedCornersTransformation
import eu.kanade.data.DatabaseHandler
import eu.kanade.domain.manga.model.MangaCover
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.core.security.SecurityPreferences
@ -52,10 +51,11 @@ import eu.kanade.tachiyomi.util.Constants
import eu.kanade.tachiyomi.util.lang.launchIO
import eu.kanade.tachiyomi.util.system.dpToPx
import kotlinx.coroutines.MainScope
import tachiyomi.data.DatabaseHandler
import tachiyomi.view.UpdatesView
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import uy.kohesive.injekt.injectLazy
import view.UpdatesView
import java.util.Calendar
import java.util.Date

View file

@ -1,6 +1,6 @@
package eu.kanade.tachiyomi.source.model
import data.Chapters
import tachiyomi.data.Chapters
fun SChapter.copyFrom(other: Chapters) {
name = other.name

View file

@ -1,6 +1,6 @@
package eu.kanade.tachiyomi.source.model
import data.Mangas
import tachiyomi.data.Mangas
fun SManga.copyFrom(other: Mangas) {
if (other.author != null) {
@ -16,7 +16,7 @@ fun SManga.copyFrom(other: Mangas) {
}
if (other.genre != null) {
genre = other.genre.joinToString(separator = ", ")
genre = other.genre!!.joinToString(separator = ", ")
}
if (other.thumbnail_url != null) {

1
data/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/build

27
data/build.gradle.kts Normal file
View file

@ -0,0 +1,27 @@
plugins {
id("com.android.library")
kotlin("android")
id("com.squareup.sqldelight")
}
android {
namespace = "tachiyomi.data"
defaultConfig {
consumerProguardFiles("consumer-rules.pro")
}
sqldelight {
database("Database") {
packageName = "tachiyomi.data"
dialect = "sqlite:3.24"
}
}
}
dependencies {
implementation(project(":source-api"))
api(libs.sqldelight.android.driver)
api(libs.sqldelight.coroutines)
api(libs.sqldelight.android.paging)
}

0
data/consumer-rules.pro Normal file
View file

21
data/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,4 +1,4 @@
package eu.kanade.data
package tachiyomi.data
import androidx.paging.PagingSource
import com.squareup.sqldelight.Query
@ -7,7 +7,6 @@ import com.squareup.sqldelight.runtime.coroutines.asFlow
import com.squareup.sqldelight.runtime.coroutines.mapToList
import com.squareup.sqldelight.runtime.coroutines.mapToOne
import com.squareup.sqldelight.runtime.coroutines.mapToOneOrNull
import eu.kanade.tachiyomi.Database
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.Flow

View file

@ -1,4 +1,4 @@
package eu.kanade.data
package tachiyomi.data
import com.squareup.sqldelight.ColumnAdapter
import eu.kanade.tachiyomi.source.model.UpdateStrategy

View file

@ -1,8 +1,7 @@
package eu.kanade.data
package tachiyomi.data
import androidx.paging.PagingSource
import com.squareup.sqldelight.Query
import eu.kanade.tachiyomi.Database
import kotlinx.coroutines.flow.Flow
interface DatabaseHandler {

View file

@ -1,9 +1,8 @@
package eu.kanade.data
package tachiyomi.data
import androidx.paging.PagingSource
import androidx.paging.PagingState
import com.squareup.sqldelight.Query
import eu.kanade.tachiyomi.Database
import kotlin.properties.Delegates
class QueryPagingSource<RowType : Any>(

View file

@ -1,4 +1,4 @@
package eu.kanade.data
package tachiyomi.data
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Job

View file

@ -41,3 +41,4 @@ include(":i18n")
include(":source-api")
include(":core")
include(":macrobenchmark")
include(":data")