Commit 044b3a65 authored by Reda Tawfik's avatar Reda Tawfik Committed by Commit Bot

[Android][Mfill] Handle empty password field in AllPasswordBottomSheet

This Cl handles the case when the password data is empty.
In the case of the focused field is a password field, the credentials
have an empty password will not be added to the model so will not
appears in the bottom sheet.
In the case of the focused field is a username field, the empty password
will be replaced with a placeholder `No password` and it is disabled
by default.

Screenshot: https://bugs.chromium.org/p/chromium/issues/detail?id=1104132#c21

Bug: 1104132
Change-Id: I158b3eb43856a827cdca2fd563afd4129d32ebc5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2424123Reviewed-by: default avatarIoana Pandele <ioanap@chromium.org>
Reviewed-by: default avatarFriedrich [CET] <fhorschig@chromium.org>
Commit-Queue: Reda Tawfik <redatawfik@google.com>
Cr-Commit-Position: refs/heads/master@{#809352}
parent 15ffa52b
......@@ -38,6 +38,7 @@ class AllPasswordsBottomSheetMediator {
sheetItems.clear();
for (Credential credential : mCredentials) {
if (credential.getPassword().isEmpty() && isPasswordField) continue;
final PropertyModel model =
AllPasswordsBottomSheetProperties.CredentialProperties.createCredentialModel(
credential, this::onCredentialSelected, isPasswordField);
......@@ -58,7 +59,10 @@ class AllPasswordsBottomSheetMediator {
sheetItems.clear();
for (Credential credential : mCredentials) {
if (shouldBeFiltered(newText, credential)) continue;
if ((credential.getPassword().isEmpty() && mIsPasswordField)
|| shouldBeFiltered(newText, credential)) {
continue;
}
final PropertyModel model =
AllPasswordsBottomSheetProperties.CredentialProperties.createCredentialModel(
credential, this::onCredentialSelected, mIsPasswordField);
......
......@@ -145,9 +145,15 @@ class AllPasswordsBottomSheetViewBinder {
usernameView.getPrimaryTextView().setText(credential.getFormattedUsername());
ChipView passwordView = view.findViewById(R.id.password_text);
passwordView.getPrimaryTextView().setTransformationMethod(
new PasswordTransformationMethod());
passwordView.getPrimaryTextView().setText(credential.getPassword());
boolean isEmptyPassword = credential.getPassword().isEmpty();
if (!isEmptyPassword) {
passwordView.getPrimaryTextView().setTransformationMethod(
new PasswordTransformationMethod());
}
passwordView.getPrimaryTextView().setText(isEmptyPassword
? view.getContext().getString(
R.string.all_passwords_bottom_sheet_no_password)
: credential.getPassword());
// Set the default icon, then try to get a better one.
FaviconHelper faviconHelper = new FaviconHelper(view.getContext());
......
......@@ -186,6 +186,9 @@
<message name="IDS_ALL_PASSWORDS_BOTTOM_SHEET_SEARCH_HINT" desc="The label for a search button appears in all passwords bottom sheet.">
Search
</message>
<message name="IDS_ALL_PASSWORDS_BOTTOM_SHEET_NO_PASSWORD" desc="The title for disabled buttons on the All passwords bottom sheet UI when a credential doesn't contains a password.">
No password
</message>
<message name="IDS_AUTOFILL_KEYBOARD_ACCESSORY_CONTENT_DESCRIPTION" desc="The text announced by the screen reader when the password suggestions are shown.">
Passwords available
</message>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment