diff --git a/src/id/shinigami/build.gradle b/src/id/shinigami/build.gradle index 8493ff7ec..c335ab99c 100644 --- a/src/id/shinigami/build.gradle +++ b/src/id/shinigami/build.gradle @@ -2,8 +2,8 @@ ext { extName = 'Shinigami' extClass = '.Shinigami' themePkg = 'madara' - baseUrl = 'https://shinigami02.com' - overrideVersionCode = 24 + baseUrl = 'https://shinigami03.com' + overrideVersionCode = 25 isNsfw = false } diff --git a/src/id/shinigami/src/eu/kanade/tachiyomi/extension/id/shinigami/Shinigami.kt b/src/id/shinigami/src/eu/kanade/tachiyomi/extension/id/shinigami/Shinigami.kt index b9cc6a795..bcdbec6ae 100644 --- a/src/id/shinigami/src/eu/kanade/tachiyomi/extension/id/shinigami/Shinigami.kt +++ b/src/id/shinigami/src/eu/kanade/tachiyomi/extension/id/shinigami/Shinigami.kt @@ -1,21 +1,64 @@ package eu.kanade.tachiyomi.extension.id.shinigami +import android.app.Application +import android.content.SharedPreferences import android.util.Base64 +import android.widget.Toast +import androidx.preference.PreferenceScreen import eu.kanade.tachiyomi.lib.cryptoaes.CryptoAES import eu.kanade.tachiyomi.lib.synchrony.Deobfuscator import eu.kanade.tachiyomi.multisrc.madara.Madara import eu.kanade.tachiyomi.network.interceptor.rateLimit +import eu.kanade.tachiyomi.source.ConfigurableSource import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.model.SChapter import kotlinx.serialization.Serializable import kotlinx.serialization.decodeFromString import org.jsoup.nodes.Document import org.jsoup.nodes.Element +import uy.kohesive.injekt.Injekt +import uy.kohesive.injekt.api.get -class Shinigami : Madara("Shinigami", "https://shinigami02.com", "id") { +class Shinigami : Madara("Shinigami", "https://shinigami03.com", "id"), ConfigurableSource { // moved from Reaper Scans (id) to Shinigami (id) override val id = 3411809758861089969 + override val baseUrl by lazy { getPrefBaseUrl() } + + private val preferences: SharedPreferences by lazy { + Injekt.get().getSharedPreferences("source_$id", 0x0000) + } + + 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 + this.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)!! + + 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 useLoadMoreRequest = LoadMoreStrategy.Never override val useNewChapterEndpoint = false @@ -101,5 +144,10 @@ class Shinigami : Madara("Shinigami", "https://shinigami02.com", "id") { private val CHAPTER_DATA_REGEX by lazy { Regex("""var chapter_data\s*=\s*'(.*?)'""") } private val POST_ID_REGEX by lazy { Regex("""var post_id\s*=\s*'(.*?)'""") } private val OTHER_ID_REGEX by lazy { Regex("""var (\w+)_id\s*=\s*'(.*?)'""") } + private const val RESTART_APP = "Untuk menerapkan perubahan, restart aplikasi." + private const val BASE_URL_PREF_TITLE = "Ubah Domain" + private const val BASE_URL_PREF = "overrideBaseUrl" + private const val BASE_URL_PREF_SUMMARY = "Untuk penggunaan sementara. Memperbarui aplikasi akan menghapus pengaturan" + private const val DEFAULT_BASE_URL_PREF = "defaultBaseUrl" } }