From f8ab0d3f2fb5b52ea31addb67724c5adebaf2864 Mon Sep 17 00:00:00 2001 From: bapeey <90949336+bapeey@users.noreply.github.com> Date: Sun, 8 Sep 2024 01:42:35 -0500 Subject: [PATCH] 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 --- .../assets/i18n/messages_en.properties | 2 ++ src/all/mangaplus/build.gradle | 2 +- .../extension/all/mangaplus/MangaPlus.kt | 26 ++++++++++++++----- .../extension/all/mangaplus/MangaPlusDto.kt | 9 +++++-- 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/all/mangaplus/assets/i18n/messages_en.properties b/src/all/mangaplus/assets/i18n/messages_en.properties index 75adbec29..828cacce4 100644 --- a/src/all/mangaplus/assets/i18n/messages_en.properties +++ b/src/all/mangaplus/assets/i18n/messages_en.properties @@ -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. diff --git a/src/all/mangaplus/build.gradle b/src/all/mangaplus/build.gradle index da47b3ce8..04b6a7990 100644 --- a/src/all/mangaplus/build.gradle +++ b/src/all/mangaplus/build.gradle @@ -1,7 +1,7 @@ ext { extName = 'MANGA Plus by SHUEISHA' extClass = '.MangaPlusFactory' - extVersionCode = 52 + extVersionCode = 53 } apply from: "$rootDir/common.gradle" diff --git a/src/all/mangaplus/src/eu/kanade/tachiyomi/extension/all/mangaplus/MangaPlus.kt b/src/all/mangaplus/src/eu/kanade/tachiyomi/extension/all/mangaplus/MangaPlus.kt index 0ae9c4482..b17f18536 100644 --- a/src/all/mangaplus/src/eu/kanade/tachiyomi/extension/all/mangaplus/MangaPlus.kt +++ b/src/all/mangaplus/src/eu/kanade/tachiyomi/extension/all/mangaplus/MangaPlus.kt @@ -289,9 +289,10 @@ class MangaPlus( } val titleDetailView = result.success.titleDetailView!! + val subtitleOnly = preferences.subtitleOnly() return titleDetailView.chapterList - .map(Chapter::toSChapter) + .map { it.toSChapter(subtitleOnly) } .reversed() } @@ -307,8 +308,8 @@ class MangaPlus( private fun pageListRequest(chapterId: String): Request { val url = "$APP_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("ticket_reading", "no") .addQueryParameter("free_reading", "yes") .addQueryParameter("subscription_reading", "no") @@ -378,8 +379,16 @@ class MangaPlus( key = "${VER_PREF_KEY}_$lang", ) + 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 PreferenceScreen.addEditTextPreference( @@ -494,11 +503,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) private val SharedPreferences.appVersion: String? get() = getString("${VER_PREF_KEY}_$lang", VER_PREF_DEFAULT_VALUE) @@ -526,6 +535,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 VER_PREF_KEY = "appVer" private const val VER_PREF_DEFAULT_VALUE = "" private const val SECRET_PREF_KEY = "accountSecret" diff --git a/src/all/mangaplus/src/eu/kanade/tachiyomi/extension/all/mangaplus/MangaPlusDto.kt b/src/all/mangaplus/src/eu/kanade/tachiyomi/extension/all/mangaplus/MangaPlusDto.kt index 6d65b6825..5ca3d179c 100644 --- a/src/all/mangaplus/src/eu/kanade/tachiyomi/extension/all/mangaplus/MangaPlusDto.kt +++ b/src/all/mangaplus/src/eu/kanade/tachiyomi/extension/all/mangaplus/MangaPlusDto.kt @@ -322,11 +322,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" } }