Commit fb092e50 authored by Eleonora Rocchi's avatar Eleonora Rocchi Committed by Commit Bot

[PwdCheckAndroid] Add subtitle to the status header in Check passwords.

This CL adds the subtitle to the header of Check Passwords. It also
adds the tests to verify the correct subtitle is shown.

Screenshots in the linked bug.

Bug: 1109691, 1092444
Change-Id: I5b29cbed5f94b84610e96b5fe64815b18e8b0eec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2342850
Commit-Queue: Eleonora Rocchi <erocchi@google.com>
Reviewed-by: default avatarFriedrich [CET] <fhorschig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#795926}
parent d1d762e3
...@@ -85,4 +85,12 @@ ...@@ -85,4 +85,12 @@
<View style="@style/HorizontalDivider"/> <View style="@style/HorizontalDivider"/>
<TextView
android:id="@+id/check_status_subtitle"
android:layout_margin="@dimen/check_status_subtitle_margin"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textAppearance="@style/TextAppearance.TextSmall.Secondary"
android:visibility="gone" />
</LinearLayout> </LinearLayout>
\ No newline at end of file
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
<dimen name="check_status_illustration_width">360dp</dimen> <dimen name="check_status_illustration_width">360dp</dimen>
<dimen name="check_status_restart_button_clickable_surface_size">48dp</dimen> <dimen name="check_status_restart_button_clickable_surface_size">48dp</dimen>
<dimen name="check_status_restart_button_margin_end">4dp</dimen> <dimen name="check_status_restart_button_margin_end">4dp</dimen>
<dimen name="check_status_subtitle_margin">16dp</dimen>
<!-- Margin for the header message, it depends on the status --> <!-- Margin for the header message, it depends on the status -->
<dimen name="check_status_message_error_margin_vertical">24dp</dimen> <dimen name="check_status_message_error_margin_vertical">24dp</dimen>
......
...@@ -182,12 +182,14 @@ class PasswordCheckViewBinder { ...@@ -182,12 +182,14 @@ class PasswordCheckViewBinder {
updateStatusIcon(view, status, compromisedCredentialsCount); updateStatusIcon(view, status, compromisedCredentialsCount);
updateStatusIllustration(view, status, compromisedCredentialsCount); updateStatusIllustration(view, status, compromisedCredentialsCount);
updateStatusText(view, status, compromisedCredentialsCount, checkTimestamp, progress); updateStatusText(view, status, compromisedCredentialsCount, checkTimestamp, progress);
updateStatusSubtitle(view, status, compromisedCredentialsCount);
} else if (key == CHECK_TIMESTAMP) { } else if (key == CHECK_TIMESTAMP) {
updateStatusText(view, status, compromisedCredentialsCount, checkTimestamp, progress); updateStatusText(view, status, compromisedCredentialsCount, checkTimestamp, progress);
} else if (key == COMPROMISED_CREDENTIALS_COUNT) { } else if (key == COMPROMISED_CREDENTIALS_COUNT) {
updateStatusIcon(view, status, compromisedCredentialsCount); updateStatusIcon(view, status, compromisedCredentialsCount);
updateStatusIllustration(view, status, compromisedCredentialsCount); updateStatusIllustration(view, status, compromisedCredentialsCount);
updateStatusText(view, status, compromisedCredentialsCount, checkTimestamp, progress); updateStatusText(view, status, compromisedCredentialsCount, checkTimestamp, progress);
updateStatusSubtitle(view, status, compromisedCredentialsCount);
} else { } else {
assert false : "Unhandled update to property:" + key; assert false : "Unhandled update to property:" + key;
} }
...@@ -397,6 +399,42 @@ class PasswordCheckViewBinder { ...@@ -397,6 +399,42 @@ class PasswordCheckViewBinder {
return 0; return 0;
} }
private static void updateStatusSubtitle(
View view, @PasswordCheckUIStatus int status, Integer compromisedCredentialsCount) {
// TODO(crbug.com/1114051): Set default values for header properties.
if (status == PasswordCheckUIStatus.IDLE && compromisedCredentialsCount == null) return;
TextView statusSubtitle = view.findViewById(R.id.check_status_subtitle);
statusSubtitle.setText(getSubtitleText(view, status, compromisedCredentialsCount));
statusSubtitle.setVisibility(getSubtitleVisibility(status));
}
private static String getSubtitleText(
View view, @PasswordCheckUIStatus int status, Integer compromisedCredentialsCount) {
switch (status) {
case PasswordCheckUIStatus.IDLE:
assert compromisedCredentialsCount != null;
return compromisedCredentialsCount == 0
? getString(view, R.string.password_check_status_subtitle_no_findings)
: getString(view,
R.string.password_check_status_subtitle_found_compromised_credentials);
case PasswordCheckUIStatus.RUNNING:
case PasswordCheckUIStatus.ERROR_OFFLINE:
case PasswordCheckUIStatus.ERROR_NO_PASSWORDS:
case PasswordCheckUIStatus.ERROR_SIGNED_OUT:
case PasswordCheckUIStatus.ERROR_QUOTA_LIMIT:
case PasswordCheckUIStatus.ERROR_QUOTA_LIMIT_ACCOUNT_CHECK:
case PasswordCheckUIStatus.ERROR_UNKNOWN:
return null;
default:
assert false : "Unhandled check status " + status + "on icon update";
}
return null;
}
private static int getSubtitleVisibility(@PasswordCheckUIStatus int status) {
return status == PasswordCheckUIStatus.IDLE ? View.VISIBLE : View.GONE;
}
private static ListMenu createCredentialMenu(Context context, CompromisedCredential credential, private static ListMenu createCredentialMenu(Context context, CompromisedCredential credential,
PasswordCheckCoordinator.CredentialEventHandler credentialHandler) { PasswordCheckCoordinator.CredentialEventHandler credentialHandler) {
MVCListAdapter.ModelList menuItems = new MVCListAdapter.ModelList(); MVCListAdapter.ModelList menuItems = new MVCListAdapter.ModelList();
......
...@@ -220,6 +220,12 @@ ...@@ -220,6 +220,12 @@
<message name="IDS_PASSWORD_CHECK_STATUS_MESSAGE_RUNNING" desc="Status message shown when the check for leaked passwords is running."> <message name="IDS_PASSWORD_CHECK_STATUS_MESSAGE_RUNNING" desc="Status message shown when the check for leaked passwords is running.">
Checking passwords (<ph name="ANALYSED_PASSWORDS">%1$s<ex>1</ex></ph> of <ph name="TOTAL_PASSWORDS">%2$s<ex>42</ex></ph>)… Checking passwords (<ph name="ANALYSED_PASSWORDS">%1$s<ex>1</ex></ph> of <ph name="TOTAL_PASSWORDS">%2$s<ex>42</ex></ph>)…
</message> </message>
<message name="IDS_PASSWORD_CHECK_STATUS_SUBTITLE_NO_FINDINGS" desc="A small paragraph below the status message that informs the user that Chrome notifies them in real-time when using compromised passwords.">
Chrome will notify you when you sign in with a compromised password.
</message>
<message name="IDS_PASSWORD_CHECK_STATUS_SUBTITLE_FOUND_COMPROMISED_CREDENTIALS" desc="A small paragraph below the status message that explains how to proceed with the compromised passwords listed below.">
The following accounts use passwords which were exposed in a third-party data breach or entered on a deceptive site. Change these passwords immediately to keep your accounts safe.
</message>
<!-- Accessibility strings --> <!-- Accessibility strings -->
<message name="IDS_ACCESSIBILITY_PASSWORD_CHECK_RESTART_BUTTON" desc="Content description for the button to restart the password check."> <message name="IDS_ACCESSIBILITY_PASSWORD_CHECK_RESTART_BUTTON" desc="Content description for the button to restart the password check.">
......
...@@ -345,6 +345,39 @@ public class PasswordCheckViewTest { ...@@ -345,6 +345,39 @@ public class PasswordCheckViewTest {
assertThat(getHeaderDescription().getVisibility(), is(View.GONE)); assertThat(getHeaderDescription().getVisibility(), is(View.GONE));
} }
@Test
@MediumTest
public void testStatusDysplaysSubtitleOnIdleNoLeaks() {
Long checkTimestamp = System.currentTimeMillis();
runOnUiThreadBlocking(
() -> { mModel.get(ITEMS).add(buildHeader(IDLE, 0, checkTimestamp)); });
waitForListViewToHaveLength(1);
assertThat(getHeaderSubtitle().getText(),
is(getString(R.string.password_check_status_subtitle_no_findings)));
assertThat(getHeaderSubtitle().getVisibility(), is(View.VISIBLE));
}
@Test
@MediumTest
public void testStatusDysplaysSubtitleOnIdleWithLeaks() {
Long checkTimestamp = System.currentTimeMillis();
runOnUiThreadBlocking(
() -> { mModel.get(ITEMS).add(buildHeader(IDLE, LEAKS_COUNT, checkTimestamp)); });
waitForListViewToHaveLength(1);
assertThat(getHeaderSubtitle().getText(),
is(getString(
R.string.password_check_status_subtitle_found_compromised_credentials)));
assertThat(getHeaderSubtitle().getVisibility(), is(View.VISIBLE));
}
@Test
@MediumTest
public void testStatusNotDysplaysSubtitle() {
runOnUiThreadBlocking(() -> { mModel.get(ITEMS).add(buildHeader(ERROR_UNKNOWN)); });
waitForListViewToHaveLength(1);
assertThat(getHeaderSubtitle().getVisibility(), is(View.GONE));
}
@Test @Test
@MediumTest @MediumTest
public void testCrendentialDisplaysNameOriginAndReason() { public void testCrendentialDisplaysNameOriginAndReason() {
...@@ -559,6 +592,10 @@ public class PasswordCheckViewTest { ...@@ -559,6 +592,10 @@ public class PasswordCheckViewTest {
return getStatus().findViewById(R.id.check_status_message); return getStatus().findViewById(R.id.check_status_message);
} }
private TextView getHeaderSubtitle() {
return getStatus().findViewById(R.id.check_status_subtitle);
}
private ImageButton getActionButton() { private ImageButton getActionButton() {
return getStatus().findViewById(R.id.check_status_restart_button); return getStatus().findViewById(R.id.check_status_restart_button);
} }
......
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