1
0
Fork 0
mirror of https://github.com/Corewala/Buran synced 2024-12-21 23:32:40 +00:00

Made home capsule setting look better when empty/invalid

This commit is contained in:
Corewala 2022-06-21 14:23:44 -04:00
parent a791521565
commit 132749016a
3 changed files with 29 additions and 3 deletions

View file

@ -51,14 +51,36 @@ class SettingsFragment: PreferenceFragmentCompat(), Preference.OnPreferenceChang
val homecapsule = preferenceManager.sharedPreferences.getString(
"home_capsule",
Buran.DEFAULT_HOME_CAPSULE
)
)?.trim()
homePreference.summary = if(homecapsule.isNullOrEmpty()){
context.getString(R.string.no_home_capsule_set)
}else if(
!homecapsule.startsWith("gemini://")
or homecapsule.contains(" ")
or !homecapsule.contains(".")
){
context.getString(R.string.not_valid_address)
}else{
homecapsule
}
homePreference.summary = homecapsule
homePreference.positiveButtonText = getString(R.string.update)
homePreference.negativeButtonText = getString(R.string.cancel)
homePreference.title = getString(R.string.home_capsule)
homePreference.setOnPreferenceChangeListener { _, newValue ->
homePreference.summary = newValue.toString()
val newHomecapsule = newValue.toString().trim()
if(newHomecapsule.isNullOrEmpty()){
homePreference.summary = context.getString(R.string.no_home_capsule_set)
}else if(
!newHomecapsule.startsWith("gemini://")
or newHomecapsule.contains(" ")
or !newHomecapsule.contains(".")
){
homePreference.summary = context.getString(R.string.not_valid_address)
}else{
homePreference.summary = newHomecapsule
}
true
}
homePreference.setOnBindEditTextListener{ editText ->

View file

@ -49,6 +49,8 @@
<string name="file_saved_to_device">Fichier sauvegardé dans l\'appareil</string>
<string name="configure_buran">Configurer Buran</string>
<string name="home_capsule">Capsule d\'accueil</string>
<string name="not_valid_address">Ceci n\'est pas une adresse valide</string>
<string name="no_home_capsule_set">Pas de capsule d\'accueil</string>
<string name="search_engine">Moteur de recherche</string>
<string name="search_base">Base de recherche</string>
<string name="update">Mettre à jour</string>

View file

@ -49,6 +49,8 @@
<string name="file_saved_to_device">File saved to device</string>
<string name="configure_buran">Configure Buran</string>
<string name="home_capsule">Home Capsule</string>
<string name="not_valid_address">This is not a valid address</string>
<string name="no_home_capsule_set">No home capsule set</string>
<string name="search_engine">Search Engine</string>
<string name="search_base">Search Base</string>
<string name="update">Update</string>