Skip to content

Commit

Permalink
Nudemoon: New domain (#7311)
Browse files Browse the repository at this point in the history
* Nudemoon: New domain

* Nudemoon: review fix
  • Loading branch information
Dr1ks authored Jan 28, 2025
1 parent 30052a1 commit 2a7a1b6
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/ru/nudemoon/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ext {
extName = 'Nude-Moon'
extClass = '.Nudemoon'
extVersionCode = 18
extVersionCode = 19
isNsfw = true
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
package eu.kanade.tachiyomi.extension.ru.nudemoon

import android.app.Application
import android.content.SharedPreferences
import android.webkit.CookieManager
import android.widget.Toast
import androidx.preference.EditTextPreference
import androidx.preference.PreferenceScreen
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.source.ConfigurableSource
import eu.kanade.tachiyomi.source.model.Filter
import eu.kanade.tachiyomi.source.model.FilterList
import eu.kanade.tachiyomi.source.model.Page
Expand All @@ -14,22 +20,27 @@ import okhttp3.Request
import okhttp3.Response
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import java.net.URLEncoder
import java.text.SimpleDateFormat
import java.util.Locale
import kotlin.math.absoluteValue
import kotlin.random.Random

class Nudemoon : ParsedHttpSource() {
class Nudemoon : ParsedHttpSource(), ConfigurableSource {

override val name = "Nude-Moon"

override val baseUrl = "https://a.nude-moon.fun"

override val lang = "ru"

override val supportsLatest = true

private val preferences: SharedPreferences =
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)

override val baseUrl by lazy { getPrefBaseUrl() }

private val dateParseRu = SimpleDateFormat("d MMMM yyyy", Locale("ru"))
private val dateParseSlash = SimpleDateFormat("d/MM/yyyy", Locale("ru"))

Expand Down Expand Up @@ -336,4 +347,38 @@ class Nudemoon : ParsedHttpSource() {
Genre("titsfuck"),
Genre("x-ray"),
)

override fun setupPreferenceScreen(screen: PreferenceScreen) {
EditTextPreference(screen.context).apply {
key = DOMAIN_PREF
title = DOMAIN_TITLE
setDefaultValue(DOMAIN_DEFAULT)
dialogTitle = DOMAIN_TITLE
dialogMessage = "Default URL:\n\t$DOMAIN_DEFAULT"
setOnPreferenceChangeListener { _, _ ->
Toast.makeText(screen.context, "Для смены домена необходимо перезапустить приложение с полной остановкой.", Toast.LENGTH_LONG).show()
true
}
}.let(screen::addPreference)
}

private fun getPrefBaseUrl(): String = preferences.getString(DOMAIN_PREF, DOMAIN_DEFAULT)!!

init {
preferences.getString(DEFAULT_DOMAIN_PREF, null).let { defaultBaseUrl ->
if (defaultBaseUrl != DOMAIN_DEFAULT) {
preferences.edit()
.putString(DOMAIN_PREF, DOMAIN_DEFAULT)
.putString(DEFAULT_DOMAIN_PREF, DOMAIN_DEFAULT)
.apply()
}
}
}

companion object {
private const val DOMAIN_PREF = "Домен"
private const val DEFAULT_DOMAIN_PREF = "pref_default_domain"
private const val DOMAIN_TITLE = "Домен"
private const val DOMAIN_DEFAULT = "https://nude-moon.org"
}
}

0 comments on commit 2a7a1b6

Please sign in to comment.