Compare commits

...

6 Commits

Author SHA1 Message Date
Philipp Crocoll
50b4a9f1b9 add missing Theme attributes 2025-06-30 12:42:05 +02:00
Philipp Crocoll
9783c3b5fe manifest for 1.12-r7 2025-06-24 17:12:22 +02:00
Philipp Crocoll
7a837e3237 show autofill more often without requiring manual requests, might mitigate issues in https://github.com/PhilippC/keepass2android/issues/2898 2025-06-24 17:10:50 +02:00
Philipp Crocoll
c8f6714373 refactoring: simplify autofill code 2025-06-24 17:10:08 +02:00
Philipp Crocoll
bc0313aa6a remove no-longer-needed step in release workflow 2025-06-24 15:41:46 +02:00
Philipp Crocoll
0f98668bcd improve app stability and refactor to get better logs 2025-06-24 15:41:11 +02:00
15 changed files with 82 additions and 79 deletions

View File

@@ -111,14 +111,3 @@ jobs:
with:
files: |
src/keepass2android-app/bin/Release/net8.0-android/*-Signed.apk
- name: Run checksum action
uses: thewh1teagle/checksum@v2
with:
pre-release: true
file-name: 'apk-checksum-sha256.txt'
patterns: |
src/keepass2android-app/bin/Release/net8.0-android/*-Signed.apk
algorithm: sha256
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -95,7 +95,7 @@ namespace Kp2aAutofillParserTest
StructureParserBase<TestInputField> parser =
new StructureParserBase<TestInputField>(new TestLogger(), new TestDalSourceTrustAll());
var result = parser.ParseForFill(false, autofillView);
var result = parser.ParseForFill(autofillView);
if (expectedPackageName != null)
Assert.Equal(expectedPackageName, result.PackageName);
if (expectedWebDomain != null)

View File

@@ -476,8 +476,16 @@ namespace Kp2aAutofillParser
foreach (var field in autofillFields.HintMap.Values.Distinct())
{
if (field == null || field.AutofillHints == null)
{
continue;
}
foreach (var hint in field.AutofillHints)
{
if (hint == null)
{
continue;
}
if (GetPartitionIndex(hint) == partitionIndex)
{
filteredCollection.Add(field);
@@ -795,12 +803,12 @@ namespace Kp2aAutofillParser
public AutofillTargetId ParseForFill(bool isManual, AutofillView<FieldT> autofillView)
{
return Parse(true, isManual, autofillView);
return Parse(true, autofillView);
}
public AutofillTargetId ParseForSave(AutofillView<FieldT> autofillView)
{
return Parse(false, true, autofillView);
return Parse(false, autofillView);
}
/// <summary>
@@ -808,8 +816,7 @@ namespace Kp2aAutofillParser
/// </summary>
/// <returns>The parse.</returns>
/// <param name="forFill">If set to <c>true</c> for fill.</param>
/// <param name="isManualRequest"></param>
protected virtual AutofillTargetId Parse(bool forFill, bool isManualRequest, AutofillView<FieldT> autofillView)
protected virtual AutofillTargetId Parse(bool forFill, AutofillView<FieldT> autofillView)
{
AutofillTargetId result = new AutofillTargetId()
{
@@ -876,8 +883,9 @@ namespace Kp2aAutofillParser
}
//for "heuristic determination" we demand that one of the filled fields is focused:
if (passwordFields.Concat(usernameFields).Any(f => f.IsFocused))
//for "heuristic determination" we demand that there is a password field or one of the username fields is focused:
//Note that "IsFocused" might be false even when tapping the field. It might require long-press to autofill.
if (passwordFields.Any() || usernameFields.Any(f => f.IsFocused))
{
foreach (var uf in usernameFields)
AddFieldToHintMap(uf, new string[] { AutofillHintsHelper.AutofillHintUsername });

View File

@@ -15,7 +15,14 @@ namespace KeePass.Util
string errorMessage = e.Message;
if (e is Java.Lang.Exception javaException)
{
errorMessage = javaException.LocalizedMessage ?? javaException.Message ?? errorMessage;
try
{
errorMessage = javaException.LocalizedMessage ?? javaException.Message ?? errorMessage;
}
finally
{
}
}
return errorMessage;

View File

@@ -14,7 +14,7 @@ using keepass2android;
namespace keepass2android
{
[Activity(Label = AppNames.AppName)]
[Activity(Label = AppNames.AppName, Theme = "@style/Kp2aTheme_BlueNoActionBar")]
public class AppKilledInfo : Activity, IDialogInterfaceOnDismissListener
{
protected override void OnCreate(Bundle bundle)

View File

@@ -19,7 +19,7 @@ using keepass2android.services.AutofillBase;
namespace keepass2android
{
[Activity(Label = "DisableAutofillForQueryActivity")]
[Activity(Label = "DisableAutofillForQueryActivity", Theme = "@style/Kp2aTheme_ActionBar")]
public class DisableAutofillForQueryActivity : Activity
{
public IAutofillIntentBuilder IntentBuilder = new Kp2aAutofillIntentBuilder();
@@ -63,8 +63,6 @@ namespace keepass2android
prefs.Edit().PutStringSet("AutoFillDisabledQueries", disabledValues).Commit();
bool isManual = Intent.GetBooleanExtra(ChooseForAutofillActivityBase.ExtraIsManualRequest, false);
Intent reply = new Intent();
FillResponse.Builder builder = new FillResponse.Builder();
AssistStructure structure = (AssistStructure)Intent.GetParcelableExtra(AutofillManager.ExtraAssistStructure);
@@ -77,7 +75,7 @@ namespace keepass2android
StructureParser parser = new StructureParser(this, structure);
try
{
parser.ParseForFill(isManual);
parser.ParseForFill();
}
catch (Java.Lang.SecurityException e)

View File

@@ -894,9 +894,14 @@ namespace keepass2android
RegisterInfoTextDisplay(
"DbReadOnly"); //this ensures that we don't show the general info texts too soon
FindViewById<TextView>(Resource.Id.dbreadonly_infotext_text).Text =
(GetString(Resource.String.FileReadOnlyMessagePre) + " " +
App.Kp2a.GetResourceString(reason.Result));
var infotext_view = FindViewById<TextView>(Resource.Id.dbreadonly_infotext_text);
if (infotext_view != null)
{
infotext_view.Text =
(GetString(Resource.String.FileReadOnlyMessagePre) + " " +
App.Kp2a.GetResourceString(reason.Result));
}
}
}
UpdateBottomBarElementVisibility(Resource.Id.dbreadonly_infotext, canShow);

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="210"
android:versionName="1.12-r6b"
android:versionCode="211"
android:versionName="1.12-r7"
package="keepass2android.keepass2android"
xmlns:tools="http://schemas.android.com/tools"
android:installLocation="auto">

View File

@@ -1245,7 +1245,7 @@ namespace keepass2android
{
var db = TryFindDatabaseForElement(element);
if (db == null)
throw new Exception("Database element not found!");
throw new Exception($"Database element {element.Uuid} not found in any of {OpenDatabases.Count()} databases!");
return db;
}

View File

@@ -15,6 +15,7 @@ using Android.Content.Res;
using Android.Preferences;
using Google.Android.Material.Dialog;
using keepass2android;
using PluginTOTP;
namespace keepass2android
{
@@ -638,19 +639,7 @@ namespace keepass2android
if (CopyTotpToClipboard && isTotpEntry)
{
Dictionary<string, string> entryFields = pwEntryOutput.OutputStrings.ToDictionary(pair => StrUtil.SafeXmlString(pair.Key), pair => pair.Value.ReadString());
var totpData= totpPluginAdapter.GetTotpData(entryFields, activity, true);
if (totpData.IsTotpEntry)
{
TOTPProvider prov = new TOTPProvider(totpData);
string totp = prov.GenerateByByte(totpData.TotpSecret);
CopyToClipboardService.CopyValueToClipboardWithTimeout(activity, totp, true);
App.Kp2a.ShowMessage(activity, activity.GetString(Resource.String.TotpCopiedToClipboard),
MessageSeverity.Info);
}
DoCopyTotpToClipboard(activity, pwEntryOutput, totpPluginAdapter);
}
if (CloseAfterCreate)
@@ -661,7 +650,23 @@ namespace keepass2android
activity.CloseAfterTaskComplete();
}
}
}
private static void DoCopyTotpToClipboard(EntryActivity activity, PwEntryOutput pwEntryOutput,
ITotpPluginAdapter? totpPluginAdapter)
{
Dictionary<string, string> entryFields = pwEntryOutput.OutputStrings.ToDictionary(pair => StrUtil.SafeXmlString(pair.Key), pair => pair.Value.ReadString());
var totpData = totpPluginAdapter.GetTotpData(entryFields, activity, true);
if (totpData.IsTotpEntry)
{
TOTPProvider prov = new TOTPProvider(totpData);
string totp = prov.GenerateByByte(totpData.TotpSecret);
CopyToClipboardService.CopyValueToClipboardWithTimeout(activity, totp, true);
App.Kp2a.ShowMessage(activity, activity.GetString(Resource.String.TotpCopiedToClipboard),
MessageSeverity.Info);
}
}
}
/// <summary>

View File

@@ -28,13 +28,11 @@ namespace keepass2android.services.AutofillBase
{
public interface IAutofillIntentBuilder
{
PendingIntent GetAuthPendingIntentForResponse(Context context, string query, string queryDomain, string queryPackage,
bool isManualRequest, bool autoReturnFromQuery, AutofillServiceBase.DisplayWarning warning);
PendingIntent GetAuthPendingIntentForResponse(Context context, string query, string queryDomain, string queryPackage, bool autoReturnFromQuery, AutofillServiceBase.DisplayWarning warning);
PendingIntent GetAuthPendingIntentForWarning(Context context, PwUuid entryUuid, AutofillServiceBase.DisplayWarning warning);
PendingIntent GetDisablePendingIntentForResponse(Context context, string query,
bool isManualRequest, bool isDisable);
PendingIntent GetDisablePendingIntentForResponse(Context context, string query, bool isDisable);
Intent GetRestartAppIntent(Context context);
int AppIconResource { get; }
@@ -150,7 +148,7 @@ namespace keepass2android.services.AutofillBase
var parser = new StructureParser(this, structure);
try
{
query = parser.ParseForFill(isManual);
query = parser.ParseForFill();
}
catch (Java.Lang.SecurityException e)
@@ -213,16 +211,14 @@ namespace keepass2android.services.AutofillBase
{
if (query.WebDomain != null)
AddQueryDataset(query.WebDomain,
query.WebDomain, query.PackageName,
isManual, autofillIds, responseBuilder, !hasEntryDataset,
query.WebDomain, query.PackageName, autofillIds, responseBuilder, !hasEntryDataset,
query.IncompatiblePackageAndDomain
? DisplayWarning.FillDomainInUntrustedApp
: DisplayWarning.None,
AutofillHelper.ExtractSpec(inlinePresentationSpecs, entryDatasets.Count));
else
AddQueryDataset(query.PackageNameWithPseudoSchema,
query.WebDomain, query.PackageName,
isManual, autofillIds, responseBuilder, !hasEntryDataset, DisplayWarning.None,
query.WebDomain, query.PackageName, autofillIds, responseBuilder, !hasEntryDataset, DisplayWarning.None,
AutofillHelper.ExtractSpec(inlinePresentationSpecs, entryDatasets.Count));
}
@@ -340,9 +336,9 @@ namespace keepass2android.services.AutofillBase
}
private void AddQueryDataset(string query, string queryDomain, string queryPackage, bool isManual, AutofillId[] autofillIds, FillResponse.Builder responseBuilder, bool autoReturnFromQuery, DisplayWarning warning, InlinePresentationSpec inlinePresentationSpec)
private void AddQueryDataset(string query, string queryDomain, string queryPackage, AutofillId[] autofillIds, FillResponse.Builder responseBuilder, bool autoReturnFromQuery, DisplayWarning warning, InlinePresentationSpec inlinePresentationSpec)
{
PendingIntent pendingIntent = IntentBuilder.GetAuthPendingIntentForResponse(this, query, queryDomain, queryPackage, isManual, autoReturnFromQuery, warning);
PendingIntent pendingIntent = IntentBuilder.GetAuthPendingIntentForResponse(this, query, queryDomain, queryPackage, autoReturnFromQuery, warning);
string text = GetString(Resource.String.autofill_sign_in_prompt);
RemoteViews overlayPresentation = AutofillHelper.NewRemoteViews(base.PackageName,
text, AppNames.LauncherIcon);
@@ -396,7 +392,7 @@ namespace keepass2android.services.AutofillBase
if (isQueryDisabled && !isManual)
return;
bool isForDisable = !isQueryDisabled;
var pendingIntent = IntentBuilder.GetDisablePendingIntentForResponse(this, query, isManual, isForDisable);
var pendingIntent = IntentBuilder.GetDisablePendingIntentForResponse(this, query, isForDisable);
string text = GetString(isForDisable ? Resource.String.autofill_disable : Resource.String.autofill_enable_for, new Java.Lang.Object[] { GetDisplayNameForQuery(query, this) });
RemoteViews presentation = AutofillHelper.NewRemoteViews(base.PackageName,

View File

@@ -27,7 +27,6 @@ namespace keepass2android.services.AutofillBase
public static string ExtraQueryPackageString => "EXTRA_QUERY_PACKAGE_STRING";
public static string ExtraQueryDomainString => "EXTRA_QUERY_DOMAIN_STRING";
public static string ExtraUseLastOpenedEntry => "EXTRA_USE_LAST_OPENED_ENTRY"; //if set to true, no query UI is displayed. Can be used to just show a warning
public static string ExtraIsManualRequest => "EXTRA_IS_MANUAL_REQUEST";
public static string ExtraAutoReturnFromQuery => "EXTRA_AUTO_RETURN_FROM_QUERY";
public static string ExtraDisplayWarning => "EXTRA_DISPLAY_WARNING";
@@ -185,18 +184,18 @@ namespace keepass2android.services.AutofillBase
ReplyIntent = null;
}
protected void OnSuccess(FilledAutofillFieldCollection<ViewNodeInputField> clientFormDataMap, bool isManual)
protected void OnSuccess(FilledAutofillFieldCollection<ViewNodeInputField> clientFormDataMap)
{
var intent = Intent;
AssistStructure structure = (AssistStructure)intent.GetParcelableExtra(AutofillManager.ExtraAssistStructure);
if (structure == null)
if (structure == null || clientFormDataMap == null)
{
SetResult(Result.Canceled);
Finish();
return;
}
StructureParser parser = new StructureParser(this, structure);
parser.ParseForFill(isManual);
parser.ParseForFill();
AutofillFieldMetadataCollection autofillFields = parser.AutofillFields;
var partitionData = AutofillHintsHelper.FilterForPartition(clientFormDataMap, parser.AutofillFields.FocusedAutofillCanonicalHints);
@@ -229,7 +228,7 @@ namespace keepass2android.services.AutofillBase
private void ReturnSuccess()
{
OnSuccess(GetDataset(), Intent.GetBooleanExtra(ExtraIsManualRequest, false));
OnSuccess(GetDataset());
Finish();
}

View File

@@ -72,7 +72,7 @@ namespace keepass2android.services.AutofillBase
domainSuffixParserCache = new PublicSuffixRuleCache(context);
}
public AutofillView<ViewNodeInputField> GetAutofillView(bool isManualRequest)
public AutofillView<ViewNodeInputField> GetAutofillView()
{
AutofillView<ViewNodeInputField> autofillView = new AutofillView<ViewNodeInputField>();
@@ -83,7 +83,7 @@ namespace keepass2android.services.AutofillBase
var node = _structure.GetWindowNodeAt(i);
var view = node.RootViewNode;
ParseRecursive(autofillView, view, isManualRequest);
ParseRecursive(autofillView, view);
}
autofillView.PackageId = autofillView.PackageId ?? _structure.ActivityComponent.PackageName;
@@ -93,7 +93,7 @@ namespace keepass2android.services.AutofillBase
}
void ParseRecursive(AutofillView<ViewNodeInputField> autofillView, AssistStructure.ViewNode viewNode, bool isManualRequest)
void ParseRecursive(AutofillView<ViewNodeInputField> autofillView, AssistStructure.ViewNode viewNode)
{
String webDomain = viewNode.WebDomain;
if ((autofillView.PackageId == null) && (!string.IsNullOrWhiteSpace(viewNode.IdPackage)) &&
@@ -129,7 +129,7 @@ namespace keepass2android.services.AutofillBase
{
for (int i = 0; i < childrenSize; i++)
{
ParseRecursive(autofillView, viewNode.GetChildAt(i), isManualRequest);
ParseRecursive(autofillView, viewNode.GetChildAt(i));
}
}
}
@@ -159,11 +159,11 @@ namespace keepass2android.services.AutofillBase
}
protected override AutofillTargetId Parse(bool forFill, bool isManualRequest, AutofillView<ViewNodeInputField> autofillView)
protected override AutofillTargetId Parse(bool forFill, AutofillView<ViewNodeInputField> autofillView)
{
if (autofillView == null)
Kp2aLog.Log("Received null autofill view!");
var result = base.Parse(forFill, isManualRequest, autofillView);
var result = base.Parse(forFill, autofillView);
Kp2aLog.Log("Parsing done");
@@ -185,14 +185,14 @@ namespace keepass2android.services.AutofillBase
public AutofillTargetId ParseForSave()
{
var autofillView = new AutofillViewFromAssistStructureFinder(_context, _structure).GetAutofillView(true);
return Parse(false, true, autofillView);
var autofillView = new AutofillViewFromAssistStructureFinder(_context, _structure).GetAutofillView();
return Parse(false, autofillView);
}
public StructureParserBase<ViewNodeInputField>.AutofillTargetId ParseForFill(bool isManual)
public StructureParserBase<ViewNodeInputField>.AutofillTargetId ParseForFill()
{
var autofillView = new AutofillViewFromAssistStructureFinder(_context, _structure).GetAutofillView(isManual);
return Parse(true, isManual, autofillView);
var autofillView = new AutofillViewFromAssistStructureFinder(_context, _structure).GetAutofillView();
return Parse(true, autofillView);
}

View File

@@ -17,14 +17,12 @@ namespace keepass2android.services
{
private static int _pendingIntentRequestCode = 0;
public PendingIntent GetAuthPendingIntentForResponse(Context context, string query, string queryDomain, string queryPackage,
bool isManualRequest, bool autoReturnFromQuery, AutofillServiceBase.DisplayWarning warning)
public PendingIntent GetAuthPendingIntentForResponse(Context context, string query, string queryDomain, string queryPackage, bool autoReturnFromQuery, AutofillServiceBase.DisplayWarning warning)
{
Intent intent = new Intent(context, typeof(ChooseForAutofillActivity));
intent.PutExtra(ChooseForAutofillActivityBase.ExtraQueryString, query);
intent.PutExtra(ChooseForAutofillActivityBase.ExtraQueryDomainString, queryDomain);
intent.PutExtra(ChooseForAutofillActivityBase.ExtraQueryPackageString, queryPackage);
intent.PutExtra(ChooseForAutofillActivityBase.ExtraIsManualRequest, isManualRequest);
intent.PutExtra(ChooseForAutofillActivityBase.ExtraAutoReturnFromQuery, autoReturnFromQuery);
intent.PutExtra(ChooseForAutofillActivityBase.ExtraDisplayWarning, (int)warning);
return PendingIntent.GetActivity(context, _pendingIntentRequestCode++, intent, Util.AddMutabilityFlag(PendingIntentFlags.CancelCurrent, PendingIntentFlags.Mutable));
@@ -40,12 +38,10 @@ namespace keepass2android.services
return PendingIntent.GetActivity(context, _pendingIntentRequestCode++, intent, Util.AddMutabilityFlag(PendingIntentFlags.CancelCurrent, PendingIntentFlags.Mutable));
}
public PendingIntent GetDisablePendingIntentForResponse(Context context, string query,
bool isManualRequest, bool isDisable)
public PendingIntent GetDisablePendingIntentForResponse(Context context, string query, bool isDisable)
{
Intent intent = new Intent(context, typeof(DisableAutofillForQueryActivity));
intent.PutExtra(ChooseForAutofillActivityBase.ExtraQueryString, query);
intent.PutExtra(ChooseForAutofillActivityBase.ExtraIsManualRequest, isManualRequest);
intent.PutExtra(DisableAutofillForQueryActivity.ExtraIsDisable, isDisable);
return PendingIntent.GetActivity(context, _pendingIntentRequestCode++, intent, Util.AddMutabilityFlag(PendingIntentFlags.CancelCurrent, PendingIntentFlags.Immutable));

View File

@@ -9,7 +9,7 @@ using KeePassLib.Serialization;
namespace keepass2android
{
[Activity]
[Activity(Theme = "@style/Kp2aTheme_ActionBar")]
public class ExportKeyfileActivity : LockCloseActivity
{