tasks no longer store references to activities. These can "expire" and are hard to update (e.g. if one task creates another). Instead, the app can provide the currently active context.
This commit is contained in:
@@ -53,14 +53,15 @@ namespace keepass2android
|
|||||||
private readonly Queue<OperationWithFinishHandler> _taskQueue = new Queue<OperationWithFinishHandler>();
|
private readonly Queue<OperationWithFinishHandler> _taskQueue = new Queue<OperationWithFinishHandler>();
|
||||||
private readonly object _taskQueueLock = new object();
|
private readonly object _taskQueueLock = new object();
|
||||||
private Java.Lang.Thread? _thread = null;
|
private Java.Lang.Thread? _thread = null;
|
||||||
|
private OperationWithFinishHandler? _currentlyRunningTask = null;
|
||||||
private ProgressUiAsStatusLoggerAdapter _statusLogger = null;
|
private ProgressUiAsStatusLoggerAdapter _statusLogger = null;
|
||||||
|
|
||||||
public void Run(Context context, IKp2aApp app, OperationWithFinishHandler operation)
|
public void Run(IKp2aApp app, OperationWithFinishHandler operation)
|
||||||
{
|
{
|
||||||
lock (Instance._taskQueueLock)
|
lock (Instance._taskQueueLock)
|
||||||
{
|
{
|
||||||
_taskQueue.Enqueue(operation);
|
_taskQueue.Enqueue(operation);
|
||||||
SetNewActiveContext(context, app);
|
SetNewActiveContext(app);
|
||||||
|
|
||||||
// Start thread to run the task (unless it's already running)
|
// Start thread to run the task (unless it's already running)
|
||||||
if (_thread == null)
|
if (_thread == null)
|
||||||
@@ -70,21 +71,22 @@ namespace keepass2android
|
|||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
OperationWithFinishHandler task;
|
|
||||||
lock (_taskQueueLock)
|
lock (_taskQueueLock)
|
||||||
{
|
{
|
||||||
if (!_taskQueue.Any())
|
if (!_taskQueue.Any())
|
||||||
{
|
{
|
||||||
_thread = null;
|
_thread = null;
|
||||||
|
_currentlyRunningTask = null;
|
||||||
_statusLogger.EndLogging();
|
_statusLogger.EndLogging();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
task = _taskQueue.Dequeue();
|
_currentlyRunningTask = _taskQueue.Dequeue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
task.Run();
|
_currentlyRunningTask.Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -95,8 +97,9 @@ namespace keepass2android
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetNewActiveContext(Context? context, IKp2aApp app)
|
public void SetNewActiveContext(IKp2aApp app)
|
||||||
{
|
{
|
||||||
|
Context? context = app.ActiveContext;
|
||||||
lock (_taskQueueLock)
|
lock (_taskQueueLock)
|
||||||
{
|
{
|
||||||
if (context == null && _thread != null)
|
if (context == null && _thread != null)
|
||||||
@@ -116,9 +119,11 @@ namespace keepass2android
|
|||||||
_statusLogger.SetNewProgressUi(progressUi);
|
_statusLogger.SetNewProgressUi(progressUi);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var task in _taskQueue)
|
foreach (var task in _taskQueue.Concat(_currentlyRunningTask == null ?
|
||||||
|
new List<OperationWithFinishHandler>() :
|
||||||
|
new List<OperationWithFinishHandler>() { _currentlyRunningTask })
|
||||||
|
)
|
||||||
{
|
{
|
||||||
task.ActiveContext = context;
|
|
||||||
task.SetStatusLogger(_statusLogger);
|
task.SetStatusLogger(_statusLogger);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,19 +243,19 @@ namespace keepass2android
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Activity ActiveActivity
|
public Context ActiveActivity
|
||||||
{
|
{
|
||||||
get { return _activeActivity; }
|
get { return _activeActivity; }
|
||||||
private set
|
private set
|
||||||
{
|
{
|
||||||
if (_activeActivity != null && _activeActivity != _previouslyActiveActivity)
|
if (_activeActivity != null && _activeActivity != _previouslyActiveContext)
|
||||||
{
|
{
|
||||||
_previouslyActiveActivity = _activeActivity;
|
_previouslyActiveContext = _activeActivity;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
_activeActivity = value;
|
_activeActivity = value;
|
||||||
if (_task != null)
|
|
||||||
_task.ActiveContext = _activeActivity;
|
|
||||||
if (_activeActivity != null)
|
if (_activeActivity != null)
|
||||||
{
|
{
|
||||||
SetupProgressDialog(_app);
|
SetupProgressDialog(_app);
|
||||||
@@ -259,9 +264,9 @@ namespace keepass2android
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Activity PreviouslyActiveActivity
|
public Context PreviouslyActiveContext
|
||||||
{
|
{
|
||||||
get { return _previouslyActiveActivity; }
|
get { return _previouslyActiveContext; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,12 +275,12 @@ namespace keepass2android
|
|||||||
private IProgressDialog _progressDialog;
|
private IProgressDialog _progressDialog;
|
||||||
private readonly IKp2aApp _app;
|
private readonly IKp2aApp _app;
|
||||||
private Java.Lang.Thread _thread;
|
private Java.Lang.Thread _thread;
|
||||||
private Activity _activeActivity, _previouslyActiveActivity;
|
private Context _activeActivity, _previouslyActiveContext;
|
||||||
private ProgressDialogStatusLogger _progressDialogStatusLogger;
|
private ProgressDialogStatusLogger _progressDialogStatusLogger;
|
||||||
|
|
||||||
public BlockingOperationRunner(IKp2aApp app, Activity activity, OperationWithFinishHandler task)
|
public BlockingOperationRunner(IKp2aApp app, OperationWithFinishHandler task)
|
||||||
{
|
{
|
||||||
_activeActivity = activity;
|
_activeActivity = app.ActiveContext;
|
||||||
_task = task;
|
_task = task;
|
||||||
_handler = app.UiThreadHandler;
|
_handler = app.UiThreadHandler;
|
||||||
_app = app;
|
_app = app;
|
||||||
@@ -283,7 +288,7 @@ namespace keepass2android
|
|||||||
SetupProgressDialog(app);
|
SetupProgressDialog(app);
|
||||||
|
|
||||||
// Set code to run when this is finished
|
// Set code to run when this is finished
|
||||||
_task.operationFinishedHandler = new AfterTask(activity, task.operationFinishedHandler, _handler, this);
|
_task.operationFinishedHandler = new AfterTask(app, task.operationFinishedHandler, _handler, this);
|
||||||
|
|
||||||
_task.SetStatusLogger(_progressDialogStatusLogger);
|
_task.SetStatusLogger(_progressDialogStatusLogger);
|
||||||
|
|
||||||
@@ -341,7 +346,7 @@ namespace keepass2android
|
|||||||
private class AfterTask : OnOperationFinishedHandler {
|
private class AfterTask : OnOperationFinishedHandler {
|
||||||
readonly BlockingOperationRunner _blockingOperationRunner;
|
readonly BlockingOperationRunner _blockingOperationRunner;
|
||||||
|
|
||||||
public AfterTask (Activity activity, OnOperationFinishedHandler operationFinishedHandler, Handler handler, BlockingOperationRunner pt): base(activity, operationFinishedHandler, handler)
|
public AfterTask (IActiveContextProvider app, OnOperationFinishedHandler operationFinishedHandler, Handler handler, BlockingOperationRunner pt): base(app, operationFinishedHandler, handler)
|
||||||
{
|
{
|
||||||
_blockingOperationRunner = pt;
|
_blockingOperationRunner = pt;
|
||||||
}
|
}
|
||||||
|
@@ -41,7 +41,7 @@ namespace keepass2android
|
|||||||
/// Interface through which Activities and the logic layer can access some app specific functionalities and Application static data
|
/// Interface through which Activities and the logic layer can access some app specific functionalities and Application static data
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// This also contains methods which are UI specific and should be replacable for testing.
|
/// This also contains methods which are UI specific and should be replacable for testing.
|
||||||
public interface IKp2aApp : ICertificateValidationHandler
|
public interface IKp2aApp : ICertificateValidationHandler, IActiveContextProvider
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Locks all currently open databases, quicklocking if available (unless false is passed for allowQuickUnlock)
|
/// Locks all currently open databases, quicklocking if available (unless false is passed for allowQuickUnlock)
|
||||||
@@ -96,7 +96,6 @@ namespace keepass2android
|
|||||||
EventHandler<DialogClickEventArgs> yesHandler,
|
EventHandler<DialogClickEventArgs> yesHandler,
|
||||||
EventHandler<DialogClickEventArgs> noHandler,
|
EventHandler<DialogClickEventArgs> noHandler,
|
||||||
EventHandler<DialogClickEventArgs> cancelHandler,
|
EventHandler<DialogClickEventArgs> cancelHandler,
|
||||||
Context ctx,
|
|
||||||
string messageSuffix = "");
|
string messageSuffix = "");
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -107,7 +106,6 @@ namespace keepass2android
|
|||||||
EventHandler<DialogClickEventArgs> yesHandler,
|
EventHandler<DialogClickEventArgs> yesHandler,
|
||||||
EventHandler<DialogClickEventArgs> noHandler,
|
EventHandler<DialogClickEventArgs> noHandler,
|
||||||
EventHandler<DialogClickEventArgs> cancelHandler,
|
EventHandler<DialogClickEventArgs> cancelHandler,
|
||||||
Context ctx,
|
|
||||||
string messageSuffix = "");
|
string messageSuffix = "");
|
||||||
|
|
||||||
void ShowMessage(Context ctx, int resourceId, MessageSeverity severity);
|
void ShowMessage(Context ctx, int resourceId, MessageSeverity severity);
|
||||||
|
@@ -19,10 +19,9 @@ namespace keepass2android
|
|||||||
private readonly IKp2aApp _app;
|
private readonly IKp2aApp _app;
|
||||||
|
|
||||||
|
|
||||||
public CheckDatabaseForChanges(Activity context, IKp2aApp app, OnOperationFinishedHandler operationFinishedHandler)
|
public CheckDatabaseForChanges(IKp2aApp app, OnOperationFinishedHandler operationFinishedHandler)
|
||||||
: base(context, operationFinishedHandler)
|
: base(app, operationFinishedHandler)
|
||||||
{
|
{
|
||||||
_context = context;
|
|
||||||
_app = app;
|
_app = app;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -16,10 +16,9 @@ namespace keepass2android
|
|||||||
private readonly IKp2aApp _app;
|
private readonly IKp2aApp _app;
|
||||||
private SaveDb _saveDb;
|
private SaveDb _saveDb;
|
||||||
|
|
||||||
public SynchronizeCachedDatabase(Context context, IKp2aApp app, OnOperationFinishedHandler operationFinishedHandler)
|
public SynchronizeCachedDatabase(IKp2aApp app, OnOperationFinishedHandler operationFinishedHandler)
|
||||||
: base(context, operationFinishedHandler)
|
: base(app, operationFinishedHandler)
|
||||||
{
|
{
|
||||||
_context = context;
|
|
||||||
_app = app;
|
_app = app;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,6 +39,9 @@ namespace keepass2android
|
|||||||
StatusLogger.UpdateSubMessage(_app.GetResourceString(UiStringKey.DownloadingRemoteFile));
|
StatusLogger.UpdateSubMessage(_app.GetResourceString(UiStringKey.DownloadingRemoteFile));
|
||||||
string hash;
|
string hash;
|
||||||
|
|
||||||
|
//TODO remove
|
||||||
|
Thread.Sleep(5000);
|
||||||
|
|
||||||
MemoryStream remoteData;
|
MemoryStream remoteData;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -58,13 +60,17 @@ namespace keepass2android
|
|||||||
//check if remote file was modified:
|
//check if remote file was modified:
|
||||||
var baseVersionHash = cachingFileStorage.GetBaseVersionHash(ioc);
|
var baseVersionHash = cachingFileStorage.GetBaseVersionHash(ioc);
|
||||||
Kp2aLog.Log("Checking for file change. baseVersionHash = " + baseVersionHash);
|
Kp2aLog.Log("Checking for file change. baseVersionHash = " + baseVersionHash);
|
||||||
if (baseVersionHash != hash)
|
if (baseVersionHash != hash ||
|
||||||
|
true//TODO remove
|
||||||
|
)
|
||||||
{
|
{
|
||||||
//remote file is modified
|
//remote file is modified
|
||||||
if (cachingFileStorage.HasLocalChanges(ioc))
|
if (cachingFileStorage.HasLocalChanges(ioc)
|
||||||
|
|| true //TODO remove
|
||||||
|
)
|
||||||
{
|
{
|
||||||
//conflict! need to merge
|
//conflict! need to merge
|
||||||
_saveDb = new SaveDb(_context, _app, new ActionOnOperationFinished(ActiveContext, (success, result, activity) =>
|
_saveDb = new SaveDb(_app, new ActionOnOperationFinished(_app, (success, result, activity) =>
|
||||||
{
|
{
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
@@ -76,6 +82,7 @@ namespace keepass2android
|
|||||||
}
|
}
|
||||||
_saveDb = null;
|
_saveDb = null;
|
||||||
}), _app.CurrentDb, false, remoteData);
|
}), _app.CurrentDb, false, remoteData);
|
||||||
|
_saveDb.SyncInBackground = false;
|
||||||
_saveDb.Run();
|
_saveDb.Run();
|
||||||
|
|
||||||
_app.CurrentDb.UpdateGlobals();
|
_app.CurrentDb.UpdateGlobals();
|
||||||
|
@@ -28,12 +28,12 @@ namespace keepass2android
|
|||||||
|
|
||||||
readonly ActionToPerformOnFinsh _actionToPerform;
|
readonly ActionToPerformOnFinsh _actionToPerform;
|
||||||
|
|
||||||
public ActionOnOperationFinished(Context context, ActionToPerformOnFinsh actionToPerform) : base(context, null, null)
|
public ActionOnOperationFinished(IKp2aApp app, ActionToPerformOnFinsh actionToPerform) : base(app, null, null)
|
||||||
{
|
{
|
||||||
_actionToPerform = actionToPerform;
|
_actionToPerform = actionToPerform;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionOnOperationFinished(Context context, ActionToPerformOnFinsh actionToPerform, OnOperationFinishedHandler operationFinishedHandler) : base(context, operationFinishedHandler)
|
public ActionOnOperationFinished(IKp2aApp app, ActionToPerformOnFinsh actionToPerform, OnOperationFinishedHandler operationFinishedHandler) : base(app, operationFinishedHandler)
|
||||||
{
|
{
|
||||||
_actionToPerform = actionToPerform;
|
_actionToPerform = actionToPerform;
|
||||||
}
|
}
|
||||||
@@ -50,7 +50,7 @@ namespace keepass2android
|
|||||||
Handler.Post(() => {_actionToPerform(Success, Message, ActiveContext);});
|
Handler.Post(() => {_actionToPerform(Success, Message, ActiveContext);});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_actionToPerform(Success, Message, AllowInactiveActivity ? (ActiveContext ?? PreviouslyActiveContext) : ActiveContext);
|
_actionToPerform(Success, Message, ActiveContext);
|
||||||
base.Run();
|
base.Run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -30,22 +30,20 @@ namespace keepass2android
|
|||||||
private readonly IKp2aApp _app;
|
private readonly IKp2aApp _app;
|
||||||
private readonly PwEntry _entry;
|
private readonly PwEntry _entry;
|
||||||
private readonly PwGroup _parentGroup;
|
private readonly PwGroup _parentGroup;
|
||||||
private readonly Activity _ctx;
|
|
||||||
private readonly Database _db;
|
private readonly Database _db;
|
||||||
|
|
||||||
public static AddEntry GetInstance(Activity ctx, IKp2aApp app, PwEntry entry, PwGroup parentGroup, OnOperationFinishedHandler operationFinishedHandler, Database db) {
|
public static AddEntry GetInstance(IKp2aApp app, PwEntry entry, PwGroup parentGroup, OnOperationFinishedHandler operationFinishedHandler, Database db) {
|
||||||
|
|
||||||
return new AddEntry(ctx, db, app, entry, parentGroup, operationFinishedHandler);
|
return new AddEntry(db, app, entry, parentGroup, operationFinishedHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AddEntry(Activity ctx, Database db, IKp2aApp app, PwEntry entry, PwGroup parentGroup, OnOperationFinishedHandler operationFinishedHandler):base(ctx, operationFinishedHandler) {
|
public AddEntry(Database db, IKp2aApp app, PwEntry entry, PwGroup parentGroup, OnOperationFinishedHandler operationFinishedHandler):base(app, operationFinishedHandler) {
|
||||||
_ctx = ctx;
|
|
||||||
_db = db;
|
_db = db;
|
||||||
_parentGroup = parentGroup;
|
_parentGroup = parentGroup;
|
||||||
_app = app;
|
_app = app;
|
||||||
_entry = entry;
|
_entry = entry;
|
||||||
|
|
||||||
_operationFinishedHandler = new AfterAdd(ctx, app.CurrentDb, entry, app,operationFinishedHandler);
|
_operationFinishedHandler = new AfterAdd(app.CurrentDb, entry, app,operationFinishedHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -65,7 +63,7 @@ namespace keepass2android
|
|||||||
_db.Elements.Add(_entry);
|
_db.Elements.Add(_entry);
|
||||||
|
|
||||||
// Commit to disk
|
// Commit to disk
|
||||||
SaveDb save = new SaveDb(_ctx, _app, _app.CurrentDb, operationFinishedHandler);
|
SaveDb save = new SaveDb(_app, _app.CurrentDb, operationFinishedHandler);
|
||||||
save.SetStatusLogger(StatusLogger);
|
save.SetStatusLogger(StatusLogger);
|
||||||
save.Run();
|
save.Run();
|
||||||
}
|
}
|
||||||
@@ -75,7 +73,7 @@ namespace keepass2android
|
|||||||
private readonly PwEntry _entry;
|
private readonly PwEntry _entry;
|
||||||
private readonly IKp2aApp _app;
|
private readonly IKp2aApp _app;
|
||||||
|
|
||||||
public AfterAdd(Activity activity, Database db, PwEntry entry, IKp2aApp app, OnOperationFinishedHandler operationFinishedHandler):base(activity, operationFinishedHandler) {
|
public AfterAdd( Database db, PwEntry entry, IKp2aApp app, OnOperationFinishedHandler operationFinishedHandler):base(app, operationFinishedHandler) {
|
||||||
_db = db;
|
_db = db;
|
||||||
_entry = entry;
|
_entry = entry;
|
||||||
_app = app;
|
_app = app;
|
||||||
|
@@ -38,18 +38,16 @@ namespace keepass2android
|
|||||||
public PwGroup Group;
|
public PwGroup Group;
|
||||||
internal PwGroup Parent;
|
internal PwGroup Parent;
|
||||||
protected bool DontSave;
|
protected bool DontSave;
|
||||||
readonly Activity _ctx;
|
|
||||||
|
|
||||||
|
|
||||||
public static AddGroup GetInstance(Activity ctx, IKp2aApp app, string name, int iconid, PwUuid groupCustomIconId, PwGroup parent, OnOperationFinishedHandler operationFinishedHandler, bool dontSave) {
|
public static AddGroup GetInstance(IKp2aApp app, string name, int iconid, PwUuid groupCustomIconId, PwGroup parent, OnOperationFinishedHandler operationFinishedHandler, bool dontSave) {
|
||||||
return new AddGroup(ctx, app, name, iconid, groupCustomIconId, parent, operationFinishedHandler, dontSave);
|
return new AddGroup(app, name, iconid, groupCustomIconId, parent, operationFinishedHandler, dontSave);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private AddGroup(Activity ctx, IKp2aApp app, String name, int iconid, PwUuid groupCustomIconId, PwGroup parent, OnOperationFinishedHandler operationFinishedHandler, bool dontSave)
|
private AddGroup(IKp2aApp app, String name, int iconid, PwUuid groupCustomIconId, PwGroup parent, OnOperationFinishedHandler operationFinishedHandler, bool dontSave)
|
||||||
: base(ctx, operationFinishedHandler)
|
: base(app, operationFinishedHandler)
|
||||||
{
|
{
|
||||||
_ctx = ctx;
|
|
||||||
_name = name;
|
_name = name;
|
||||||
_iconId = iconid;
|
_iconId = iconid;
|
||||||
_groupCustomIconId = groupCustomIconId;
|
_groupCustomIconId = groupCustomIconId;
|
||||||
@@ -57,7 +55,7 @@ namespace keepass2android
|
|||||||
DontSave = dontSave;
|
DontSave = dontSave;
|
||||||
_app = app;
|
_app = app;
|
||||||
|
|
||||||
_operationFinishedHandler = new AfterAdd(ctx, this, operationFinishedHandler);
|
_operationFinishedHandler = new AfterAdd(_app, this, operationFinishedHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -74,7 +72,7 @@ namespace keepass2android
|
|||||||
_app.CurrentDb.Elements.Add(Group);
|
_app.CurrentDb.Elements.Add(Group);
|
||||||
|
|
||||||
// Commit to disk
|
// Commit to disk
|
||||||
SaveDb save = new SaveDb(_ctx, _app, _app.CurrentDb, operationFinishedHandler, DontSave);
|
SaveDb save = new SaveDb(_app, _app.CurrentDb, operationFinishedHandler, DontSave);
|
||||||
save.SetStatusLogger(StatusLogger);
|
save.SetStatusLogger(StatusLogger);
|
||||||
save.Run();
|
save.Run();
|
||||||
}
|
}
|
||||||
@@ -82,7 +80,7 @@ namespace keepass2android
|
|||||||
private class AfterAdd : OnOperationFinishedHandler {
|
private class AfterAdd : OnOperationFinishedHandler {
|
||||||
readonly AddGroup _addGroup;
|
readonly AddGroup _addGroup;
|
||||||
|
|
||||||
public AfterAdd(Activity activity, AddGroup addGroup,OnOperationFinishedHandler operationFinishedHandler): base(activity, operationFinishedHandler) {
|
public AfterAdd(IKp2aApp app, AddGroup addGroup,OnOperationFinishedHandler operationFinishedHandler): base(app, operationFinishedHandler) {
|
||||||
_addGroup = addGroup;
|
_addGroup = addGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -130,13 +130,11 @@ namespace keepass2android
|
|||||||
}
|
}
|
||||||
|
|
||||||
private readonly IKp2aApp _app;
|
private readonly IKp2aApp _app;
|
||||||
private readonly Activity _ctx;
|
|
||||||
|
|
||||||
public AddTemplateEntries(Activity ctx, IKp2aApp app, OnOperationFinishedHandler operationFinishedHandler)
|
public AddTemplateEntries(IKp2aApp app, OnOperationFinishedHandler operationFinishedHandler)
|
||||||
: base(ctx, operationFinishedHandler)
|
: base(app, operationFinishedHandler)
|
||||||
{
|
{
|
||||||
_ctx = ctx;
|
_app = app;
|
||||||
_app = app;
|
|
||||||
|
|
||||||
//_operationFinishedHandler = new AfterAdd(this, operationFinishedHandler);
|
//_operationFinishedHandler = new AfterAdd(this, operationFinishedHandler);
|
||||||
}
|
}
|
||||||
@@ -313,7 +311,7 @@ namespace keepass2android
|
|||||||
_app.DirtyGroups.Add(templateGroup);
|
_app.DirtyGroups.Add(templateGroup);
|
||||||
|
|
||||||
// Commit to disk
|
// Commit to disk
|
||||||
SaveDb save = new SaveDb(_ctx, _app, _app.CurrentDb, operationFinishedHandler);
|
SaveDb save = new SaveDb( _app, _app.CurrentDb, operationFinishedHandler);
|
||||||
save.SetStatusLogger(StatusLogger);
|
save.SetStatusLogger(StatusLogger);
|
||||||
save.Run();
|
save.Run();
|
||||||
}
|
}
|
||||||
@@ -373,7 +371,7 @@ namespace keepass2android
|
|||||||
private readonly Database _db;
|
private readonly Database _db;
|
||||||
private readonly List<PwEntry> _entries;
|
private readonly List<PwEntry> _entries;
|
||||||
|
|
||||||
public AfterAdd(Activity activity, Database db, List<PwEntry> entries, OnOperationFinishedHandler operationFinishedHandler):base(activity, operationFinishedHandler) {
|
public AfterAdd(IKp2aApp app, Database db, List<PwEntry> entries, OnOperationFinishedHandler operationFinishedHandler):base(app, operationFinishedHandler) {
|
||||||
_db = db;
|
_db = db;
|
||||||
_entries = entries;
|
_entries = entries;
|
||||||
|
|
||||||
|
@@ -16,8 +16,8 @@ namespace keepass2android.database.edit
|
|||||||
{
|
{
|
||||||
public class CopyEntry: AddEntry
|
public class CopyEntry: AddEntry
|
||||||
{
|
{
|
||||||
public CopyEntry(Activity ctx, IKp2aApp app, PwEntry entry, OnOperationFinishedHandler operationFinishedHandler, Database db)
|
public CopyEntry(IKp2aApp app, PwEntry entry, OnOperationFinishedHandler operationFinishedHandler, Database db)
|
||||||
: base(ctx, db, app, CreateCopy(entry, app), entry.ParentGroup, operationFinishedHandler)
|
: base(db, app, CreateCopy(entry, app), entry.ParentGroup, operationFinishedHandler)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -29,24 +29,21 @@ namespace keepass2android
|
|||||||
public class CreateDb : OperationWithFinishHandler {
|
public class CreateDb : OperationWithFinishHandler {
|
||||||
private readonly IOConnectionInfo _ioc;
|
private readonly IOConnectionInfo _ioc;
|
||||||
private readonly bool _dontSave;
|
private readonly bool _dontSave;
|
||||||
private readonly Activity _ctx;
|
|
||||||
private readonly IKp2aApp _app;
|
private readonly IKp2aApp _app;
|
||||||
private CompositeKey _key;
|
private CompositeKey _key;
|
||||||
private readonly bool _makeCurrent;
|
private readonly bool _makeCurrent;
|
||||||
|
|
||||||
public CreateDb(IKp2aApp app, Activity ctx, IOConnectionInfo ioc, OnOperationFinishedHandler operationFinishedHandler, bool dontSave, bool makeCurrent): base(ctx, operationFinishedHandler) {
|
public CreateDb(IKp2aApp app, Activity ctx, IOConnectionInfo ioc, OnOperationFinishedHandler operationFinishedHandler, bool dontSave, bool makeCurrent): base(app, operationFinishedHandler) {
|
||||||
_ctx = ctx;
|
_ioc = ioc;
|
||||||
_ioc = ioc;
|
|
||||||
_dontSave = dontSave;
|
_dontSave = dontSave;
|
||||||
_makeCurrent = makeCurrent;
|
_makeCurrent = makeCurrent;
|
||||||
_app = app;
|
_app = app;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CreateDb(IKp2aApp app, Activity ctx, IOConnectionInfo ioc, OnOperationFinishedHandler operationFinishedHandler, bool dontSave, CompositeKey key, bool makeCurrent)
|
public CreateDb(IKp2aApp app, Activity ctx, IOConnectionInfo ioc, OnOperationFinishedHandler operationFinishedHandler, bool dontSave, CompositeKey key, bool makeCurrent)
|
||||||
: base(ctx, operationFinishedHandler)
|
: base(app, operationFinishedHandler)
|
||||||
{
|
{
|
||||||
_ctx = ctx;
|
_ioc = ioc;
|
||||||
_ioc = ioc;
|
|
||||||
_dontSave = dontSave;
|
_dontSave = dontSave;
|
||||||
_app = app;
|
_app = app;
|
||||||
_key = key;
|
_key = key;
|
||||||
@@ -77,17 +74,17 @@ namespace keepass2android
|
|||||||
db.SearchHelper = new SearchDbHelper(_app);
|
db.SearchHelper = new SearchDbHelper(_app);
|
||||||
|
|
||||||
// Add a couple default groups
|
// Add a couple default groups
|
||||||
AddGroup internet = AddGroup.GetInstance(_ctx, _app, "Internet", 1, null, db.KpDatabase.RootGroup, null, true);
|
AddGroup internet = AddGroup.GetInstance(_app, "Internet", 1, null, db.KpDatabase.RootGroup, null, true);
|
||||||
internet.Run();
|
internet.Run();
|
||||||
AddGroup email = AddGroup.GetInstance(_ctx, _app, "eMail", 19, null, db.KpDatabase.RootGroup, null, true);
|
AddGroup email = AddGroup.GetInstance(_app, "eMail", 19, null, db.KpDatabase.RootGroup, null, true);
|
||||||
email.Run();
|
email.Run();
|
||||||
|
|
||||||
List<PwEntry> addedEntries;
|
List<PwEntry> addedEntries;
|
||||||
AddTemplateEntries addTemplates = new AddTemplateEntries(_ctx, _app, null);
|
AddTemplateEntries addTemplates = new AddTemplateEntries(_app, null);
|
||||||
addTemplates.AddTemplates(out addedEntries);
|
addTemplates.AddTemplates(out addedEntries);
|
||||||
|
|
||||||
// Commit changes
|
// Commit changes
|
||||||
SaveDb save = new SaveDb(_ctx, _app, db, operationFinishedHandler, _dontSave);
|
SaveDb save = new SaveDb(_app, db, operationFinishedHandler, _dontSave);
|
||||||
save.SetStatusLogger(StatusLogger);
|
save.SetStatusLogger(StatusLogger);
|
||||||
_operationFinishedHandler = null;
|
_operationFinishedHandler = null;
|
||||||
save.Run();
|
save.Run();
|
||||||
|
@@ -29,8 +29,8 @@ namespace keepass2android
|
|||||||
private readonly PwEntry _entry;
|
private readonly PwEntry _entry;
|
||||||
private UiStringKey _statusMessage;
|
private UiStringKey _statusMessage;
|
||||||
|
|
||||||
public DeleteEntry(Activity activiy, IKp2aApp app, PwEntry entry, OnOperationFinishedHandler operationFinishedHandler):base(activiy, operationFinishedHandler, app) {
|
public DeleteEntry(IKp2aApp app, PwEntry entry, OnOperationFinishedHandler operationFinishedHandler):base(operationFinishedHandler, app) {
|
||||||
Ctx = activiy;
|
|
||||||
Db = app.FindDatabaseForElement(entry);
|
Db = app.FindDatabaseForElement(entry);
|
||||||
_entry = entry;
|
_entry = entry;
|
||||||
|
|
||||||
|
@@ -30,9 +30,9 @@ namespace keepass2android
|
|||||||
protected bool DontSave;
|
protected bool DontSave;
|
||||||
|
|
||||||
public DeleteGroup(Activity activity, IKp2aApp app, PwGroup group, OnOperationFinishedHandler operationFinishedHandler)
|
public DeleteGroup(Activity activity, IKp2aApp app, PwGroup group, OnOperationFinishedHandler operationFinishedHandler)
|
||||||
: base(activity, operationFinishedHandler, app)
|
: base(operationFinishedHandler, app)
|
||||||
{
|
{
|
||||||
SetMembers(activity, app, group, false);
|
SetMembers(app, group, false);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
public DeleteGroup(Context ctx, Database db, PwGroup group, Activity act, OnOperationFinishedHandler operationFinishedHandler, bool dontSave)
|
public DeleteGroup(Context ctx, Database db, PwGroup group, Activity act, OnOperationFinishedHandler operationFinishedHandler, bool dontSave)
|
||||||
@@ -45,9 +45,9 @@ namespace keepass2android
|
|||||||
SetMembers(ctx, db, group, null, dontSave);
|
SetMembers(ctx, db, group, null, dontSave);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
private void SetMembers(Activity activity, IKp2aApp app, PwGroup group, bool dontSave)
|
private void SetMembers(IKp2aApp app, PwGroup group, bool dontSave)
|
||||||
{
|
{
|
||||||
base.SetMembers(activity, app.FindDatabaseForElement(group));
|
base.SetMembers(app.FindDatabaseForElement(group));
|
||||||
|
|
||||||
_group = group;
|
_group = group;
|
||||||
DontSave = dontSave;
|
DontSave = dontSave;
|
||||||
|
@@ -13,10 +13,10 @@ namespace keepass2android
|
|||||||
private readonly bool _canRecycle;
|
private readonly bool _canRecycle;
|
||||||
|
|
||||||
public DeleteMultipleItemsFromOneDatabase(Activity activity, Database db, List<IStructureItem> elementsToDelete, OnOperationFinishedHandler operationFinishedHandler, IKp2aApp app)
|
public DeleteMultipleItemsFromOneDatabase(Activity activity, Database db, List<IStructureItem> elementsToDelete, OnOperationFinishedHandler operationFinishedHandler, IKp2aApp app)
|
||||||
: base(activity, operationFinishedHandler, app)
|
: base(operationFinishedHandler, app)
|
||||||
{
|
{
|
||||||
_elementsToDelete = elementsToDelete;
|
_elementsToDelete = elementsToDelete;
|
||||||
SetMembers(activity, db);
|
SetMembers(db);
|
||||||
|
|
||||||
//determine once. The property is queried for each delete operation, but might return false
|
//determine once. The property is queried for each delete operation, but might return false
|
||||||
//after one entry/group is deleted (and thus in recycle bin and thus can't be recycled anymore)
|
//after one entry/group is deleted (and thus in recycle bin and thus can't be recycled anymore)
|
||||||
|
@@ -8,8 +8,8 @@ namespace keepass2android
|
|||||||
{
|
{
|
||||||
public abstract class DeleteRunnable : OperationWithFinishHandler
|
public abstract class DeleteRunnable : OperationWithFinishHandler
|
||||||
{
|
{
|
||||||
protected DeleteRunnable(Activity activity, OnOperationFinishedHandler operationFinishedHandler, IKp2aApp app)
|
protected DeleteRunnable(OnOperationFinishedHandler operationFinishedHandler, IKp2aApp app)
|
||||||
: base(activity, operationFinishedHandler)
|
: base(app, operationFinishedHandler)
|
||||||
{
|
{
|
||||||
App = app;
|
App = app;
|
||||||
}
|
}
|
||||||
@@ -18,11 +18,10 @@ namespace keepass2android
|
|||||||
|
|
||||||
protected Database Db;
|
protected Database Db;
|
||||||
|
|
||||||
protected Activity Ctx;
|
|
||||||
|
|
||||||
protected void SetMembers(Activity activity, Database db)
|
|
||||||
|
protected void SetMembers( Database db)
|
||||||
{
|
{
|
||||||
Ctx = activity;
|
|
||||||
Db = db;
|
Db = db;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,18 +130,18 @@ namespace keepass2android
|
|||||||
(dlgSender, dlgEvt) =>
|
(dlgSender, dlgEvt) =>
|
||||||
{
|
{
|
||||||
DeletePermanently = true;
|
DeletePermanently = true;
|
||||||
BlockingOperationRunner pt = new BlockingOperationRunner(App, Ctx, this);
|
BlockingOperationRunner pt = new BlockingOperationRunner(App, this);
|
||||||
pt.Run();
|
pt.Run();
|
||||||
|
|
||||||
},
|
},
|
||||||
(dlgSender, dlgEvt) =>
|
(dlgSender, dlgEvt) =>
|
||||||
{
|
{
|
||||||
DeletePermanently = false;
|
DeletePermanently = false;
|
||||||
BlockingOperationRunner pt = new BlockingOperationRunner(App, Ctx, this);
|
BlockingOperationRunner pt = new BlockingOperationRunner(App, this);
|
||||||
pt.Run();
|
pt.Run();
|
||||||
},
|
},
|
||||||
(dlgSender, dlgEvt) => { },
|
(dlgSender, dlgEvt) => { },
|
||||||
Ctx, messageSuffix);
|
messageSuffix);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -153,12 +152,12 @@ namespace keepass2android
|
|||||||
QuestionNoRecycleResourceId,
|
QuestionNoRecycleResourceId,
|
||||||
(dlgSender, dlgEvt) =>
|
(dlgSender, dlgEvt) =>
|
||||||
{
|
{
|
||||||
BlockingOperationRunner pt = new BlockingOperationRunner(App, Ctx, this);
|
BlockingOperationRunner pt = new BlockingOperationRunner(App, this);
|
||||||
pt.Run();
|
pt.Run();
|
||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
(dlgSender, dlgEvt) => { },
|
(dlgSender, dlgEvt) => { },
|
||||||
Ctx, messageSuffix);
|
messageSuffix);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -215,7 +214,7 @@ namespace keepass2android
|
|||||||
Android.Util.Log.Debug("KP2A", "Calling PerformDelete..");
|
Android.Util.Log.Debug("KP2A", "Calling PerformDelete..");
|
||||||
PerformDelete(touchedGroups, permanentlyDeletedGroups);
|
PerformDelete(touchedGroups, permanentlyDeletedGroups);
|
||||||
|
|
||||||
_operationFinishedHandler = new ActionOnOperationFinished(ActiveContext,(success, message, activity) =>
|
_operationFinishedHandler = new ActionOnOperationFinished(App,(success, message, activity) =>
|
||||||
{
|
{
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
@@ -239,7 +238,7 @@ namespace keepass2android
|
|||||||
}, operationFinishedHandler);
|
}, operationFinishedHandler);
|
||||||
|
|
||||||
// Commit database
|
// Commit database
|
||||||
SaveDb save = new SaveDb(Ctx, App, Db, operationFinishedHandler, false);
|
SaveDb save = new SaveDb( App, Db, operationFinishedHandler, false);
|
||||||
save.ShowDatabaseIocInStatus = ShowDatabaseIocInStatus;
|
save.ShowDatabaseIocInStatus = ShowDatabaseIocInStatus;
|
||||||
|
|
||||||
save.SetStatusLogger(StatusLogger);
|
save.SetStatusLogger(StatusLogger);
|
||||||
|
@@ -36,19 +36,17 @@ namespace keepass2android
|
|||||||
private readonly PwIcon _iconId;
|
private readonly PwIcon _iconId;
|
||||||
private readonly PwUuid _customIconId;
|
private readonly PwUuid _customIconId;
|
||||||
internal PwGroup Group;
|
internal PwGroup Group;
|
||||||
readonly Activity _ctx;
|
|
||||||
|
|
||||||
public EditGroup(Activity ctx, IKp2aApp app, String name, PwIcon iconid, PwUuid customIconId, PwGroup group, OnOperationFinishedHandler operationFinishedHandler)
|
public EditGroup(IKp2aApp app, String name, PwIcon iconid, PwUuid customIconId, PwGroup group, OnOperationFinishedHandler operationFinishedHandler)
|
||||||
: base(ctx, operationFinishedHandler)
|
: base(app, operationFinishedHandler)
|
||||||
{
|
{
|
||||||
_ctx = ctx;
|
|
||||||
_name = name;
|
_name = name;
|
||||||
_iconId = iconid;
|
_iconId = iconid;
|
||||||
Group = group;
|
Group = group;
|
||||||
_customIconId = customIconId;
|
_customIconId = customIconId;
|
||||||
_app = app;
|
_app = app;
|
||||||
|
|
||||||
_operationFinishedHandler = new AfterEdit(ctx, this, operationFinishedHandler);
|
_operationFinishedHandler = new AfterEdit(app, this, operationFinishedHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -60,7 +58,7 @@ namespace keepass2android
|
|||||||
Group.Touch(true);
|
Group.Touch(true);
|
||||||
|
|
||||||
// Commit to disk
|
// Commit to disk
|
||||||
SaveDb save = new SaveDb(_ctx, _app, Db, operationFinishedHandler);
|
SaveDb save = new SaveDb(_app, Db, operationFinishedHandler);
|
||||||
save.SetStatusLogger(StatusLogger);
|
save.SetStatusLogger(StatusLogger);
|
||||||
save.Run();
|
save.Run();
|
||||||
}
|
}
|
||||||
@@ -68,8 +66,8 @@ namespace keepass2android
|
|||||||
private class AfterEdit : OnOperationFinishedHandler {
|
private class AfterEdit : OnOperationFinishedHandler {
|
||||||
readonly EditGroup _editGroup;
|
readonly EditGroup _editGroup;
|
||||||
|
|
||||||
public AfterEdit(Activity ctx, EditGroup editGroup, OnOperationFinishedHandler operationFinishedHandler)
|
public AfterEdit(IKp2aApp app, EditGroup editGroup, OnOperationFinishedHandler operationFinishedHandler)
|
||||||
: base(ctx, operationFinishedHandler)
|
: base(app, operationFinishedHandler)
|
||||||
{
|
{
|
||||||
_editGroup = editGroup;
|
_editGroup = editGroup;
|
||||||
}
|
}
|
||||||
|
@@ -24,7 +24,7 @@ namespace keepass2android
|
|||||||
public abstract class FileOnFinish : OnOperationFinishedHandler {
|
public abstract class FileOnFinish : OnOperationFinishedHandler {
|
||||||
private String _filename = "";
|
private String _filename = "";
|
||||||
|
|
||||||
protected FileOnFinish(Activity activity, FileOnFinish operationFinishedHandler):base(activity, operationFinishedHandler) {
|
protected FileOnFinish(IKp2aApp app, FileOnFinish operationFinishedHandler):base(app, operationFinishedHandler) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Filename
|
public string Filename
|
||||||
|
@@ -40,7 +40,7 @@ namespace keepass2android
|
|||||||
private readonly bool _rememberKeyfile;
|
private readonly bool _rememberKeyfile;
|
||||||
IDatabaseFormat _format;
|
IDatabaseFormat _format;
|
||||||
|
|
||||||
public LoadDb(Activity activity, IKp2aApp app, IOConnectionInfo ioc, Task<MemoryStream> databaseData, CompositeKey compositeKey, String keyfileOrProvider, OnOperationFinishedHandler operationFinishedHandler, bool updateLastUsageTimestamp, bool makeCurrent): base(activity, operationFinishedHandler)
|
public LoadDb(Activity activity, IKp2aApp app, IOConnectionInfo ioc, Task<MemoryStream> databaseData, CompositeKey compositeKey, String keyfileOrProvider, OnOperationFinishedHandler operationFinishedHandler, bool updateLastUsageTimestamp, bool makeCurrent): base(app, operationFinishedHandler)
|
||||||
{
|
{
|
||||||
_app = app;
|
_app = app;
|
||||||
_ioc = ioc;
|
_ioc = ioc;
|
||||||
@@ -169,7 +169,7 @@ namespace keepass2android
|
|||||||
|
|
||||||
if (requiresSubsequentSync)
|
if (requiresSubsequentSync)
|
||||||
{
|
{
|
||||||
var syncTask = new SynchronizeCachedDatabase(ActiveContext, _app, new ActionOnOperationFinished(ActiveContext,
|
var syncTask = new SynchronizeCachedDatabase(_app, new ActionOnOperationFinished(_app,
|
||||||
(success, message, activeActivity) =>
|
(success, message, activeActivity) =>
|
||||||
{
|
{
|
||||||
if (!String.IsNullOrEmpty(message))
|
if (!String.IsNullOrEmpty(message))
|
||||||
@@ -177,7 +177,7 @@ namespace keepass2android
|
|||||||
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
BackgroundOperationRunner.Instance.Run(ActiveContext, _app, syncTask);
|
BackgroundOperationRunner.Instance.Run(_app, syncTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
Finish(true, _format.SuccessMessage);
|
Finish(true, _format.SuccessMessage);
|
||||||
|
@@ -14,14 +14,12 @@ namespace keepass2android.database.edit
|
|||||||
{
|
{
|
||||||
private readonly List<IStructureItem> _elementsToMove;
|
private readonly List<IStructureItem> _elementsToMove;
|
||||||
private readonly PwGroup _targetGroup;
|
private readonly PwGroup _targetGroup;
|
||||||
private readonly Activity _ctx;
|
private readonly IKp2aApp _app;
|
||||||
private readonly IKp2aApp _app;
|
|
||||||
|
|
||||||
public MoveElements(List<IStructureItem> elementsToMove, PwGroup targetGroup, Activity ctx, IKp2aApp app, OnOperationFinishedHandler operationFinishedHandler) : base(ctx, operationFinishedHandler)
|
public MoveElements(List<IStructureItem> elementsToMove, PwGroup targetGroup,IKp2aApp app, OnOperationFinishedHandler operationFinishedHandler) : base(app, operationFinishedHandler)
|
||||||
{
|
{
|
||||||
_elementsToMove = elementsToMove;
|
_elementsToMove = elementsToMove;
|
||||||
_targetGroup = targetGroup;
|
_targetGroup = targetGroup;
|
||||||
_ctx = ctx;
|
|
||||||
_app = app;
|
_app = app;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,14 +131,14 @@ namespace keepass2android.database.edit
|
|||||||
operationFinishedHandler.Run();
|
operationFinishedHandler.Run();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SaveDb saveDb = new SaveDb(_ctx, _app, allDatabasesToSave[indexToSave], new ActionOnOperationFinished(activeActivity, ContinueSave), false);
|
SaveDb saveDb = new SaveDb( _app, allDatabasesToSave[indexToSave], new ActionOnOperationFinished(_app, ContinueSave), false);
|
||||||
saveDb.SetStatusLogger(StatusLogger);
|
saveDb.SetStatusLogger(StatusLogger);
|
||||||
saveDb.ShowDatabaseIocInStatus = allDatabasesToSave.Count > 1;
|
saveDb.ShowDatabaseIocInStatus = allDatabasesToSave.Count > 1;
|
||||||
saveDb.Run();
|
saveDb.Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SaveDb save = new SaveDb(_ctx, _app, allDatabasesToSave[0], new ActionOnOperationFinished(ActiveContext, ContinueSave), false);
|
SaveDb save = new SaveDb(_app, allDatabasesToSave[0], new ActionOnOperationFinished(_app, ContinueSave), false);
|
||||||
save.SetStatusLogger(StatusLogger);
|
save.SetStatusLogger(StatusLogger);
|
||||||
save.ShowDatabaseIocInStatus = allDatabasesToSave.Count > 1;
|
save.ShowDatabaseIocInStatus = allDatabasesToSave.Count > 1;
|
||||||
save.Run();
|
save.Run();
|
||||||
|
@@ -26,6 +26,11 @@ using KeePassLib.Interfaces;
|
|||||||
|
|
||||||
namespace keepass2android
|
namespace keepass2android
|
||||||
{
|
{
|
||||||
|
public interface IActiveContextProvider
|
||||||
|
{
|
||||||
|
Context ActiveContext { get; }
|
||||||
|
}
|
||||||
|
|
||||||
public abstract class OnOperationFinishedHandler
|
public abstract class OnOperationFinishedHandler
|
||||||
{
|
{
|
||||||
protected bool Success;
|
protected bool Success;
|
||||||
@@ -38,62 +43,40 @@ namespace keepass2android
|
|||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected Context ActiveContext
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _activeContextProvider?.ActiveContext;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected OnOperationFinishedHandler NextOnOperationFinishedHandler;
|
protected OnOperationFinishedHandler NextOnOperationFinishedHandler;
|
||||||
protected Handler Handler;
|
protected Handler Handler;
|
||||||
private IKp2aStatusLogger _statusLogger = new Kp2aNullStatusLogger(); //default: no logging but not null -> can be used whenever desired
|
private IKp2aStatusLogger _statusLogger = new Kp2aNullStatusLogger(); //default: no logging but not null -> can be used whenever desired
|
||||||
private Context _activeContext, _previouslyActiveContext;
|
private readonly IActiveContextProvider _activeContextProvider;
|
||||||
|
|
||||||
|
public IKp2aStatusLogger StatusLogger
|
||||||
public IKp2aStatusLogger StatusLogger
|
|
||||||
{
|
{
|
||||||
get { return _statusLogger; }
|
get { return _statusLogger; }
|
||||||
set { _statusLogger = value; }
|
set { _statusLogger = value; }
|
||||||
}
|
} protected OnOperationFinishedHandler(IActiveContextProvider activeContextProvider, Handler handler)
|
||||||
|
|
||||||
public Context ActiveContext
|
|
||||||
{
|
|
||||||
get { return _activeContext; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (_activeContext != null && _activeContext != _previouslyActiveContext)
|
|
||||||
{
|
|
||||||
_previouslyActiveContext = _activeContext;
|
|
||||||
|
|
||||||
}
|
|
||||||
_activeContext = value;
|
|
||||||
if (NextOnOperationFinishedHandler != null)
|
|
||||||
{
|
|
||||||
NextOnOperationFinishedHandler.ActiveContext = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Context PreviouslyActiveContext
|
|
||||||
{
|
{
|
||||||
get { return _previouslyActiveContext; }
|
_activeContextProvider = activeContextProvider;
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected OnOperationFinishedHandler(Context activeContext, Handler handler)
|
|
||||||
{
|
|
||||||
ActiveContext = activeContext;
|
|
||||||
NextOnOperationFinishedHandler = null;
|
NextOnOperationFinishedHandler = null;
|
||||||
Handler = handler;
|
Handler = handler;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected OnOperationFinishedHandler(Context activeContext, OnOperationFinishedHandler operationFinishedHandler, Handler handler)
|
protected OnOperationFinishedHandler(IActiveContextProvider activeContextProvider, OnOperationFinishedHandler operationFinishedHandler, Handler handler)
|
||||||
{
|
{
|
||||||
ActiveContext = activeContext;
|
_activeContextProvider = activeContextProvider;
|
||||||
NextOnOperationFinishedHandler = operationFinishedHandler;
|
NextOnOperationFinishedHandler = operationFinishedHandler;
|
||||||
Handler = handler;
|
Handler = handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected OnOperationFinishedHandler(Context activeContext, OnOperationFinishedHandler operationFinishedHandler)
|
protected OnOperationFinishedHandler(IActiveContextProvider activeContextProvider, OnOperationFinishedHandler operationFinishedHandler)
|
||||||
{
|
{
|
||||||
ActiveContext = activeContext;
|
_activeContextProvider = activeContextProvider;
|
||||||
NextOnOperationFinishedHandler = operationFinishedHandler;
|
NextOnOperationFinishedHandler = operationFinishedHandler;
|
||||||
Handler = null;
|
Handler = null;
|
||||||
}
|
}
|
||||||
@@ -153,3 +136,4 @@ namespace keepass2android
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -26,11 +26,11 @@ namespace keepass2android
|
|||||||
|
|
||||||
protected OnOperationFinishedHandler _operationFinishedHandler;
|
protected OnOperationFinishedHandler _operationFinishedHandler;
|
||||||
public IKp2aStatusLogger StatusLogger = new Kp2aNullStatusLogger(); //default: empty but not null
|
public IKp2aStatusLogger StatusLogger = new Kp2aNullStatusLogger(); //default: empty but not null
|
||||||
private Context _activeContext;
|
private IActiveContextProvider _activeContextProvider;
|
||||||
|
|
||||||
protected OperationWithFinishHandler(Context activeContext, OnOperationFinishedHandler operationFinishedHandler)
|
protected OperationWithFinishHandler(IActiveContextProvider activeContextProvider, OnOperationFinishedHandler operationFinishedHandler)
|
||||||
{
|
{
|
||||||
_activeContext = activeContext;
|
_activeContextProvider = activeContextProvider;
|
||||||
_operationFinishedHandler = operationFinishedHandler;
|
_operationFinishedHandler = operationFinishedHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,16 +40,6 @@ namespace keepass2android
|
|||||||
set { _operationFinishedHandler = value; }
|
set { _operationFinishedHandler = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public Context ActiveContext
|
|
||||||
{
|
|
||||||
get { return _activeContext; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_activeContext = value;
|
|
||||||
if (_operationFinishedHandler != null)
|
|
||||||
_operationFinishedHandler.ActiveContext = _activeContext;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void Finish(bool result, String message, bool importantMessage = false, Exception exception = null) {
|
protected void Finish(bool result, String message, bool importantMessage = false, Exception exception = null) {
|
||||||
if ( operationFinishedHandler != null ) {
|
if ( operationFinishedHandler != null ) {
|
||||||
|
@@ -30,6 +30,7 @@ using keepass2android.Io;
|
|||||||
using Debug = System.Diagnostics.Debug;
|
using Debug = System.Diagnostics.Debug;
|
||||||
using Exception = System.Exception;
|
using Exception = System.Exception;
|
||||||
using KeePass.Util;
|
using KeePass.Util;
|
||||||
|
using Thread = System.Threading.Thread;
|
||||||
|
|
||||||
namespace keepass2android
|
namespace keepass2android
|
||||||
{
|
{
|
||||||
@@ -44,14 +45,13 @@ namespace keepass2android
|
|||||||
/// stream for reading the data from the original file. If this is set to a non-null value, we know we need to sync
|
/// stream for reading the data from the original file. If this is set to a non-null value, we know we need to sync
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly Stream _streamForOrigFile;
|
private readonly Stream _streamForOrigFile;
|
||||||
private readonly Context _ctx;
|
|
||||||
private Java.Lang.Thread _workerThread;
|
private Java.Lang.Thread _workerThread;
|
||||||
|
|
||||||
public SaveDb(Activity ctx, IKp2aApp app, Database db, OnOperationFinishedHandler operationFinishedHandler, bool dontSave)
|
public SaveDb(IKp2aApp app, Database db, OnOperationFinishedHandler operationFinishedHandler, bool dontSave)
|
||||||
: base(ctx, operationFinishedHandler)
|
: base(app, operationFinishedHandler)
|
||||||
{
|
{
|
||||||
_db = db;
|
_db = db;
|
||||||
_ctx = ctx;
|
|
||||||
_app = app;
|
_app = app;
|
||||||
_dontSave = dontSave;
|
_dontSave = dontSave;
|
||||||
}
|
}
|
||||||
@@ -59,29 +59,29 @@ namespace keepass2android
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor for sync
|
/// Constructor for sync
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="ctx"></param>
|
|
||||||
/// <param name="app"></param>
|
/// <param name="app"></param>
|
||||||
/// <param name="operationFinishedHandler"></param>
|
/// <param name="operationFinishedHandler"></param>
|
||||||
/// <param name="dontSave"></param>
|
/// <param name="dontSave"></param>
|
||||||
/// <param name="streamForOrigFile">Stream for reading the data from the (changed) original location</param>
|
/// <param name="streamForOrigFile">Stream for reading the data from the (changed) original location</param>
|
||||||
public SaveDb(Context ctx, IKp2aApp app, OnOperationFinishedHandler operationFinishedHandler, Database db, bool dontSave, Stream streamForOrigFile)
|
public SaveDb(IKp2aApp app, OnOperationFinishedHandler operationFinishedHandler, Database db, bool dontSave, Stream streamForOrigFile)
|
||||||
: base(ctx, operationFinishedHandler)
|
: base(app, operationFinishedHandler)
|
||||||
{
|
{
|
||||||
_db = db;
|
_db = db;
|
||||||
_ctx = ctx;
|
|
||||||
_app = app;
|
_app = app;
|
||||||
_dontSave = dontSave;
|
_dontSave = dontSave;
|
||||||
_streamForOrigFile = streamForOrigFile;
|
_streamForOrigFile = streamForOrigFile;
|
||||||
}
|
SyncInBackground = _app.SyncInBackgroundPreference;
|
||||||
|
|
||||||
public SaveDb(Activity ctx, IKp2aApp app, Database db, OnOperationFinishedHandler operationFinishedHandler)
|
}
|
||||||
: base(ctx, operationFinishedHandler)
|
|
||||||
|
public SaveDb(IKp2aApp app, Database db, OnOperationFinishedHandler operationFinishedHandler)
|
||||||
|
: base(app, operationFinishedHandler)
|
||||||
{
|
{
|
||||||
_ctx = ctx;
|
|
||||||
_app = app;
|
_app = app;
|
||||||
_db = db;
|
_db = db;
|
||||||
_dontSave = false;
|
_dontSave = false;
|
||||||
}
|
SyncInBackground = _app.SyncInBackgroundPreference;
|
||||||
|
}
|
||||||
|
|
||||||
public bool ShowDatabaseIocInStatus { get; set; }
|
public bool ShowDatabaseIocInStatus { get; set; }
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ namespace keepass2android
|
|||||||
IOConnectionInfo ioc = _db.Ioc;
|
IOConnectionInfo ioc = _db.Ioc;
|
||||||
IFileStorage fileStorage = _app.GetFileStorage(ioc);
|
IFileStorage fileStorage = _app.GetFileStorage(ioc);
|
||||||
|
|
||||||
if (_app.SyncInBackgroundPreference && fileStorage is IOfflineSwitchable offlineSwitchable)
|
if (SyncInBackground && fileStorage is IOfflineSwitchable offlineSwitchable)
|
||||||
{
|
{
|
||||||
offlineSwitchable.IsOffline = true;
|
offlineSwitchable.IsOffline = true;
|
||||||
//no warning. We'll trigger a sync later.
|
//no warning. We'll trigger a sync later.
|
||||||
@@ -176,8 +176,7 @@ namespace keepass2android
|
|||||||
(sender, args) =>
|
(sender, args) =>
|
||||||
{
|
{
|
||||||
RunInWorkerThread(() => Finish(false));
|
RunInWorkerThread(() => Finish(false));
|
||||||
},
|
}
|
||||||
_ctx
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,11 +209,13 @@ namespace keepass2android
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool SyncInBackground { get; set; }
|
||||||
|
|
||||||
private void FinishWithSuccess()
|
private void FinishWithSuccess()
|
||||||
{
|
{
|
||||||
if (requiresSubsequentSync)
|
if (requiresSubsequentSync)
|
||||||
{
|
{
|
||||||
var syncTask = new SynchronizeCachedDatabase(ActiveContext, _app, new ActionOnOperationFinished(ActiveContext,
|
var syncTask = new SynchronizeCachedDatabase(_app, new ActionOnOperationFinished(_app,
|
||||||
(success, message, activeActivity) =>
|
(success, message, activeActivity) =>
|
||||||
{
|
{
|
||||||
if (!System.String.IsNullOrEmpty(message))
|
if (!System.String.IsNullOrEmpty(message))
|
||||||
@@ -222,7 +223,7 @@ namespace keepass2android
|
|||||||
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
BackgroundOperationRunner.Instance.Run(ActiveContext, _app, syncTask);
|
BackgroundOperationRunner.Instance.Run(_app, syncTask);
|
||||||
}
|
}
|
||||||
Finish(true);
|
Finish(true);
|
||||||
}
|
}
|
||||||
|
@@ -28,20 +28,18 @@ namespace keepass2android
|
|||||||
private readonly String _keyfile;
|
private readonly String _keyfile;
|
||||||
private readonly IKp2aApp _app;
|
private readonly IKp2aApp _app;
|
||||||
private readonly bool _dontSave;
|
private readonly bool _dontSave;
|
||||||
private readonly Activity _ctx;
|
|
||||||
|
|
||||||
public SetPassword(Activity ctx, IKp2aApp app, String password, String keyfile, OnOperationFinishedHandler operationFinishedHandler): base(ctx, operationFinishedHandler) {
|
public SetPassword(IKp2aApp app, String password, String keyfile, OnOperationFinishedHandler operationFinishedHandler): base(app, operationFinishedHandler) {
|
||||||
_ctx = ctx;
|
|
||||||
_app = app;
|
_app = app;
|
||||||
_password = password;
|
_password = password;
|
||||||
_keyfile = keyfile;
|
_keyfile = keyfile;
|
||||||
_dontSave = false;
|
_dontSave = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SetPassword(Activity ctx, IKp2aApp app, String password, String keyfile, OnOperationFinishedHandler operationFinishedHandler, bool dontSave)
|
public SetPassword(IKp2aApp app, String password, String keyfile, OnOperationFinishedHandler operationFinishedHandler, bool dontSave)
|
||||||
: base(ctx, operationFinishedHandler)
|
: base(app, operationFinishedHandler)
|
||||||
{
|
{
|
||||||
_ctx = ctx;
|
|
||||||
_app = app;
|
_app = app;
|
||||||
_password = password;
|
_password = password;
|
||||||
_keyfile = keyfile;
|
_keyfile = keyfile;
|
||||||
@@ -73,8 +71,8 @@ namespace keepass2android
|
|||||||
pm.MasterKey = newKey;
|
pm.MasterKey = newKey;
|
||||||
|
|
||||||
// Save Database
|
// Save Database
|
||||||
_operationFinishedHandler = new AfterSave(ActiveContext, previousKey, previousMasterKeyChanged, pm, operationFinishedHandler);
|
_operationFinishedHandler = new AfterSave(_app, previousKey, previousMasterKeyChanged, pm, operationFinishedHandler);
|
||||||
SaveDb save = new SaveDb(_ctx, _app, _app.CurrentDb, operationFinishedHandler, _dontSave);
|
SaveDb save = new SaveDb(_app, _app.CurrentDb, operationFinishedHandler, _dontSave);
|
||||||
save.SetStatusLogger(StatusLogger);
|
save.SetStatusLogger(StatusLogger);
|
||||||
save.Run();
|
save.Run();
|
||||||
}
|
}
|
||||||
@@ -84,7 +82,7 @@ namespace keepass2android
|
|||||||
private readonly DateTime _previousKeyChanged;
|
private readonly DateTime _previousKeyChanged;
|
||||||
private readonly PwDatabase _db;
|
private readonly PwDatabase _db;
|
||||||
|
|
||||||
public AfterSave(Context context, CompositeKey backup, DateTime previousKeyChanged, PwDatabase db, OnOperationFinishedHandler operationFinishedHandler): base(context, operationFinishedHandler) {
|
public AfterSave(IActiveContextProvider activeContextProvider, CompositeKey backup, DateTime previousKeyChanged, PwDatabase db, OnOperationFinishedHandler operationFinishedHandler): base(activeContextProvider, operationFinishedHandler) {
|
||||||
_previousKeyChanged = previousKeyChanged;
|
_previousKeyChanged = previousKeyChanged;
|
||||||
_backup = backup;
|
_backup = backup;
|
||||||
_db = db;
|
_db = db;
|
||||||
|
@@ -24,19 +24,17 @@ namespace keepass2android
|
|||||||
|
|
||||||
public class UpdateEntry : OperationWithFinishHandler {
|
public class UpdateEntry : OperationWithFinishHandler {
|
||||||
private readonly IKp2aApp _app;
|
private readonly IKp2aApp _app;
|
||||||
private readonly Activity _ctx;
|
|
||||||
|
|
||||||
public UpdateEntry(Activity ctx, IKp2aApp app, PwEntry oldE, PwEntry newE, OnOperationFinishedHandler operationFinishedHandler):base(ctx, operationFinishedHandler) {
|
public UpdateEntry(IKp2aApp app, PwEntry oldE, PwEntry newE, OnOperationFinishedHandler operationFinishedHandler):base(app, operationFinishedHandler) {
|
||||||
_ctx = ctx;
|
_app = app;
|
||||||
_app = app;
|
|
||||||
|
|
||||||
_operationFinishedHandler = new AfterUpdate(ctx, oldE, newE, app, operationFinishedHandler);
|
_operationFinishedHandler = new AfterUpdate( oldE, newE, app, operationFinishedHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public override void Run() {
|
public override void Run() {
|
||||||
// Commit to disk
|
// Commit to disk
|
||||||
SaveDb save = new SaveDb(_ctx, _app, _app.CurrentDb, operationFinishedHandler);
|
SaveDb save = new SaveDb(_app, _app.CurrentDb, operationFinishedHandler);
|
||||||
save.SetStatusLogger(StatusLogger);
|
save.SetStatusLogger(StatusLogger);
|
||||||
save.Run();
|
save.Run();
|
||||||
}
|
}
|
||||||
@@ -46,7 +44,7 @@ namespace keepass2android
|
|||||||
private readonly PwEntry _updatedEntry;
|
private readonly PwEntry _updatedEntry;
|
||||||
private readonly IKp2aApp _app;
|
private readonly IKp2aApp _app;
|
||||||
|
|
||||||
public AfterUpdate(Activity activity, PwEntry backup, PwEntry updatedEntry, IKp2aApp app, OnOperationFinishedHandler operationFinishedHandler):base(activity, operationFinishedHandler) {
|
public AfterUpdate(PwEntry backup, PwEntry updatedEntry, IKp2aApp app, OnOperationFinishedHandler operationFinishedHandler):base(app, operationFinishedHandler) {
|
||||||
_backup = backup;
|
_backup = backup;
|
||||||
_updatedEntry = updatedEntry;
|
_updatedEntry = updatedEntry;
|
||||||
_app = app;
|
_app = app;
|
||||||
|
@@ -228,9 +228,9 @@ namespace keepass2android
|
|||||||
newEntry.SetUuid(new PwUuid(true), true); // Create new UUID
|
newEntry.SetUuid(new PwUuid(true), true); // Create new UUID
|
||||||
string strTitle = newEntry.Strings.ReadSafe(PwDefs.TitleField);
|
string strTitle = newEntry.Strings.ReadSafe(PwDefs.TitleField);
|
||||||
newEntry.Strings.Set(PwDefs.TitleField, new ProtectedString(false, strTitle + " (" + Android.OS.Build.Model + ")"));
|
newEntry.Strings.Set(PwDefs.TitleField, new ProtectedString(false, strTitle + " (" + Android.OS.Build.Model + ")"));
|
||||||
var addTask = new AddEntry(this, App.Kp2a.CurrentDb, App.Kp2a, newEntry,item.Entry.ParentGroup,new ActionOnOperationFinished(this, (success, message, activity) => ((ConfigureChildDatabasesActivity)activity).Update()));
|
var addTask = new AddEntry( App.Kp2a.CurrentDb, App.Kp2a, newEntry,item.Entry.ParentGroup,new ActionOnOperationFinished(App.Kp2a, (success, message, activity) => ((ConfigureChildDatabasesActivity)activity).Update()));
|
||||||
|
|
||||||
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, this, addTask);
|
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, addTask);
|
||||||
pt.Run();
|
pt.Run();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -260,9 +260,9 @@ namespace keepass2android
|
|||||||
|
|
||||||
private void Save(AutoExecItem item)
|
private void Save(AutoExecItem item)
|
||||||
{
|
{
|
||||||
var addTask = new SaveDb(this, App.Kp2a, App.Kp2a.FindDatabaseForElement(item.Entry), new ActionOnOperationFinished(this, (success, message, activity) => ((ConfigureChildDatabasesActivity)activity).Update()));
|
var addTask = new SaveDb(App.Kp2a, App.Kp2a.FindDatabaseForElement(item.Entry), new ActionOnOperationFinished(App.Kp2a, (success, message, activity) => ((ConfigureChildDatabasesActivity)activity).Update()));
|
||||||
|
|
||||||
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, this, addTask);
|
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, addTask);
|
||||||
pt.Run();
|
pt.Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -343,7 +343,7 @@ namespace keepass2android
|
|||||||
}
|
}
|
||||||
if (autoOpenGroup == null)
|
if (autoOpenGroup == null)
|
||||||
{
|
{
|
||||||
AddGroup addGroupTask = AddGroup.GetInstance(this, App.Kp2a, "AutoOpen", 1, null, rootGroup, null, true);
|
AddGroup addGroupTask = AddGroup.GetInstance(App.Kp2a, "AutoOpen", 1, null, rootGroup, null, true);
|
||||||
addGroupTask.Run();
|
addGroupTask.Run();
|
||||||
autoOpenGroup = addGroupTask.Group;
|
autoOpenGroup = addGroupTask.Group;
|
||||||
}
|
}
|
||||||
@@ -367,9 +367,9 @@ namespace keepass2android
|
|||||||
{KeeAutoExecExt.ThisDeviceId, true}
|
{KeeAutoExecExt.ThisDeviceId, true}
|
||||||
})));
|
})));
|
||||||
|
|
||||||
var addTask = new AddEntry(this, db, App.Kp2a, newEntry, autoOpenGroup, new ActionOnOperationFinished(this, (success, message, activity) => (activity as ConfigureChildDatabasesActivity)?.Update()));
|
var addTask = new AddEntry( db, App.Kp2a, newEntry, autoOpenGroup, new ActionOnOperationFinished(App.Kp2a, (success, message, activity) => (activity as ConfigureChildDatabasesActivity)?.Update()));
|
||||||
|
|
||||||
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, this, addTask);
|
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, addTask);
|
||||||
pt.Run();
|
pt.Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -213,10 +213,9 @@ namespace keepass2android
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create the new database
|
// Create the new database
|
||||||
CreateDb create = new CreateDb(App.Kp2a, this, _ioc, new LaunchGroupActivity(_ioc, this), false, newKey, makeCurrent);
|
CreateDb create = new CreateDb(App.Kp2a, this, _ioc, new LaunchGroupActivity(_ioc, App.Kp2a, this), false, newKey, makeCurrent);
|
||||||
BlockingOperationRunner createTask = new BlockingOperationRunner(
|
BlockingOperationRunner createTask = new BlockingOperationRunner(
|
||||||
App.Kp2a,
|
App.Kp2a, create);
|
||||||
this, create);
|
|
||||||
createTask.Run();
|
createTask.Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -403,14 +402,14 @@ namespace keepass2android
|
|||||||
|
|
||||||
private class LaunchGroupActivity : FileOnFinish
|
private class LaunchGroupActivity : FileOnFinish
|
||||||
{
|
{
|
||||||
readonly CreateDatabaseActivity _activity;
|
|
||||||
private readonly IOConnectionInfo _ioc;
|
private readonly IOConnectionInfo _ioc;
|
||||||
|
private readonly CreateDatabaseActivity _activity;
|
||||||
|
|
||||||
public LaunchGroupActivity(IOConnectionInfo ioc, CreateDatabaseActivity activity)
|
public LaunchGroupActivity(IOConnectionInfo ioc, IKp2aApp app, CreateDatabaseActivity activity)
|
||||||
: base(activity, null)
|
: base(app, null)
|
||||||
{
|
{
|
||||||
_activity = activity;
|
_activity = activity;
|
||||||
_ioc = ioc;
|
_ioc = ioc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Run()
|
public override void Run()
|
||||||
@@ -420,7 +419,7 @@ namespace keepass2android
|
|||||||
// Update the ongoing notification
|
// Update the ongoing notification
|
||||||
App.Kp2a.UpdateOngoingNotification();
|
App.Kp2a.UpdateOngoingNotification();
|
||||||
|
|
||||||
if (PreferenceManager.GetDefaultSharedPreferences(_activity).GetBoolean(_activity.GetString(Resource.String.RememberRecentFiles_key), _activity.Resources.GetBoolean(Resource.Boolean.RememberRecentFiles_default)))
|
if (PreferenceManager.GetDefaultSharedPreferences(App.Context).GetBoolean(App.Context.GetString(Resource.String.RememberRecentFiles_key), App.Context.Resources.GetBoolean(Resource.Boolean.RememberRecentFiles_default)))
|
||||||
{
|
{
|
||||||
// Add to recent files
|
// Add to recent files
|
||||||
FileDbHelper dbHelper = App.Kp2a.FileDbHelper;
|
FileDbHelper dbHelper = App.Kp2a.FileDbHelper;
|
||||||
|
@@ -8,8 +8,8 @@ namespace keepass2android
|
|||||||
{
|
{
|
||||||
private readonly string _filename;
|
private readonly string _filename;
|
||||||
|
|
||||||
public CreateNewFilename(Activity activity, OnOperationFinishedHandler operationFinishedHandler, string filename)
|
public CreateNewFilename(IKp2aApp app, OnOperationFinishedHandler operationFinishedHandler, string filename)
|
||||||
: base(activity,operationFinishedHandler)
|
: base(app,operationFinishedHandler)
|
||||||
{
|
{
|
||||||
_filename = filename;
|
_filename = filename;
|
||||||
}
|
}
|
||||||
|
@@ -76,13 +76,13 @@ namespace keepass2android
|
|||||||
|
|
||||||
protected override void SaveFile(IOConnectionInfo ioc)
|
protected override void SaveFile(IOConnectionInfo ioc)
|
||||||
{
|
{
|
||||||
var task = new EntryActivity.WriteBinaryTask(_activity, App.Kp2a, new ActionOnOperationFinished(_activity, (success, message, activity) =>
|
var task = new EntryActivity.WriteBinaryTask(App.Kp2a, new ActionOnOperationFinished(App.Kp2a, (success, message, activity) =>
|
||||||
{
|
{
|
||||||
if (!success)
|
if (!success)
|
||||||
App.Kp2a.ShowMessage(activity, message, MessageSeverity.Error);
|
App.Kp2a.ShowMessage(activity, message, MessageSeverity.Error);
|
||||||
}
|
}
|
||||||
), ((EntryActivity)_activity).Entry.Binaries.Get(_binaryToSave), ioc);
|
), ((EntryActivity)_activity).Entry.Binaries.Get(_binaryToSave), ioc);
|
||||||
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, _activity, task);
|
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, task);
|
||||||
pt.Run();
|
pt.Run();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -482,8 +482,8 @@ namespace keepass2android
|
|||||||
Entry.Expires = true;
|
Entry.Expires = true;
|
||||||
Entry.Touch(true);
|
Entry.Touch(true);
|
||||||
RequiresRefresh();
|
RequiresRefresh();
|
||||||
UpdateEntry update = new UpdateEntry(this, App.Kp2a, backupEntry, Entry, null);
|
UpdateEntry update = new UpdateEntry(App.Kp2a, backupEntry, Entry, null);
|
||||||
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, this, update);
|
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, update);
|
||||||
pt.Run();
|
pt.Run();
|
||||||
}
|
}
|
||||||
FillData();
|
FillData();
|
||||||
@@ -526,7 +526,7 @@ namespace keepass2android
|
|||||||
App.Kp2a.DirtyGroups.Add(parent);
|
App.Kp2a.DirtyGroups.Add(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
var saveTask = new SaveDb(this, App.Kp2a, App.Kp2a.FindDatabaseForElement(Entry), new ActionOnOperationFinished(this, (success, message, context) =>
|
var saveTask = new SaveDb( App.Kp2a, App.Kp2a.FindDatabaseForElement(Entry), new ActionOnOperationFinished(App.Kp2a, (success, message, context) =>
|
||||||
{
|
{
|
||||||
if (context is Activity activity)
|
if (context is Activity activity)
|
||||||
{
|
{
|
||||||
@@ -536,7 +536,7 @@ namespace keepass2android
|
|||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, this, saveTask);
|
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, saveTask);
|
||||||
pt.Run();
|
pt.Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1271,7 +1271,7 @@ namespace keepass2android
|
|||||||
private readonly ProtectedBinary _data;
|
private readonly ProtectedBinary _data;
|
||||||
private IOConnectionInfo _targetIoc;
|
private IOConnectionInfo _targetIoc;
|
||||||
|
|
||||||
public WriteBinaryTask(Activity activity, IKp2aApp app, OnOperationFinishedHandler onOperationFinishedHandler, ProtectedBinary data, IOConnectionInfo targetIoc) : base(activity, onOperationFinishedHandler)
|
public WriteBinaryTask(IKp2aApp app, OnOperationFinishedHandler onOperationFinishedHandler, ProtectedBinary data, IOConnectionInfo targetIoc) : base(app, onOperationFinishedHandler)
|
||||||
{
|
{
|
||||||
_app = app;
|
_app = app;
|
||||||
_data = data;
|
_data = data;
|
||||||
@@ -1445,8 +1445,8 @@ namespace keepass2android
|
|||||||
Finish();
|
Finish();
|
||||||
return true;
|
return true;
|
||||||
case Resource.Id.menu_delete:
|
case Resource.Id.menu_delete:
|
||||||
DeleteEntry task = new DeleteEntry(this, App.Kp2a, Entry,
|
DeleteEntry task = new DeleteEntry(App.Kp2a, Entry,
|
||||||
new ActionOnOperationFinished(this, (success, message, activity) => { if (success) { RequiresRefresh(); Finish();}}));
|
new ActionOnOperationFinished(App.Kp2a, (success, message, activity) => { if (success) { RequiresRefresh(); Finish();}}));
|
||||||
task.Start();
|
task.Start();
|
||||||
break;
|
break;
|
||||||
case Resource.Id.menu_toggle_pass:
|
case Resource.Id.menu_toggle_pass:
|
||||||
@@ -1509,16 +1509,16 @@ namespace keepass2android
|
|||||||
|
|
||||||
//save the entry:
|
//save the entry:
|
||||||
|
|
||||||
ActionOnOperationFinished closeOrShowError = new ActionOnOperationFinished(this, (success, message, activity) =>
|
ActionOnOperationFinished closeOrShowError = new ActionOnOperationFinished(App.Kp2a, (success, message, activity) =>
|
||||||
{
|
{
|
||||||
OnOperationFinishedHandler.DisplayMessage(this, message, true);
|
OnOperationFinishedHandler.DisplayMessage(this, message, true);
|
||||||
finishAction((EntryActivity)activity);
|
finishAction((EntryActivity)activity);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
OperationWithFinishHandler runnable = new UpdateEntry(this, App.Kp2a, initialEntry, newEntry, closeOrShowError);
|
OperationWithFinishHandler runnable = new UpdateEntry(App.Kp2a, initialEntry, newEntry, closeOrShowError);
|
||||||
|
|
||||||
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, this, runnable);
|
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, runnable);
|
||||||
pt.Run();
|
pt.Run();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -521,7 +521,7 @@ namespace keepass2android
|
|||||||
|
|
||||||
OperationWithFinishHandler runnable;
|
OperationWithFinishHandler runnable;
|
||||||
|
|
||||||
ActionOnOperationFinished closeOrShowError = new ActionOnOperationFinished(this, (success, message, context) => {
|
ActionOnOperationFinished closeOrShowError = new ActionOnOperationFinished(App.Kp2a, (success, message, context) => {
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
(context as Activity)?.Finish();
|
(context as Activity)?.Finish();
|
||||||
@@ -536,18 +536,18 @@ namespace keepass2android
|
|||||||
closeOrShowError.AllowInactiveActivity = true;
|
closeOrShowError.AllowInactiveActivity = true;
|
||||||
|
|
||||||
|
|
||||||
ActionOnOperationFinished afterAddEntry = new ActionOnOperationFinished(this, (success, message, activity) =>
|
ActionOnOperationFinished afterAddEntry = new ActionOnOperationFinished(App.Kp2a, (success, message, activity) =>
|
||||||
{
|
{
|
||||||
if (success && activity is EntryEditActivity entryEditActivity)
|
if (success && activity is EntryEditActivity entryEditActivity)
|
||||||
AppTask.AfterAddNewEntry(entryEditActivity, newEntry);
|
AppTask.AfterAddNewEntry(entryEditActivity, newEntry);
|
||||||
},closeOrShowError);
|
},closeOrShowError);
|
||||||
|
|
||||||
if ( State.IsNew ) {
|
if ( State.IsNew ) {
|
||||||
runnable = AddEntry.GetInstance(this, App.Kp2a, newEntry, State.ParentGroup, afterAddEntry, db);
|
runnable = AddEntry.GetInstance(App.Kp2a, newEntry, State.ParentGroup, afterAddEntry, db);
|
||||||
} else {
|
} else {
|
||||||
runnable = new UpdateEntry(this, App.Kp2a, initialEntry, newEntry, closeOrShowError);
|
runnable = new UpdateEntry(App.Kp2a, initialEntry, newEntry, closeOrShowError);
|
||||||
}
|
}
|
||||||
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, act, runnable);
|
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, runnable);
|
||||||
pt.Run();
|
pt.Run();
|
||||||
|
|
||||||
|
|
||||||
|
@@ -26,16 +26,16 @@ namespace keepass2android
|
|||||||
|
|
||||||
protected override void SaveFile(IOConnectionInfo ioc)
|
protected override void SaveFile(IOConnectionInfo ioc)
|
||||||
{
|
{
|
||||||
var exportDb = new ExportDatabaseActivity.ExportDb(_activity, App.Kp2a, new ActionOnOperationFinished(_activity, (success, message, context) =>
|
var exportDb = new ExportDatabaseActivity.ExportDb(App.Kp2a, new ActionOnOperationFinished(App.Kp2a, (success, message, context) =>
|
||||||
{
|
{
|
||||||
if (!success)
|
if (!success)
|
||||||
App.Kp2a.ShowMessage(context, message, MessageSeverity.Error);
|
App.Kp2a.ShowMessage(context, message, MessageSeverity.Error);
|
||||||
else
|
else
|
||||||
App.Kp2a.ShowMessage(context, _activity.GetString(Resource.String.export_database_successful), MessageSeverity.Info);
|
App.Kp2a.ShowMessage(context, _activity.GetString(Resource.String.export_database_successful), MessageSeverity.Info);
|
||||||
(context as Activity)?.Finish();
|
(context as Activity)?.Finish();
|
||||||
}
|
}
|
||||||
), _ffp, ioc);
|
), _ffp, ioc);
|
||||||
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, _activity, exportDb);
|
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, exportDb);
|
||||||
pt.Run();
|
pt.Run();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -99,7 +99,7 @@ namespace keepass2android
|
|||||||
private readonly FileFormatProvider _fileFormat;
|
private readonly FileFormatProvider _fileFormat;
|
||||||
private IOConnectionInfo _targetIoc;
|
private IOConnectionInfo _targetIoc;
|
||||||
|
|
||||||
public ExportDb(Activity activity, IKp2aApp app, OnOperationFinishedHandler onOperationFinishedHandler, FileFormatProvider fileFormat, IOConnectionInfo targetIoc) : base(activity, onOperationFinishedHandler)
|
public ExportDb(IKp2aApp app, OnOperationFinishedHandler onOperationFinishedHandler, FileFormatProvider fileFormat, IOConnectionInfo targetIoc) : base(app, onOperationFinishedHandler)
|
||||||
{
|
{
|
||||||
_app = app;
|
_app = app;
|
||||||
this._fileFormat = fileFormat;
|
this._fileFormat = fileFormat;
|
||||||
|
@@ -103,7 +103,7 @@ namespace keepass2android
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var task = new CreateNewFilename(_activity, new ActionOnOperationFinished(_activity, (success, messageOrFilename, activity) =>
|
var task = new CreateNewFilename(App.Kp2a, new ActionOnOperationFinished(App.Kp2a, (success, messageOrFilename, activity) =>
|
||||||
{
|
{
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
@@ -115,7 +115,7 @@ namespace keepass2android
|
|||||||
|
|
||||||
}), filename);
|
}), filename);
|
||||||
|
|
||||||
new BlockingOperationRunner(App.Kp2a, _activity, task).Run();
|
new BlockingOperationRunner(App.Kp2a, task).Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@@ -781,7 +781,7 @@ namespace keepass2android
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var task = new CreateNewFilename(activity, new ActionOnOperationFinished(activity, (success, messageOrFilename, newActivity) =>
|
var task = new CreateNewFilename(App.Kp2a, new ActionOnOperationFinished(App.Kp2a, (success, messageOrFilename, newActivity) =>
|
||||||
{
|
{
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
@@ -793,7 +793,7 @@ namespace keepass2android
|
|||||||
|
|
||||||
}), filename);
|
}), filename);
|
||||||
|
|
||||||
new BlockingOperationRunner(App.Kp2a, activity, task).Run();
|
new BlockingOperationRunner(App.Kp2a, task).Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -223,8 +223,8 @@ namespace keepass2android
|
|||||||
(o, args) =>
|
(o, args) =>
|
||||||
{
|
{
|
||||||
//yes
|
//yes
|
||||||
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, this,
|
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a,
|
||||||
new AddTemplateEntries(this, App.Kp2a, new ActionOnOperationFinished(this,
|
new AddTemplateEntries(App.Kp2a, new ActionOnOperationFinished(App.Kp2a,
|
||||||
(success, message, activity) => ((GroupActivity)activity)?.StartAddEntry())));
|
(success, message, activity) => ((GroupActivity)activity)?.StartAddEntry())));
|
||||||
pt.Run();
|
pt.Run();
|
||||||
},
|
},
|
||||||
@@ -235,7 +235,7 @@ namespace keepass2android
|
|||||||
edit.Commit();
|
edit.Commit();
|
||||||
//no
|
//no
|
||||||
StartAddEntry();
|
StartAddEntry();
|
||||||
},null, this);
|
},null);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -206,15 +206,15 @@ namespace keepass2android
|
|||||||
OperationWithFinishHandler task;
|
OperationWithFinishHandler task;
|
||||||
if (strGroupUuid == null)
|
if (strGroupUuid == null)
|
||||||
{
|
{
|
||||||
task = AddGroup.GetInstance(this, App.Kp2a, groupName, groupIconId, groupCustomIconId, Group, new RefreshTask(handler, this), false);
|
task = AddGroup.GetInstance(App.Kp2a, groupName, groupIconId, groupCustomIconId, Group, new RefreshTask(handler, this), false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PwUuid groupUuid = new PwUuid(MemUtil.HexStringToByteArray(strGroupUuid));
|
PwUuid groupUuid = new PwUuid(MemUtil.HexStringToByteArray(strGroupUuid));
|
||||||
task = new EditGroup(this, App.Kp2a, groupName, (PwIcon)groupIconId, groupCustomIconId, App.Kp2a.FindGroup(groupUuid),
|
task = new EditGroup(App.Kp2a, groupName, (PwIcon)groupIconId, groupCustomIconId, App.Kp2a.FindGroup(groupUuid),
|
||||||
new RefreshTask(handler, this));
|
new RefreshTask(handler, this));
|
||||||
}
|
}
|
||||||
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, act, task);
|
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, task);
|
||||||
pt.Run();
|
pt.Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -925,14 +925,14 @@ namespace keepass2android
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
var moveElement = new MoveElements(elementsToMove.ToList(), Group, this, App.Kp2a, new ActionOnOperationFinished(this,
|
var moveElement = new MoveElements(elementsToMove.ToList(), Group, App.Kp2a, new ActionOnOperationFinished(App.Kp2a,
|
||||||
(success, message, activity) =>
|
(success, message, activity) =>
|
||||||
{
|
{
|
||||||
((GroupBaseActivity)activity)?.StopMovingElements();
|
((GroupBaseActivity)activity)?.StopMovingElements();
|
||||||
if (!String.IsNullOrEmpty(message))
|
if (!String.IsNullOrEmpty(message))
|
||||||
App.Kp2a.ShowMessage(activity, message, MessageSeverity.Error);
|
App.Kp2a.ShowMessage(activity, message, MessageSeverity.Error);
|
||||||
}));
|
}));
|
||||||
var progressTask = new BlockingOperationRunner(App.Kp2a, this, moveElement);
|
var progressTask = new BlockingOperationRunner(App.Kp2a, moveElement);
|
||||||
progressTask.Run();
|
progressTask.Run();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1297,7 +1297,7 @@ namespace keepass2android
|
|||||||
public class RefreshTask : OnOperationFinishedHandler
|
public class RefreshTask : OnOperationFinishedHandler
|
||||||
{
|
{
|
||||||
public RefreshTask(Handler handler, GroupBaseActivity act)
|
public RefreshTask(Handler handler, GroupBaseActivity act)
|
||||||
: base(act, handler)
|
: base(App.Kp2a, handler)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1316,7 +1316,7 @@ namespace keepass2android
|
|||||||
public class AfterDeleteGroup : OnOperationFinishedHandler
|
public class AfterDeleteGroup : OnOperationFinishedHandler
|
||||||
{
|
{
|
||||||
public AfterDeleteGroup(Handler handler, GroupBaseActivity act)
|
public AfterDeleteGroup(Handler handler, GroupBaseActivity act)
|
||||||
: base(act, handler)
|
: base(App.Kp2a, handler)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1492,10 +1492,10 @@ namespace keepass2android
|
|||||||
break;
|
break;
|
||||||
case Resource.Id.menu_copy:
|
case Resource.Id.menu_copy:
|
||||||
|
|
||||||
var copyTask = new CopyEntry((GroupBaseActivity)Activity, App.Kp2a, (PwEntry)checkedItems.First(),
|
var copyTask = new CopyEntry(App.Kp2a, (PwEntry)checkedItems.First(),
|
||||||
new GroupBaseActivity.RefreshTask(handler, ((GroupBaseActivity)Activity)), App.Kp2a.CurrentDb);
|
new GroupBaseActivity.RefreshTask(handler, ((GroupBaseActivity)Activity)), App.Kp2a.CurrentDb);
|
||||||
|
|
||||||
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, Activity, copyTask);
|
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, copyTask);
|
||||||
pt.Run();
|
pt.Run();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -1684,7 +1684,7 @@ namespace keepass2android
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
new DeleteMultipleItemsFromOneDatabase(activity, itemsForDatabases[dbIndex].Key,
|
new DeleteMultipleItemsFromOneDatabase(activity, itemsForDatabases[dbIndex].Key,
|
||||||
itemsForDatabases[dbIndex].Value, new ActionOnOperationFinished(activeActivity, (b, s, activity1) => action(b, s, activity1)), app)
|
itemsForDatabases[dbIndex].Value, new ActionOnOperationFinished(App.Kp2a, (b, s, activity1) => action(b, s, activity1)), app)
|
||||||
.Start();
|
.Start();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1694,7 +1694,7 @@ namespace keepass2android
|
|||||||
};
|
};
|
||||||
|
|
||||||
new DeleteMultipleItemsFromOneDatabase(activity, itemsForDatabases[dbIndex].Key,
|
new DeleteMultipleItemsFromOneDatabase(activity, itemsForDatabases[dbIndex].Key,
|
||||||
itemsForDatabases[dbIndex].Value, new ActionOnOperationFinished(activity, (b, s, activity1) => action(b, s, activity1)), app)
|
itemsForDatabases[dbIndex].Value, new ActionOnOperationFinished(App.Kp2a, (b, s, activity1) => action(b, s, activity1)), app)
|
||||||
.Start();
|
.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -104,8 +104,10 @@ namespace keepass2android
|
|||||||
|
|
||||||
protected override void OnStart()
|
protected override void OnStart()
|
||||||
{
|
{
|
||||||
|
App.Kp2a.ActiveContext = this;
|
||||||
BlockingOperationRunner.SetNewActiveActivity(this);
|
BlockingOperationRunner.SetNewActiveActivity(this);
|
||||||
BackgroundOperationRunner.Instance.SetNewActiveContext(this, App.Kp2a);
|
BackgroundOperationRunner.Instance.SetNewActiveContext( App.Kp2a);
|
||||||
|
|
||||||
base.OnStart();
|
base.OnStart();
|
||||||
Kp2aLog.Log(ClassName + ".OnStart" + " " + ID);
|
Kp2aLog.Log(ClassName + ".OnStart" + " " + ID);
|
||||||
}
|
}
|
||||||
|
@@ -1447,7 +1447,7 @@ namespace keepass2android
|
|||||||
: new LoadDb(this, App.Kp2a, _ioConnection, _loadDbFileTask, compositeKey, GetKeyProviderString(), onOperationFinishedHandler,true, _makeCurrent);
|
: new LoadDb(this, App.Kp2a, _ioConnection, _loadDbFileTask, compositeKey, GetKeyProviderString(), onOperationFinishedHandler,true, _makeCurrent);
|
||||||
_loadDbFileTask = null; // prevent accidental re-use
|
_loadDbFileTask = null; // prevent accidental re-use
|
||||||
|
|
||||||
new BlockingOperationRunner(App.Kp2a, this, task).Run();
|
new BlockingOperationRunner(App.Kp2a, task).Run();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -1889,7 +1889,7 @@ namespace keepass2android
|
|||||||
LoadDb task = new LoadDb(this, App.Kp2a, _ioConnection, _loadDbFileTask, compositeKeyForImmediateLoad, GetKeyProviderString(),
|
LoadDb task = new LoadDb(this, App.Kp2a, _ioConnection, _loadDbFileTask, compositeKeyForImmediateLoad, GetKeyProviderString(),
|
||||||
onOperationFinishedHandler, false, _makeCurrent);
|
onOperationFinishedHandler, false, _makeCurrent);
|
||||||
_loadDbFileTask = null; // prevent accidental re-use
|
_loadDbFileTask = null; // prevent accidental re-use
|
||||||
new BlockingOperationRunner(App.Kp2a, this, task).Run();
|
new BlockingOperationRunner(App.Kp2a, task).Run();
|
||||||
compositeKeyForImmediateLoad = null; //don't reuse or keep in memory
|
compositeKeyForImmediateLoad = null; //don't reuse or keep in memory
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2135,7 +2135,7 @@ namespace keepass2android
|
|||||||
readonly PasswordActivity _act;
|
readonly PasswordActivity _act;
|
||||||
private readonly IOConnectionInfo _ioConnection;
|
private readonly IOConnectionInfo _ioConnection;
|
||||||
|
|
||||||
public AfterLoad(Handler handler, PasswordActivity act, IOConnectionInfo ioConnection):base(act, handler)
|
public AfterLoad(Handler handler, PasswordActivity act, IOConnectionInfo ioConnection):base(App.Kp2a, handler)
|
||||||
{
|
{
|
||||||
_act = act;
|
_act = act;
|
||||||
_ioConnection = ioConnection;
|
_ioConnection = ioConnection;
|
||||||
|
@@ -72,8 +72,8 @@ namespace keepass2android
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SetPassword sp = new SetPassword(_activity, App.Kp2a, pass, keyfile, new AfterSave(_activity, this, null, new Handler()));
|
SetPassword sp = new SetPassword(App.Kp2a, pass, keyfile, new AfterSave(_activity, this, null, new Handler()));
|
||||||
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, _activity, sp);
|
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, sp);
|
||||||
pt.Run();
|
pt.Run();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ namespace keepass2android
|
|||||||
|
|
||||||
readonly SetPasswordDialog _dlg;
|
readonly SetPasswordDialog _dlg;
|
||||||
|
|
||||||
public AfterSave(Activity activity, SetPasswordDialog dlg, FileOnFinish operationFinishedHandler, Handler handler): base(activity, operationFinishedHandler, handler) {
|
public AfterSave(Activity activity, SetPasswordDialog dlg, FileOnFinish operationFinishedHandler, Handler handler): base(App.Kp2a, operationFinishedHandler, handler) {
|
||||||
_operationFinishedHandler = operationFinishedHandler;
|
_operationFinishedHandler = operationFinishedHandler;
|
||||||
_dlg = dlg;
|
_dlg = dlg;
|
||||||
}
|
}
|
||||||
|
@@ -21,7 +21,7 @@ namespace keepass2android
|
|||||||
private readonly IOConnectionInfo _ioc;
|
private readonly IOConnectionInfo _ioc;
|
||||||
|
|
||||||
public SyncOtpAuxFile(Activity activity, IOConnectionInfo ioc)
|
public SyncOtpAuxFile(Activity activity, IOConnectionInfo ioc)
|
||||||
: base(activity, null)
|
: base(App.Kp2a, null)
|
||||||
{
|
{
|
||||||
_ioc = ioc;
|
_ioc = ioc;
|
||||||
}
|
}
|
||||||
@@ -54,7 +54,7 @@ namespace keepass2android
|
|||||||
{
|
{
|
||||||
var filestorage = App.Kp2a.GetFileStorage(App.Kp2a.CurrentDb.Ioc);
|
var filestorage = App.Kp2a.GetFileStorage(App.Kp2a.CurrentDb.Ioc);
|
||||||
OperationWithFinishHandler task;
|
OperationWithFinishHandler task;
|
||||||
OnOperationFinishedHandler onOperationFinishedHandler = new ActionOnOperationFinished(_activity, (success, message, activity) =>
|
OnOperationFinishedHandler onOperationFinishedHandler = new ActionOnOperationFinished(App.Kp2a, (success, message, activity) =>
|
||||||
{
|
{
|
||||||
new Handler(Looper.MainLooper).Post(() =>
|
new Handler(Looper.MainLooper).Post(() =>
|
||||||
{
|
{
|
||||||
@@ -71,7 +71,7 @@ namespace keepass2android
|
|||||||
{
|
{
|
||||||
var task2 = new SyncOtpAuxFile(_activity, App.Kp2a.CurrentDb.OtpAuxFileIoc);
|
var task2 = new SyncOtpAuxFile(_activity, App.Kp2a.CurrentDb.OtpAuxFileIoc);
|
||||||
|
|
||||||
BackgroundOperationRunner.Instance.Run(_activity, App.Kp2a, task2);
|
BackgroundOperationRunner.Instance.Run(App.Kp2a, task2);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -79,15 +79,15 @@ namespace keepass2android
|
|||||||
if (filestorage is CachingFileStorage)
|
if (filestorage is CachingFileStorage)
|
||||||
{
|
{
|
||||||
|
|
||||||
task = new SynchronizeCachedDatabase(_activity, App.Kp2a, onOperationFinishedHandler);
|
task = new SynchronizeCachedDatabase(App.Kp2a, onOperationFinishedHandler);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//TODO do we want this to run in the background?
|
//TODO do we want this to run in the background?
|
||||||
task = new CheckDatabaseForChanges(_activity, App.Kp2a, onOperationFinishedHandler);
|
task = new CheckDatabaseForChanges( App.Kp2a, onOperationFinishedHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
BackgroundOperationRunner.Instance.Run(_activity, App.Kp2a, task);
|
BackgroundOperationRunner.Instance.Run(App.Kp2a, task);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -576,20 +576,19 @@ namespace keepass2android
|
|||||||
return LocaleManager.LocalizedAppContext.Resources.GetDrawable((int)field.GetValue(null));
|
return LocaleManager.LocalizedAppContext.Resources.GetDrawable((int)field.GetValue(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AskYesNoCancel(UiStringKey titleKey, UiStringKey messageKey, EventHandler<DialogClickEventArgs> yesHandler, EventHandler<DialogClickEventArgs> noHandler, EventHandler<DialogClickEventArgs> cancelHandler, Context ctx, string messageSuffix)
|
public void AskYesNoCancel(UiStringKey titleKey, UiStringKey messageKey, EventHandler<DialogClickEventArgs> yesHandler, EventHandler<DialogClickEventArgs> noHandler, EventHandler<DialogClickEventArgs> cancelHandler, string messageSuffix)
|
||||||
{
|
{
|
||||||
AskYesNoCancel(titleKey, messageKey, UiStringKey.yes, UiStringKey.no,
|
AskYesNoCancel(titleKey, messageKey, UiStringKey.yes, UiStringKey.no,
|
||||||
yesHandler, noHandler, cancelHandler, ctx, messageSuffix);
|
yesHandler, noHandler, cancelHandler, messageSuffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AskYesNoCancel(UiStringKey titleKey, UiStringKey messageKey,
|
public void AskYesNoCancel(UiStringKey titleKey, UiStringKey messageKey,
|
||||||
UiStringKey yesString, UiStringKey noString,
|
UiStringKey yesString, UiStringKey noString,
|
||||||
EventHandler<DialogClickEventArgs> yesHandler,
|
EventHandler<DialogClickEventArgs> yesHandler,
|
||||||
EventHandler<DialogClickEventArgs> noHandler,
|
EventHandler<DialogClickEventArgs> noHandler,
|
||||||
EventHandler<DialogClickEventArgs> cancelHandler,
|
EventHandler<DialogClickEventArgs> cancelHandler, string messageSuffix = "")
|
||||||
Context ctx, string messageSuffix = "")
|
|
||||||
{
|
{
|
||||||
AskYesNoCancel(titleKey, messageKey, yesString, noString, yesHandler, noHandler, cancelHandler, null, ctx, messageSuffix);
|
AskYesNoCancel(titleKey, messageKey, yesString, noString, yesHandler, noHandler, cancelHandler, null, messageSuffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AskYesNoCancel(UiStringKey titleKey, UiStringKey messageKey,
|
public void AskYesNoCancel(UiStringKey titleKey, UiStringKey messageKey,
|
||||||
@@ -597,13 +596,12 @@ namespace keepass2android
|
|||||||
EventHandler<DialogClickEventArgs> yesHandler,
|
EventHandler<DialogClickEventArgs> yesHandler,
|
||||||
EventHandler<DialogClickEventArgs> noHandler,
|
EventHandler<DialogClickEventArgs> noHandler,
|
||||||
EventHandler<DialogClickEventArgs> cancelHandler,
|
EventHandler<DialogClickEventArgs> cancelHandler,
|
||||||
EventHandler dismissHandler,
|
EventHandler dismissHandler,string messageSuffix = "")
|
||||||
Context ctx, string messageSuffix = "")
|
|
||||||
{
|
{
|
||||||
Handler handler = new Handler(Looper.MainLooper);
|
Handler handler = new Handler(Looper.MainLooper);
|
||||||
handler.Post(() =>
|
handler.Post(() =>
|
||||||
{
|
{
|
||||||
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(ctx);
|
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(ActiveContext);
|
||||||
builder.SetTitle(GetResourceString(titleKey));
|
builder.SetTitle(GetResourceString(titleKey));
|
||||||
|
|
||||||
builder.SetMessage(GetResourceString(messageKey) + (messageSuffix != "" ? " " + messageSuffix : ""));
|
builder.SetMessage(GetResourceString(messageKey) + (messageSuffix != "" ? " " + messageSuffix : ""));
|
||||||
@@ -638,7 +636,7 @@ namespace keepass2android
|
|||||||
cancelHandler.Invoke(sender, args);
|
cancelHandler.Invoke(sender, args);
|
||||||
};
|
};
|
||||||
|
|
||||||
cancelText = ctx.GetString(Android.Resource.String.Cancel);
|
cancelText = App.Context.GetString(Android.Resource.String.Cancel);
|
||||||
builder.SetNeutralButton(cancelText,
|
builder.SetNeutralButton(cancelText,
|
||||||
cancelHandlerWithShow);
|
cancelHandlerWithShow);
|
||||||
}
|
}
|
||||||
@@ -653,9 +651,17 @@ namespace keepass2android
|
|||||||
}
|
}
|
||||||
|
|
||||||
OnUserInputDialogShow();
|
OnUserInputDialogShow();
|
||||||
dialog.Show();
|
try
|
||||||
|
{
|
||||||
|
dialog.Show();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Kp2aLog.LogUnexpectedError(e);
|
||||||
|
}
|
||||||
|
|
||||||
if (yesText.Length + noText.Length + cancelText.Length >= 20)
|
|
||||||
|
if (yesText.Length + noText.Length + cancelText.Length >= 20)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -1362,6 +1368,8 @@ namespace keepass2android
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Context ActiveContext { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1432,7 +1440,10 @@ namespace keepass2android
|
|||||||
public void OnAppBackgrounded()
|
public void OnAppBackgrounded()
|
||||||
{
|
{
|
||||||
Kp2aLog.Log("Going to background");
|
Kp2aLog.Log("Going to background");
|
||||||
BackgroundOperationRunner.Instance.SetNewActiveContext(null, Kp2a);
|
Kp2a.ActiveContext = null;
|
||||||
|
BackgroundOperationRunner.Instance.SetNewActiveContext( Kp2a);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Lifecycle.Event.OnStart]
|
[Lifecycle.Event.OnStart]
|
||||||
|
@@ -51,7 +51,8 @@ namespace keepass2android.services
|
|||||||
_cts = new CancellationTokenSource();
|
_cts = new CancellationTokenSource();
|
||||||
CreateNotificationChannel();
|
CreateNotificationChannel();
|
||||||
StartForeground(NotificationId, BuildNotification());
|
StartForeground(NotificationId, BuildNotification());
|
||||||
BackgroundOperationRunner.Instance.SetNewActiveContext(this, App.Kp2a);
|
App.Kp2a.ActiveContext = this;
|
||||||
|
BackgroundOperationRunner.Instance.SetNewActiveContext(App.Kp2a);
|
||||||
return StartCommandResult.Sticky;
|
return StartCommandResult.Sticky;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@@ -117,7 +117,7 @@ namespace keepass2android
|
|||||||
var previousUsername = db.KpDatabase.DefaultUserName;
|
var previousUsername = db.KpDatabase.DefaultUserName;
|
||||||
db.KpDatabase.DefaultUserName = e.NewValue.ToString();
|
db.KpDatabase.DefaultUserName = e.NewValue.ToString();
|
||||||
|
|
||||||
SaveDb save = new SaveDb(Activity, App.Kp2a, App.Kp2a.CurrentDb, new ActionOnOperationFinished(Activity, (success, message, activity) =>
|
SaveDb save = new SaveDb(App.Kp2a, App.Kp2a.CurrentDb, new ActionOnOperationFinished(App.Kp2a, (success, message, activity) =>
|
||||||
{
|
{
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
@@ -126,7 +126,7 @@ namespace keepass2android
|
|||||||
App.Kp2a.ShowMessage(activity, message, MessageSeverity.Error);
|
App.Kp2a.ShowMessage(activity, message, MessageSeverity.Error);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, Activity, save);
|
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, save);
|
||||||
pt.Run();
|
pt.Run();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -144,8 +144,8 @@ namespace keepass2android
|
|||||||
{
|
{
|
||||||
pref.PreferenceClick += (sender, args) =>
|
pref.PreferenceClick += (sender, args) =>
|
||||||
{
|
{
|
||||||
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, Activity,
|
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a,
|
||||||
new AddTemplateEntries(Activity, App.Kp2a, new ActionOnOperationFinished(Activity,
|
new AddTemplateEntries(App.Kp2a, new ActionOnOperationFinished(App.Kp2a,
|
||||||
delegate
|
delegate
|
||||||
{
|
{
|
||||||
pref.Enabled = false;
|
pref.Enabled = false;
|
||||||
@@ -183,7 +183,7 @@ namespace keepass2android
|
|||||||
String previousName = db.KpDatabase.Name;
|
String previousName = db.KpDatabase.Name;
|
||||||
db.KpDatabase.Name = e.NewValue.ToString();
|
db.KpDatabase.Name = e.NewValue.ToString();
|
||||||
|
|
||||||
SaveDb save = new SaveDb(Activity, App.Kp2a, App.Kp2a.CurrentDb, new ActionOnOperationFinished(Activity, (success, message, activity) =>
|
SaveDb save = new SaveDb(App.Kp2a, App.Kp2a.CurrentDb, new ActionOnOperationFinished(App.Kp2a, (success, message, activity) =>
|
||||||
{
|
{
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
@@ -197,7 +197,7 @@ namespace keepass2android
|
|||||||
App.Kp2a.UpdateOngoingNotification();
|
App.Kp2a.UpdateOngoingNotification();
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, Activity, save);
|
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, save);
|
||||||
pt.Run();
|
pt.Run();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -410,7 +410,7 @@ namespace keepass2android
|
|||||||
var previousCipher = db.KpDatabase.DataCipherUuid;
|
var previousCipher = db.KpDatabase.DataCipherUuid;
|
||||||
db.KpDatabase.DataCipherUuid = new PwUuid(MemUtil.HexStringToByteArray((string)preferenceChangeEventArgs.NewValue));
|
db.KpDatabase.DataCipherUuid = new PwUuid(MemUtil.HexStringToByteArray((string)preferenceChangeEventArgs.NewValue));
|
||||||
|
|
||||||
SaveDb save = new SaveDb(Activity, App.Kp2a, App.Kp2a.CurrentDb, new ActionOnOperationFinished(Activity, (success, message, activity) =>
|
SaveDb save = new SaveDb(App.Kp2a, App.Kp2a.CurrentDb, new ActionOnOperationFinished(App.Kp2a, (success, message, activity) =>
|
||||||
{
|
{
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
@@ -421,7 +421,7 @@ namespace keepass2android
|
|||||||
preferenceChangeEventArgs.Preference.Summary =
|
preferenceChangeEventArgs.Preference.Summary =
|
||||||
CipherPool.GlobalPool.GetCipher(db.KpDatabase.DataCipherUuid).DisplayName;
|
CipherPool.GlobalPool.GetCipher(db.KpDatabase.DataCipherUuid).DisplayName;
|
||||||
}));
|
}));
|
||||||
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, Activity, save);
|
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, save);
|
||||||
pt.Run();
|
pt.Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1071,7 +1071,7 @@ namespace keepass2android
|
|||||||
|
|
||||||
Kp2aLog.Log("--new kdf: " + KdfPool.Get(db.KpDatabase.KdfParameters.KdfUuid) + " " + db.KpDatabase.KdfParameters.KdfUuid.ToHexString());
|
Kp2aLog.Log("--new kdf: " + KdfPool.Get(db.KpDatabase.KdfParameters.KdfUuid) + " " + db.KpDatabase.KdfParameters.KdfUuid.ToHexString());
|
||||||
|
|
||||||
SaveDb save = new SaveDb(Activity, App.Kp2a, App.Kp2a.CurrentDb, new ActionOnOperationFinished(Activity, (success, message, activity) =>
|
SaveDb save = new SaveDb(App.Kp2a, App.Kp2a.CurrentDb, new ActionOnOperationFinished(App.Kp2a, (success, message, activity) =>
|
||||||
{
|
{
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
@@ -1082,7 +1082,7 @@ namespace keepass2android
|
|||||||
UpdateKdfScreen();
|
UpdateKdfScreen();
|
||||||
|
|
||||||
}));
|
}));
|
||||||
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, Activity, save);
|
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, save);
|
||||||
pt.Run();
|
pt.Run();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -18,8 +18,8 @@ namespace keepass2android
|
|||||||
private readonly IKp2aApp _app;
|
private readonly IKp2aApp _app;
|
||||||
private IOConnectionInfo _targetIoc;
|
private IOConnectionInfo _targetIoc;
|
||||||
|
|
||||||
public ExportKeyfile(Activity activity, IKp2aApp app, OnOperationFinishedHandler onOperationFinishedHandler, IOConnectionInfo targetIoc) : base(
|
public ExportKeyfile(IKp2aApp app, OnOperationFinishedHandler onOperationFinishedHandler, IOConnectionInfo targetIoc) : base(
|
||||||
activity, onOperationFinishedHandler)
|
App.Kp2a, onOperationFinishedHandler)
|
||||||
{
|
{
|
||||||
_app = app;
|
_app = app;
|
||||||
_targetIoc = targetIoc;
|
_targetIoc = targetIoc;
|
||||||
@@ -70,7 +70,7 @@ namespace keepass2android
|
|||||||
|
|
||||||
protected override void SaveFile(IOConnectionInfo ioc)
|
protected override void SaveFile(IOConnectionInfo ioc)
|
||||||
{
|
{
|
||||||
var exportKeyfile = new ExportKeyfile(_activity, App.Kp2a, new ActionOnOperationFinished(_activity,
|
var exportKeyfile = new ExportKeyfile(App.Kp2a, new ActionOnOperationFinished(App.Kp2a,
|
||||||
(success, message, context) =>
|
(success, message, context) =>
|
||||||
{
|
{
|
||||||
if (!success)
|
if (!success)
|
||||||
@@ -81,7 +81,7 @@ namespace keepass2android
|
|||||||
(context as Activity)?.Finish();
|
(context as Activity)?.Finish();
|
||||||
}
|
}
|
||||||
), ioc);
|
), ioc);
|
||||||
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, _activity, exportKeyfile);
|
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, exportKeyfile);
|
||||||
pt.Run();
|
pt.Run();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -113,8 +113,8 @@ namespace keepass2android.settings
|
|||||||
ParamValue = paramValue;
|
ParamValue = paramValue;
|
||||||
|
|
||||||
Handler handler = new Handler();
|
Handler handler = new Handler();
|
||||||
SaveDb save = new SaveDb((Activity)Context, App.Kp2a, App.Kp2a.CurrentDb, new AfterSave((Activity)Context, handler, oldValue, this));
|
SaveDb save = new SaveDb(App.Kp2a, App.Kp2a.CurrentDb, new AfterSave(App.Kp2a, handler, oldValue, this));
|
||||||
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, (Activity)Context, save);
|
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, save);
|
||||||
pt.Run();
|
pt.Run();
|
||||||
});
|
});
|
||||||
db.SetNegativeButton(Android.Resource.String.Cancel, ((sender, args) => { }));
|
db.SetNegativeButton(Android.Resource.String.Cancel, ((sender, args) => { }));
|
||||||
@@ -131,13 +131,12 @@ namespace keepass2android.settings
|
|||||||
|
|
||||||
private class AfterSave : OnOperationFinishedHandler {
|
private class AfterSave : OnOperationFinishedHandler {
|
||||||
private readonly ulong _oldParamValue;
|
private readonly ulong _oldParamValue;
|
||||||
private readonly Context _ctx;
|
private readonly IKp2aApp _app;
|
||||||
private readonly KdfNumberDialogPreference _pref;
|
private readonly KdfNumberDialogPreference _pref;
|
||||||
|
|
||||||
public AfterSave(Activity ctx, Handler handler, ulong oldParamValue, KdfNumberDialogPreference pref):base(ctx, handler) {
|
public AfterSave(IKp2aApp app, Handler handler, ulong oldParamValue, KdfNumberDialogPreference pref):base(app, handler) {
|
||||||
|
_app = app;
|
||||||
_pref = pref;
|
_pref = pref;
|
||||||
_ctx = ctx;
|
|
||||||
_oldParamValue = oldParamValue;
|
_oldParamValue = oldParamValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,7 +147,7 @@ namespace keepass2android.settings
|
|||||||
_pref.OnPreferenceChangeListener.OnPreferenceChange(_pref, null);
|
_pref.OnPreferenceChangeListener.OnPreferenceChange(_pref, null);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DisplayMessage(_ctx);
|
DisplayMessage(_app.ActiveContext);
|
||||||
|
|
||||||
_pref.ParamValue = _oldParamValue;
|
_pref.ParamValue = _oldParamValue;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user