Don't allow setting blank user agent string

This commit is contained in:
arkon 2022-08-19 08:23:55 -04:00
parent 47b56644de
commit 3760b310df
2 changed files with 16 additions and 10 deletions

View File

@ -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)
}
}
}

View File

@ -475,6 +475,7 @@
<string name="pref_clear_cookies">Clear cookies</string>
<string name="pref_dns_over_https">DNS over HTTPS (DoH)</string>
<string name="pref_user_agent_string">Default user agent string</string>
<string name="error_user_agent_string_blank">User agent string can not be blank</string>
<string name="pref_reset_user_agent_string">Reset default user agent string</string>
<string name="requires_app_restart">Requires app restart to take effect</string>
<string name="cookies_cleared">Cookies cleared</string>