How to build an app supporting 1Password?
Hi, I'm an Android Developer
I found my company's app doesn't support 1Password well, so I do some tests.
I build an app like below
with layout xml
<?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" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true"> <EditText android:id="@+id/emailEditText" android:layout_width="match_parent" android:layout_height="150dp" android:autofillHints="username" android:inputType="textEmailAddress" app:layout_constraintTop_toTopOf="parent" /> <EditText android:id="@+id/passwordEditText" android:layout_width="match_parent" android:layout_height="150dp" android:autofillHints="password" android:inputType="textPassword" app:layout_constraintTop_toBottomOf="@+id/emailEditText" /> </androidx.constraintlayout.widget.ConstraintLayout>
This is my 1Password settings for this app
Even though I have set the autofillHints for emailEditText to "username", 1Password still cannot autofill the field.
But passwordEditText
works
And only fill passwordEditText
When I change first EditText's id from emailEditText
to usernameEditText
, it works perfectly
<?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" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true"> <EditText android:id="@+id/usernameEditText" android:layout_width="match_parent" android:layout_height="150dp" android:autofillHints="username" android:inputType="textEmailAddress" app:layout_constraintTop_toTopOf="parent" /> <EditText android:id="@+id/passwordEditText" android:layout_width="match_parent" android:layout_height="150dp" android:autofillHints="password" android:inputType="textPassword" app:layout_constraintTop_toBottomOf="@+id/usernameEditText" /> </androidx.constraintlayout.widget.ConstraintLayout>
I'm not sure why it's based on the View's ID instead of the autofillHints.
And I do another test, I adding an EditText which id is emailEditText
like below
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true"> <EditText android:id="@+id/userNameEditText" android:layout_width="match_parent" android:layout_height="150dp" android:autofillHints="username" android:inputType="text" app:layout_constraintTop_toTopOf="parent" /> <EditText android:id="@+id/passwordEditText" android:layout_width="match_parent" android:layout_height="150dp" android:autofillHints="password" android:inputType="textPassword" app:layout_constraintTop_toBottomOf="@+id/userNameEditText" /> <EditText android:id="@+id/emailEditText" android:layout_width="match_parent" android:layout_height="150dp" android:autofillHints="emailAddress" android:inputType="textEmailAddress" app:layout_constraintTop_toBottomOf="@+id/passwordEditText" /> </androidx.constraintlayout.widget.ConstraintLayout>
Both userNameEditText
and emailEditText
are not working
Do I miss something? Thanks~
1Password Version: 8.10.4
Extension Version: Not Provided
OS Version: Android 13, Android 10
Browser:_ Not Provided
Comments
-
Hi @aids61517! Thanks for reaching out. Looking at your XML I don't see any reason why we wouldn't be filling, and you're right that changing the
id
attribute for the field shouldn't have any effect.That said, if no value is set for
android:importantForAutofill
, the system will try to determine if the field is important for Autofill based on heuristics. I wonder if that's the case here, and it's simply determining it's not important based on the value of the field'sid
. Could you please try setting the following:android:importantForAutofill="yes"
Let me know if that helps!
0 -
By adding
android:importantForAutofill="yes"
, layout xml is<?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" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true"> <EditText android:id="@+id/emailEditText" android:layout_width="match_parent" android:layout_height="150dp" android:autofillHints="username" android:importantForAutofill="yes" android:inputType="textEmailAddress" app:layout_constraintTop_toTopOf="parent" /> <EditText android:id="@+id/passwordEditText" android:layout_width="match_parent" android:layout_height="150dp" android:autofillHints="password" android:importantForAutofill="yes" android:inputType="textPassword" app:layout_constraintTop_toBottomOf="@+id/emailEditText" /> </androidx.constraintlayout.widget.ConstraintLayout>
Still not working on
emailEditText
And Still working by changing
emailEditText
tousernameEditText
0