Commit 622a3ff6 authored by Ivana Zuzic's avatar Ivana Zuzic Committed by Commit Bot

[PWD Editing Android] Add edit icon to password preferences

The icon is going to lead to a password editing activity which doesn't exist yet and will be created in the next CL.
The icon is flag-guarded since the feature of editing passwords is still in the making.

Bug: 377410
Change-Id: Ibd7d702b884d1a9ab0228e6f8b8c7be424a04946
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1695353
Commit-Queue: Ivana Zuzic <izuzic@google.com>
Reviewed-by: default avatarBoris Sazonov <bsazonov@chromium.org>
Reviewed-by: default avatarFriedrich [CET] <fhorschig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#676875}
parent e6bd6af8
......@@ -6,6 +6,14 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" >
<item
android:id="@+id/action_edit_saved_password"
android:icon="@drawable/ic_edit_24dp"
app:iconTint="@color/default_icon_color"
android:contentDescription="@string/password_entry_editor_edit_stored_password"
android:title="@string/password_entry_editor_edit_stored_password_action_title"
app:showAsAction="ifRoom"/>
<item
android:id="@+id/action_delete_saved_password"
android:icon="@drawable/ic_delete_white_24dp"
......
......@@ -33,6 +33,7 @@ import android.widget.TextView;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.metrics.RecordHistogram;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeFeatureList;
import org.chromium.chrome.browser.preferences.PreferenceUtils;
import org.chromium.chrome.browser.sync.ProfileSyncService;
import org.chromium.components.sync.AndroidSyncSettings;
......@@ -95,8 +96,8 @@ public class PasswordEntryEditor extends Fragment {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
public View onCreateView(
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Extras are set on this intent in class {@link SavePasswordsPreferences}.
mExtras = getArguments();
......@@ -207,6 +208,9 @@ public class PasswordEntryEditor extends Fragment {
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.password_entry_editor_action_bar_menu, menu);
menu.findItem(R.id.action_edit_saved_password)
.setVisible(
ChromeFeatureList.isEnabled(ChromeFeatureList.PASSWORD_EDITING_ANDROID));
}
@Override
......@@ -216,6 +220,7 @@ public class PasswordEntryEditor extends Fragment {
removeItem();
return true;
}
// TODO(crbug.com/377410): Handle action_edit_saved_password clicks.
return super.onOptionsItemSelected(item);
}
......
......@@ -575,12 +575,18 @@ CHAR-LIMIT guidelines:
<message name="IDS_PASSWORD_ENTRY_EDITOR_DELETE_STORED_PASSWORD_ACTION_TITLE" desc='Title for button on action bar that deletes the stored password.'>
Delete password
</message>
<message name="IDS_PASSWORD_ENTRY_EDITOR_EDIT_STORED_PASSWORD_ACTION_TITLE" desc='Title for button on action bar that edits the stored password.'>
Edit password
</message>
<message name="IDS_PASSWORD_ENTRY_EDITOR_HIDE_STORED_PASSWORD" desc="A tooltip on a button that hides the saved password that is being shown.">
Hide password
</message>
<message name="IDS_PASSWORD_ENTRY_EDITOR_DELETE_STORED_PASSWORD" desc='Content description for the button that allows users to delete the stored password.'>
Delete stored password
</message>
<message name="IDS_PASSWORD_ENTRY_EDITOR_EDIT_STORED_PASSWORD" desc='Content description for the button that allows users to edit the stored password.'>
Edit stored password
</message>
<message name="IDS_PASSWORD_ENTRY_EDITOR_USERNAME_COPIED_INTO_CLIPBOARD" desc='Text that announces to the user that the username of a saved account has been copied into clipboard.'>
Username copied
</message>
......
......@@ -76,6 +76,7 @@ import org.chromium.base.test.BaseJUnit4ClassRunner;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.MetricsUtils;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeFeatureList;
import org.chromium.chrome.browser.history.HistoryActivity;
import org.chromium.chrome.browser.history.HistoryManager;
import org.chromium.chrome.browser.history.StubbedHistoryProvider;
......@@ -288,6 +289,24 @@ public class SavePasswordsPreferencesTest {
}
}
/**
* Looks for the edit saved password icon by id. If it cannot be found, it's probably hidden in
* the overflow menu. In that case, open the menu and search for its title.
* @return Returns either the edit saved password icon button or the edit saved password menu
* option.
*/
public static Matcher<View> withEditMenuIdOrText() {
Matcher<View> matcher = withId(R.id.action_edit_saved_password);
try {
Espresso.onView(matcher).check(matches(isDisplayed()));
return matcher;
} catch (Exception NoMatchingViewException) {
openActionBarOverflowOrOptionsMenu(
InstrumentationRegistry.getInstrumentation().getTargetContext());
return withText(R.string.password_entry_editor_edit_stored_password_action_title);
}
}
/**
* Taps the menu item to trigger exporting and ensures that reauthentication passes.
* It also disables the timer in {@link DialogManager} which is used to allow hiding the
......@@ -1450,6 +1469,25 @@ public class SavePasswordsPreferencesTest {
Espresso.onView(withId(R.id.menu_id_search)).check(matches(isDisplayed()));
}
/**
* Check that the icon for editing saved passwords is visible if the Feature is enabled.
*/
@Test
@SmallTest
@Feature({"Preferences"})
@Features.EnableFeatures(ChromeFeatureList.PASSWORD_EDITING_ANDROID)
public void testEditSavedPasswordIconVisibleInActionBarWithFeature() throws Exception {
setPasswordSource( // Initialize preferences
new SavedPasswordEntry("https://example.com", "test user", "test password"));
PreferencesTest.startPreferences(InstrumentationRegistry.getInstrumentation(),
SavePasswordsPreferences.class.getName());
Espresso.onView(withText(containsString("test user"))).perform(click());
Espresso.onView(withEditMenuIdOrText()).check(matches(isDisplayed()));
}
/**
* Check that the search item is visible if the Feature is enabled.
*/
......
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