mirror of
https://github.com/Corewala/Buran
synced 2024-12-22 07:42:43 +00:00
Made home capsule setting look better when empty/invalid
This commit is contained in:
parent
a791521565
commit
132749016a
3 changed files with 29 additions and 3 deletions
|
@ -51,14 +51,36 @@ class SettingsFragment: PreferenceFragmentCompat(), Preference.OnPreferenceChang
|
||||||
val homecapsule = preferenceManager.sharedPreferences.getString(
|
val homecapsule = preferenceManager.sharedPreferences.getString(
|
||||||
"home_capsule",
|
"home_capsule",
|
||||||
Buran.DEFAULT_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.positiveButtonText = getString(R.string.update)
|
||||||
homePreference.negativeButtonText = getString(R.string.cancel)
|
homePreference.negativeButtonText = getString(R.string.cancel)
|
||||||
homePreference.title = getString(R.string.home_capsule)
|
homePreference.title = getString(R.string.home_capsule)
|
||||||
homePreference.setOnPreferenceChangeListener { _, newValue ->
|
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
|
true
|
||||||
}
|
}
|
||||||
homePreference.setOnBindEditTextListener{ editText ->
|
homePreference.setOnBindEditTextListener{ editText ->
|
||||||
|
|
|
@ -49,6 +49,8 @@
|
||||||
<string name="file_saved_to_device">Fichier sauvegardé dans l\'appareil</string>
|
<string name="file_saved_to_device">Fichier sauvegardé dans l\'appareil</string>
|
||||||
<string name="configure_buran">Configurer Buran</string>
|
<string name="configure_buran">Configurer Buran</string>
|
||||||
<string name="home_capsule">Capsule d\'accueil</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_engine">Moteur de recherche</string>
|
||||||
<string name="search_base">Base de recherche</string>
|
<string name="search_base">Base de recherche</string>
|
||||||
<string name="update">Mettre à jour</string>
|
<string name="update">Mettre à jour</string>
|
||||||
|
|
|
@ -49,6 +49,8 @@
|
||||||
<string name="file_saved_to_device">File saved to device</string>
|
<string name="file_saved_to_device">File saved to device</string>
|
||||||
<string name="configure_buran">Configure Buran</string>
|
<string name="configure_buran">Configure Buran</string>
|
||||||
<string name="home_capsule">Home Capsule</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_engine">Search Engine</string>
|
||||||
<string name="search_base">Search Base</string>
|
<string name="search_base">Search Base</string>
|
||||||
<string name="update">Update</string>
|
<string name="update">Update</string>
|
||||||
|
|
Loading…
Reference in a new issue