[RU]Remanga AgeLimit warning & language option (#10861)

* [RU]Remanga AgeLimit authorization warning

* [RU]Remanga option for changing cover language
This commit is contained in:
e-shl 2022-02-19 04:12:02 +05:00 committed by GitHub
parent 06c12928cc
commit c42cf60d41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 7 deletions

View File

@ -6,7 +6,7 @@ ext {
extName = 'Remanga'
pkgNameSuffix = 'ru.remanga'
extClass = '.Remanga'
extVersionCode = 45
extVersionCode = 46
}
dependencies {

View File

@ -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<PageWrapperDto<LibraryDto>>(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 = "Показывать платные главы"