From c42cf60d417771b3a76d8e97ea6e6e1b619f244c Mon Sep 17 00:00:00 2001 From: e-shl <35057681+e-shl@users.noreply.github.com> Date: Sat, 19 Feb 2022 04:12:02 +0500 Subject: [PATCH] [RU]Remanga AgeLimit warning & language option (#10861) * [RU]Remanga AgeLimit authorization warning * [RU]Remanga option for changing cover language --- src/ru/remanga/build.gradle | 2 +- .../tachiyomi/extension/ru/remanga/Remanga.kt | 35 +++++++++++++++---- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/ru/remanga/build.gradle b/src/ru/remanga/build.gradle index 8d4395ce6..875483f3f 100644 --- a/src/ru/remanga/build.gradle +++ b/src/ru/remanga/build.gradle @@ -6,7 +6,7 @@ ext { extName = 'Remanga' pkgNameSuffix = 'ru.remanga' extClass = '.Remanga' - extVersionCode = 45 + extVersionCode = 46 } dependencies { diff --git a/src/ru/remanga/src/eu/kanade/tachiyomi/extension/ru/remanga/Remanga.kt b/src/ru/remanga/src/eu/kanade/tachiyomi/extension/ru/remanga/Remanga.kt index d511784ad..4384c3b06 100644 --- a/src/ru/remanga/src/eu/kanade/tachiyomi/extension/ru/remanga/Remanga.kt +++ b/src/ru/remanga/src/eu/kanade/tachiyomi/extension/ru/remanga/Remanga.kt @@ -122,6 +122,7 @@ class Remanga : ConfigurableSource, HttpSource() { val mangas = page.content.map { it.title.toSManga() } + return MangasPage(mangas, page.props.page < page.props.total_pages) } else { val page = json.decodeFromString>(response.body!!.string()) @@ -139,7 +140,7 @@ class Remanga : ConfigurableSource, HttpSource() { private fun LibraryDto.toSManga(): SManga = SManga.create().apply { // Do not change the title name to ensure work with a multilingual catalog! - title = en_name + title = if (isEng.equals("rus")) rus_name else en_name url = "/api/titles/$dir/" thumbnail_url = if (img.high.isNotEmpty()) { baseUrl + img.high @@ -186,6 +187,9 @@ class Remanga : ConfigurableSource, HttpSource() { } is AgeList -> filter.state.forEach { age -> if (age.state) { + if ((age.id == "2") and (USER_ID == "")) { + throw Exception("Для просмотра 18+ контента необходима авторизация через WebView") + } url.addQueryParameter("age_limit", age.id) } } @@ -197,7 +201,7 @@ class Remanga : ConfigurableSource, HttpSource() { is MyList -> { if (filter.state > 0) { if (USER_ID == "") { - throw Exception("Пользователь не найден") + throw Exception("Пользователь не найден, необходима авторизация через WebView") } val TypeQ = getMyList()[filter.state].id val UserProfileUrl = "$baseUrl/api/users/$USER_ID/bookmarks/?type=$TypeQ&page=$page".toHttpUrl().newBuilder() @@ -252,14 +256,15 @@ class Remanga : ConfigurableSource, HttpSource() { val o = this return SManga.create().apply { // Do not change the title name to ensure work with a multilingual catalog! - title = en_name + title = if (isEng.equals("rus")) rus_name else en_name url = "/api/titles/$dir/" thumbnail_url = baseUrl + img.high var altName = "" if (another_name.isNotEmpty()) { altName = "Альтернативные названия:\n" + another_name + "\n\n" } - this.description = rus_name + "\n" + ratingStar + " " + ratingValue + " (голосов: " + count_rating + ")\n" + altName + Jsoup.parse(o.description).text() + val mediaNameLanguage = if (isEng.equals("rus")) en_name else rus_name + this.description = mediaNameLanguage + "\n" + ratingStar + " " + ratingValue + " (голосов: " + count_rating + ")\n" + altName + Jsoup.parse(o.description).text() genre = parseType(type) + ", " + parseAge(age_limit) + ", " + (genres + categories).joinToString { it.name } status = parseStatus(o.status.id) } @@ -279,7 +284,7 @@ class Remanga : ConfigurableSource, HttpSource() { } } .map { response -> - (if (warnLogin) manga.apply { description = "Авторизуйтесь для просмотра списка глав" } else mangaDetailsParse(response)) + (if (warnLogin) manga.apply { description = "Для просмотра 18+ контента необходима авторизация через WebView" } else mangaDetailsParse(response)) .apply { initialized = true } @@ -642,7 +647,7 @@ class Remanga : ConfigurableSource, HttpSource() { MyListUnit("Брошено ", "3"), MyListUnit("Не интересно ", "5") ) - + private var isEng: String? = preferences.getString(LANGUAGE_PREF, "eng") override fun setupPreferenceScreen(screen: androidx.preference.PreferenceScreen) { val domainPref = ListPreference(screen.context).apply { key = DOMAIN_PREF @@ -663,6 +668,20 @@ class Remanga : ConfigurableSource, HttpSource() { } } } + val titleLanguagePref = ListPreference(screen.context).apply { + key = LANGUAGE_PREF + title = LANGUAGE_PREF_Title + entries = arrayOf("Английский", "Русский") + entryValues = arrayOf("eng", "rus") + summary = "%s" + setDefaultValue("eng") + setOnPreferenceChangeListener { _, newValue -> + val titleLanguage = preferences.edit().putString(LANGUAGE_PREF, newValue as String).commit() + val warning = "Если язык обложки не изменился очистите базу данных в приложении (Настройки -> Дополнительно -> Очистить базу данных)" + Toast.makeText(screen.context, warning, Toast.LENGTH_LONG).show() + titleLanguage + } + } val paidChapterShow = androidx.preference.CheckBoxPreference(screen.context).apply { key = PAID_PREF title = PAID_PREF_Title @@ -686,6 +705,7 @@ class Remanga : ConfigurableSource, HttpSource() { } } screen.addPreference(domainPref) + screen.addPreference(titleLanguagePref) screen.addPreference(paidChapterShow) screen.addPreference(bookmarksHide) } @@ -702,6 +722,9 @@ class Remanga : ConfigurableSource, HttpSource() { private const val DOMAIN_PREF = "REMangaDomain" private const val DOMAIN_PREF_Title = "Выбор домена" + private const val LANGUAGE_PREF = "ReMangaTitleLanguage" + private const val LANGUAGE_PREF_Title = "Выбор языка на обложке" + private const val PAID_PREF = "PaidChapter" private const val PAID_PREF_Title = "Показывать платные главы"