Implement most gallery settings.
This commit is contained in:
parent
caa1e1ef09
commit
c836f52460
@ -149,6 +149,16 @@ class PreferencesHelper(val context: Context) {
|
||||
|
||||
fun secureEXH() = rxPrefs.getBoolean("secure_exh", true)
|
||||
|
||||
fun imageQuality() = rxPrefs.getString("ehentai_quality", "auto")
|
||||
|
||||
fun useHentaiAtHome() = rxPrefs.getBoolean("enable_hah", true)
|
||||
|
||||
fun useJapaneseTitle() = rxPrefs.getBoolean("use_jp_title", false)
|
||||
|
||||
fun ehSearchSize() = rxPrefs.getString("ex_search_size", "rc_0")
|
||||
|
||||
fun thumbnailRows() = rxPrefs.getString("ex_thumb_rows", "tr_2")
|
||||
|
||||
//EH Cookies
|
||||
fun memberIdVal() = rxPrefs.getString("eh_ipb_member_id", null)
|
||||
fun passHashVal() = rxPrefs.getString("eh_ipb_pass_hash", null)
|
||||
|
@ -17,6 +17,7 @@ import eu.kanade.tachiyomi.data.source.online.russian.Mintmanga
|
||||
import eu.kanade.tachiyomi.data.source.online.russian.Readmanga
|
||||
import eu.kanade.tachiyomi.util.hasPermission
|
||||
import org.yaml.snakeyaml.Yaml
|
||||
import rx.functions.Action1
|
||||
import timber.log.Timber
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.io.File
|
||||
@ -59,10 +60,17 @@ open class SourceManager(private val context: Context) {
|
||||
}
|
||||
|
||||
init {
|
||||
prefs.enableExhentai().asObservable().subscribe {
|
||||
//Refresh sources when ExHentai enabled/disabled change
|
||||
sourcesMap = createSources()
|
||||
//Rebuild EH when settings change
|
||||
val action: Action1<Any> = Action1 { sourcesMap = createSources() }
|
||||
|
||||
prefs.enableExhentai().asObservable().subscribe(action)
|
||||
prefs.imageQuality().asObservable().subscribe (action)
|
||||
prefs.useHentaiAtHome().asObservable().subscribe(action)
|
||||
prefs.useJapaneseTitle().asObservable().subscribe {
|
||||
action.call(null)
|
||||
}
|
||||
prefs.ehSearchSize().asObservable().subscribe (action)
|
||||
prefs.thumbnailRows().asObservable().subscribe(action)
|
||||
}
|
||||
|
||||
private fun createSources(): Map<Int, Source> = hashMapOf<Int, Source>().apply {
|
||||
|
@ -28,7 +28,6 @@ class EHentai(override val id: Int,
|
||||
val exh: Boolean,
|
||||
val context: Context) : OnlineSource() {
|
||||
|
||||
|
||||
val schema: String
|
||||
get() = if(prefs.secureEXH().getOrDefault())
|
||||
"https"
|
||||
@ -291,18 +290,56 @@ class EHentai(override val id: Int,
|
||||
}
|
||||
|
||||
val cookiesHeader by lazy {
|
||||
val cookies: MutableMap<String, String> = HashMap()
|
||||
val cookies: MutableMap<String, String> = mutableMapOf()
|
||||
if(prefs.enableExhentai().getOrDefault()) {
|
||||
cookies.put(LoginActivity.MEMBER_ID_COOKIE, prefs.memberIdVal().getOrDefault())
|
||||
cookies.put(LoginActivity.PASS_HASH_COOKIE, prefs.passHashVal().getOrDefault())
|
||||
cookies.put(LoginActivity.IGNEOUS_COOKIE, prefs.igneousVal().getOrDefault())
|
||||
}
|
||||
|
||||
//Setup settings
|
||||
val settings = mutableListOf<String?>()
|
||||
//Image quality
|
||||
settings.add(when(prefs.imageQuality()
|
||||
.getOrDefault()
|
||||
.toLowerCase()) {
|
||||
"ovrs_2400" -> "xr_2400"
|
||||
"ovrs_1600" -> "xr_1600"
|
||||
"high" -> "xr_1280"
|
||||
"med" -> "xr_980"
|
||||
"low" -> "xr_780"
|
||||
"auto" -> null
|
||||
else -> null
|
||||
})
|
||||
//Use Hentai@Home
|
||||
settings.add(if(prefs.useHentaiAtHome().getOrDefault())
|
||||
null
|
||||
else
|
||||
"uh_n")
|
||||
//Japanese titles
|
||||
settings.add(if(prefs.useJapaneseTitle().getOrDefault())
|
||||
"tl_j"
|
||||
else
|
||||
null)
|
||||
//Do not show popular right now pane as we can't parse it
|
||||
settings.add("prn_n")
|
||||
//Paging size
|
||||
settings.add(prefs.ehSearchSize().getOrDefault())
|
||||
//Thumbnail rows
|
||||
settings.add(prefs.thumbnailRows().getOrDefault())
|
||||
|
||||
cookies.put("uconfig", buildSettings(settings))
|
||||
|
||||
buildCookies(cookies)
|
||||
}
|
||||
|
||||
//Headers
|
||||
override fun headersBuilder()
|
||||
= super.headersBuilder().add("Cookie", cookiesHeader)!!
|
||||
= super.headersBuilder().add("Cookie", cookiesHeader)!!
|
||||
|
||||
fun buildSettings(settings: List<String?>): String {
|
||||
return settings.filterNotNull().joinToString(separator = "-")
|
||||
}
|
||||
|
||||
fun buildCookies(cookies: Map<String, String>)
|
||||
= cookies.entries.map {
|
||||
|
@ -196,4 +196,48 @@
|
||||
<item>pt</item>
|
||||
</string-array>
|
||||
|
||||
<!-- EH -->
|
||||
<string-array name="ehentai_quality">
|
||||
<item>Auto</item>
|
||||
<item>2400x</item>
|
||||
<item>1600x</item>
|
||||
<item>1280x</item>
|
||||
<item>980x</item>
|
||||
<item>780x</item>
|
||||
</string-array>
|
||||
<string-array name="ehentai_quality_values">
|
||||
<item>auto</item>
|
||||
<item>ovrs_2400</item>
|
||||
<item>ovrs_1600</item>
|
||||
<item>high</item>
|
||||
<item>med</item>
|
||||
<item>low</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="ehentai_search_result_count">
|
||||
<item>25 results</item>
|
||||
<item>50 results</item>
|
||||
<item>100 results</item>
|
||||
<item>200 results</item>
|
||||
</string-array>
|
||||
<string-array name="ehentai_search_result_count_values">
|
||||
<item>rc_0</item>
|
||||
<item>rc_1</item>
|
||||
<item>rc_2</item>
|
||||
<item>rc_3</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="ehentai_thumbnail_rows">
|
||||
<item>4</item>
|
||||
<item>10 (requires \'More Thumbs\' hath perk)</item>
|
||||
<item>20 (requires \'Thumbs Up\' hath perk)</item>
|
||||
<item>40 (requires \'All Thumbs\' hath perk)</item>
|
||||
</string-array>
|
||||
<string-array name="ehentai_thumbnail_rows_values">
|
||||
<item>tr_2</item>
|
||||
<item>tr_5</item>
|
||||
<item>tr_10</item>
|
||||
<item>tr_20</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
@ -17,12 +17,51 @@
|
||||
android:key="enable_exhentai"
|
||||
android:defaultValue="false" />
|
||||
|
||||
<SwitchPreference
|
||||
android:title="Use Hentai@Home Network"
|
||||
android:summary="Do you wish to load images through the Hentai@Home Network? Disabling this option will reduce the amount of pages you are able to view"
|
||||
android:key="enable_hah"
|
||||
android:defaultValue="true"/>
|
||||
|
||||
<SwitchPreference
|
||||
android:title="Show Japanese titles in search results"
|
||||
android:summaryOn="Currently showing Japanese titles in search results"
|
||||
android:summaryOff="Currently showing English/Romanized titles in search results"
|
||||
android:key="use_jp_title"
|
||||
android:defaultValue="false" />
|
||||
|
||||
<SwitchPreference
|
||||
android:dependency="enable_exhentai"
|
||||
android:defaultValue="true"
|
||||
android:key="secure_exh"
|
||||
android:title="Secure ExHentai"
|
||||
android:summary="Use the HTTPS version of ExHentai. Uncheck if ExHentai is not working." />
|
||||
android:summary="Use the HTTPS version of ExHentai. Uncheck if ExHentai is not working" />
|
||||
|
||||
<ListPreference
|
||||
android:defaultValue="auto"
|
||||
android:key="ehentai_quality"
|
||||
android:summary="The quality of the downloaded images"
|
||||
android:title="Image quality"
|
||||
android:entries="@array/ehentai_quality"
|
||||
android:entryValues="@array/ehentai_quality_values" />
|
||||
|
||||
<ListPreference
|
||||
android:title="Search result count"
|
||||
android:summary="Requires the \'Paging Enlargement\' hath perk"
|
||||
android:defaultValue="rc_0"
|
||||
android:key="ex_search_size"
|
||||
android:entries="@array/ehentai_search_result_count"
|
||||
android:entryValues="@array/ehentai_search_result_count_values"
|
||||
android:dependency="enable_exhentai" />
|
||||
|
||||
<ListPreference
|
||||
android:defaultValue="tr_2"
|
||||
android:title="Thumbnail rows"
|
||||
android:summary="It is recommended to set this to the maximum size your hath perks allow"
|
||||
android:key="ex_thumb_rows"
|
||||
android:dependency="enable_exhentai"
|
||||
android:entries="@array/ehentai_thumbnail_rows"
|
||||
android:entryValues="@array/ehentai_thumbnail_rows_values" />
|
||||
|
||||
</PreferenceScreen>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user