when storing package names of target apps in Password entries, no longer use the Url field or KP2A_URL_x fields, instead use AndroidAppX (X being a counter starting at 1), closes #657
This commit is contained in:
@@ -809,7 +809,7 @@ namespace keepass2android
|
||||
|
||||
RegisterTextPopup(FindViewById<RelativeLayout>(Resource.Id.url_container),
|
||||
FindViewById(Resource.Id.url_vdots), PwDefs.UrlField)
|
||||
.Add(new GotoUrlMenuItem(this));
|
||||
.Add(new GotoUrlMenuItem(this, PwDefs.UrlField));
|
||||
RegisterTextPopup(FindViewById<RelativeLayout>(Resource.Id.password_container),
|
||||
FindViewById(Resource.Id.password_vdots), PwDefs.PasswordField);
|
||||
|
||||
@@ -877,6 +877,12 @@ namespace keepass2android
|
||||
popupItems.Add(new CopyToClipboardPopupMenuIcon(this, _stringViews[fieldKey]));
|
||||
if (isProtected)
|
||||
popupItems.Add(new ToggleVisibilityPopupMenuItem(this));
|
||||
if (_stringViews[fieldKey].Text.StartsWith(KeePass.AndroidAppScheme)
|
||||
|| _stringViews[fieldKey].Text.StartsWith("http://")
|
||||
|| _stringViews[fieldKey].Text.StartsWith("https://"))
|
||||
{
|
||||
popupItems.Add(new GotoUrlMenuItem(this, fieldKey));
|
||||
}
|
||||
return popupItems;
|
||||
}
|
||||
|
||||
@@ -1209,19 +1215,15 @@ namespace keepass2android
|
||||
newEntry.Touch(true, false); // Touch *after* backup
|
||||
|
||||
//if there is no URL in the entry, set that field. If it's already in use, use an additional (not existing) field
|
||||
if (String.IsNullOrEmpty(newEntry.Strings.ReadSafe(PwDefs.UrlField)))
|
||||
if (!url.StartsWith(KeePass.AndroidAppScheme) && String.IsNullOrEmpty(newEntry.Strings.ReadSafe(PwDefs.UrlField)))
|
||||
{
|
||||
newEntry.Strings.Set(PwDefs.UrlField, new ProtectedString(false, url));
|
||||
}
|
||||
else
|
||||
{
|
||||
int c = 1;
|
||||
while (newEntry.Strings.Get("KP2A_URL_" + c) != null)
|
||||
{
|
||||
c++;
|
||||
}
|
||||
{
|
||||
Util.SetNextFreeUrlField(newEntry, url);
|
||||
|
||||
newEntry.Strings.Set("KP2A_URL_" + c, new ProtectedString(false, url));
|
||||
|
||||
}
|
||||
|
||||
//save the entry:
|
||||
@@ -1247,9 +1249,9 @@ namespace keepass2android
|
||||
}
|
||||
|
||||
|
||||
public bool GotoUrl()
|
||||
{
|
||||
string url = _stringViews[PwDefs.UrlField].Text;
|
||||
public bool GotoUrl(string urlFieldKey)
|
||||
{
|
||||
string url = _stringViews[urlFieldKey].Text;
|
||||
if (url == null) return false;
|
||||
|
||||
// Default http:// if no protocol specified
|
||||
|
||||
@@ -8,12 +8,14 @@ namespace keepass2android
|
||||
/// </summary>
|
||||
class GotoUrlMenuItem : IPopupMenuItem
|
||||
{
|
||||
private readonly EntryActivity _ctx;
|
||||
public string UrlFieldKey { get; }
|
||||
private readonly EntryActivity _ctx;
|
||||
|
||||
public GotoUrlMenuItem(EntryActivity ctx)
|
||||
{
|
||||
_ctx = ctx;
|
||||
}
|
||||
public GotoUrlMenuItem(EntryActivity ctx, string urlFieldKey)
|
||||
{
|
||||
UrlFieldKey = urlFieldKey;
|
||||
_ctx = ctx;
|
||||
}
|
||||
|
||||
public Drawable Icon
|
||||
{
|
||||
@@ -27,7 +29,7 @@ namespace keepass2android
|
||||
|
||||
public void HandleClick()
|
||||
{
|
||||
_ctx.GotoUrl();
|
||||
_ctx.GotoUrl(UrlFieldKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,6 +85,8 @@ namespace keepass2android
|
||||
public const Result ExitLoadAnotherDb = Result.FirstUser + 10;
|
||||
public const Result ExitLockByTimeout = Result.FirstUser + 11;
|
||||
|
||||
public const string AndroidAppScheme = "androidapp://";
|
||||
|
||||
|
||||
public const string TagsKey = "@tags";
|
||||
public const string OverrideUrlKey = "@override";
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace keepass2android
|
||||
if (Intent.Action == Strings.ActionQueryCredentialsForOwnPackage)
|
||||
{
|
||||
_requiredScope = Strings.ScopeQueryCredentialsForOwnPackage;
|
||||
_requestedUrl = "androidapp://" + _pluginPackage;
|
||||
_requestedUrl = KeePass.AndroidAppScheme + _pluginPackage;
|
||||
}
|
||||
else if (Intent.Action == Strings.ActionQueryCredentials)
|
||||
{
|
||||
|
||||
@@ -168,7 +168,7 @@ namespace keepass2android
|
||||
{
|
||||
//first: search for exact url
|
||||
var resultsForThisDb = db.SearchForExactUrl(url);
|
||||
if (!url.StartsWith("androidapp://"))
|
||||
if (!url.StartsWith(KeePass.AndroidAppScheme))
|
||||
{
|
||||
//if no results, search for host (e.g. "accounts.google.com")
|
||||
if (!resultsForThisDb.Entries.Any())
|
||||
|
||||
@@ -36,6 +36,8 @@ using Android.Hardware.Display;
|
||||
using Android.Util;
|
||||
using Android.Views.InputMethods;
|
||||
using AndroidX.Core.View.InputMethod;
|
||||
using KeePassLib;
|
||||
using KeePassLib.Security;
|
||||
using KeePassLib.Serialization;
|
||||
using Uri = Android.Net.Uri;
|
||||
|
||||
@@ -666,6 +668,18 @@ namespace keepass2android
|
||||
SetNoPersonalizedLearning(editText);
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetNextFreeUrlField(PwEntry entry, string url)
|
||||
{
|
||||
string prefix = url.StartsWith(KeePass.AndroidAppScheme) ? "AndroidApp" : "KP2A_URL_";
|
||||
int c = 1;
|
||||
while (entry.Strings.Get(prefix + c) != null)
|
||||
{
|
||||
c++;
|
||||
}
|
||||
|
||||
entry.Strings.Set(prefix + c, new ProtectedString(false, url));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -701,9 +701,9 @@ namespace keepass2android
|
||||
public override void PrepareNewEntry(PwEntry newEntry)
|
||||
{
|
||||
if (Url != null)
|
||||
{
|
||||
newEntry.Strings.Set(PwDefs.UrlField, new ProtectedString(false, Url));
|
||||
}
|
||||
{
|
||||
Util.SetNextFreeUrlField(newEntry, Url);
|
||||
}
|
||||
if (AllFields != null)
|
||||
{
|
||||
|
||||
|
||||
@@ -233,7 +233,7 @@ namespace keepass2android.services.AutofillBase
|
||||
string displayName = str;
|
||||
try
|
||||
{
|
||||
string appPrefix = "androidapp://";
|
||||
string appPrefix = KeePass.AndroidAppScheme;
|
||||
if (str.StartsWith(appPrefix))
|
||||
{
|
||||
str = str.Substring(appPrefix.Length);
|
||||
@@ -282,7 +282,7 @@ namespace keepass2android.services.AutofillBase
|
||||
|
||||
private bool CanAutofill(StructureParser.AutofillTargetId query, bool isManual)
|
||||
{
|
||||
if (query.PackageNameWithPseudoSchema == "androidapp://android" || query.PackageNameWithPseudoSchema == "androidapp://" + this.PackageName)
|
||||
if (query.PackageNameWithPseudoSchema == KeePass.AndroidAppScheme+"android" || query.PackageNameWithPseudoSchema == KeePass.AndroidAppScheme + this.PackageName)
|
||||
return false;
|
||||
if (!isManual)
|
||||
{
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace keepass2android.services.AutofillBase
|
||||
|
||||
public string PackageNameWithPseudoSchema
|
||||
{
|
||||
get { return "androidapp://" + PackageName; }
|
||||
get { return KeePass.AndroidAppScheme + PackageName; }
|
||||
}
|
||||
|
||||
public string WebDomain { get; set; }
|
||||
|
||||
Reference in New Issue
Block a user