Add basic E/Ex-Hentai watched tag settings, possibly more to come
This commit is contained in:
parent
6e1da22353
commit
3bfda338ef
@ -224,4 +224,8 @@ object PreferenceKeys {
|
||||
const val eh_hl_useHighQualityThumbs = "eh_hl_hq_thumbs"
|
||||
|
||||
const val eh_preload_size = "eh_preload_size"
|
||||
|
||||
const val eh_tag_filtering_value = "eh_tag_filtering_value"
|
||||
|
||||
const val eh_tag_watching_value = "eh_tag_watching_value"
|
||||
}
|
||||
|
@ -270,6 +270,10 @@ class PreferencesHelper(val context: Context) {
|
||||
|
||||
fun eh_useOriginalImages() = flowPrefs.getBoolean(Keys.eh_useOrigImages, false)
|
||||
|
||||
fun ehTagFilterValue() = flowPrefs.getInt(Keys.eh_tag_filtering_value, 0)
|
||||
|
||||
fun ehTagWatchingValue() = flowPrefs.getInt(Keys.eh_tag_watching_value, 0)
|
||||
|
||||
fun ehSearchSize() = flowPrefs.getString("ex_search_size", "rc_0")
|
||||
|
||||
fun thumbnailRows() = flowPrefs.getString("ex_thumb_rows", "tr_2")
|
||||
|
@ -1,9 +1,14 @@
|
||||
package eu.kanade.tachiyomi.ui.setting
|
||||
|
||||
import android.os.Handler
|
||||
import android.text.InputType
|
||||
import android.widget.Toast
|
||||
import androidx.preference.PreferenceScreen
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.WhichButton
|
||||
import com.afollestad.materialdialogs.actions.setActionButtonEnabled
|
||||
import com.afollestad.materialdialogs.input.getInputField
|
||||
import com.afollestad.materialdialogs.input.input
|
||||
import com.bluelinelabs.conductor.RouterTransaction
|
||||
import com.bluelinelabs.conductor.changehandler.FadeChangeHandler
|
||||
import com.github.salomonbrys.kotson.fromJson
|
||||
@ -15,6 +20,7 @@ import com.tfcporciuncula.flow.Preference
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys
|
||||
import eu.kanade.tachiyomi.ui.webview.WebViewActivity
|
||||
import eu.kanade.tachiyomi.util.preference.defaultValue
|
||||
import eu.kanade.tachiyomi.util.preference.entriesRes
|
||||
import eu.kanade.tachiyomi.util.preference.intListPreference
|
||||
@ -135,6 +141,94 @@ class SettingsEhController : SettingsController() {
|
||||
onChange { preferences.eh_useOriginalImages().reconfigure() }
|
||||
}.dependency = PreferenceKeys.eh_enableExHentai
|
||||
|
||||
preference {
|
||||
title = "Watched Tags"
|
||||
summary = "Opens a webview to your E/ExHentai watched tags page"
|
||||
onClick {
|
||||
val intent = if (preferences.enableExhentai().get()) {
|
||||
WebViewActivity.newIntent(activity!!, url = "https://exhentai.org/mytags", title = "ExHentai Watched Tags")
|
||||
} else {
|
||||
WebViewActivity.newIntent(activity!!, url = "https://e-hentai.org/mytags", title = "E-Hentai Watched Tags")
|
||||
}
|
||||
startActivity(intent)
|
||||
}
|
||||
}.dependency = PreferenceKeys.eh_enableExHentai
|
||||
|
||||
preference {
|
||||
title = "Tag Filtering Threshold"
|
||||
key = PreferenceKeys.eh_tag_filtering_value
|
||||
defaultValue = 0
|
||||
|
||||
var value = preferences.ehTagFilterValue().get()
|
||||
|
||||
summary = "You can soft filter tags by adding them to the \"My Tags\" E/ExHentai page with a negative weight. If a gallery has tags that add up to weight below this value, it is filtered from view. This threshold can be set between -9999 and 0. Currently: $value"
|
||||
|
||||
onClick {
|
||||
MaterialDialog(activity!!)
|
||||
.title(text = "Tag Filtering Threshold")
|
||||
.input(
|
||||
inputType = InputType.TYPE_NUMBER_FLAG_SIGNED,
|
||||
waitForPositiveButton = false,
|
||||
allowEmpty = false
|
||||
) { dialog, number ->
|
||||
val inputField = dialog.getInputField()
|
||||
val tempValue = number.toString().toIntOrNull()
|
||||
|
||||
if (tempValue != null && tempValue in -9999..0) {
|
||||
inputField.error = null
|
||||
value = tempValue
|
||||
} else {
|
||||
inputField.error = "Must be between -9999 and 0!"
|
||||
}
|
||||
dialog.setActionButtonEnabled(WhichButton.POSITIVE, value in -9999..0)
|
||||
}
|
||||
.positiveButton(android.R.string.ok) {
|
||||
preferences.ehTagFilterValue().set(value)
|
||||
summary = "You can soft filter tags by adding them to the \"My Tags\" E/ExHentai page with a negative weight. If a gallery has tags that add up to weight below this value, it is filtered from view. This threshold can be set between 0 and -9999. Currently: $value"
|
||||
preferences.ehTagFilterValue().reconfigure()
|
||||
}
|
||||
.show()
|
||||
}
|
||||
}.dependency = PreferenceKeys.eh_enableExHentai
|
||||
|
||||
preference {
|
||||
title = "Tag Watching Threshold"
|
||||
key = PreferenceKeys.eh_tag_watching_value
|
||||
defaultValue = 0
|
||||
|
||||
var value = preferences.ehTagWatchingValue().get()
|
||||
|
||||
summary = "Recently uploaded galleries will be included on the watched screen if it has at least one watched tag with positive weight, and the sum of weights on its watched tags add up to this value or higher. This threshold can be set between 0 and 9999. Currently: $value"
|
||||
|
||||
onClick {
|
||||
MaterialDialog(activity!!)
|
||||
.title(text = "Tag Watching Threshold")
|
||||
.input(
|
||||
inputType = InputType.TYPE_NUMBER_FLAG_SIGNED,
|
||||
maxLength = 4,
|
||||
waitForPositiveButton = false,
|
||||
allowEmpty = false
|
||||
) { dialog, number ->
|
||||
val inputField = dialog.getInputField()
|
||||
val tempValue = number.toString().toIntOrNull()
|
||||
|
||||
if (tempValue != null && tempValue in 0..9999) {
|
||||
inputField.error = null
|
||||
value = tempValue
|
||||
} else {
|
||||
inputField.error = "Must be between 0 and 9999!"
|
||||
}
|
||||
dialog.setActionButtonEnabled(WhichButton.POSITIVE, value in 0..9999)
|
||||
}
|
||||
.positiveButton(android.R.string.ok) {
|
||||
preferences.ehTagWatchingValue().set(value)
|
||||
summary = "Recently uploaded galleries will be included on the watched screen if it has at least one watched tag with positive weight, and the sum of weights on its watched tags add up to this value or higher. This threshold can be set between 0 and 9999. Currently: $value"
|
||||
preferences.ehTagWatchingValue().reconfigure()
|
||||
}
|
||||
.show()
|
||||
}
|
||||
}.dependency = PreferenceKeys.eh_enableExHentai
|
||||
|
||||
switchPreference {
|
||||
defaultValue = true
|
||||
key = "secure_exh"
|
||||
|
@ -60,6 +60,9 @@ class EhUConfigBuilder {
|
||||
configItems += Entry.UseMPV()
|
||||
configItems += Entry.ShowPopularRightNowPane()
|
||||
|
||||
configItems += Entry.TagFilteringThreshold(prefs.ehTagFilterValue().get())
|
||||
configItems += Entry.TagWatchingThreshold(prefs.ehTagWatchingValue().get())
|
||||
|
||||
// Actually build form body
|
||||
val formBody = FormBody.Builder()
|
||||
configItems.forEach {
|
||||
@ -138,6 +141,16 @@ object Entry {
|
||||
override val key = "pp"
|
||||
override val value = "1"
|
||||
}
|
||||
|
||||
class TagFilteringThreshold(value: Int) : ConfigItem {
|
||||
override val key = "tf"
|
||||
override val value = "$value"
|
||||
}
|
||||
|
||||
class TagWatchingThreshold(value: Int) : ConfigItem {
|
||||
override val key = "wt"
|
||||
override val value = "$value"
|
||||
}
|
||||
}
|
||||
|
||||
interface ConfigItem {
|
||||
|
Loading…
x
Reference in New Issue
Block a user