From 3760b310df8701f929d4ca4acbe7facfa97a2220 Mon Sep 17 00:00:00 2001 From: arkon Date: Fri, 19 Aug 2022 08:23:55 -0400 Subject: [PATCH] Don't allow setting blank user agent string --- .../ui/setting/SettingsAdvancedController.kt | 25 +++++++++++-------- app/src/main/res/values/strings.xml | 1 + 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt index 0c34cf1d36..8d75adffb9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt @@ -229,19 +229,24 @@ class SettingsAdvancedController( summary = network.defaultUserAgent onChange { - activity?.toast(R.string.requires_app_restart) - true + if (it.toString().isBlank()) { + activity?.toast(R.string.error_user_agent_string_blank) + false + } else { + activity?.toast(R.string.requires_app_restart) + true + } } } - if (preferences.defaultUserAgent().isSet()) { - preference { - key = "pref_reset_user_agent" - titleRes = R.string.pref_reset_user_agent_string + preference { + key = "pref_reset_user_agent" + titleRes = R.string.pref_reset_user_agent_string - onClick { - preferences.defaultUserAgent().delete() - activity?.toast(R.string.requires_app_restart) - } + visibleIf(preferences.defaultUserAgent()) { it != preferences.defaultUserAgent().defaultValue } + + onClick { + preferences.defaultUserAgent().delete() + activity?.toast(R.string.requires_app_restart) } } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b6c6a5cfa3..e934a30c78 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -475,6 +475,7 @@ Clear cookies DNS over HTTPS (DoH) Default user agent string + User agent string can not be blank Reset default user agent string Requires app restart to take effect Cookies cleared