Make sure "duplicate UUID" error is not repeated after fixing the db

Make sure no duplicate UUIDs are created by cancelling the save operation and saving again
Reverse sort order for modification date (now descending)
Added beta warning for kdb
change log + manifest for 0.9.7-pre1
This commit is contained in:
Philipp Crocoll 2015-02-19 20:30:26 +01:00
parent 7f6a8c6544
commit ba1e591dc7
20 changed files with 96 additions and 30 deletions

2
.gitignore vendored
View File

@ -119,3 +119,5 @@ Thumbs.db
/src/MasterKeeWinPlugin/bin/Release
/src/SamplePlugin
/src/packages/
*.apk

View File

@ -56,6 +56,7 @@ namespace keepass2android
FileIsReadOnlyOnKitkat,
CopyFileRequiredForEditing,
DuplicateUuidsError,
DuplicateUuidsErrorAdditional
DuplicateUuidsErrorAdditional,
KdbBetaWarning
}
}

View File

@ -110,21 +110,31 @@ namespace keepass2android
Stream s = databaseData ?? fileStorage.OpenFileForRead(iocInfo);
var fileVersion = _app.GetFileStorage(iocInfo).GetCurrentFileVersionFast(iocInfo);
PopulateDatabaseFromStream(pwDatabase, s, iocInfo, compositeKey, status, databaseFormat);
LastFileVersion = fileVersion;
try
{
LastFileVersion = fileVersion;
status.UpdateSubMessage("");
Root = pwDatabase.RootGroup;
PopulateGlobals(Root);
Loaded = true;
KpDatabase = pwDatabase;
SearchHelper = new SearchDbHelper(app);
_databaseFormat = databaseFormat;
CanWrite = databaseFormat.CanWrite && !fileStorage.IsReadOnly(iocInfo);
}
catch (Exception)
{
Clear();
throw;
}
status.UpdateSubMessage("");
Root = pwDatabase.RootGroup;
PopulateGlobals(Root);
Loaded = true;
KpDatabase = pwDatabase;
SearchHelper = new SearchDbHelper(app);
_databaseFormat = databaseFormat;
CanWrite = databaseFormat.CanWrite && !fileStorage.IsReadOnly(iocInfo);
}
/// <summary>

View File

