Load Database task async wait moved to LoadDb runnable rather than blocking UI thread (in case the file is very slow, or the user is very quick to enter their password)

Database Unlocked warning notification now uses a 4.1 extended "Lock Database" button, and the main action is now just to activate the app.

PasswordActivity no longer loads the database file into memory ready for loading if it's already loaded and we're showing QuickUnlock instead.
This commit is contained in:
AlexVallat
2013-08-03 19:58:01 +01:00
parent 84efaae462
commit f0dfdefd67
4 changed files with 43 additions and 35 deletions

View File

@@ -17,19 +17,20 @@ This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll. This file
using System;
using System.IO;
using System.Threading.Tasks;
using KeePassLib.Serialization;
namespace keepass2android
{
public class LoadDb : RunnableOnFinish {
private readonly IOConnectionInfo _ioc;
private readonly MemoryStream _databaseData;
private readonly Task<MemoryStream> _databaseData;
private readonly String _pass;
private readonly String _key;
private readonly IKp2aApp _app;
private readonly bool _rememberKeyfile;
public LoadDb(IKp2aApp app, IOConnectionInfo ioc, MemoryStream databaseData, String pass, String key, OnFinish finish): base(finish)
public LoadDb(IKp2aApp app, IOConnectionInfo ioc, Task<MemoryStream> databaseData, String pass, String key, OnFinish finish): base(finish)
{
_app = app;
_ioc = ioc;
@@ -47,7 +48,7 @@ namespace keepass2android
try
{
StatusLogger.UpdateMessage(UiStringKey.loading_database);
_app.LoadDatabase(_ioc, _databaseData, _pass, _key, StatusLogger);
_app.LoadDatabase(_ioc, _databaseData.Result, _pass, _key, StatusLogger);
SaveFileData (_ioc, _key);
} catch (KeyFileException) {