diff --git a/src/Kp2aAutofillParserTest/AutofillTest.cs b/src/Kp2aAutofillParserTest/AutofillTest.cs index 2c9c2a7e..df9f2a42 100644 --- a/src/Kp2aAutofillParserTest/AutofillTest.cs +++ b/src/Kp2aAutofillParserTest/AutofillTest.cs @@ -51,6 +51,13 @@ namespace Kp2aAutofillParserTest RunTestFromAutofillInput(resourceName, "org.mozilla.firefox", "www.amazon.it"); } + [Fact] + public void TestDoNotFillPasswordAsUsername() + { + var resourceName = "Kp2aAutofillParserTest.citibank.json"; + RunTestFromAutofillInput(resourceName, "com.konylabs.cbplpat", null); + } + [Fact] public void CanDetectFieldsWithoutAutofillHints() { diff --git a/src/Kp2aAutofillParserTest/Kp2aAutofillParserTest.csproj b/src/Kp2aAutofillParserTest/Kp2aAutofillParserTest.csproj index d68279ff..862ddead 100644 --- a/src/Kp2aAutofillParserTest/Kp2aAutofillParserTest.csproj +++ b/src/Kp2aAutofillParserTest/Kp2aAutofillParserTest.csproj @@ -1,4 +1,4 @@ - + net6.0 @@ -11,6 +11,7 @@ + @@ -46,6 +47,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest diff --git a/src/keepass2android/EntryActivity.cs b/src/keepass2android/EntryActivity.cs index 91545a37..e9691cc9 100644 --- a/src/keepass2android/EntryActivity.cs +++ b/src/keepass2android/EntryActivity.cs @@ -721,7 +721,7 @@ namespace keepass2android var stringView = new ExtraStringView(layout, valueView, valueViewVisible, keyView); _stringViews.Add(key, stringView); - RegisterTextPopup(valueViewContainer, valueViewContainer.FindViewById(Resource.Id.extra_vdots), key, isProtected); + RegisterTextPopup(valueViewContainer, valueViewContainer.FindViewById(Resource.Id.extra_vdots), key, isProtected, layout); return stringView; @@ -731,6 +731,7 @@ namespace keepass2android private List RegisterPopup(string popupKey, View clickView, View anchorView) { + clickView.Click += (sender, args) => { ShowPopup(anchorView, popupKey); @@ -959,16 +960,20 @@ namespace keepass2android RegisterProtectedTextView(Kp2aTotp.TotpKey, FindViewById(Resource.Id.entry_totp), FindViewById(Resource.Id.entry_totp_visible)); RegisterTextPopup(FindViewById (Resource.Id.groupname_container), - FindViewById (Resource.Id.entry_group_name), KeyGroupFullPath); + FindViewById (Resource.Id.entry_group_name), KeyGroupFullPath, + FindViewById(Resource.Id.entryfield_group_container)); RegisterTextPopup(FindViewById(Resource.Id.username_container), - FindViewById(Resource.Id.username_vdots), PwDefs.UserNameField); + FindViewById(Resource.Id.username_vdots), PwDefs.UserNameField, + FindViewById(Resource.Id.entryfield_container_username)); RegisterTextPopup(FindViewById(Resource.Id.url_container), - FindViewById(Resource.Id.url_vdots), PwDefs.UrlField) + FindViewById(Resource.Id.url_vdots), PwDefs.UrlField, + FindViewById(Resource.Id.entryfield_container_url)) .Add(new GotoUrlMenuItem(this, PwDefs.UrlField)); RegisterTextPopup(FindViewById(Resource.Id.password_container), - FindViewById(Resource.Id.password_vdots), PwDefs.PasswordField); + FindViewById(Resource.Id.password_vdots), PwDefs.PasswordField, + FindViewById(Resource.Id.entryfield_container_password)); RegisterTextPopup(FindViewById(Resource.Id.totp_container), FindViewById(Resource.Id.totp_vdots), Kp2aTotp.TotpKey); @@ -987,7 +992,8 @@ namespace keepass2android } PopulateStandardText(Resource.Id.entry_comment, Resource.Id.entryfield_container_comment, PwDefs.NotesField); RegisterTextPopup(FindViewById(Resource.Id.comment_container), - FindViewById(Resource.Id.comment_vdots), PwDefs.NotesField); + FindViewById(Resource.Id.comment_vdots), PwDefs.NotesField, + FindViewById(Resource.Id.entryfield_container_comment)); PopulateText(Resource.Id.entry_tags, Resource.Id.entryfield_container_tags, concatTags(Entry.Tags)); PopulateText(Resource.Id.entry_override_url, Resource.Id.entryfield_container_overrideurl, Entry.OverrideUrl); @@ -1084,12 +1090,12 @@ namespace keepass2android SendBroadcast(i); } } - private List RegisterTextPopup(View container, View anchor, string fieldKey) + private List RegisterTextPopup(View container, View anchor, string fieldKey, View outerContainer) { - return RegisterTextPopup(container, anchor, fieldKey, Entry.Strings.GetSafe(fieldKey).IsProtected || fieldKey == Kp2aTotp.TotpKey); + return RegisterTextPopup(container, anchor, fieldKey, Entry.Strings.GetSafe(fieldKey).IsProtected || fieldKey == Kp2aTotp.TotpKey, outerContainer); } - private List RegisterTextPopup(View container, View anchor, string fieldKey, bool isProtected) + private List RegisterTextPopup(View container, View anchor, string fieldKey, bool isProtected, View outerContainer) { string popupKey = Strings.PrefixString + fieldKey; var popupItems = RegisterPopup( @@ -1108,6 +1114,11 @@ namespace keepass2android popupItems.Add(new ToggleVisibilityPopupMenuItem(this, valueView)); } + //copy text to clipboard when the outer container (including the field icon on the left) or the inner container + // (containing the textview and the vertical dots for the popup menu) is long-clicked. + RegisterCopyOnLongClick(outerContainer, fieldKey, isProtected); + RegisterCopyOnLongClick(container, fieldKey, isProtected); + if (fieldKey != PwDefs.UrlField //url already has a go-to-url menu && (_stringViews[fieldKey].Text.StartsWith(KeePass.AndroidAppScheme) || _stringViews[fieldKey].Text.StartsWith("http://") @@ -1118,6 +1129,11 @@ namespace keepass2android return popupItems; } + private void RegisterCopyOnLongClick(View container, string fieldKey, bool isProtected) + { + container.LongClick += (sender, args) => + CopyToClipboardService.CopyValueToClipboardWithTimeout(this, _stringViews[fieldKey].Text, isProtected); + } private void ShowPopup(View anchor, string popupKey) @@ -1184,6 +1200,8 @@ namespace keepass2android value = SprEngine.Compile(value, new SprContext(Entry, App.Kp2a.CurrentDb.KpDatabase, SprCompileFlags.All)); PopulateText(viewIds, containerViewId, value); _stringViews.Add(key, new StandardStringView(viewIds, containerViewId, this)); + + } private void PopulateGroupText(int viewId, int containerViewId, String key)