Allow manhwas to be read in non webtoon formats

but only them. Webtoons will still force webtoon mode

It's about time for this anyway, not all sources can be mangadex but the original goal has been reached: force users libraries to webtoon for manhwa

Now they can be free...ish

Also some changes to the logic for series type
This commit is contained in:
Jays2Kings 2021-04-14 20:37:00 -04:00
parent 5c741e2fc5
commit 71e6c3132f
3 changed files with 19 additions and 4 deletions

View File

@ -86,6 +86,11 @@ interface Manga : SManga {
isComicSource(sourceName)
) {
TYPE_COMIC
} else if (sourceName.contains("webtoon", true) &&
currentTags.none { tag -> isManhuaTag(tag) } &&
currentTags.none { tag -> isManhwaTag(tag) }
) {
TYPE_WEBTOON
} else if (currentTags.any { tag -> isManhuaTag(tag) } || sourceName.contains("manhua", true)
) {
TYPE_MANHUA
@ -107,7 +112,7 @@ interface Manga : SManga {
val currentTags = genre?.split(",")?.map { it.trim().toLowerCase(Locale.US) }
return if (currentTags?.any
{ tag ->
tag == "long strip" || tag == "manhwa" || tag.contains("webtoon")
isManhwaTag(tag) || tag.contains("webtoon")
} == true || isWebtoonSource(sourceName)
) {
ReaderActivity.WEBTOON
@ -130,6 +135,13 @@ interface Manga : SManga {
return tag in listOf("manhua", "маньхуа", "cn", "hk", "zh-Hans", "zh-Hant") || tag.startsWith("chinese")
}
fun isLongStrip(): Boolean {
val currentTags =
genre?.split(",")?.map { it.trim().toLowerCase(Locale.US) } ?: emptyList()
val sourceName by lazy { Injekt.get<SourceManager>().getOrStub(source).name }
return currentTags.any { it == "long strip" } || sourceName.contains("webtoon", true)
}
fun isManhwaTag(tag: String): Boolean {
return tag in listOf("long strip", "manhwa", "манхва", "kr") || tag.startsWith("korean")
}
@ -140,7 +152,7 @@ interface Manga : SManga {
fun isWebtoonSource(sourceName: String): Boolean {
return sourceName.contains("webtoon", true) ||
sourceName.contains("manwha", true) ||
sourceName.contains("manhwa", true) ||
sourceName.contains("toonily", true)
}

View File

@ -781,7 +781,7 @@ class ReaderActivity :
),
4000
) {
if (mangaViewer != WEBTOON) setAction(R.string.use_default) {
if (presenter.manga?.isLongStrip() != true) setAction(R.string.use_default) {
presenter.setMangaViewer(0)
}
}

View File

@ -560,7 +560,10 @@ class ReaderPresenter(
val default = preferences.defaultViewer()
val manga = manga ?: return default
val readerType = manga.defaultReaderType()
if (manga.viewer == -1 || (readerType == ReaderActivity.WEBTOON && readerType != manga.viewer)) {
if (manga.viewer == -1 ||
// Force webtoon mode
(manga.isLongStrip() && readerType != manga.viewer)
) {
val cantSwitchToLTR =
(readerType == ReaderActivity.LEFT_TO_RIGHT && default != ReaderActivity.RIGHT_TO_LEFT)
manga.viewer = if (cantSwitchToLTR) 0 else readerType