NetworkPreference: Show current proxy URL when possible

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
Aayush Gupta
2024-10-26 11:10:16 +05:30
parent 870f25f8fa
commit 577bc0d775
2 changed files with 7 additions and 1 deletions

View File

@@ -46,6 +46,7 @@ class NetworkPreference : BasePreferenceFragment(),
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.preferences_network, rootKey)
val proxyURL = Preferences.getString(requireContext(), PREFERENCE_PROXY_URL)
sharedPreferences = Preferences.getPrefs(requireContext())
sharedPreferences.registerOnSharedPreferenceChangeListener(this)
@@ -56,8 +57,12 @@ class NetworkPreference : BasePreferenceFragment(),
}
}
findPreference<Preference>(PREFERENCE_PROXY_URL)?.apply {
if (proxyURL.isNotBlank()) summary = proxyURL
}
findPreference<SwitchPreferenceCompat>(PREFERENCE_PROXY_ENABLED)?.apply {
isChecked = Preferences.getString(context, PREFERENCE_PROXY_URL).isNotBlank()
isChecked = proxyURL.isNotBlank()
setOnPreferenceChangeListener { _, newValue ->
if (newValue.toString().toBoolean()) {
findNavController().navigate(R.id.proxyURLDialog)

View File

@@ -27,6 +27,7 @@
<PreferenceCategory
app:iconSpaceReserved="false"
app:key="PREFERENCE_PROXY_URL"
app:singleLineTitle="false"
app:summary="protocol://user:password@host:port"
app:title="@string/pref_network_proxy_title" />