From dd9c9e05a5514cee8cb363b6c1345367398176d0 Mon Sep 17 00:00:00 2001 From: Jobobby04 Date: Mon, 1 Jun 2020 22:00:20 -0400 Subject: [PATCH] Remove some weirdness I did for Tag filtering and Tag watching threshholds --- .../ui/setting/SettingsEhController.kt | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsEhController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsEhController.kt index 34784dd87..1ab63e54b 100755 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsEhController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsEhController.kt @@ -211,9 +211,7 @@ class SettingsEhController : SettingsController() { 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" + 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: ${preferences.ehTagFilterValue().get()}" onClick { MaterialDialog(activity!!) @@ -224,17 +222,17 @@ class SettingsEhController : SettingsController() { allowEmpty = false ) { dialog, number -> val inputField = dialog.getInputField() - val tempValue = number.toString().toIntOrNull() + val value = number.toString().toIntOrNull() - if (tempValue != null && tempValue in -9999..0) { + if (value != null && value 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) + dialog.setActionButtonEnabled(WhichButton.POSITIVE, value != null && value in -9999..0) } .positiveButton(android.R.string.ok) { + val value = it.getInputField().text.toString().toInt() 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() @@ -248,9 +246,7 @@ class SettingsEhController : SettingsController() { 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" + 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: ${preferences.ehTagWatchingValue().get()}" onClick { MaterialDialog(activity!!) @@ -262,17 +258,17 @@ class SettingsEhController : SettingsController() { allowEmpty = false ) { dialog, number -> val inputField = dialog.getInputField() - val tempValue = number.toString().toIntOrNull() + val value = number.toString().toIntOrNull() - if (tempValue != null && tempValue in 0..9999) { + if (value != null && value 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) + dialog.setActionButtonEnabled(WhichButton.POSITIVE, value != null && value in 0..9999) } .positiveButton(android.R.string.ok) { + val value = it.getInputField().text.toString().toInt() 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()