Login: Show error message when account name is already taken

This commit is contained in:
Ricki Hirner 2019-01-05 11:54:47 +01:00
parent 8d0d920033
commit e764d31d18
2 changed files with 8 additions and 0 deletions

View file

@ -81,6 +81,13 @@ class AccountDetailsFragment: Fragment() {
if (name.isEmpty())
v.account_name.error = getString(R.string.login_account_name_required)
else {
// check whether account name already exists
val am = AccountManager.get(requireActivity())
if (am.getAccountsByType(getString(R.string.account_type)).any { it.name == name }) {
v.account_name.error = getString(R.string.login_account_name_already_taken)
return@setOnClickListener
}
val idx = view!!.contact_group_method.selectedItemPosition
val groupMethodName = resources.getStringArray(R.array.settings_contact_group_method_values)[idx]

View file

@ -159,6 +159,7 @@
<string name="login_account_name_info">Use your email address as account name because Android will use the account name as ORGANIZER field for events you create. You can\'t have two accounts with the same name.</string>
<string name="login_account_contact_group_method">Contact group method:</string>
<string name="login_account_name_required">Account name required</string>
<string name="login_account_name_already_taken">Account name already taken</string>
<string name="login_account_not_created">Account could not be created</string>
<string name="login_configuration_detection">Configuration detection</string>