@ -24,10 +24,16 @@ namespace keepass2android
{
public class KdbDatabaseFormat: IDatabaseFormat
{
private readonly IKp2aApp _app;
private Dictionary<PwUuid, AdditionalGroupData> _groupData = new Dictionary<PwUuid, AdditionalGroupData>();
private static readonly DateTime _expireNever = new DateTime(2999,12,28,23,59,59);
private List<PwEntryV3> _metaStreams;
public KdbDatabaseFormat(IKp2aApp app)
{
_app = app;
}
public void PopulateDatabaseFromStream(PwDatabase db, Stream s, IStatusLogger slLogger)
{
#if !EXCLUDE_KEYTRANSFORM
@ -215,7 +221,7 @@ namespace keepass2android
public bool CanWrite { get { return true; } }
public string SuccessMessage { get
{
return "";
return _app.GetResourceString(UiStringKey.KdbBetaWarning);
} }
public void Save(PwDatabase kpDatabase, Stream stream)

View File

@ -48,7 +48,15 @@ namespace keepass2android
public override void Run() {
StatusLogger.UpdateMessage(UiStringKey.AddingEntry);
_parentGroup.AddEntry(_entry, true);
//make sure we're not adding the entry if it was added before.
//(this might occur in very rare cases where the user dismissis the save dialog
//by rotating the screen while saving and then presses save again)
if (_parentGroup.FindEntry(_entry.Uuid, false) == null)
{
_parentGroup.AddEntry(_entry, true);
}
// Commit to disk
SaveDb save = new SaveDb(_ctx, _app, OnFinishToRun);

View File

@ -125,7 +125,7 @@ namespace keepass2android
}
catch (OldFormatException)
{
_format = new KdbDatabaseFormat();
_format = new KdbDatabaseFormat(_app);
TryLoad(databaseStream);
}
catch (InvalidCompositeKeyException)

View File

@ -138,7 +138,7 @@ namespace Kp2aUnitTests
Database db = app.CreateNewDatabase();
if (filename.EndsWith(".kdb"))
{
db.DatabaseFormat = new KdbDatabaseFormat();
db.DatabaseFormat = new KdbDatabaseFormat(app);
}
db.KpDatabase = new PwDatabase();

View File

@ -26,7 +26,7 @@ namespace keepass2android
AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(ctx, Android.Resource.Style.ThemeHoloLightDialog));
builder.SetTitle(ctx.GetString(Resource.String.ChangeLog_title));
List<string> changeLog = new List<string>{
ctx.GetString(Resource.String.ChangeLog_0_9_7),
ctx.GetString(Resource.String.ChangeLog_0_9_6),
ctx.GetString(Resource.String.ChangeLog_0_9_5),
ctx.GetString(Resource.String.ChangeLog_0_9_4),

View File

@ -19,6 +19,7 @@
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
using System.Diagnostics;
@ -56,7 +57,7 @@ namespace KeeChallenge
set;
}
private KeeChallengeProv()
public KeeChallengeProv()
{
LT64 = false;
}

View File

@ -1464,9 +1464,6 @@ namespace keepass2android
{
_act.ClearEnteredPassword();
_act.LaunchNextActivity();
_act.BroadcastOpenDatabase();
@ -1476,12 +1473,24 @@ namespace keepass2android
{
new AlertDialog.Builder(_act).SetMessage(Message)
.SetPositiveButton(Android.Resource.String.Ok,
(sender, args) => ((Dialog) sender).Dismiss())
(sender, args) =>
{
((Dialog) sender).Dismiss();
_act.LaunchNextActivity();
})
.SetCancelable(false)
.Show();
}
else
{
DisplayMessage(_act);
if (Success)
{
_act.LaunchNextActivity();
}
}

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="52"
android:versionName="0.9.6"
android:versionCode="53"
android:versionName="0.9.7-pre1"
package="keepass2android.keepass2android"
android:installLocation="auto">
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="21" />

View File

@ -49,12 +49,12 @@ namespace keepass2android
public int CompareEntries(PwEntry a, PwEntry b)
{
return a.LastModificationTime.CompareTo(b.LastModificationTime);
return -a.LastModificationTime.CompareTo(b.LastModificationTime);
}
public int CompareGroups(PwGroup a, PwGroup b)
{
return a.LastModificationTime.CompareTo(b.LastModificationTime);
return -a.LastModificationTime.CompareTo(b.LastModificationTime);
}
}
class CreationDateSortOrder : IGroupViewSortOrder

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

View File

@ -521,12 +521,24 @@
<string name="CancelReadOnly">Cancel, open read-only.</string>
<string name="CopyingFile">Copying file...</string>
<string name="KdbBetaWarning">Please note: You have loaded a Keepass 1 database. Keepass2Android has recently added write support for this database format. Despite thorough testing, the author does not guarantee that all data will be saved correctly. Please always keep a backup of the original database (Dropbox automatically stores recent versions) before making changes. Please report any issues. Thanks!</string>
<string name="ChangeLog_title">Change log</string>
<string name="PreviewWarning">Please note! This is a preview release and might come with some flaws! If you experience *anything* unexpected, please let me know (on Codeplex or by email).</string>
<string name="ChangeLog_0_9_6">
<string name="ChangeLog_0_9_7">
Version 0.9.7\n
* write support for Keepass 1 (kdb) databases (beta!)\n
* better switching back to previous keyboard (also works on non-rooted devices)\n
* support for KeeChallenge with variable length challenges\n
* prevent taking screenshots from QuickUnlock and password screens\n
* reverse sort order for Sort by Modification Date (now descending)\n
* bug fixes: Notes view now updated correctly after changes, Password views now hiding password correctly on (hopefully) all devices, fixed issue that allowed to add an entry twice, fixed issue with showing Duplicate UUID warning even after fixing the database\n
</string>
<string name="ChangeLog_0_9_6">
Version 0.9.6\n
* allow to import key file and/or local database file to app internal directory (see settings)\n
* allow different sorting options\n

View File

@ -367,6 +367,7 @@ namespace keepass2android
public RealProgressDialog(Context ctx)
{
_pd = new ProgressDialog(ctx);
_pd.SetCancelable(false);
}
public void SetTitle(string title)
@ -381,7 +382,15 @@ namespace keepass2android
public void Dismiss()
{
_pd.Dismiss();
try
{
_pd.Dismiss();
}
catch (Exception e)
{
Kp2aLog.Log(e.ToString());
}
}
public void Show()

View File

@ -689,6 +689,7 @@
<ProjectReference Include="..\Kp2aBusinessLogic\Kp2aBusinessLogic.csproj">
<Project>{53A9CB7F-6553-4BC0-B56B-9410BB2E59AA}</Project>
<Name>Kp2aBusinessLogic</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\KP2AKdbLibraryBinding\KP2AKdbLibraryBinding.csproj">
<Project>{70D3844A-D9FA-4A64-B205-A84C6A822196}</Project>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Xamarin.Android.Support.v4" version="21.0.3.0" targetFramework="MonoAndroid50" />
<package id="Xamarin.Android.Support.v7.AppCompat" version="21.0.3.0" targetFramework="MonoAndroid50" />
<package id="Xamarin.Android.Support.v7.MediaRouter" version="21.0.3.0" targetFramework="MonoAndroid50" />
<package id="Xamarin.GooglePlayServices" version="22.0.0.0" targetFramework="MonoAndroid50" />
</packages>