mirror of
https://github.com/moparisthebest/keepass2android
synced 2024-11-22 01:02:16 -05:00
* added option to ignore duplicate uuids
* fixed issue with clearing entered passwords when leaving PasswordActivity (passwords were cleared when opening FS-Setup-Activity or NfcOtpActivity as well)
This commit is contained in:
parent
7cffa9a3c3
commit
687416d2bb
@ -100,6 +100,6 @@ namespace keepass2android
|
||||
|
||||
RemoteCertificateValidationCallback CertificateValidationCallback { get; }
|
||||
|
||||
|
||||
bool CheckForDuplicateUuids { get; }
|
||||
}
|
||||
}
|
@ -55,6 +55,7 @@ namespace keepass2android
|
||||
FileIsReadOnly,
|
||||
FileIsReadOnlyOnKitkat,
|
||||
CopyFileRequiredForEditing,
|
||||
DuplicateUuidsError
|
||||
DuplicateUuidsError,
|
||||
DuplicateUuidsErrorAdditional
|
||||
}
|
||||
}
|
||||
|
@ -174,31 +174,42 @@ namespace keepass2android
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void PopulateGlobals (PwGroup currentGroup)
|
||||
private void PopulateGlobals(PwGroup currentGroup, bool checkForDuplicateUuids )
|
||||
{
|
||||
|
||||
var childGroups = currentGroup.Groups;
|
||||
var childEntries = currentGroup.Entries;
|
||||
|
||||
foreach (PwEntry e in childEntries)
|
||||
{
|
||||
if (checkForDuplicateUuids)
|
||||
{
|
||||
if (Entries.ContainsKey(e.Uuid))
|
||||
{
|
||||
throw new DuplicateUuidsException();
|
||||
}
|
||||
|
||||
}
|
||||
Entries [e.Uuid] = e;
|
||||
}
|
||||
foreach (PwGroup g in childGroups)
|
||||
{
|
||||
if (checkForDuplicateUuids)
|
||||
{
|
||||
|
||||
if (Groups.ContainsKey(g.Uuid))
|
||||
{
|
||||
throw new DuplicateUuidsException();
|
||||
}
|
||||
}
|
||||
Groups[g.Uuid] = g;
|
||||
PopulateGlobals(g);
|
||||
}
|
||||
}
|
||||
private void PopulateGlobals (PwGroup currentGroup)
|
||||
{
|
||||
PopulateGlobals(currentGroup, _app.CheckForDuplicateUuids);
|
||||
}
|
||||
|
||||
public void Clear() {
|
||||
Groups.Clear();
|
||||
|
@ -92,7 +92,7 @@ namespace keepass2android
|
||||
catch (DuplicateUuidsException e)
|
||||
{
|
||||
Kp2aLog.Log("Exception: " + e);
|
||||
Finish(false, _app.GetResourceString(UiStringKey.DuplicateUuidsError));
|
||||
Finish(false, _app.GetResourceString(UiStringKey.DuplicateUuidsError)+" " + _app.GetResourceString(UiStringKey.DuplicateUuidsErrorAdditional));
|
||||
return;
|
||||
}
|
||||
catch (Exception e)
|
||||
|
@ -139,6 +139,7 @@ namespace keepass2android
|
||||
|
||||
private ActivityDesign _design;
|
||||
private bool _performingLoad;
|
||||
private bool _keepPasswordInOnResume;
|
||||
|
||||
|
||||
public PasswordActivity (IntPtr javaReference, JniHandleOwnership transfer)
|
||||
@ -213,7 +214,7 @@ namespace keepass2android
|
||||
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
|
||||
{
|
||||
base.OnActivityResult(requestCode, resultCode, data);
|
||||
|
||||
_keepPasswordInOnResume = true;
|
||||
Kp2aLog.Log("PasswordActivity.OnActivityResult "+resultCode+"/"+requestCode);
|
||||
|
||||
AppTask.TryGetFromActivityResult(data, ref AppTask);
|
||||
@ -576,6 +577,7 @@ namespace keepass2android
|
||||
else if ((action != null) && (action.Equals(Intents.StartWithOtp)))
|
||||
{
|
||||
if (!GetIocFromOtpIntent(savedInstanceState, i)) return;
|
||||
_keepPasswordInOnResume = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -596,6 +598,10 @@ namespace keepass2android
|
||||
{
|
||||
_keyFileOrProvider = GetKeyFile(_ioConnection.Path);
|
||||
}
|
||||
if ((!string.IsNullOrEmpty(_keyFileOrProvider)) || (_password != ""))
|
||||
{
|
||||
_keepPasswordInOnResume = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (App.Kp2a.GetDb().Loaded && App.Kp2a.GetDb().Ioc != null &&
|
||||
@ -1199,7 +1205,7 @@ namespace keepass2android
|
||||
if ((intent != null) && (intent.HasExtra(Intents.OtpExtraKey)))
|
||||
{
|
||||
string otp = intent.GetStringExtra(Intents.OtpExtraKey);
|
||||
|
||||
_keepPasswordInOnResume = true;
|
||||
if (_otpInfo == null)
|
||||
{
|
||||
//Entering OTPs not yet initialized:
|
||||
@ -1260,6 +1266,12 @@ namespace keepass2android
|
||||
killButton.Visibility = ViewStates.Gone;
|
||||
}
|
||||
|
||||
if (!_keepPasswordInOnResume)
|
||||
{
|
||||
ClearEnteredPassword();
|
||||
}
|
||||
_keepPasswordInOnResume = false;
|
||||
|
||||
MakePasswordMaskedOrVisible();
|
||||
|
||||
UpdateOkButtonState();
|
||||
@ -1347,11 +1359,6 @@ namespace keepass2android
|
||||
}
|
||||
|
||||
}
|
||||
protected override void OnPause()
|
||||
{
|
||||
base.OnPause();
|
||||
ClearEnteredPassword(); //if the activity is left without opening the database, clear the password if entered
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
{
|
||||
@ -1437,7 +1444,18 @@ namespace keepass2android
|
||||
|
||||
GC.Collect(); // Ensure temporary memory used while loading is collected
|
||||
}
|
||||
if ((Message != null) && (Message.Length > 150)) //show long messages as dialog
|
||||
{
|
||||
new AlertDialog.Builder(_act).SetMessage(Message)
|
||||
.SetPositiveButton(Android.Resource.String.Ok,
|
||||
(sender, args) => ((Dialog) sender).Dismiss())
|
||||
.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
DisplayMessage(_act);
|
||||
}
|
||||
|
||||
|
||||
_act._performingLoad = false;
|
||||
|
||||
|
2222
src/keepass2android/Resources/Resource.designer.cs
generated
2222
src/keepass2android/Resources/Resource.designer.cs
generated
File diff suppressed because it is too large
Load Diff
@ -106,6 +106,7 @@
|
||||
<string name="UseOfflineCache_key">UseOfflineCache</string>
|
||||
<string name="AcceptAllServerCertificates_key">AcceptAllServerCertificates</string>
|
||||
<string name="CheckForFileChangesOnSave_key">CheckForFileChangesOnSave</string>
|
||||
<string name="CheckForDuplicateUuids_key">CheckForDuplicateUuids_key</string>
|
||||
|
||||
<string name="about_prefs_key">about_prefs</string>
|
||||
|
||||
|
@ -303,6 +303,9 @@
|
||||
<string name="CheckForFileChangesOnSave_title">Check for modifications</string>
|
||||
<string name="CheckForFileChangesOnSave_summary">Check whether the file was modified externally before saving changes.</string>
|
||||
|
||||
<string name="CheckForDuplicateUuids_title">Check for duplicate UUIDs</string>
|
||||
<string name="CheckForDuplicateUuids_summary">Check whether the database file is corrupt by having multiple entries with the same ID. This might cause unexpected behavior.</string>
|
||||
|
||||
<string name="ShowCopyToClipboardNotification_title">Clipboard notifications</string>
|
||||
<string name="ShowCopyToClipboardNotification_summary">Make username and password accessible through the notification bar and clipboard. Beware of password sniffers!</string>
|
||||
|
||||
@ -387,6 +390,7 @@
|
||||
|
||||
<string name="ErrorOcurred">An error occured:</string>
|
||||
<string name="DuplicateUuidsError">Database is corrupt: Duplicate IDs found. (Did you save with Minikeepass?) Please re-import to a new database with Keepass 2 for PC and select \'Create new IDs\'.</string>
|
||||
<string name="DuplicateUuidsErrorAdditional">You can disable this error message in Settings/Application settings/File handling/Check for duplicate UUIDs. Please note that you might experience unexpected behavior. It is recommended to fix the database.</string>
|
||||
|
||||
<string name="synchronize_database_menu">Synchronize database…</string>
|
||||
|
||||
|
@ -365,6 +365,13 @@
|
||||
android:title="@string/TanExpiresOnUse_title"
|
||||
android:summary="@string/TanExpiresOnUse_summary"
|
||||
android:defaultValue="@bool/TanExpiresOnUse_default"/>
|
||||
<CheckBoxPreference
|
||||
android:enabled="true"
|
||||
android:persistent="true"
|
||||
android:summary="@string/CheckForDuplicateUuids_summary"
|
||||
android:defaultValue="true"
|
||||
android:title="@string/CheckForDuplicateUuids_title"
|
||||
android:key="@string/CheckForDuplicateUuids_key" />
|
||||
|
||||
</PreferenceScreen>
|
||||
<PreferenceScreen
|
||||
|
@ -514,6 +514,15 @@ namespace keepass2android
|
||||
|
||||
}
|
||||
|
||||
public bool CheckForDuplicateUuids
|
||||
{
|
||||
get
|
||||
{
|
||||
var prefs = PreferenceManager.GetDefaultSharedPreferences(Application.Context);
|
||||
return prefs.GetBoolean(Application.Context.GetString(Resource.String.CheckForDuplicateUuids_key), true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
enum ValidationMode
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user