HentaiVN.plus: update domain, add override URL setting (#5073)
This commit is contained in:
parent
0e08a7c946
commit
99605056e3
|
@ -2,8 +2,8 @@ ext {
|
||||||
extName = 'HentaiVN.plus'
|
extName = 'HentaiVN.plus'
|
||||||
extClass = '.HentaiVNPlus'
|
extClass = '.HentaiVNPlus'
|
||||||
themePkg = 'madara'
|
themePkg = 'madara'
|
||||||
baseUrl = 'https://hentaivn.cafe'
|
baseUrl = 'https://hentaivn.fit'
|
||||||
overrideVersionCode = 1
|
overrideVersionCode = 2
|
||||||
isNsfw = true
|
isNsfw = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,70 @@
|
||||||
package eu.kanade.tachiyomi.extension.vi.hentaivnplus
|
package eu.kanade.tachiyomi.extension.vi.hentaivnplus
|
||||||
|
|
||||||
|
import android.app.Application
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import android.widget.Toast
|
||||||
|
import androidx.preference.PreferenceScreen
|
||||||
import eu.kanade.tachiyomi.multisrc.madara.Madara
|
import eu.kanade.tachiyomi.multisrc.madara.Madara
|
||||||
|
import eu.kanade.tachiyomi.source.ConfigurableSource
|
||||||
|
import uy.kohesive.injekt.Injekt
|
||||||
|
import uy.kohesive.injekt.api.get
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
|
||||||
class HentaiVNPlus : Madara(
|
class HentaiVNPlus :
|
||||||
"HentaiVN.plus",
|
Madara(
|
||||||
"https://hentaivn.cafe",
|
"HentaiVN.plus",
|
||||||
"vi",
|
"https://hentaivn.fit",
|
||||||
dateFormat = SimpleDateFormat("MM/dd/yyyy", Locale.ROOT),
|
"vi",
|
||||||
) {
|
dateFormat = SimpleDateFormat("MM/dd/yyyy", Locale.ROOT),
|
||||||
|
),
|
||||||
|
ConfigurableSource {
|
||||||
override val useLoadMoreRequest = LoadMoreStrategy.Never
|
override val useLoadMoreRequest = LoadMoreStrategy.Never
|
||||||
override val useNewChapterEndpoint = false
|
override val useNewChapterEndpoint = false
|
||||||
|
|
||||||
override val mangaSubString = "truyen-hentai"
|
override val mangaSubString = "truyen-hentai"
|
||||||
|
|
||||||
|
private val preferences: SharedPreferences =
|
||||||
|
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
||||||
|
|
||||||
|
init {
|
||||||
|
preferences.getString(DEFAULT_BASE_URL_PREF, null).let { prefDefaultBaseUrl ->
|
||||||
|
if (prefDefaultBaseUrl != super.baseUrl) {
|
||||||
|
preferences.edit()
|
||||||
|
.putString(BASE_URL_PREF, super.baseUrl)
|
||||||
|
.putString(DEFAULT_BASE_URL_PREF, super.baseUrl)
|
||||||
|
.apply()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override val baseUrl by lazy { getPrefBaseUrl() }
|
||||||
|
|
||||||
|
override fun setupPreferenceScreen(screen: PreferenceScreen) {
|
||||||
|
val baseUrlPref = androidx.preference.EditTextPreference(screen.context).apply {
|
||||||
|
key = BASE_URL_PREF
|
||||||
|
title = BASE_URL_PREF_TITLE
|
||||||
|
summary = BASE_URL_PREF_SUMMARY
|
||||||
|
setDefaultValue(super.baseUrl)
|
||||||
|
dialogTitle = BASE_URL_PREF_TITLE
|
||||||
|
dialogMessage = "Default: ${super.baseUrl}"
|
||||||
|
|
||||||
|
setOnPreferenceChangeListener { _, _ ->
|
||||||
|
Toast.makeText(screen.context, RESTART_APP, Toast.LENGTH_LONG).show()
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
screen.addPreference(baseUrlPref)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getPrefBaseUrl(): String = preferences.getString(BASE_URL_PREF, super.baseUrl)!!
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val DEFAULT_BASE_URL_PREF = "defaultBaseUrl"
|
||||||
|
private const val RESTART_APP = "Khởi chạy lại ứng dụng để áp dụng thay đổi."
|
||||||
|
private const val BASE_URL_PREF_TITLE = "Ghi đè URL cơ sở"
|
||||||
|
private const val BASE_URL_PREF = "overrideBaseUrl"
|
||||||
|
private const val BASE_URL_PREF_SUMMARY =
|
||||||
|
"Dành cho sử dụng tạm thời, cập nhật tiện ích sẽ xóa cài đặt."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue