mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-14 05:15:10 +01:00
Reader now defaults to webtoon style for webtoons
This commit is contained in:
parent
bd9633dd08
commit
10674890a7
@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.data.backup.serializer
|
|||||||
import com.github.salomonbrys.kotson.typeAdapter
|
import com.github.salomonbrys.kotson.typeAdapter
|
||||||
import com.google.gson.TypeAdapter
|
import com.google.gson.TypeAdapter
|
||||||
import eu.kanade.tachiyomi.data.database.models.MangaImpl
|
import eu.kanade.tachiyomi.data.database.models.MangaImpl
|
||||||
|
import kotlin.math.max
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JSON Serializer used to write / read [MangaImpl] to / from json
|
* JSON Serializer used to write / read [MangaImpl] to / from json
|
||||||
@ -16,7 +17,7 @@ object MangaTypeAdapter {
|
|||||||
value(it.url)
|
value(it.url)
|
||||||
value(it.originalTitle())
|
value(it.originalTitle())
|
||||||
value(it.source)
|
value(it.source)
|
||||||
value(it.viewer)
|
value(max(0, it.viewer))
|
||||||
value(it.chapter_flags)
|
value(it.chapter_flags)
|
||||||
endArray()
|
endArray()
|
||||||
}
|
}
|
||||||
|
@ -1,30 +1,9 @@
|
|||||||
package eu.kanade.tachiyomi.data.database.models
|
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() {
|
class LibraryManga : MangaImpl() {
|
||||||
|
|
||||||
var unread: Int = 0
|
var unread: Int = 0
|
||||||
|
|
||||||
var category: 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
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -1,6 +1,9 @@
|
|||||||
package eu.kanade.tachiyomi.data.database.models
|
package eu.kanade.tachiyomi.data.database.models
|
||||||
|
|
||||||
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
import eu.kanade.tachiyomi.source.model.SManga
|
import eu.kanade.tachiyomi.source.model.SManga
|
||||||
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
import java.util.Locale
|
||||||
|
|
||||||
interface Manga : SManga {
|
interface Manga : SManga {
|
||||||
|
|
||||||
@ -30,6 +33,19 @@ interface Manga : SManga {
|
|||||||
return chapter_flags and SORT_MASK == SORT_DESC
|
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
|
// Used to display the chapter's title one way or another
|
||||||
var displayMode: Int
|
var displayMode: Int
|
||||||
get() = chapter_flags and DISPLAY_MASK
|
get() = chapter_flags and DISPLAY_MASK
|
||||||
@ -80,6 +96,9 @@ interface Manga : SManga {
|
|||||||
const val DISPLAY_NUMBER = 0x00100000
|
const val DISPLAY_NUMBER = 0x00100000
|
||||||
const val DISPLAY_MASK = 0x00100000
|
const val DISPLAY_MASK = 0x00100000
|
||||||
|
|
||||||
|
const val TYPE_MANGA = 1
|
||||||
|
const val TYPE_MANWHA = 2
|
||||||
|
|
||||||
fun create(source: Long): Manga = MangaImpl().apply {
|
fun create(source: Long): Manga = MangaImpl().apply {
|
||||||
this.source = source
|
this.source = source
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,6 @@ import eu.kanade.tachiyomi.data.download.DownloadManager
|
|||||||
import eu.kanade.tachiyomi.data.download.DownloadProvider
|
import eu.kanade.tachiyomi.data.download.DownloadProvider
|
||||||
import eu.kanade.tachiyomi.source.model.SManga
|
import eu.kanade.tachiyomi.source.model.SManga
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
import kotlin.collections.MutableMap
|
|
||||||
import kotlin.collections.mutableMapOf
|
|
||||||
import kotlin.collections.set
|
import kotlin.collections.set
|
||||||
|
|
||||||
open class MangaImpl : Manga {
|
open class MangaImpl : Manga {
|
||||||
@ -36,7 +34,7 @@ open class MangaImpl : Manga {
|
|||||||
|
|
||||||
override var initialized: Boolean = false
|
override var initialized: Boolean = false
|
||||||
|
|
||||||
override var viewer: Int = 0
|
override var viewer: Int = -1
|
||||||
|
|
||||||
override var chapter_flags: Int = 0
|
override var chapter_flags: Int = 0
|
||||||
|
|
||||||
|
@ -169,11 +169,11 @@ class LibraryPresenter(
|
|||||||
return@f false
|
return@f false
|
||||||
if (filterUnread == STATE_REALLY_EXCLUDE && item.manga.unread > 0) return@f false
|
if (filterUnread == STATE_REALLY_EXCLUDE && item.manga.unread > 0) return@f false
|
||||||
|
|
||||||
if (filterMangaType == LibraryManga.MANGA &&
|
if (filterMangaType == Manga.TYPE_MANGA &&
|
||||||
item.manga.mangaType() == LibraryManga.MANWHA)
|
item.manga.mangaType() == Manga.TYPE_MANWHA)
|
||||||
return@f false
|
return@f false
|
||||||
if ((filterMangaType == LibraryManga.MANWHA) &&
|
if ((filterMangaType == Manga.TYPE_MANWHA) &&
|
||||||
item.manga.mangaType() == LibraryManga.MANGA) return@f false
|
item.manga.mangaType() == Manga.TYPE_MANGA) return@f false
|
||||||
|
|
||||||
|
|
||||||
if (filterCompleted == STATE_INCLUDE && item.manga.status != SManga.COMPLETED)
|
if (filterCompleted == STATE_INCLUDE && item.manga.status != SManga.COMPLETED)
|
||||||
|
@ -20,7 +20,7 @@ import com.google.android.material.bottomsheet.BottomSheetBehavior
|
|||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||||
import eu.kanade.tachiyomi.data.database.models.Category
|
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.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||||
import eu.kanade.tachiyomi.data.track.TrackManager
|
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) {
|
GlobalScope.launch(Dispatchers.IO, CoroutineStart.DEFAULT) {
|
||||||
val db:DatabaseHelper by injectLazy()
|
val db:DatabaseHelper by injectLazy()
|
||||||
val librryManga = db.getLibraryMangas().executeAsBlocking()
|
val librryManga = db.getLibraryMangas().executeAsBlocking()
|
||||||
if (librryManga.any { it.mangaType() == LibraryManga.MANWHA }) {
|
if (librryManga.any { it.mangaType() == Manga.TYPE_MANWHA }) {
|
||||||
launchUI {
|
launchUI {
|
||||||
val mangaType = inflate(R.layout.filter_buttons) as FilterTagGroup
|
val mangaType = inflate(R.layout.filter_buttons) as FilterTagGroup
|
||||||
mangaType.setup(
|
mangaType.setup(
|
||||||
|
@ -33,7 +33,7 @@ import timber.log.Timber
|
|||||||
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.File
|
import java.io.File
|
||||||
import java.util.*
|
import java.util.Date
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -394,6 +394,12 @@ class ReaderPresenter(
|
|||||||
*/
|
*/
|
||||||
fun getMangaViewer(): Int {
|
fun getMangaViewer(): Int {
|
||||||
val manga = manga ?: return preferences.defaultViewer()
|
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
|
return if (manga.viewer == 0) preferences.defaultViewer() else manga.viewer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user