Commit 25ea4099 authored by Nicolas Dossou-gbete's avatar Nicolas Dossou-gbete Committed by Commit Bot

Fix lint issues in PasswordEntryEditor

Duplicate resource id lookups in PasswordEntryEditor were
flagged by Android Linter and broke compilation. This CL fixes
them as well as some other warnings around unnecessary casts
and lambda conversions.

Bug: 788943
Change-Id: I194b7c80e6ba5d0e37c4b5eba3c95488b4003a0b
Reviewed-on: https://chromium-review.googlesource.com/832406Reviewed-by: default avatarTatiana Gornak <melandory@chromium.org>
Reviewed-by: default avatarBernhard Bauer <bauerb@chromium.org>
Commit-Queue: Nicolas Dossou-Gbété <dgn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#524733}
parent eb3770c4
......@@ -28,7 +28,6 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager.LayoutParams;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import org.chromium.base.ApiCompatibilityUtils;
......@@ -37,6 +36,7 @@ import org.chromium.chrome.R;
import org.chromium.chrome.browser.PasswordManagerHandler.PasswordListObserver;
import org.chromium.chrome.browser.PasswordUIView;
import org.chromium.chrome.browser.sync.ProfileSyncService;
import org.chromium.chrome.browser.widget.TintedImageButton;
import org.chromium.components.sync.AndroidSyncSettings;
import org.chromium.ui.text.SpanApplier;
import org.chromium.ui.widget.Toast;
......@@ -250,17 +250,14 @@ public class PasswordEntryEditor extends Fragment {
}
private void hookupCopyUsernameButton(View usernameView) {
final ImageButton copyUsernameButton =
(ImageButton) usernameView.findViewById(R.id.password_entry_editor_copy);
final ImageView copy_image = usernameView.findViewById(R.id.password_entry_editor_copy);
copy_image.setImageDrawable(
final TintedImageButton copyUsernameButton =
usernameView.findViewById(R.id.password_entry_editor_copy);
copyUsernameButton.setImageDrawable(
AppCompatResources.getDrawable(getActivity(), R.drawable.ic_content_copy_black));
copyUsernameButton.setContentDescription(
getActivity().getString(R.string.password_entry_editor_copy_stored_username));
copyUsernameButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
copyUsernameButton.setOnClickListener(v -> {
ClipData clip = ClipData.newPlainText("username",
getArguments().getString(SavePasswordsPreferences.PASSWORD_LIST_NAME));
mClipboard.setPrimaryClip(clip);
......@@ -271,24 +268,20 @@ public class PasswordEntryEditor extends Fragment {
RecordHistogram.recordEnumeratedHistogram(
"PasswordManager.Android.PasswordCredentialEntry.Username",
USERNAME_ACTION_COPIED, USERNAME_ACTION_BOUNDARY);
}
});
}
private void hookupCopySiteButton(View siteView) {
final ImageButton copySiteButton =
(ImageButton) siteView.findViewById(R.id.password_entry_editor_copy);
final TintedImageButton copySiteButton =
siteView.findViewById(R.id.password_entry_editor_copy);
copySiteButton.setContentDescription(
getActivity().getString(R.string.password_entry_editor_copy_stored_site));
final ImageView copy_image = siteView.findViewById(R.id.password_entry_editor_copy);
copy_image.setImageDrawable(
copySiteButton.setImageDrawable(
AppCompatResources.getDrawable(getActivity(), R.drawable.ic_content_copy_black));
copySiteButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ClipData clip = ClipData.newPlainText("site",
getArguments().getString(SavePasswordsPreferences.PASSWORD_LIST_URL));
copySiteButton.setOnClickListener(v -> {
ClipData clip = ClipData.newPlainText(
"site", getArguments().getString(SavePasswordsPreferences.PASSWORD_LIST_URL));
mClipboard.setPrimaryClip(clip);
Toast.makeText(getActivity().getApplicationContext(),
R.string.password_entry_editor_site_copied_into_clipboard,
......@@ -303,15 +296,14 @@ public class PasswordEntryEditor extends Fragment {
"PasswordManager.Android.PasswordCredentialEntry.Website",
WEBSITE_ACTION_COPIED, WEBSITE_ACTION_BOUNDARY);
}
}
});
}
private void changeHowPasswordIsDisplayed(
int visibilityIcon, int inputType, @StringRes int annotation) {
TextView passwordView = (TextView) mView.findViewById(R.id.password_entry_editor_password);
TextView passwordView = mView.findViewById(R.id.password_entry_editor_password);
ImageButton viewPasswordButton =
(ImageButton) mView.findViewById(R.id.password_entry_editor_view_password);
mView.findViewById(R.id.password_entry_editor_view_password);
passwordView.setText(mExtras.getString(SavePasswordsPreferences.PASSWORD_LIST_PASSWORD));
passwordView.setInputType(inputType);
viewPasswordButton.setImageResource(visibilityIcon);
......@@ -354,19 +346,14 @@ public class PasswordEntryEditor extends Fragment {
}
private void hookupPasswordButtons() {
final ImageButton copyPasswordButton =
(ImageButton) mView.findViewById(R.id.password_entry_editor_copy_password);
final ImageButton viewPasswordButton =
(ImageButton) mView.findViewById(R.id.password_entry_editor_view_password);
final ImageView copy_password =
final TintedImageButton copyPasswordButton =
mView.findViewById(R.id.password_entry_editor_copy_password);
copy_password.setImageDrawable(
final ImageButton viewPasswordButton =
mView.findViewById(R.id.password_entry_editor_view_password);
copyPasswordButton.setImageDrawable(
AppCompatResources.getDrawable(getActivity(), R.drawable.ic_content_copy_black));
copyPasswordButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!ReauthenticationManager.isScreenLockSetUp(
getActivity().getApplicationContext())) {
copyPasswordButton.setOnClickListener(v -> {
if (!ReauthenticationManager.isScreenLockSetUp(getActivity().getApplicationContext())) {
Toast.makeText(getActivity().getApplicationContext(),
R.string.password_entry_editor_set_lock_screen, Toast.LENGTH_LONG)
.show();
......@@ -378,15 +365,10 @@ public class PasswordEntryEditor extends Fragment {
R.string.lockscreen_description_copy,
R.id.password_entry_editor_interactive, getFragmentManager());
}
}
});
viewPasswordButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
TextView passwordView =
(TextView) mView.findViewById(R.id.password_entry_editor_password);
if (!ReauthenticationManager.isScreenLockSetUp(
getActivity().getApplicationContext())) {
viewPasswordButton.setOnClickListener(v -> {
TextView passwordView = mView.findViewById(R.id.password_entry_editor_password);
if (!ReauthenticationManager.isScreenLockSetUp(getActivity().getApplicationContext())) {
Toast.makeText(getActivity().getApplicationContext(),
R.string.password_entry_editor_set_lock_screen, Toast.LENGTH_LONG)
.show();
......@@ -402,7 +384,6 @@ public class PasswordEntryEditor extends Fragment {
R.string.lockscreen_description_view,
R.id.password_entry_editor_interactive, getFragmentManager());
}
}
});
}
}
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