From cd91ea9b7723eec378bbbefd916d3da6407d685e Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 29 Jul 2023 16:14:23 -0400 Subject: [PATCH] Remove need for SQLDelight primitive adapters --- app/build.gradle.kts | 1 - .../interactor/SyncChaptersWithSource.kt | 6 +++--- .../eu/kanade/domain/chapter/model/Chapter.kt | 6 +++--- .../eu/kanade/domain/manga/model/Manga.kt | 2 +- .../eu/kanade/domain/track/model/Track.kt | 4 ++-- .../presentation/track/TrackInfoDialogHome.kt | 2 +- .../util/ChapterNumberFormatter.kt | 2 +- .../java/eu/kanade/tachiyomi/AppModule.kt | 21 ++++++------------- .../tachiyomi/data/backup/BackupManager.kt | 7 +++---- .../data/backup/models/BackupChapter.kt | 6 +++--- .../data/backup/models/BackupTracking.kt | 6 +++--- .../tachiyomi/data/database/models/Chapter.kt | 2 +- .../tachiyomi/data/track/TrackService.kt | 2 +- .../tachiyomi/data/track/anilist/Anilist.kt | 4 ++-- .../source/model/SChapterExtensions.kt | 2 +- .../tachiyomi/ui/stats/StatsScreenModel.kt | 6 ++---- .../java/tachiyomi/data/DatabaseAdapter.kt | 12 +++++------ .../tachiyomi/data/chapter/ChapterMapper.kt | 2 +- .../tachiyomi/data/history/HistoryMapper.kt | 2 +- .../data/manga/MangaRepositoryImpl.kt | 9 ++++---- .../java/tachiyomi/data/track/TrackMapper.kt | 2 +- .../sqldelight/tachiyomi/data/chapters.sq | 3 +-- .../sqldelight/tachiyomi/data/manga_sync.sq | 4 +--- .../tachiyomi/domain/chapter/model/Chapter.kt | 4 ++-- .../domain/chapter/model/ChapterUpdate.kt | 2 +- .../chapter/service/ChapterRecognition.kt | 10 ++++----- .../domain/chapter/service/MissingChapters.kt | 10 ++++----- .../history/model/HistoryWithRelations.kt | 2 +- .../tachiyomi/domain/track/model/Track.kt | 2 +- gradle/libs.versions.toml | 3 +-- .../tachiyomi/source/local/LocalSource.kt | 4 +++- 31 files changed, 67 insertions(+), 83 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 0da63e175d..74477e52fa 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -170,7 +170,6 @@ dependencies { implementation(androidx.paging.compose) implementation(libs.bundles.sqlite) - implementation(libs.sqldelight.primitive.adapters) implementation(kotlinx.reflect) diff --git a/app/src/main/java/eu/kanade/domain/chapter/interactor/SyncChaptersWithSource.kt b/app/src/main/java/eu/kanade/domain/chapter/interactor/SyncChaptersWithSource.kt index 5d0192ffb4..f7270e6610 100644 --- a/app/src/main/java/eu/kanade/domain/chapter/interactor/SyncChaptersWithSource.kt +++ b/app/src/main/java/eu/kanade/domain/chapter/interactor/SyncChaptersWithSource.kt @@ -151,9 +151,9 @@ class SyncChaptersWithSource( val reAdded = mutableListOf() - val deletedChapterNumbers = TreeSet() - val deletedReadChapterNumbers = TreeSet() - val deletedBookmarkedChapterNumbers = TreeSet() + val deletedChapterNumbers = TreeSet() + val deletedReadChapterNumbers = TreeSet() + val deletedBookmarkedChapterNumbers = TreeSet() toDelete.forEach { chapter -> if (chapter.read) deletedReadChapterNumbers.add(chapter.chapterNumber) diff --git a/app/src/main/java/eu/kanade/domain/chapter/model/Chapter.kt b/app/src/main/java/eu/kanade/domain/chapter/model/Chapter.kt index b3c7edb714..af99f0e631 100644 --- a/app/src/main/java/eu/kanade/domain/chapter/model/Chapter.kt +++ b/app/src/main/java/eu/kanade/domain/chapter/model/Chapter.kt @@ -12,7 +12,7 @@ fun Chapter.toSChapter(): SChapter { it.url = url it.name = name it.date_upload = dateUpload - it.chapter_number = chapterNumber + it.chapter_number = chapterNumber.toFloat() it.scanlator = scanlator } } @@ -22,7 +22,7 @@ fun Chapter.copyFromSChapter(sChapter: SChapter): Chapter { name = sChapter.name, url = sChapter.url, dateUpload = sChapter.date_upload, - chapterNumber = sChapter.chapter_number, + chapterNumber = sChapter.chapter_number.toDouble(), scanlator = sChapter.scanlator?.ifBlank { null }, ) } @@ -48,6 +48,6 @@ fun Chapter.toDbChapter(): DbChapter = ChapterImpl().also { it.last_page_read = lastPageRead.toInt() it.date_fetch = dateFetch it.date_upload = dateUpload - it.chapter_number = chapterNumber + it.chapter_number = chapterNumber.toFloat() it.source_order = sourceOrder.toInt() } diff --git a/app/src/main/java/eu/kanade/domain/manga/model/Manga.kt b/app/src/main/java/eu/kanade/domain/manga/model/Manga.kt index ef8efa3591..6c2ee4a5ef 100644 --- a/app/src/main/java/eu/kanade/domain/manga/model/Manga.kt +++ b/app/src/main/java/eu/kanade/domain/manga/model/Manga.kt @@ -99,7 +99,7 @@ fun getComicInfo(manga: Manga, chapter: Chapter, chapterUrl: String, categories: title = ComicInfo.Title(chapter.name), series = ComicInfo.Series(manga.title), number = chapter.chapterNumber.takeIf { it >= 0 }?.let { - if ((it.rem(1) == 0.0F)) { + if ((it.rem(1) == 0.0)) { ComicInfo.Number(it.toInt().toString()) } else { ComicInfo.Number(it.toString()) diff --git a/app/src/main/java/eu/kanade/domain/track/model/Track.kt b/app/src/main/java/eu/kanade/domain/track/model/Track.kt index f9712b6983..e16846e0e3 100644 --- a/app/src/main/java/eu/kanade/domain/track/model/Track.kt +++ b/app/src/main/java/eu/kanade/domain/track/model/Track.kt @@ -22,7 +22,7 @@ fun Track.toDbTrack(): DbTrack = DbTrack.create(syncId).also { it.last_chapter_read = lastChapterRead.toFloat() it.total_chapters = totalChapters.toInt() it.status = status.toInt() - it.score = score + it.score = score.toFloat() it.tracking_url = remoteUrl it.started_reading_date = startDate it.finished_reading_date = finishDate @@ -40,7 +40,7 @@ fun DbTrack.toDomainTrack(idRequired: Boolean = true): Track? { lastChapterRead = last_chapter_read.toDouble(), totalChapters = total_chapters.toLong(), status = status.toLong(), - score = score, + score = score.toDouble(), remoteUrl = tracking_url, startDate = started_reading_date, finishDate = finished_reading_date, diff --git a/app/src/main/java/eu/kanade/presentation/track/TrackInfoDialogHome.kt b/app/src/main/java/eu/kanade/presentation/track/TrackInfoDialogHome.kt index db1b242b3c..d9a899d5d3 100644 --- a/app/src/main/java/eu/kanade/presentation/track/TrackInfoDialogHome.kt +++ b/app/src/main/java/eu/kanade/presentation/track/TrackInfoDialogHome.kt @@ -98,7 +98,7 @@ fun TrackInfoDialogHome( }, onChaptersClick = { onChapterClick(item) }, score = item.service.displayScore(item.track.toDbTrack()) - .takeIf { supportsScoring && item.track.score != 0F }, + .takeIf { supportsScoring && item.track.score != 0.0 }, onScoreClick = { onScoreClick(item) } .takeIf { supportsScoring }, startDate = remember(item.track.startDate) { dateFormat.format(item.track.startDate) } diff --git a/app/src/main/java/eu/kanade/presentation/util/ChapterNumberFormatter.kt b/app/src/main/java/eu/kanade/presentation/util/ChapterNumberFormatter.kt index eafeb38846..a4f1e4ed16 100644 --- a/app/src/main/java/eu/kanade/presentation/util/ChapterNumberFormatter.kt +++ b/app/src/main/java/eu/kanade/presentation/util/ChapterNumberFormatter.kt @@ -8,6 +8,6 @@ private val formatter = DecimalFormat( DecimalFormatSymbols().apply { decimalSeparator = '.' }, ) -fun formatChapterNumber(chapterNumber: Float): String { +fun formatChapterNumber(chapterNumber: Double): String { return formatter.format(chapterNumber) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/AppModule.kt b/app/src/main/java/eu/kanade/tachiyomi/AppModule.kt index dbedb3e0b1..481ff079a1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/AppModule.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/AppModule.kt @@ -5,7 +5,6 @@ import android.os.Build import androidx.core.content.ContextCompat import androidx.sqlite.db.SupportSQLiteDatabase import androidx.sqlite.db.framework.FrameworkSQLiteOpenHelperFactory -import app.cash.sqldelight.adapter.primitive.FloatColumnAdapter import app.cash.sqldelight.db.SqlDriver import app.cash.sqldelight.driver.android.AndroidSqliteDriver import eu.kanade.domain.base.BasePreferences @@ -38,15 +37,13 @@ import tachiyomi.core.preference.PreferenceStore import tachiyomi.core.provider.AndroidBackupFolderProvider import tachiyomi.core.provider.AndroidDownloadFolderProvider import tachiyomi.data.AndroidDatabaseHandler -import tachiyomi.data.Chapters import tachiyomi.data.Database import tachiyomi.data.DatabaseHandler +import tachiyomi.data.DateColumnAdapter import tachiyomi.data.History -import tachiyomi.data.Manga_sync import tachiyomi.data.Mangas -import tachiyomi.data.dateAdapter -import tachiyomi.data.listOfStringsAdapter -import tachiyomi.data.updateStrategyAdapter +import tachiyomi.data.StringListColumnAdapter +import tachiyomi.data.UpdateStrategyColumnAdapter import tachiyomi.domain.backup.service.BackupPreferences import tachiyomi.domain.download.service.DownloadPreferences import tachiyomi.domain.library.service.LibraryPreferences @@ -93,18 +90,12 @@ class AppModule(val app: Application) : InjektModule { addSingletonFactory { Database( driver = get(), - chaptersAdapter = Chapters.Adapter( - chapter_numberAdapter = FloatColumnAdapter, - ), historyAdapter = History.Adapter( - last_readAdapter = dateAdapter, - ), - manga_syncAdapter = Manga_sync.Adapter( - scoreAdapter = FloatColumnAdapter, + last_readAdapter = DateColumnAdapter, ), mangasAdapter = Mangas.Adapter( - genreAdapter = listOfStringsAdapter, - update_strategyAdapter = updateStrategyAdapter, + genreAdapter = StringListColumnAdapter, + update_strategyAdapter = UpdateStrategyColumnAdapter, ), ) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupManager.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupManager.kt index d9b0406dfa..9c699f5353 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupManager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupManager.kt @@ -30,12 +30,11 @@ import logcat.LogPriority import okio.buffer import okio.gzip import okio.sink -import tachiyomi.core.util.lang.toLong import tachiyomi.core.util.system.logcat import tachiyomi.data.DatabaseHandler import tachiyomi.data.Manga_sync import tachiyomi.data.Mangas -import tachiyomi.data.updateStrategyAdapter +import tachiyomi.data.UpdateStrategyColumnAdapter import tachiyomi.domain.backup.service.BackupPreferences import tachiyomi.domain.category.interactor.GetCategories import tachiyomi.domain.category.model.Category @@ -415,7 +414,7 @@ class BackupManager( track.last_chapter_read, track.total_chapters, track.status, - track.score.toDouble(), + track.score, track.remote_url, track.start_date, track.finish_date, @@ -536,7 +535,7 @@ class BackupManager( coverLastModified = manga.coverLastModified, dateAdded = manga.dateAdded, mangaId = manga.id, - updateStrategy = manga.updateStrategy.let(updateStrategyAdapter::encode), + updateStrategy = manga.updateStrategy.let(UpdateStrategyColumnAdapter::encode), ) } return manga.id diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/models/BackupChapter.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/models/BackupChapter.kt index ed42a75ad8..6d8cba4e2d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/models/BackupChapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/models/BackupChapter.kt @@ -26,7 +26,7 @@ data class BackupChapter( return Chapter.create().copy( url = this@BackupChapter.url, name = this@BackupChapter.name, - chapterNumber = this@BackupChapter.chapterNumber, + chapterNumber = this@BackupChapter.chapterNumber.toDouble(), scanlator = this@BackupChapter.scanlator, read = this@BackupChapter.read, bookmark = this@BackupChapter.bookmark, @@ -39,11 +39,11 @@ data class BackupChapter( } } -val backupChapterMapper = { _: Long, _: Long, url: String, name: String, scanlator: String?, read: Boolean, bookmark: Boolean, lastPageRead: Long, chapterNumber: Float, source_order: Long, dateFetch: Long, dateUpload: Long, lastModifiedAt: Long -> +val backupChapterMapper = { _: Long, _: Long, url: String, name: String, scanlator: String?, read: Boolean, bookmark: Boolean, lastPageRead: Long, chapterNumber: Double, source_order: Long, dateFetch: Long, dateUpload: Long, lastModifiedAt: Long -> BackupChapter( url = url, name = name, - chapterNumber = chapterNumber, + chapterNumber = chapterNumber.toFloat(), scanlator = scanlator, read = read, bookmark = bookmark, diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/models/BackupTracking.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/models/BackupTracking.kt index e9153ad748..0cbbf51a0e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/models/BackupTracking.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/models/BackupTracking.kt @@ -44,7 +44,7 @@ data class BackupTracking( title = this@BackupTracking.title, lastChapterRead = this@BackupTracking.lastChapterRead.toDouble(), totalChapters = this@BackupTracking.totalChapters.toLong(), - score = this@BackupTracking.score, + score = this@BackupTracking.score.toDouble(), status = this@BackupTracking.status.toLong(), startDate = this@BackupTracking.startedReadingDate, finishDate = this@BackupTracking.finishedReadingDate, @@ -54,7 +54,7 @@ data class BackupTracking( } val backupTrackMapper = { - _: Long, _: Long, syncId: Long, mediaId: Long, libraryId: Long?, title: String, lastChapterRead: Double, totalChapters: Long, status: Long, score: Float, remoteUrl: String, startDate: Long, finishDate: Long -> + _: Long, _: Long, syncId: Long, mediaId: Long, libraryId: Long?, title: String, lastChapterRead: Double, totalChapters: Long, status: Long, score: Double, remoteUrl: String, startDate: Long, finishDate: Long -> BackupTracking( syncId = syncId.toInt(), mediaId = mediaId, @@ -63,7 +63,7 @@ val backupTrackMapper = { title = title, lastChapterRead = lastChapterRead.toFloat(), totalChapters = totalChapters.toInt(), - score = score, + score = score.toFloat(), status = status.toInt(), startedReadingDate = startDate, finishedReadingDate = finishDate, diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Chapter.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Chapter.kt index be1d72b08e..4ff50483ec 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Chapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Chapter.kt @@ -36,7 +36,7 @@ fun Chapter.toDomainChapter(): DomainChapter? { url = url, name = name, dateUpload = date_upload, - chapterNumber = chapter_number, + chapterNumber = chapter_number.toDouble(), scanlator = scanlator, lastModifiedAt = last_modified, ) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/TrackService.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/TrackService.kt index 02c92c2b7c..a24afd2ff1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/TrackService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/TrackService.kt @@ -65,7 +65,7 @@ abstract class TrackService(val id: Long) { abstract fun getScoreList(): List // TODO: Store all scores as 10 point in the future maybe? - open fun get10PointScore(track: DomainTrack): Float { + open fun get10PointScore(track: DomainTrack): Double { return track.score } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/Anilist.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/Anilist.kt index c40c4438af..e5718acf05 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/Anilist.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/Anilist.kt @@ -93,9 +93,9 @@ class Anilist(id: Long) : TrackService(id), DeletableTrackService { } } - override fun get10PointScore(track: DomainTrack): Float { + override fun get10PointScore(track: DomainTrack): Double { // Score is stored in 100 point format - return track.score / 10f + return track.score / 10.0 } override fun indexToScore(index: Int): Float { diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/model/SChapterExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/source/model/SChapterExtensions.kt index ad13c090a7..0fd2f860f9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/model/SChapterExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/model/SChapterExtensions.kt @@ -6,6 +6,6 @@ fun SChapter.copyFrom(other: Chapters) { name = other.name url = other.url date_upload = other.date_upload - chapter_number = other.chapter_number + chapter_number = other.chapter_number.toFloat() scanlator = other.scanlator } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/stats/StatsScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/stats/StatsScreenModel.kt index 366486a0d6..68cc4b324b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/stats/StatsScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/stats/StatsScreenModel.kt @@ -137,15 +137,13 @@ class StatsScreenModel( private fun getTrackMeanScore(scoredMangaTrackMap: Map>): Double { return scoredMangaTrackMap .map { (_, tracks) -> - tracks.map { - get10PointScore(it) - }.average() + tracks.map(::get10PointScore).average() } .fastFilter { !it.isNaN() } .average() } - private fun get10PointScore(track: Track): Float { + private fun get10PointScore(track: Track): Double { val service = trackManager.getService(track.syncId)!! return service.get10PointScore(track) } diff --git a/data/src/main/java/tachiyomi/data/DatabaseAdapter.kt b/data/src/main/java/tachiyomi/data/DatabaseAdapter.kt index 809e96d3d9..4a3475b4ff 100644 --- a/data/src/main/java/tachiyomi/data/DatabaseAdapter.kt +++ b/data/src/main/java/tachiyomi/data/DatabaseAdapter.kt @@ -4,23 +4,23 @@ import app.cash.sqldelight.ColumnAdapter import eu.kanade.tachiyomi.source.model.UpdateStrategy import java.util.Date -val dateAdapter = object : ColumnAdapter { +object DateColumnAdapter : ColumnAdapter { override fun decode(databaseValue: Long): Date = Date(databaseValue) override fun encode(value: Date): Long = value.time } -private const val listOfStringsSeparator = ", " -val listOfStringsAdapter = object : ColumnAdapter, String> { +private const val LIST_OF_STRINGS_SEPARATOR = ", " +object StringListColumnAdapter : ColumnAdapter, String> { override fun decode(databaseValue: String) = if (databaseValue.isEmpty()) { emptyList() } else { - databaseValue.split(listOfStringsSeparator) + databaseValue.split(LIST_OF_STRINGS_SEPARATOR) } - override fun encode(value: List) = value.joinToString(separator = listOfStringsSeparator) + override fun encode(value: List) = value.joinToString(separator = LIST_OF_STRINGS_SEPARATOR) } -val updateStrategyAdapter = object : ColumnAdapter { +object UpdateStrategyColumnAdapter : ColumnAdapter { override fun decode(databaseValue: Long): UpdateStrategy = UpdateStrategy.entries.getOrElse(databaseValue.toInt()) { UpdateStrategy.ALWAYS_UPDATE } diff --git a/data/src/main/java/tachiyomi/data/chapter/ChapterMapper.kt b/data/src/main/java/tachiyomi/data/chapter/ChapterMapper.kt index b91ccd7b46..71ae1720ee 100644 --- a/data/src/main/java/tachiyomi/data/chapter/ChapterMapper.kt +++ b/data/src/main/java/tachiyomi/data/chapter/ChapterMapper.kt @@ -2,7 +2,7 @@ package tachiyomi.data.chapter import tachiyomi.domain.chapter.model.Chapter -val chapterMapper: (Long, Long, String, String, String?, Boolean, Boolean, Long, Float, Long, Long, Long, Long) -> Chapter = +val chapterMapper: (Long, Long, String, String, String?, Boolean, Boolean, Long, Double, Long, Long, Long, Long) -> Chapter = { id, mangaId, url, name, scanlator, read, bookmark, lastPageRead, chapterNumber, sourceOrder, dateFetch, dateUpload, lastModifiedAt -> Chapter( id = id, diff --git a/data/src/main/java/tachiyomi/data/history/HistoryMapper.kt b/data/src/main/java/tachiyomi/data/history/HistoryMapper.kt index c59062010a..c2d110f747 100644 --- a/data/src/main/java/tachiyomi/data/history/HistoryMapper.kt +++ b/data/src/main/java/tachiyomi/data/history/HistoryMapper.kt @@ -14,7 +14,7 @@ val historyMapper: (Long, Long, Date?, Long) -> History = { id, chapterId, readA ) } -val historyWithRelationsMapper: (Long, Long, Long, String, String?, Long, Boolean, Long, Float, Date?, Long) -> HistoryWithRelations = { +val historyWithRelationsMapper: (Long, Long, Long, String, String?, Long, Boolean, Long, Double, Date?, Long) -> HistoryWithRelations = { historyId, mangaId, chapterId, title, thumbnailUrl, sourceId, isFavorite, coverLastModified, chapterNumber, readAt, readDuration -> HistoryWithRelations( id = historyId, diff --git a/data/src/main/java/tachiyomi/data/manga/MangaRepositoryImpl.kt b/data/src/main/java/tachiyomi/data/manga/MangaRepositoryImpl.kt index d6f93c5961..49f3160a6d 100644 --- a/data/src/main/java/tachiyomi/data/manga/MangaRepositoryImpl.kt +++ b/data/src/main/java/tachiyomi/data/manga/MangaRepositoryImpl.kt @@ -2,11 +2,10 @@ package tachiyomi.data.manga import kotlinx.coroutines.flow.Flow import logcat.LogPriority -import tachiyomi.core.util.lang.toLong import tachiyomi.core.util.system.logcat import tachiyomi.data.DatabaseHandler -import tachiyomi.data.listOfStringsAdapter -import tachiyomi.data.updateStrategyAdapter +import tachiyomi.data.StringListColumnAdapter +import tachiyomi.data.UpdateStrategyColumnAdapter import tachiyomi.domain.library.model.LibraryManga import tachiyomi.domain.manga.model.Manga import tachiyomi.domain.manga.model.MangaUpdate @@ -129,7 +128,7 @@ class MangaRepositoryImpl( artist = value.artist, author = value.author, description = value.description, - genre = value.genre?.let(listOfStringsAdapter::encode), + genre = value.genre?.let(StringListColumnAdapter::encode), title = value.title, status = value.status, thumbnailUrl = value.thumbnailUrl, @@ -143,7 +142,7 @@ class MangaRepositoryImpl( coverLastModified = value.coverLastModified, dateAdded = value.dateAdded, mangaId = value.id, - updateStrategy = value.updateStrategy?.let(updateStrategyAdapter::encode), + updateStrategy = value.updateStrategy?.let(UpdateStrategyColumnAdapter::encode), ) } } diff --git a/data/src/main/java/tachiyomi/data/track/TrackMapper.kt b/data/src/main/java/tachiyomi/data/track/TrackMapper.kt index d08a8b9a52..e8978e25b7 100644 --- a/data/src/main/java/tachiyomi/data/track/TrackMapper.kt +++ b/data/src/main/java/tachiyomi/data/track/TrackMapper.kt @@ -2,7 +2,7 @@ package tachiyomi.data.track import tachiyomi.domain.track.model.Track -val trackMapper: (Long, Long, Long, Long, Long?, String, Double, Long, Long, Float, String, Long, Long) -> Track = +val trackMapper: (Long, Long, Long, Long, Long?, String, Double, Long, Long, Double, String, Long, Long) -> Track = { id, mangaId, syncId, remoteId, libraryId, title, lastChapterRead, totalChapters, status, score, remoteUrl, startDate, finishDate -> Track( id = id, diff --git a/data/src/main/sqldelight/tachiyomi/data/chapters.sq b/data/src/main/sqldelight/tachiyomi/data/chapters.sq index 029c36164e..ef22228853 100644 --- a/data/src/main/sqldelight/tachiyomi/data/chapters.sq +++ b/data/src/main/sqldelight/tachiyomi/data/chapters.sq @@ -1,5 +1,4 @@ import kotlin.Boolean; -import kotlin.Float; CREATE TABLE chapters( _id INTEGER NOT NULL PRIMARY KEY, @@ -10,7 +9,7 @@ CREATE TABLE chapters( read INTEGER AS Boolean NOT NULL, bookmark INTEGER AS Boolean NOT NULL, last_page_read INTEGER NOT NULL, - chapter_number REAL AS Float NOT NULL, + chapter_number REAL NOT NULL, source_order INTEGER NOT NULL, date_fetch INTEGER NOT NULL, date_upload INTEGER NOT NULL, diff --git a/data/src/main/sqldelight/tachiyomi/data/manga_sync.sq b/data/src/main/sqldelight/tachiyomi/data/manga_sync.sq index bfe1ec8ff1..bf8d0cba31 100644 --- a/data/src/main/sqldelight/tachiyomi/data/manga_sync.sq +++ b/data/src/main/sqldelight/tachiyomi/data/manga_sync.sq @@ -1,5 +1,3 @@ -import kotlin.Float; - CREATE TABLE manga_sync( _id INTEGER NOT NULL PRIMARY KEY, manga_id INTEGER NOT NULL, @@ -10,7 +8,7 @@ CREATE TABLE manga_sync( last_chapter_read REAL NOT NULL, total_chapters INTEGER NOT NULL, status INTEGER NOT NULL, - score REAL AS Float NOT NULL, + score REAL NOT NULL, remote_url TEXT NOT NULL, start_date INTEGER NOT NULL, finish_date INTEGER NOT NULL, diff --git a/domain/src/main/java/tachiyomi/domain/chapter/model/Chapter.kt b/domain/src/main/java/tachiyomi/domain/chapter/model/Chapter.kt index 9adee3f1bb..0029d67ead 100644 --- a/domain/src/main/java/tachiyomi/domain/chapter/model/Chapter.kt +++ b/domain/src/main/java/tachiyomi/domain/chapter/model/Chapter.kt @@ -11,7 +11,7 @@ data class Chapter( val url: String, val name: String, val dateUpload: Long, - val chapterNumber: Float, + val chapterNumber: Double, val scanlator: String?, val lastModifiedAt: Long, ) { @@ -30,7 +30,7 @@ data class Chapter( url = "", name = "", dateUpload = -1, - chapterNumber = -1f, + chapterNumber = -1.0, scanlator = null, lastModifiedAt = 0, ) diff --git a/domain/src/main/java/tachiyomi/domain/chapter/model/ChapterUpdate.kt b/domain/src/main/java/tachiyomi/domain/chapter/model/ChapterUpdate.kt index 7cfe4ab232..58cc88821e 100644 --- a/domain/src/main/java/tachiyomi/domain/chapter/model/ChapterUpdate.kt +++ b/domain/src/main/java/tachiyomi/domain/chapter/model/ChapterUpdate.kt @@ -11,7 +11,7 @@ data class ChapterUpdate( val url: String? = null, val name: String? = null, val dateUpload: Long? = null, - val chapterNumber: Float? = null, + val chapterNumber: Double? = null, val scanlator: String? = null, ) diff --git a/domain/src/main/java/tachiyomi/domain/chapter/service/ChapterRecognition.kt b/domain/src/main/java/tachiyomi/domain/chapter/service/ChapterRecognition.kt index 5c009f6d2e..bd8e2c7934 100644 --- a/domain/src/main/java/tachiyomi/domain/chapter/service/ChapterRecognition.kt +++ b/domain/src/main/java/tachiyomi/domain/chapter/service/ChapterRecognition.kt @@ -30,9 +30,9 @@ object ChapterRecognition { */ private val unwantedWhiteSpace = Regex("""\s(?=extra|special|omake)""") - fun parseChapterNumber(mangaTitle: String, chapterName: String, chapterNumber: Float? = null): Float { + fun parseChapterNumber(mangaTitle: String, chapterName: String, chapterNumber: Double? = null): Double { // If chapter number is known return. - if (chapterNumber != null && (chapterNumber == -2f || chapterNumber > -1f)) { + if (chapterNumber != null && (chapterNumber == -2.0 || chapterNumber > -1.0)) { return chapterNumber } @@ -57,7 +57,7 @@ object ChapterRecognition { // Take the first number encountered. number.find(name)?.let { return getChapterNumberFromMatch(it) } - return chapterNumber ?: -1f + return chapterNumber ?: -1.0 } /** @@ -65,9 +65,9 @@ object ChapterRecognition { * @param match result of regex * @return chapter number if found else null */ - private fun getChapterNumberFromMatch(match: MatchResult): Float { + private fun getChapterNumberFromMatch(match: MatchResult): Double { return match.let { - val initial = it.groups[1]?.value?.toFloat()!! + val initial = it.groups[1]?.value?.toDouble()!! val subChapterDecimal = it.groups[2]?.value val subChapterAlpha = it.groups[3]?.value val addition = checkForDecimal(subChapterDecimal, subChapterAlpha) diff --git a/domain/src/main/java/tachiyomi/domain/chapter/service/MissingChapters.kt b/domain/src/main/java/tachiyomi/domain/chapter/service/MissingChapters.kt index b5b728ff6b..55cce541b7 100644 --- a/domain/src/main/java/tachiyomi/domain/chapter/service/MissingChapters.kt +++ b/domain/src/main/java/tachiyomi/domain/chapter/service/MissingChapters.kt @@ -3,16 +3,16 @@ package tachiyomi.domain.chapter.service import tachiyomi.domain.chapter.model.Chapter import kotlin.math.floor -fun List.missingChaptersCount(): Int { +fun List.missingChaptersCount(): Int { if (this.isEmpty()) { return 0 } val chapters = this // Ignore unknown chapter numbers - .filterNot { it == -1f } + .filterNot { it == -1.0 } // Convert to integers, as we cannot check if 16.5 is missing - .map(Float::toInt) + .map(Double::toInt) // Only keep unique chapters so that -1 or 16 are not counted multiple times .distinct() .sorted() @@ -43,7 +43,7 @@ fun calculateChapterGap(higherChapter: Chapter?, lowerChapter: Chapter?): Int { return calculateChapterGap(higherChapter.chapterNumber, lowerChapter.chapterNumber) } -fun calculateChapterGap(higherChapterNumber: Float, lowerChapterNumber: Float): Int { - if (higherChapterNumber < 0f || lowerChapterNumber < 0f) return 0 +fun calculateChapterGap(higherChapterNumber: Double, lowerChapterNumber: Double): Int { + if (higherChapterNumber < 0.0 || lowerChapterNumber < 0.0) return 0 return floor(higherChapterNumber).toInt() - floor(lowerChapterNumber).toInt() - 1 } diff --git a/domain/src/main/java/tachiyomi/domain/history/model/HistoryWithRelations.kt b/domain/src/main/java/tachiyomi/domain/history/model/HistoryWithRelations.kt index 590544e932..68d93dd955 100644 --- a/domain/src/main/java/tachiyomi/domain/history/model/HistoryWithRelations.kt +++ b/domain/src/main/java/tachiyomi/domain/history/model/HistoryWithRelations.kt @@ -8,7 +8,7 @@ data class HistoryWithRelations( val chapterId: Long, val mangaId: Long, val title: String, - val chapterNumber: Float, + val chapterNumber: Double, val readAt: Date?, val readDuration: Long, val coverData: MangaCover, diff --git a/domain/src/main/java/tachiyomi/domain/track/model/Track.kt b/domain/src/main/java/tachiyomi/domain/track/model/Track.kt index e3af5b7f7a..91ac2c833c 100644 --- a/domain/src/main/java/tachiyomi/domain/track/model/Track.kt +++ b/domain/src/main/java/tachiyomi/domain/track/model/Track.kt @@ -10,7 +10,7 @@ data class Track( val lastChapterRead: Double, val totalChapters: Long, val status: Long, - val score: Float, + val score: Double, val remoteUrl: String, val startDate: Long, val finishDate: Long, diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index a6801f17fd..c1070683d6 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -80,7 +80,6 @@ leakcanary-plumber = { module = "com.squareup.leakcanary:plumber-android", versi sqldelight-android-driver = { module = "app.cash.sqldelight:android-driver", version.ref = "sqldelight" } sqldelight-coroutines = { module = "app.cash.sqldelight:coroutines-extensions-jvm", version.ref = "sqldelight" } sqldelight-android-paging = { module = "app.cash.sqldelight:androidx-paging3-extensions", version.ref = "sqldelight" } -sqldelight-primitive-adapters = { module = "app.cash.sqldelight:primitive-adapters", version.ref = "sqldelight" } sqldelight-dialects-sql = { module = "app.cash.sqldelight:sqlite-3-38-dialect", version.ref = "sqldelight" } sqldelight-gradle = { module = "app.cash.sqldelight:gradle-plugin", version.ref = "sqldelight" } @@ -101,7 +100,7 @@ js-engine = ["quickjs-android"] sqlite = ["sqlite-framework", "sqlite-ktx", "sqlite-android"] coil = ["coil-core", "coil-gif", "coil-compose"] shizuku = ["shizuku-api", "shizuku-provider"] -sqldelight = ["sqldelight-android-driver", "sqldelight-coroutines", "sqldelight-android-paging", "sqldelight-primitive-adapters"] +sqldelight = ["sqldelight-android-driver", "sqldelight-coroutines", "sqldelight-android-paging"] voyager = ["voyager-navigator", "voyager-tab-navigator", "voyager-transitions"] richtext = ["richtext-commonmark", "richtext-m3"] test = ["junit", "kotest-assertions", "mockk"] \ No newline at end of file diff --git a/source-local/src/androidMain/kotlin/tachiyomi/source/local/LocalSource.kt b/source-local/src/androidMain/kotlin/tachiyomi/source/local/LocalSource.kt index 76633cbda9..403419df25 100644 --- a/source-local/src/androidMain/kotlin/tachiyomi/source/local/LocalSource.kt +++ b/source-local/src/androidMain/kotlin/tachiyomi/source/local/LocalSource.kt @@ -264,7 +264,9 @@ actual class LocalSource( chapterFile.nameWithoutExtension } date_upload = chapterFile.lastModified() - chapter_number = ChapterRecognition.parseChapterNumber(manga.title, this.name, this.chapter_number) + chapter_number = ChapterRecognition + .parseChapterNumber(manga.title, this.name, this.chapter_number.toDouble()) + .toFloat() val format = Format.valueOf(chapterFile) if (format is Format.Epub) {