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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,9 +1,9 @@
package eu.kanade.data.updates package eu.kanade.data.updates
import eu.kanade.data.DatabaseHandler
import eu.kanade.domain.updates.model.UpdatesWithRelations import eu.kanade.domain.updates.model.UpdatesWithRelations
import eu.kanade.domain.updates.repository.UpdatesRepository import eu.kanade.domain.updates.repository.UpdatesRepository
import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow
import tachiyomi.data.DatabaseHandler
class UpdatesRepositoryImpl( class UpdatesRepositoryImpl(
val databaseHandler: DatabaseHandler, 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.LoadingScreen
import eu.kanade.presentation.components.Scaffold import eu.kanade.presentation.components.Scaffold
import eu.kanade.presentation.util.selectedBackground import eu.kanade.presentation.util.selectedBackground
import eu.kanade.tachiyomi.Database
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.util.lang.launchIO import eu.kanade.tachiyomi.util.lang.launchIO
import eu.kanade.tachiyomi.util.lang.launchUI 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 eu.kanade.tachiyomi.util.system.toast
import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.update import kotlinx.coroutines.flow.update
import tachiyomi.data.Database
import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get import uy.kohesive.injekt.api.get

View File

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

View File

@ -7,13 +7,6 @@ import androidx.sqlite.db.SupportSQLiteDatabase
import androidx.sqlite.db.framework.FrameworkSQLiteOpenHelperFactory import androidx.sqlite.db.framework.FrameworkSQLiteOpenHelperFactory
import com.squareup.sqldelight.android.AndroidSqliteDriver import com.squareup.sqldelight.android.AndroidSqliteDriver
import com.squareup.sqldelight.db.SqlDriver 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.backup.service.BackupPreferences
import eu.kanade.domain.base.BasePreferences import eu.kanade.domain.base.BasePreferences
import eu.kanade.domain.download.service.DownloadPreferences 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.core.XmlVersion
import nl.adaptivity.xmlutil.serialization.UnknownChildHandler import nl.adaptivity.xmlutil.serialization.UnknownChildHandler
import nl.adaptivity.xmlutil.serialization.XML 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.InjektModule
import uy.kohesive.injekt.api.InjektRegistrar import uy.kohesive.injekt.api.InjektRegistrar
import uy.kohesive.injekt.api.addSingleton import uy.kohesive.injekt.api.addSingleton

View File

@ -4,10 +4,6 @@ import android.Manifest
import android.content.Context import android.content.Context
import android.net.Uri import android.net.Uri
import com.hippo.unifile.UniFile 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.backup.service.BackupPreferences
import eu.kanade.domain.category.interactor.GetCategories import eu.kanade.domain.category.interactor.GetCategories
import eu.kanade.domain.category.model.Category import eu.kanade.domain.category.model.Category
@ -45,6 +41,10 @@ import logcat.LogPriority
import okio.buffer import okio.buffer
import okio.gzip import okio.gzip
import okio.sink 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.Injekt
import uy.kohesive.injekt.api.get import uy.kohesive.injekt.api.get
import java.io.FileOutputStream import java.io.FileOutputStream

View File

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

View File

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

View File

@ -1,6 +1,6 @@
package eu.kanade.tachiyomi.source.model package eu.kanade.tachiyomi.source.model
import data.Mangas import tachiyomi.data.Mangas
fun SManga.copyFrom(other: Mangas) { fun SManga.copyFrom(other: Mangas) {
if (other.author != null) { if (other.author != null) {
@ -16,7 +16,7 @@ fun SManga.copyFrom(other: Mangas) {
} }
if (other.genre != null) { if (other.genre != null) {
genre = other.genre.joinToString(separator = ", ") genre = other.genre!!.joinToString(separator = ", ")
} }
if (other.thumbnail_url != null) { 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 androidx.paging.PagingSource
import com.squareup.sqldelight.Query 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.mapToList
import com.squareup.sqldelight.runtime.coroutines.mapToOne import com.squareup.sqldelight.runtime.coroutines.mapToOne
import com.squareup.sqldelight.runtime.coroutines.mapToOneOrNull import com.squareup.sqldelight.runtime.coroutines.mapToOneOrNull
import eu.kanade.tachiyomi.Database
import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow

View File

@ -1,4 +1,4 @@
package eu.kanade.data package tachiyomi.data
import com.squareup.sqldelight.ColumnAdapter import com.squareup.sqldelight.ColumnAdapter
import eu.kanade.tachiyomi.source.model.UpdateStrategy 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 androidx.paging.PagingSource
import com.squareup.sqldelight.Query import com.squareup.sqldelight.Query
import eu.kanade.tachiyomi.Database
import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow
interface DatabaseHandler { interface DatabaseHandler {

View File

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

View File

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

View File

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