Reader now defaults to webtoon style for webtoons

This commit is contained in:
Jay 2020-02-23 00:32:30 -08:00
parent bd9633dd08
commit 10674890a7
7 changed files with 35 additions and 32 deletions

View File

@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.data.backup.serializer
import com.github.salomonbrys.kotson.typeAdapter
import com.google.gson.TypeAdapter
import eu.kanade.tachiyomi.data.database.models.MangaImpl
import kotlin.math.max
/**
* JSON Serializer used to write / read [MangaImpl] to / from json
@ -16,7 +17,7 @@ object MangaTypeAdapter {
value(it.url)
value(it.originalTitle())
value(it.source)
value(it.viewer)
value(max(0, it.viewer))
value(it.chapter_flags)
endArray()
}

View File

@ -1,30 +1,9 @@
package eu.kanade.tachiyomi.data.database.models
import eu.kanade.tachiyomi.source.SourceManager
import uy.kohesive.injekt.injectLazy
import java.util.Locale
class LibraryManga : MangaImpl() {
var unread: Int = 0
var category: Int = 0
fun mangaType(): Int {
val sourceManager:SourceManager by injectLazy()
return if (currentGenres()?.split(",")?.any
{ tag ->
val trimmedTag = tag.trim().toLowerCase(Locale.getDefault())
trimmedTag == "long strip" || trimmedTag == "manwha"
} == true ||
sourceManager.getOrStub(source).name.contains("webtoon", true))
MANWHA
else MANGA
}
companion object {
const val MANGA = 1
const val MANWHA = 2
}
}

View File

@ -1,6 +1,9 @@
package eu.kanade.tachiyomi.data.database.models
import eu.kanade.tachiyomi.source.SourceManager
import eu.kanade.tachiyomi.source.model.SManga
import uy.kohesive.injekt.injectLazy
import java.util.Locale
interface Manga : SManga {
@ -30,6 +33,19 @@ interface Manga : SManga {
return chapter_flags and SORT_MASK == SORT_DESC
}
fun mangaType(): Int {
val sourceManager: SourceManager by injectLazy()
return if (currentGenres()?.split(",")?.any
{ tag ->
val trimmedTag = tag.trim().toLowerCase(Locale.US)
trimmedTag == "long strip" || trimmedTag == "manwha" ||
trimmedTag.contains("webtoon")
} == true ||
sourceManager.getOrStub(source).name.contains("webtoon", true))
TYPE_MANWHA
else TYPE_MANGA
}
// Used to display the chapter's title one way or another
var displayMode: Int
get() = chapter_flags and DISPLAY_MASK
@ -80,6 +96,9 @@ interface Manga : SManga {
const val DISPLAY_NUMBER = 0x00100000
const val DISPLAY_MASK = 0x00100000
const val TYPE_MANGA = 1
const val TYPE_MANWHA = 2
fun create(source: Long): Manga = MangaImpl().apply {
this.source = source
}

View File

@ -4,8 +4,6 @@ import eu.kanade.tachiyomi.data.download.DownloadManager
import eu.kanade.tachiyomi.data.download.DownloadProvider
import eu.kanade.tachiyomi.source.model.SManga
import uy.kohesive.injekt.injectLazy
import kotlin.collections.MutableMap
import kotlin.collections.mutableMapOf
import kotlin.collections.set
open class MangaImpl : Manga {
@ -36,7 +34,7 @@ open class MangaImpl : Manga {
override var initialized: Boolean = false
override var viewer: Int = 0
override var viewer: Int = -1
override var chapter_flags: Int = 0

View File

@ -169,11 +169,11 @@ class LibraryPresenter(
return@f false
if (filterUnread == STATE_REALLY_EXCLUDE && item.manga.unread > 0) return@f false
if (filterMangaType == LibraryManga.MANGA &&
item.manga.mangaType() == LibraryManga.MANWHA)
if (filterMangaType == Manga.TYPE_MANGA &&
item.manga.mangaType() == Manga.TYPE_MANWHA)
return@f false
if ((filterMangaType == LibraryManga.MANWHA) &&
item.manga.mangaType() == LibraryManga.MANGA) return@f false
if ((filterMangaType == Manga.TYPE_MANWHA) &&
item.manga.mangaType() == Manga.TYPE_MANGA) return@f false
if (filterCompleted == STATE_INCLUDE && item.manga.status != SManga.COMPLETED)

View File

@ -20,7 +20,7 @@ import com.google.android.material.bottomsheet.BottomSheetBehavior
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.database.DatabaseHelper
import eu.kanade.tachiyomi.data.database.models.Category
import eu.kanade.tachiyomi.data.database.models.LibraryManga
import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.data.preference.getOrDefault
import eu.kanade.tachiyomi.data.track.TrackManager
@ -372,7 +372,7 @@ class SortFilterBottomSheet @JvmOverloads constructor(context: Context, attrs: A
GlobalScope.launch(Dispatchers.IO, CoroutineStart.DEFAULT) {
val db:DatabaseHelper by injectLazy()
val librryManga = db.getLibraryMangas().executeAsBlocking()
if (librryManga.any { it.mangaType() == LibraryManga.MANWHA }) {
if (librryManga.any { it.mangaType() == Manga.TYPE_MANWHA }) {
launchUI {
val mangaType = inflate(R.layout.filter_buttons) as FilterTagGroup
mangaType.setup(

View File

@ -33,7 +33,7 @@ import timber.log.Timber
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import java.io.File
import java.util.*
import java.util.Date
import java.util.concurrent.TimeUnit
/**
@ -394,6 +394,12 @@ class ReaderPresenter(
*/
fun getMangaViewer(): Int {
val manga = manga ?: return preferences.defaultViewer()
if (manga.viewer == -1) {
val type =
if (manga.mangaType() == Manga.TYPE_MANWHA) ReaderActivity.WEBTOON
else 0
setMangaViewer(type)
}
return if (manga.viewer == 0) preferences.defaultViewer() else manga.viewer
}