MANGA Plus: Add preference to remove the chapter number from the name and add the site name as scanlator (#4965)

* asasdsa

* more

* this is useless
This commit is contained in:
bapeey 2024-09-08 01:42:35 -05:00 committed by GitHub
parent ca54fbeb02
commit 8ddac0df2b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 29 additions and 10 deletions

View File

@ -17,6 +17,8 @@ schedule_monthly=Monthly
schedule_other=Other
schedule_trimonthly=Trimonthly
schedule_weekly=Weekly
subtitle_only=Show subtitle only
subtitle_only_summary=Removes the redundant chapter number from the chapter name.
serialization=Serialization: %s
split_double_pages=Split double pages
split_double_pages_summary=Only a few titles supports disabling this setting.

View File

@ -1,7 +1,7 @@
ext {
extName = 'MANGA Plus by SHUEISHA'
extClass = '.MangaPlusFactory'
extVersionCode = 51
extVersionCode = 52
}
apply from: "$rootDir/common.gradle"

View File

@ -284,10 +284,11 @@ class MangaPlus(
}
val titleDetailView = result.success.titleDetailView!!
val subtitleOnly = preferences.subtitleOnly()
return titleDetailView.chapterList
.filterNot(Chapter::isExpired)
.map(Chapter::toSChapter)
.map { it.toSChapter(subtitleOnly) }
.reversed()
}
@ -303,8 +304,8 @@ class MangaPlus(
private fun pageListRequest(chapterId: String): Request {
val url = "$API_URL/manga_viewer".toHttpUrl().newBuilder()
.addQueryParameter("chapter_id", chapterId)
.addQueryParameter("split", if (preferences.splitImages) "yes" else "no")
.addQueryParameter("img_quality", preferences.imageQuality)
.addQueryParameter("split", if (preferences.splitImages()) "yes" else "no")
.addQueryParameter("img_quality", preferences.imageQuality())
.addQueryParameter("format", "json")
.toString()
@ -355,8 +356,16 @@ class MangaPlus(
setDefaultValue(SPLIT_PREF_DEFAULT_VALUE)
}
val titlePref = SwitchPreferenceCompat(screen.context).apply {
key = "${SUBTITLE_ONLY_KEY}_$lang"
title = intl["subtitle_only"]
summary = intl["subtitle_only_summary"]
setDefaultValue(SUBTITLE_ONLY_DEFAULT_VALUE)
}
screen.addPreference(qualityPref)
screen.addPreference(splitPref)
screen.addPreference(titlePref)
}
private fun imageIntercept(chain: Interceptor.Chain): Response {
@ -412,11 +421,11 @@ class MangaPlus(
json.decodeFromString(body.string())
}
private val SharedPreferences.imageQuality: String
get() = getString("${QUALITY_PREF_KEY}_$lang", QUALITY_PREF_DEFAULT_VALUE)!!
private fun SharedPreferences.imageQuality(): String = getString("${QUALITY_PREF_KEY}_$lang", QUALITY_PREF_DEFAULT_VALUE)!!
private val SharedPreferences.splitImages: Boolean
get() = getBoolean("${SPLIT_PREF_KEY}_$lang", SPLIT_PREF_DEFAULT_VALUE)
private fun SharedPreferences.splitImages(): Boolean = getBoolean("${SPLIT_PREF_KEY}_$lang", SPLIT_PREF_DEFAULT_VALUE)
private fun SharedPreferences.subtitleOnly(): Boolean = getBoolean("${SUBTITLE_ONLY_KEY}_$lang", SUBTITLE_ONLY_DEFAULT_VALUE)
companion object {
const val PREFIX_ID_SEARCH = "id:"
@ -437,6 +446,9 @@ private val QUALITY_PREF_DEFAULT_VALUE = QUALITY_PREF_ENTRY_VALUES[2]
private const val SPLIT_PREF_KEY = "splitImage"
private const val SPLIT_PREF_DEFAULT_VALUE = true
private const val SUBTITLE_ONLY_KEY = "subtitleOnly"
private const val SUBTITLE_ONLY_DEFAULT_VALUE = false
private const val NOT_FOUND_SUBJECT = "Not Found"
private const val TITLE_THUMBNAIL_PATH = "title_thumbnail_portrait_list"

View File

@ -314,11 +314,16 @@ class Chapter(
val isExpired: Boolean
get() = subTitle == null
fun toSChapter(): SChapter = SChapter.create().apply {
name = "${this@Chapter.name} - $subTitle"
fun toSChapter(subtitlePref: Boolean): SChapter = SChapter.create().apply {
name = if (subtitlePref && subTitle != null) {
subTitle
} else {
"${this@Chapter.name} - $subTitle"
}
date_upload = 1000L * startTimeStamp
url = "#/viewer/$chapterId"
chapter_number = this@Chapter.name.substringAfter("#").toFloatOrNull() ?: -1f
scanlator = "MANGA Plus"
}
}