Commit e034ec3e authored by Jaeyong Bae's avatar Jaeyong Bae Committed by Commit Bot

[Passwords] Add a message when there is no password match

This patch means adding a message which indicates that
there is no result when searching for a password.

Bug: 1040875
Change-Id: If980d685a3f0bc3eec3d5717b484edb3f03c4cf9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2049424
Commit-Queue: Jaeyong Bae <jdragon.bae@gmail.com>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Reviewed-by: default avatarFriedrich [CET] <fhorschig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#744651}
parent 2ae8db12
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2020 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<FrameLayout 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">
<FrameLayout
style="@style/Card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp">
<org.chromium.ui.widget.TextViewWithLeading
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="@dimen/card_padding"
android:text="@string/password_no_result"
android:textAlignment="center"
android:textAppearance="@style/TextAppearance.TextMedium.Secondary"
app:leading="@dimen/text_size_medium_leading" />
</FrameLayout>
</FrameLayout>
...@@ -202,6 +202,16 @@ public class PasswordSettings ...@@ -202,6 +202,16 @@ public class PasswordSettings
getPreferenceScreen().addPreference(mEmptyView); getPreferenceScreen().addPreference(mEmptyView);
} }
/**
* Include a message when there's no match.
*/
private void displayPasswordNoResultScreenMessage() {
Preference noResultView = new Preference(getStyledContext());
noResultView.setLayoutResource(R.layout.password_no_result);
noResultView.setSelectable(false);
getPreferenceScreen().addPreference(noResultView);
}
@Override @Override
public void onDetach() { public void onDetach() {
super.onDetach(); super.onDetach();
...@@ -296,6 +306,7 @@ public class PasswordSettings ...@@ -296,6 +306,7 @@ public class PasswordSettings
// If not searching, the category needs to be removed again. // If not searching, the category needs to be removed again.
getPreferenceScreen().removePreference(passwordParent); getPreferenceScreen().removePreference(passwordParent);
} else { } else {
displayPasswordNoResultScreenMessage();
getView().announceForAccessibility( getView().announceForAccessibility(
getString(R.string.accessible_find_in_page_no_results)); getString(R.string.accessible_find_in_page_no_results));
} }
......
...@@ -1875,7 +1875,7 @@ public class PasswordSettingsTest { ...@@ -1875,7 +1875,7 @@ public class PasswordSettingsTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"Preferences"}) @Feature({"Preferences"})
public void testSearchDisplaysBlankPageIfSearchTurnsUpEmpty() { public void testSearchDisplaysNoResultMessageIfSearchTurnsUpEmpty() {
setPasswordSourceWithMultipleEntries(GREEK_GODS); setPasswordSourceWithMultipleEntries(GREEK_GODS);
SettingsActivityTest.startSettingsActivity( SettingsActivityTest.startSettingsActivity(
InstrumentationRegistry.getInstrumentation(), PasswordSettings.class.getName()); InstrumentationRegistry.getInstrumentation(), PasswordSettings.class.getName());
...@@ -1898,6 +1898,8 @@ public class PasswordSettingsTest { ...@@ -1898,6 +1898,8 @@ public class PasswordSettingsTest {
Espresso.onView(allOf(withParent(isAssignableFrom(LinearLayout.class)), Espresso.onView(allOf(withParent(isAssignableFrom(LinearLayout.class)),
withText(R.string.password_settings_title))) withText(R.string.password_settings_title)))
.check(doesNotExist()); .check(doesNotExist());
// Check the message for no result.
Espresso.onView(withText(R.string.password_no_result)).check(matches(isDisplayed()));
} }
/** /**
......
...@@ -500,6 +500,9 @@ CHAR-LIMIT guidelines: ...@@ -500,6 +500,9 @@ CHAR-LIMIT guidelines:
<message name="IDS_SAVED_PASSWORDS_NONE_TEXT" desc="Text when there are no saved passwords/exceptions."> <message name="IDS_SAVED_PASSWORDS_NONE_TEXT" desc="Text when there are no saved passwords/exceptions.">
Saved passwords will appear here. Saved passwords will appear here.
</message> </message>
<message name="IDS_PASSWORD_NO_RESULT" desc="Text when a password search returned no results.">
Can’t find that password. Check your spelling and try again.
</message>
<message name="IDS_PASSWORD_ENTRY_VIEWER_TITLE" desc='Title of the overview screen for a saved password.'> <message name="IDS_PASSWORD_ENTRY_VIEWER_TITLE" desc='Title of the overview screen for a saved password.'>
Saved password Saved password
</message> </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