Added HTTP proxy to settings

It doesn't do anything yet. Great feature I know.
This commit is contained in:
Corewala 2022-07-09 18:38:31 -04:00
parent 4c94bd97e4
commit affa99e8f2
3 changed files with 48 additions and 0 deletions

View File

@ -191,6 +191,50 @@ class SettingsFragment: PreferenceFragmentCompat(), Preference.OnPreferenceChang
showInlineImages.title = getString(R.string.show_inline_images)
webCategory.addPreference(showInlineImages)
val httpGeminiProxy = EditTextPreference(context)
httpGeminiProxy.title = getString(R.string.http_proxy)
httpGeminiProxy.key = "http_proxy"
httpGeminiProxy.dialogTitle = getString(R.string.http_proxy)
val httpProxy = preferenceManager.sharedPreferences.getString(
"http_proxy",
null
)?.trim()
httpGeminiProxy.summary = if(httpProxy.isNullOrEmpty()){
getString(R.string.no_http_proxy_set)
}else if(
!httpProxy.startsWith("gemini://")
or httpProxy.contains(" ")
or !httpProxy.contains(".")
){
getString(R.string.not_valid_address)
}else{
httpProxy
}
httpGeminiProxy.positiveButtonText = getString(R.string.update)
httpGeminiProxy.negativeButtonText = getString(R.string.cancel)
httpGeminiProxy.setOnPreferenceChangeListener { _, newValue ->
val newHomecapsule = newValue.toString().trim()
httpGeminiProxy.summary = if(newHomecapsule.isNullOrEmpty()){
getString(R.string.no_http_proxy_set)
}else if(
!newHomecapsule.startsWith("gemini://")
or newHomecapsule.contains(" ")
or !newHomecapsule.contains(".")
){
getString(R.string.not_valid_address)
}else{
newHomecapsule
}
true
}
httpGeminiProxy.setOnBindEditTextListener{ editText ->
editText.imeOptions = EditorInfo.IME_ACTION_DONE
editText.setSelection(editText.text.toString().length)//Set caret position to end
}
webCategory.addPreference(httpGeminiProxy)
}
private fun buildAppearanceSection(context: Context?, appCategory: PreferenceCategory) {

View File

@ -66,6 +66,8 @@
<string name="web_content">Contenu Web</string>
<string name="web_content_label">Ouvrir les sites web en interne en utilisant des \'Onglets Personnalisés\', plutôt que d\'utiliser le navigateur par défaut. Cela pourrait vous aider à rester dans le Geminispace plutôt que d\'être distrait·e par le vaste web. Cela requiert un navigateur par défaut compatible.</string>
<string name="web_content_switch_label">Ouvrir en interne</string>
<string name="http_proxy">Mandataire HTTP</string>
<string name="no_http_proxy_set">Pas de mandataire HTTP</string>
<string name="show_inline_images">Images locales en ligne</string>
<string name="pkcs_notice">Seuls les magasins de clés client PKCS12 sont actuellement supportés.</string>
<string name="client_certificate">Certificat Client</string>

View File

@ -66,6 +66,8 @@
<string name="web_content">Web Content</string>
<string name="web_content_label">Open websites internally using \'Custom Tabs\', instead of using the default browser. This might help you stay in Geminispace instead of being distracted by the wider web. Requires compatible default browser.</string>
<string name="web_content_switch_label">Open internally</string>
<string name="http_proxy">HTTP proxy</string>
<string name="no_http_proxy_set">No HTTP proxy set</string>
<string name="show_inline_images">Inline local images</string>
<string name="pkcs_notice">Only PKCS12 client keystores are currently supported.</string>
<string name="client_certificate">Client Certificate</string>