From c934755e1c54d90baa13762916602b53e4ca1943 Mon Sep 17 00:00:00 2001 From: Philipp Crocoll Date: Wed, 3 Jan 2024 08:06:20 +0100 Subject: [PATCH] make settings field for TrayTotp style otp entries optional closes https://github.com/PhilippC/keepass2android/issues/2458 --- .../Totp/TrayTotpPluginAdapter.cs | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/src/keepass2android/Totp/TrayTotpPluginAdapter.cs b/src/keepass2android/Totp/TrayTotpPluginAdapter.cs index 1aeae561..d1266cfa 100644 --- a/src/keepass2android/Totp/TrayTotpPluginAdapter.cs +++ b/src/keepass2android/Totp/TrayTotpPluginAdapter.cs @@ -31,17 +31,8 @@ namespace PluginTOTP _muteWarnings = muteWarnings; } - /// - /// Check if specified Entry contains Settings that are not null. - /// - internal bool SettingsCheck(IDictionary entryFields) - { - string settings; - entryFields.TryGetValue(SettingsFieldName, out settings); - return !String.IsNullOrEmpty(settings); - } - - internal bool SeedCheck(IDictionary entryFields) + + internal bool HasSeed(IDictionary entryFields) { string seed; entryFields.TryGetValue(SeedFieldName, out seed); @@ -100,15 +91,15 @@ namespace PluginTOTP } private string[] SettingsGet(IDictionary entryFields) - { - return entryFields[SettingsFieldName].Split(';'); - } + { + return entryFields.TryGetValue(SettingsFieldName, out var settings) ? settings.Split(';') : new[] { "30", "6" }; + } public TotpData GetTotpData(IDictionary entryFields) { TotpData res = new TotpData(); - if (SettingsCheck(entryFields) && SeedCheck(entryFields)) + if (HasSeed(entryFields)) { bool ValidInterval; bool ValidLength; bool ValidUrl; if (SettingsValidate(entryFields, out ValidInterval, out ValidLength, out ValidUrl))