Autofill in Android proposes the wrong field (email instead of the phone). Filtering of the autofill combinations

206 views Asked by At

I have a signIn in the Android app by the email and password combination. After a month of the using I have a list of this combinations in the "Passwords & accounts" list on my device.

Now I have a signIn by the phone and password, but the autofill propose the email/password combination on the screen with a phone input and password.

Methods like:

binding.phoneEditText.setAutofillHints(HintConstants.AUTOFILL_HINT_PHONE_NATIONAL)

Changes nothing in this case. It works only if there is no password field on the screen.

Can I somehow filter the saved combination of the credentials to show only "phone/password" not "email/password"?

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/loginLayout"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="24dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <com.google.android.material.textfield.TextInputLayout
            android:id="@+id/codeEditTextLayout"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            app:layout_constraintEnd_toStartOf="@+id/phoneEditTextLayout"
            app:layout_constraintHorizontal_weight="0.4"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent">

         <com.google.android.material.textfield.TextInputEditText
                android:id="@+id/codeEditText"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />
        </com.google.android.material.textfield.TextInputLayout>

        <com.google.android.material.textfield.TextInputLayout
            android:id="@+id/phoneEditTextLayout"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_weight="0.6"
            app:layout_constraintStart_toEndOf="@+id/codeEditTextLayout"
            app:layout_constraintTop_toTopOf="parent">

            <com.google.android.material.textfield.TextInputEditText
                android:id="@+id/phoneEditText"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:autofillHints="phone"
                android:gravity="center"
                android:importantForAutofill="yes"
                android:inputType="phone" />
        </com.google.android.material.textfield.TextInputLayout>

    </androidx.constraintlayout.widget.ConstraintLayout>

    <com.google.android.material.textfield.TextInputLayout
        android:id="@+id/passwordEditTextLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/loginLayout">

        <com.google.android.material.textfield.TextInputEditText
            android:id="@+id/passwordEditText"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:autofillHints="password"
            android:gravity="center"
            android:importantForAutofill="yes"
            android:inputType="textPassword" />
    </com.google.android.material.textfield.TextInputLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
0

There are 0 answers