Add warning to avoid apostrophes in account names

Add warning to avoid apostrophes in account names. Resolves bitfireAT/davx5#5
This commit is contained in:
sunkup 2022-01-05 15:14:12 +01:00 committed by Ricki Hirner
parent ed08cc8d15
commit 9ac05f4f51
3 changed files with 18 additions and 3 deletions

View file

@ -138,8 +138,10 @@ class AccountDetailsFragment : Fragment() {
val name = MutableLiveData<String>()
val nameError = MutableLiveData<String>()
val showApostropheWarning = MutableLiveData<Boolean>(false)
fun clearNameError(s: Editable) {
fun validateAccountName(s: Editable) {
showApostropheWarning.value = s.toString().contains('\'')
nameError.value = null
}

View file

@ -4,6 +4,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<import type="android.view.View"/>
<variable
name="details"
type="at.bitfire.davdroid.ui.setup.AccountDetailsFragment.AccountDetailsModel"/>
@ -45,16 +46,27 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
unfilteredText="@={details.name}"
android:afterTextChanged="@{details::clearNameError}"
android:afterTextChanged="@{details::validateAccountName}"
android:inputType="textEmailAddress" />
</com.google.android.material.textfield.TextInputLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/TextAppearance.AppCompat.Body2"
app:drawableStartCompat="@drawable/ic_info"
android:drawablePadding="8dp"
android:layout_marginBottom="4dp"
android:text="@string/login_account_avoid_apostrophe"
android:visibility="@{details.showApostropheWarning ? View.VISIBLE : View.GONE}"/>
<TextView
android:id="@+id/account_email_hint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/login_account_name_info"/>
style="@style/TextAppearance.AppCompat.Body2"
android:text="@string/login_account_name_info" />
<LinearLayout
android:id="@+id/carddav"

View file

@ -244,6 +244,7 @@
<string name="login_login">Login</string>
<string name="login_create_account">Create account</string>
<string name="login_account_name">Account name</string>
<string name="login_account_avoid_apostrophe">Use of apostrophes (\'), have been reported to cause problems on some devices.</string>
<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>