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),
|
RegisterTextPopup(FindViewById<RelativeLayout>(Resource.Id.url_container),
|
||||||
FindViewById(Resource.Id.url_vdots), PwDefs.UrlField)
|
FindViewById(Resource.Id.url_vdots), PwDefs.UrlField)
|
||||||
.Add(new GotoUrlMenuItem(this));
|
.Add(new GotoUrlMenuItem(this, PwDefs.UrlField));
|
||||||
RegisterTextPopup(FindViewById<RelativeLayout>(Resource.Id.password_container),
|
RegisterTextPopup(FindViewById<RelativeLayout>(Resource.Id.password_container),
|
||||||
FindViewById(Resource.Id.password_vdots), PwDefs.PasswordField);
|
FindViewById(Resource.Id.password_vdots), PwDefs.PasswordField);
|
||||||
|
|
||||||
@@ -877,6 +877,12 @@ namespace keepass2android
|
|||||||
popupItems.Add(new CopyToClipboardPopupMenuIcon(this, _stringViews[fieldKey]));
|
popupItems.Add(new CopyToClipboardPopupMenuIcon(this, _stringViews[fieldKey]));
|
||||||
if (isProtected)
|
if (isProtected)
|
||||||
popupItems.Add(new ToggleVisibilityPopupMenuItem(this));
|
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;
|
return popupItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1209,19 +1215,15 @@ namespace keepass2android
|
|||||||
newEntry.Touch(true, false); // Touch *after* backup
|
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 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));
|
newEntry.Strings.Set(PwDefs.UrlField, new ProtectedString(false, url));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int c = 1;
|
Util.SetNextFreeUrlField(newEntry, url);
|
||||||
while (newEntry.Strings.Get("KP2A_URL_" + c) != null)
|
|
||||||
{
|
|
||||||
c++;
|
|
||||||
}
|
|
||||||
|
|
||||||
newEntry.Strings.Set("KP2A_URL_" + c, new ProtectedString(false, url));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//save the entry:
|
//save the entry:
|
||||||
@@ -1247,9 +1249,9 @@ namespace keepass2android
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public bool GotoUrl()
|
public bool GotoUrl(string urlFieldKey)
|
||||||
{
|
{
|
||||||
string url = _stringViews[PwDefs.UrlField].Text;
|
string url = _stringViews[urlFieldKey].Text;
|
||||||
if (url == null) return false;
|
if (url == null) return false;
|
||||||
|
|
||||||
// Default http:// if no protocol specified
|
// Default http:// if no protocol specified
|
||||||
|
|||||||
@@ -8,12 +8,14 @@ namespace keepass2android
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
class GotoUrlMenuItem : IPopupMenuItem
|
class GotoUrlMenuItem : IPopupMenuItem
|
||||||
{
|
{
|
||||||
private readonly EntryActivity _ctx;
|
public string UrlFieldKey { get; }
|
||||||
|
private readonly EntryActivity _ctx;
|
||||||
|
|
||||||
public GotoUrlMenuItem(EntryActivity ctx)
|
public GotoUrlMenuItem(EntryActivity ctx, string urlFieldKey)
|
||||||
{
|
{
|
||||||
_ctx = ctx;
|
UrlFieldKey = urlFieldKey;
|
||||||
}
|
_ctx = ctx;
|
||||||
|
}
|
||||||
|
|
||||||
public Drawable Icon
|
public Drawable Icon
|
||||||
{
|
{
|
||||||
@@ -27,7 +29,7 @@ namespace keepass2android
|
|||||||
|
|
||||||
public void HandleClick()
|
public void HandleClick()
|
||||||
{
|
{
|
||||||
_ctx.GotoUrl();
|
_ctx.GotoUrl(UrlFieldKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -85,6 +85,8 @@ namespace keepass2android
|
|||||||
public const Result ExitLoadAnotherDb = Result.FirstUser + 10;
|
public const Result ExitLoadAnotherDb = Result.FirstUser + 10;
|
||||||
public const Result ExitLockByTimeout = Result.FirstUser + 11;
|
public const Result ExitLockByTimeout = Result.FirstUser + 11;
|
||||||
|
|
||||||
|
public const string AndroidAppScheme = "androidapp://";
|
||||||
|
|
||||||
|
|
||||||
public const string TagsKey = "@tags";
|
public const string TagsKey = "@tags";
|
||||||
public const string OverrideUrlKey = "@override";
|
public const string OverrideUrlKey = "@override";
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ namespace keepass2android
|
|||||||
if (Intent.Action == Strings.ActionQueryCredentialsForOwnPackage)
|
if (Intent.Action == Strings.ActionQueryCredentialsForOwnPackage)
|
||||||
{
|
{
|
||||||
_requiredScope = Strings.ScopeQueryCredentialsForOwnPackage;
|
_requiredScope = Strings.ScopeQueryCredentialsForOwnPackage;
|
||||||
_requestedUrl = "androidapp://" + _pluginPackage;
|
_requestedUrl = KeePass.AndroidAppScheme + _pluginPackage;
|
||||||
}
|
}
|
||||||
else if (Intent.Action == Strings.ActionQueryCredentials)
|
else if (Intent.Action == Strings.ActionQueryCredentials)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ namespace keepass2android
|
|||||||
{
|
{
|
||||||
//first: search for exact url
|
//first: search for exact url
|
||||||
var resultsForThisDb = db.SearchForExactUrl(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 no results, search for host (e.g. "accounts.google.com")
|
||||||
if (!resultsForThisDb.Entries.Any())
|
if (!resultsForThisDb.Entries.Any())
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ using Android.Hardware.Display;
|
|||||||
using Android.Util;
|
using Android.Util;
|
||||||
using Android.Views.InputMethods;
|
using Android.Views.InputMethods;
|
||||||
using AndroidX.Core.View.InputMethod;
|
using AndroidX.Core.View.InputMethod;
|
||||||
|
using KeePassLib;
|
||||||
|
using KeePassLib.Security;
|
||||||
using KeePassLib.Serialization;
|
using KeePassLib.Serialization;
|
||||||
using Uri = Android.Net.Uri;
|
using Uri = Android.Net.Uri;
|
||||||
|
|
||||||
@@ -666,6 +668,18 @@ namespace keepass2android
|
|||||||
SetNoPersonalizedLearning(editText);
|
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)
|
public override void PrepareNewEntry(PwEntry newEntry)
|
||||||
{
|
{
|
||||||
if (Url != null)
|
if (Url != null)
|
||||||
{
|
{
|
||||||
newEntry.Strings.Set(PwDefs.UrlField, new ProtectedString(false, Url));
|
Util.SetNextFreeUrlField(newEntry, Url);
|
||||||
}
|
}
|
||||||
if (AllFields != null)
|
if (AllFields != null)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ namespace keepass2android.services.AutofillBase
|
|||||||
string displayName = str;
|
string displayName = str;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string appPrefix = "androidapp://";
|
string appPrefix = KeePass.AndroidAppScheme;
|
||||||
if (str.StartsWith(appPrefix))
|
if (str.StartsWith(appPrefix))
|
||||||
{
|
{
|
||||||
str = str.Substring(appPrefix.Length);
|
str = str.Substring(appPrefix.Length);
|
||||||
@@ -282,7 +282,7 @@ namespace keepass2android.services.AutofillBase
|
|||||||
|
|
||||||
private bool CanAutofill(StructureParser.AutofillTargetId query, bool isManual)
|
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;
|
return false;
|
||||||
if (!isManual)
|
if (!isManual)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace keepass2android.services.AutofillBase
|
|||||||
|
|
||||||
public string PackageNameWithPseudoSchema
|
public string PackageNameWithPseudoSchema
|
||||||
{
|
{
|
||||||
get { return "androidapp://" + PackageName; }
|
get { return KeePass.AndroidAppScheme + PackageName; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public string WebDomain { get; set; }
|
public string WebDomain { get; set; }
|
||||||
|
|||||||
Reference in New Issue
Block a user