rename OnFinish => OnOperationFinishedHandler
This commit is contained in:
@@ -89,7 +89,7 @@ namespace keepass2android
|
||||
SetupProgressDialog(app);
|
||||
|
||||
// Set code to run when this is finished
|
||||
_task.OnFinishToRun = new AfterTask(activity, task.OnFinishToRun, _handler, this);
|
||||
_task.operationFinishedHandler = new AfterTask(activity, task.operationFinishedHandler, _handler, this);
|
||||
|
||||
_task.SetStatusLogger(_progressDialogStatusLogger);
|
||||
|
||||
@@ -144,10 +144,10 @@ namespace keepass2android
|
||||
_thread.Join();
|
||||
}
|
||||
|
||||
private class AfterTask : OnFinish {
|
||||
private class AfterTask : OnOperationFinishedHandler {
|
||||
readonly ProgressTask _progressTask;
|
||||
|
||||
public AfterTask (Activity activity, OnFinish finish, Handler handler, ProgressTask pt): base(activity, finish, handler)
|
||||
public AfterTask (Activity activity, OnOperationFinishedHandler operationFinishedHandler, Handler handler, ProgressTask pt): base(activity, operationFinishedHandler, handler)
|
||||
{
|
||||
_progressTask = pt;
|
||||
}
|
||||
|
@@ -19,8 +19,8 @@ namespace keepass2android
|
||||
private readonly IKp2aApp _app;
|
||||
|
||||
|
||||
public CheckDatabaseForChanges(Activity context, IKp2aApp app, OnFinish finish)
|
||||
: base(context, finish)
|
||||
public CheckDatabaseForChanges(Activity context, IKp2aApp app, OnOperationFinishedHandler operationFinishedHandler)
|
||||
: base(context, operationFinishedHandler)
|
||||
{
|
||||
_context = context;
|
||||
_app = app;
|
||||
|
@@ -16,8 +16,8 @@ namespace keepass2android
|
||||
private readonly IKp2aApp _app;
|
||||
private SaveDb _saveDb;
|
||||
|
||||
public SynchronizeCachedDatabase(Activity context, IKp2aApp app, OnFinish finish)
|
||||
: base(context, finish)
|
||||
public SynchronizeCachedDatabase(Activity context, IKp2aApp app, OnOperationFinishedHandler operationFinishedHandler)
|
||||
: base(context, operationFinishedHandler)
|
||||
{
|
||||
_context = context;
|
||||
_app = app;
|
||||
@@ -64,7 +64,7 @@ namespace keepass2android
|
||||
if (cachingFileStorage.HasLocalChanges(ioc))
|
||||
{
|
||||
//conflict! need to merge
|
||||
_saveDb = new SaveDb(_context, _app, new ActionOnFinish(ActiveActivity, (success, result, activity) =>
|
||||
_saveDb = new SaveDb(_context, _app, new ActionOnOperationFinished(ActiveActivity, (success, result, activity) =>
|
||||
{
|
||||
if (!success)
|
||||
{
|
||||
|
@@ -21,18 +21,18 @@ using Android.OS;
|
||||
|
||||
namespace keepass2android
|
||||
{
|
||||
public class ActionOnFinish: OnFinish
|
||||
public class ActionOnOperationFinished: OnOperationFinishedHandler
|
||||
{
|
||||
public delegate void ActionToPerformOnFinsh(bool success, String message, Activity activeActivity);
|
||||
|
||||
readonly ActionToPerformOnFinsh _actionToPerform;
|
||||
|
||||
public ActionOnFinish(Activity activity, ActionToPerformOnFinsh actionToPerform) : base(activity, null, null)
|
||||
public ActionOnOperationFinished(Activity activity, ActionToPerformOnFinsh actionToPerform) : base(activity, null, null)
|
||||
{
|
||||
_actionToPerform = actionToPerform;
|
||||
}
|
||||
|
||||
public ActionOnFinish(Activity activity, ActionToPerformOnFinsh actionToPerform, OnFinish finish) : base(activity, finish)
|
||||
public ActionOnOperationFinished(Activity activity, ActionToPerformOnFinsh actionToPerform, OnOperationFinishedHandler operationFinishedHandler) : base(activity, operationFinishedHandler)
|
||||
{
|
||||
_actionToPerform = actionToPerform;
|
||||
}
|
@@ -33,19 +33,19 @@ namespace keepass2android
|
||||
private readonly Activity _ctx;
|
||||
private readonly Database _db;
|
||||
|
||||
public static AddEntry GetInstance(Activity ctx, IKp2aApp app, PwEntry entry, PwGroup parentGroup, OnFinish finish, Database db) {
|
||||
public static AddEntry GetInstance(Activity ctx, IKp2aApp app, PwEntry entry, PwGroup parentGroup, OnOperationFinishedHandler operationFinishedHandler, Database db) {
|
||||
|
||||
return new AddEntry(ctx, db, app, entry, parentGroup, finish);
|
||||
return new AddEntry(ctx, db, app, entry, parentGroup, operationFinishedHandler);
|
||||
}
|
||||
|
||||
public AddEntry(Activity ctx, Database db, IKp2aApp app, PwEntry entry, PwGroup parentGroup, OnFinish finish):base(ctx, finish) {
|
||||
public AddEntry(Activity ctx, Database db, IKp2aApp app, PwEntry entry, PwGroup parentGroup, OnOperationFinishedHandler operationFinishedHandler):base(ctx, operationFinishedHandler) {
|
||||
_ctx = ctx;
|
||||
_db = db;
|
||||
_parentGroup = parentGroup;
|
||||
_app = app;
|
||||
_entry = entry;
|
||||
|
||||
_onFinishToRun = new AfterAdd(ctx, app.CurrentDb, entry, app,OnFinishToRun);
|
||||
_operationFinishedHandler = new AfterAdd(ctx, app.CurrentDb, entry, app,operationFinishedHandler);
|
||||
}
|
||||
|
||||
|
||||
@@ -65,17 +65,17 @@ namespace keepass2android
|
||||
_db.Elements.Add(_entry);
|
||||
|
||||
// Commit to disk
|
||||
SaveDb save = new SaveDb(_ctx, _app, _app.CurrentDb, OnFinishToRun);
|
||||
SaveDb save = new SaveDb(_ctx, _app, _app.CurrentDb, operationFinishedHandler);
|
||||
save.SetStatusLogger(StatusLogger);
|
||||
save.Run();
|
||||
}
|
||||
|
||||
private class AfterAdd : OnFinish {
|
||||
private class AfterAdd : OnOperationFinishedHandler {
|
||||
private readonly Database _db;
|
||||
private readonly PwEntry _entry;
|
||||
private readonly IKp2aApp _app;
|
||||
|
||||
public AfterAdd(Activity activity, Database db, PwEntry entry, IKp2aApp app, OnFinish finish):base(activity, finish) {
|
||||
public AfterAdd(Activity activity, Database db, PwEntry entry, IKp2aApp app, OnOperationFinishedHandler operationFinishedHandler):base(activity, operationFinishedHandler) {
|
||||
_db = db;
|
||||
_entry = entry;
|
||||
_app = app;
|
||||
|
@@ -41,13 +41,13 @@ namespace keepass2android
|
||||
readonly Activity _ctx;
|
||||
|
||||
|
||||
public static AddGroup GetInstance(Activity ctx, IKp2aApp app, string name, int iconid, PwUuid groupCustomIconId, PwGroup parent, OnFinish finish, bool dontSave) {
|
||||
return new AddGroup(ctx, app, name, iconid, groupCustomIconId, parent, finish, dontSave);
|
||||
public static AddGroup GetInstance(Activity ctx, 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);
|
||||
}
|
||||
|
||||
|
||||
private AddGroup(Activity ctx, IKp2aApp app, String name, int iconid, PwUuid groupCustomIconId, PwGroup parent, OnFinish finish, bool dontSave)
|
||||
: base(ctx, finish)
|
||||
private AddGroup(Activity ctx, IKp2aApp app, String name, int iconid, PwUuid groupCustomIconId, PwGroup parent, OnOperationFinishedHandler operationFinishedHandler, bool dontSave)
|
||||
: base(ctx, operationFinishedHandler)
|
||||
{
|
||||
_ctx = ctx;
|
||||
_name = name;
|
||||
@@ -57,7 +57,7 @@ namespace keepass2android
|
||||
DontSave = dontSave;
|
||||
_app = app;
|
||||
|
||||
_onFinishToRun = new AfterAdd(ctx, this, OnFinishToRun);
|
||||
_operationFinishedHandler = new AfterAdd(ctx, this, operationFinishedHandler);
|
||||
}
|
||||
|
||||
|
||||
@@ -74,15 +74,15 @@ namespace keepass2android
|
||||
_app.CurrentDb.Elements.Add(Group);
|
||||
|
||||
// Commit to disk
|
||||
SaveDb save = new SaveDb(_ctx, _app, _app.CurrentDb, OnFinishToRun, DontSave);
|
||||
SaveDb save = new SaveDb(_ctx, _app, _app.CurrentDb, operationFinishedHandler, DontSave);
|
||||
save.SetStatusLogger(StatusLogger);
|
||||
save.Run();
|
||||
}
|
||||
|
||||
private class AfterAdd : OnFinish {
|
||||
private class AfterAdd : OnOperationFinishedHandler {
|
||||
readonly AddGroup _addGroup;
|
||||
|
||||
public AfterAdd(Activity activity, AddGroup addGroup,OnFinish finish): base(activity, finish) {
|
||||
public AfterAdd(Activity activity, AddGroup addGroup,OnOperationFinishedHandler operationFinishedHandler): base(activity, operationFinishedHandler) {
|
||||
_addGroup = addGroup;
|
||||
}
|
||||
|
||||
|
@@ -132,13 +132,13 @@ namespace keepass2android
|
||||
private readonly IKp2aApp _app;
|
||||
private readonly Activity _ctx;
|
||||
|
||||
public AddTemplateEntries(Activity ctx, IKp2aApp app, OnFinish finish)
|
||||
: base(ctx, finish)
|
||||
public AddTemplateEntries(Activity ctx, IKp2aApp app, OnOperationFinishedHandler operationFinishedHandler)
|
||||
: base(ctx, operationFinishedHandler)
|
||||
{
|
||||
_ctx = ctx;
|
||||
_app = app;
|
||||
|
||||
//_onFinishToRun = new AfterAdd(this, OnFinishToRun);
|
||||
//_operationFinishedHandler = new AfterAdd(this, operationFinishedHandler);
|
||||
}
|
||||
|
||||
public static readonly List<TemplateEntry> TemplateEntries = new List<TemplateEntry>()
|
||||
@@ -313,7 +313,7 @@ namespace keepass2android
|
||||
_app.DirtyGroups.Add(templateGroup);
|
||||
|
||||
// Commit to disk
|
||||
SaveDb save = new SaveDb(_ctx, _app, _app.CurrentDb, OnFinishToRun);
|
||||
SaveDb save = new SaveDb(_ctx, _app, _app.CurrentDb, operationFinishedHandler);
|
||||
save.SetStatusLogger(StatusLogger);
|
||||
save.Run();
|
||||
}
|
||||
@@ -369,11 +369,11 @@ namespace keepass2android
|
||||
return entry;
|
||||
}
|
||||
|
||||
private class AfterAdd : OnFinish {
|
||||
private class AfterAdd : OnOperationFinishedHandler {
|
||||
private readonly Database _db;
|
||||
private readonly List<PwEntry> _entries;
|
||||
|
||||
public AfterAdd(Activity activity, Database db, List<PwEntry> entries, OnFinish finish):base(activity, finish) {
|
||||
public AfterAdd(Activity activity, Database db, List<PwEntry> entries, OnOperationFinishedHandler operationFinishedHandler):base(activity, operationFinishedHandler) {
|
||||
_db = db;
|
||||
_entries = entries;
|
||||
|
||||
|
@@ -16,8 +16,8 @@ namespace keepass2android.database.edit
|
||||
{
|
||||
public class CopyEntry: AddEntry
|
||||
{
|
||||
public CopyEntry(Activity ctx, IKp2aApp app, PwEntry entry, OnFinish finish, Database db)
|
||||
: base(ctx, db, app, CreateCopy(entry, app), entry.ParentGroup, finish)
|
||||
public CopyEntry(Activity ctx, IKp2aApp app, PwEntry entry, OnOperationFinishedHandler operationFinishedHandler, Database db)
|
||||
: base(ctx, db, app, CreateCopy(entry, app), entry.ParentGroup, operationFinishedHandler)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -34,7 +34,7 @@ namespace keepass2android
|
||||
private CompositeKey _key;
|
||||
private readonly bool _makeCurrent;
|
||||
|
||||
public CreateDb(IKp2aApp app, Activity ctx, IOConnectionInfo ioc, OnFinish finish, bool dontSave, bool makeCurrent): base(ctx, finish) {
|
||||
public CreateDb(IKp2aApp app, Activity ctx, IOConnectionInfo ioc, OnOperationFinishedHandler operationFinishedHandler, bool dontSave, bool makeCurrent): base(ctx, operationFinishedHandler) {
|
||||
_ctx = ctx;
|
||||
_ioc = ioc;
|
||||
_dontSave = dontSave;
|
||||
@@ -42,8 +42,8 @@ namespace keepass2android
|
||||
_app = app;
|
||||
}
|
||||
|
||||
public CreateDb(IKp2aApp app, Activity ctx, IOConnectionInfo ioc, OnFinish finish, bool dontSave, CompositeKey key, bool makeCurrent)
|
||||
: base(ctx, finish)
|
||||
public CreateDb(IKp2aApp app, Activity ctx, IOConnectionInfo ioc, OnOperationFinishedHandler operationFinishedHandler, bool dontSave, CompositeKey key, bool makeCurrent)
|
||||
: base(ctx, operationFinishedHandler)
|
||||
{
|
||||
_ctx = ctx;
|
||||
_ioc = ioc;
|
||||
@@ -87,9 +87,9 @@ namespace keepass2android
|
||||
addTemplates.AddTemplates(out addedEntries);
|
||||
|
||||
// Commit changes
|
||||
SaveDb save = new SaveDb(_ctx, _app, db, OnFinishToRun, _dontSave);
|
||||
SaveDb save = new SaveDb(_ctx, _app, db, operationFinishedHandler, _dontSave);
|
||||
save.SetStatusLogger(StatusLogger);
|
||||
_onFinishToRun = null;
|
||||
_operationFinishedHandler = null;
|
||||
save.Run();
|
||||
|
||||
db.UpdateGlobals();
|
||||
|
@@ -29,7 +29,7 @@ namespace keepass2android
|
||||
private readonly PwEntry _entry;
|
||||
private UiStringKey _statusMessage;
|
||||
|
||||
public DeleteEntry(Activity activiy, IKp2aApp app, PwEntry entry, OnFinish finish):base(activiy, finish, app) {
|
||||
public DeleteEntry(Activity activiy, IKp2aApp app, PwEntry entry, OnOperationFinishedHandler operationFinishedHandler):base(activiy, operationFinishedHandler, app) {
|
||||
Ctx = activiy;
|
||||
Db = app.FindDatabaseForElement(entry);
|
||||
_entry = entry;
|
||||
|
@@ -29,19 +29,19 @@ namespace keepass2android
|
||||
private PwGroup _group;
|
||||
protected bool DontSave;
|
||||
|
||||
public DeleteGroup(Activity activity, IKp2aApp app, PwGroup group, OnFinish finish)
|
||||
: base(activity, finish, app)
|
||||
public DeleteGroup(Activity activity, IKp2aApp app, PwGroup group, OnOperationFinishedHandler operationFinishedHandler)
|
||||
: base(activity, operationFinishedHandler, app)
|
||||
{
|
||||
SetMembers(activity, app, group, false);
|
||||
}
|
||||
/*
|
||||
public DeleteGroup(Context ctx, Database db, PwGroup group, Activity act, OnFinish finish, bool dontSave)
|
||||
: base(finish)
|
||||
public DeleteGroup(Context ctx, Database db, PwGroup group, Activity act, OnOperationFinishedHandler operationFinishedHandler, bool dontSave)
|
||||
: base(operationFinishedHandler)
|
||||
{
|
||||
SetMembers(ctx, db, group, act, dontSave);
|
||||
}
|
||||
|
||||
public DeleteGroup(Context ctx, Database db, PwGroup group, OnFinish finish, bool dontSave):base(finish) {
|
||||
public DeleteGroup(Context ctx, Database db, PwGroup group, OnOperationFinishedHandler operationFinishedHandler, bool dontSave):base(operationFinishedHandler) {
|
||||
SetMembers(ctx, db, group, null, dontSave);
|
||||
}
|
||||
*/
|
||||
|
@@ -12,8 +12,8 @@ namespace keepass2android
|
||||
private readonly List<IStructureItem> _elementsToDelete;
|
||||
private readonly bool _canRecycle;
|
||||
|
||||
public DeleteMultipleItemsFromOneDatabase(Activity activity, Database db, List<IStructureItem> elementsToDelete, OnFinish finish, IKp2aApp app)
|
||||
: base(activity, finish, app)
|
||||
public DeleteMultipleItemsFromOneDatabase(Activity activity, Database db, List<IStructureItem> elementsToDelete, OnOperationFinishedHandler operationFinishedHandler, IKp2aApp app)
|
||||
: base(activity, operationFinishedHandler, app)
|
||||
{
|
||||
_elementsToDelete = elementsToDelete;
|
||||
SetMembers(activity, db);
|
||||
|
@@ -8,8 +8,8 @@ namespace keepass2android
|
||||
{
|
||||
public abstract class DeleteRunnable : RunnableOnFinish
|
||||
{
|
||||
protected DeleteRunnable(Activity activity, OnFinish finish, IKp2aApp app)
|
||||
: base(activity, finish)
|
||||
protected DeleteRunnable(Activity activity, OnOperationFinishedHandler operationFinishedHandler, IKp2aApp app)
|
||||
: base(activity, operationFinishedHandler)
|
||||
{
|
||||
App = app;
|
||||
}
|
||||
@@ -215,7 +215,7 @@ namespace keepass2android
|
||||
Android.Util.Log.Debug("KP2A", "Calling PerformDelete..");
|
||||
PerformDelete(touchedGroups, permanentlyDeletedGroups);
|
||||
|
||||
_onFinishToRun = new ActionOnFinish(ActiveActivity,(success, message, activity) =>
|
||||
_operationFinishedHandler = new ActionOnOperationFinished(ActiveActivity,(success, message, activity) =>
|
||||
{
|
||||
if (success)
|
||||
{
|
||||
@@ -236,10 +236,10 @@ namespace keepass2android
|
||||
// Let's not bother recovering from a failure to save. It is too much work.
|
||||
App.Lock(false, false);
|
||||
}
|
||||
}, OnFinishToRun);
|
||||
}, operationFinishedHandler);
|
||||
|
||||
// Commit database
|
||||
SaveDb save = new SaveDb(Ctx, App, Db, OnFinishToRun, false);
|
||||
SaveDb save = new SaveDb(Ctx, App, Db, operationFinishedHandler, false);
|
||||
save.ShowDatabaseIocInStatus = ShowDatabaseIocInStatus;
|
||||
|
||||
save.SetStatusLogger(StatusLogger);
|
||||
|
@@ -38,8 +38,8 @@ namespace keepass2android
|
||||
internal PwGroup Group;
|
||||
readonly Activity _ctx;
|
||||
|
||||
public EditGroup(Activity ctx, IKp2aApp app, String name, PwIcon iconid, PwUuid customIconId, PwGroup group, OnFinish finish)
|
||||
: base(ctx, finish)
|
||||
public EditGroup(Activity ctx, IKp2aApp app, String name, PwIcon iconid, PwUuid customIconId, PwGroup group, OnOperationFinishedHandler operationFinishedHandler)
|
||||
: base(ctx, operationFinishedHandler)
|
||||
{
|
||||
_ctx = ctx;
|
||||
_name = name;
|
||||
@@ -48,7 +48,7 @@ namespace keepass2android
|
||||
_customIconId = customIconId;
|
||||
_app = app;
|
||||
|
||||
_onFinishToRun = new AfterEdit(ctx, this, OnFinishToRun);
|
||||
_operationFinishedHandler = new AfterEdit(ctx, this, operationFinishedHandler);
|
||||
}
|
||||
|
||||
|
||||
@@ -60,16 +60,16 @@ namespace keepass2android
|
||||
Group.Touch(true);
|
||||
|
||||
// Commit to disk
|
||||
SaveDb save = new SaveDb(_ctx, _app, Db, OnFinishToRun);
|
||||
SaveDb save = new SaveDb(_ctx, _app, Db, operationFinishedHandler);
|
||||
save.SetStatusLogger(StatusLogger);
|
||||
save.Run();
|
||||
}
|
||||
|
||||
private class AfterEdit : OnFinish {
|
||||
private class AfterEdit : OnOperationFinishedHandler {
|
||||
readonly EditGroup _editGroup;
|
||||
|
||||
public AfterEdit(Activity ctx, EditGroup editGroup, OnFinish finish)
|
||||
: base(ctx, finish)
|
||||
public AfterEdit(Activity ctx, EditGroup editGroup, OnOperationFinishedHandler operationFinishedHandler)
|
||||
: base(ctx, operationFinishedHandler)
|
||||
{
|
||||
_editGroup = editGroup;
|
||||
}
|
||||
|
@@ -21,10 +21,10 @@ using Android.App;
|
||||
namespace keepass2android
|
||||
{
|
||||
|
||||
public abstract class FileOnFinish : OnFinish {
|
||||
public abstract class FileOnFinish : OnOperationFinishedHandler {
|
||||
private String _filename = "";
|
||||
|
||||
protected FileOnFinish(Activity activity, FileOnFinish finish):base(activity, finish) {
|
||||
protected FileOnFinish(Activity activity, FileOnFinish operationFinishedHandler):base(activity, operationFinishedHandler) {
|
||||
}
|
||||
|
||||
public string Filename
|
||||
|
@@ -38,7 +38,7 @@ namespace keepass2android
|
||||
private readonly bool _rememberKeyfile;
|
||||
IDatabaseFormat _format;
|
||||
|
||||
public LoadDb(Activity activity, IKp2aApp app, IOConnectionInfo ioc, Task<MemoryStream> databaseData, CompositeKey compositeKey, String keyfileOrProvider, OnFinish finish, bool updateLastUsageTimestamp, bool makeCurrent): base(activity, finish)
|
||||
public LoadDb(Activity activity, IKp2aApp app, IOConnectionInfo ioc, Task<MemoryStream> databaseData, CompositeKey compositeKey, String keyfileOrProvider, OnOperationFinishedHandler operationFinishedHandler, bool updateLastUsageTimestamp, bool makeCurrent): base(activity, operationFinishedHandler)
|
||||
{
|
||||
_app = app;
|
||||
_ioc = ioc;
|
||||
|
@@ -17,7 +17,7 @@ namespace keepass2android.database.edit
|
||||
private readonly Activity _ctx;
|
||||
private readonly IKp2aApp _app;
|
||||
|
||||
public MoveElements(List<IStructureItem> elementsToMove, PwGroup targetGroup, Activity ctx, IKp2aApp app, OnFinish finish) : base(ctx, finish)
|
||||
public MoveElements(List<IStructureItem> elementsToMove, PwGroup targetGroup, Activity ctx, IKp2aApp app, OnOperationFinishedHandler operationFinishedHandler) : base(ctx, operationFinishedHandler)
|
||||
{
|
||||
_elementsToMove = elementsToMove;
|
||||
_targetGroup = targetGroup;
|
||||
@@ -129,18 +129,18 @@ namespace keepass2android.database.edit
|
||||
indexToSave++;
|
||||
if (indexToSave == allDatabasesToSave.Count)
|
||||
{
|
||||
OnFinishToRun.SetResult(allSavesSuccess);
|
||||
OnFinishToRun.Run();
|
||||
operationFinishedHandler.SetResult(allSavesSuccess);
|
||||
operationFinishedHandler.Run();
|
||||
return;
|
||||
}
|
||||
SaveDb saveDb = new SaveDb(_ctx, _app, allDatabasesToSave[indexToSave], new ActionOnFinish(activeActivity, ContinueSave), false);
|
||||
SaveDb saveDb = new SaveDb(_ctx, _app, allDatabasesToSave[indexToSave], new ActionOnOperationFinished(activeActivity, ContinueSave), false);
|
||||
saveDb.SetStatusLogger(StatusLogger);
|
||||
saveDb.ShowDatabaseIocInStatus = allDatabasesToSave.Count > 1;
|
||||
saveDb.Run();
|
||||
}
|
||||
|
||||
|
||||
SaveDb save = new SaveDb(_ctx, _app, allDatabasesToSave[0], new ActionOnFinish(ActiveActivity, ContinueSave), false);
|
||||
SaveDb save = new SaveDb(_ctx, _app, allDatabasesToSave[0], new ActionOnOperationFinished(ActiveActivity, ContinueSave), false);
|
||||
save.SetStatusLogger(StatusLogger);
|
||||
save.ShowDatabaseIocInStatus = allDatabasesToSave.Count > 1;
|
||||
save.Run();
|
||||
|
@@ -25,7 +25,7 @@ using Google.Android.Material.Dialog;
|
||||
|
||||
namespace keepass2android
|
||||
{
|
||||
public abstract class OnFinish
|
||||
public abstract class OnOperationFinishedHandler
|
||||
{
|
||||
protected bool Success;
|
||||
protected String Message;
|
||||
@@ -37,7 +37,7 @@ namespace keepass2android
|
||||
set;
|
||||
}
|
||||
|
||||
protected OnFinish BaseOnFinish;
|
||||
protected OnOperationFinishedHandler NextOnOperationFinishedHandler;
|
||||
protected Handler Handler;
|
||||
private ProgressDialogStatusLogger _statusLogger = new ProgressDialogStatusLogger(); //default: no logging but not null -> can be used whenever desired
|
||||
private Activity _activeActivity, _previouslyActiveActivity;
|
||||
@@ -60,9 +60,9 @@ namespace keepass2android
|
||||
|
||||
}
|
||||
_activeActivity = value;
|
||||
if (BaseOnFinish != null)
|
||||
if (NextOnOperationFinishedHandler != null)
|
||||
{
|
||||
BaseOnFinish.ActiveActivity = value;
|
||||
NextOnOperationFinishedHandler.ActiveActivity = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -75,25 +75,25 @@ namespace keepass2android
|
||||
|
||||
|
||||
|
||||
protected OnFinish(Activity activeActivity, Handler handler)
|
||||
protected OnOperationFinishedHandler(Activity activeActivity, Handler handler)
|
||||
{
|
||||
ActiveActivity = activeActivity;
|
||||
BaseOnFinish = null;
|
||||
NextOnOperationFinishedHandler = null;
|
||||
Handler = handler;
|
||||
|
||||
}
|
||||
|
||||
protected OnFinish(Activity activeActivity, OnFinish finish, Handler handler)
|
||||
protected OnOperationFinishedHandler(Activity activeActivity, OnOperationFinishedHandler operationFinishedHandler, Handler handler)
|
||||
{
|
||||
ActiveActivity = activeActivity;
|
||||
BaseOnFinish = finish;
|
||||
NextOnOperationFinishedHandler = operationFinishedHandler;
|
||||
Handler = handler;
|
||||
}
|
||||
|
||||
protected OnFinish(Activity activeActivity, OnFinish finish)
|
||||
protected OnOperationFinishedHandler(Activity activeActivity, OnOperationFinishedHandler operationFinishedHandler)
|
||||
{
|
||||
ActiveActivity = activeActivity;
|
||||
BaseOnFinish = finish;
|
||||
NextOnOperationFinishedHandler = operationFinishedHandler;
|
||||
Handler = null;
|
||||
}
|
||||
|
||||
@@ -110,14 +110,14 @@ namespace keepass2android
|
||||
}
|
||||
|
||||
public virtual void Run() {
|
||||
if (BaseOnFinish == null) return;
|
||||
if (NextOnOperationFinishedHandler == null) return;
|
||||
// Pass on result on call finish
|
||||
BaseOnFinish.SetResult(Success, Message, ImportantMessage, Exception);
|
||||
NextOnOperationFinishedHandler.SetResult(Success, Message, ImportantMessage, Exception);
|
||||
|
||||
if ( Handler != null ) {
|
||||
Handler.Post(BaseOnFinish.Run);
|
||||
Handler.Post(NextOnOperationFinishedHandler.Run);
|
||||
} else {
|
||||
BaseOnFinish.Run();
|
||||
NextOnOperationFinishedHandler.Run();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ namespace keepass2android
|
||||
public static void DisplayMessage(Context ctx, string message, bool makeDialog)
|
||||
{
|
||||
if ( !String.IsNullOrEmpty(message) ) {
|
||||
Kp2aLog.Log("OnFinish message: " + message);
|
||||
Kp2aLog.Log("OnOperationFinishedHandler message: " + message);
|
||||
if (makeDialog && ctx != null)
|
||||
{
|
||||
try
|
@@ -23,20 +23,20 @@ namespace keepass2android
|
||||
|
||||
public abstract class RunnableOnFinish {
|
||||
|
||||
protected OnFinish _onFinishToRun;
|
||||
protected OnOperationFinishedHandler _operationFinishedHandler;
|
||||
public ProgressDialogStatusLogger StatusLogger = new ProgressDialogStatusLogger(); //default: empty but not null
|
||||
private Activity _activeActivity;
|
||||
|
||||
protected RunnableOnFinish(Activity activeActivity, OnFinish finish)
|
||||
protected RunnableOnFinish(Activity activeActivity, OnOperationFinishedHandler operationFinishedHandler)
|
||||
{
|
||||
_activeActivity = activeActivity;
|
||||
_onFinishToRun = finish;
|
||||
_operationFinishedHandler = operationFinishedHandler;
|
||||
}
|
||||
|
||||
public OnFinish OnFinishToRun
|
||||
public OnOperationFinishedHandler operationFinishedHandler
|
||||
{
|
||||
get { return _onFinishToRun; }
|
||||
set { _onFinishToRun = value; }
|
||||
get { return _operationFinishedHandler; }
|
||||
set { _operationFinishedHandler = value; }
|
||||
}
|
||||
|
||||
public Activity ActiveActivity
|
||||
@@ -45,29 +45,29 @@ namespace keepass2android
|
||||
set
|
||||
{
|
||||
_activeActivity = value;
|
||||
if (_onFinishToRun != null)
|
||||
_onFinishToRun.ActiveActivity = _activeActivity;
|
||||
if (_operationFinishedHandler != null)
|
||||
_operationFinishedHandler.ActiveActivity = _activeActivity;
|
||||
}
|
||||
}
|
||||
|
||||
protected void Finish(bool result, String message, bool importantMessage = false, Exception exception = null) {
|
||||
if ( OnFinishToRun != null ) {
|
||||
OnFinishToRun.SetResult(result, message, importantMessage, exception);
|
||||
OnFinishToRun.Run();
|
||||
if ( operationFinishedHandler != null ) {
|
||||
operationFinishedHandler.SetResult(result, message, importantMessage, exception);
|
||||
operationFinishedHandler.Run();
|
||||
}
|
||||
}
|
||||
|
||||
protected void Finish(bool result) {
|
||||
if ( OnFinishToRun != null ) {
|
||||
OnFinishToRun.SetResult(result);
|
||||
OnFinishToRun.Run();
|
||||
if ( operationFinishedHandler != null ) {
|
||||
operationFinishedHandler.SetResult(result);
|
||||
operationFinishedHandler.Run();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetStatusLogger(ProgressDialogStatusLogger status) {
|
||||
if (OnFinishToRun != null)
|
||||
if (operationFinishedHandler != null)
|
||||
{
|
||||
OnFinishToRun.StatusLogger = status;
|
||||
operationFinishedHandler.StatusLogger = status;
|
||||
}
|
||||
StatusLogger = status;
|
||||
}
|
||||
|
@@ -46,8 +46,8 @@ namespace keepass2android
|
||||
private readonly Context _ctx;
|
||||
private Java.Lang.Thread _workerThread;
|
||||
|
||||
public SaveDb(Activity ctx, IKp2aApp app, Database db, OnFinish finish, bool dontSave)
|
||||
: base(ctx, finish)
|
||||
public SaveDb(Activity ctx, IKp2aApp app, Database db, OnOperationFinishedHandler operationFinishedHandler, bool dontSave)
|
||||
: base(ctx, operationFinishedHandler)
|
||||
{
|
||||
_db = db;
|
||||
_ctx = ctx;
|
||||
@@ -60,11 +60,11 @@ namespace keepass2android
|
||||
/// </summary>
|
||||
/// <param name="ctx"></param>
|
||||
/// <param name="app"></param>
|
||||
/// <param name="finish"></param>
|
||||
/// <param name="operationFinishedHandler"></param>
|
||||
/// <param name="dontSave"></param>
|
||||
/// <param name="streamForOrigFile">Stream for reading the data from the (changed) original location</param>
|
||||
public SaveDb(Activity ctx, IKp2aApp app, OnFinish finish, Database db, bool dontSave, Stream streamForOrigFile)
|
||||
: base(ctx, finish)
|
||||
public SaveDb(Activity ctx, IKp2aApp app, OnOperationFinishedHandler operationFinishedHandler, Database db, bool dontSave, Stream streamForOrigFile)
|
||||
: base(ctx, operationFinishedHandler)
|
||||
{
|
||||
_db = db;
|
||||
_ctx = ctx;
|
||||
@@ -73,8 +73,8 @@ namespace keepass2android
|
||||
_streamForOrigFile = streamForOrigFile;
|
||||
}
|
||||
|
||||
public SaveDb(Activity ctx, IKp2aApp app, Database db, OnFinish finish)
|
||||
: base(ctx, finish)
|
||||
public SaveDb(Activity ctx, IKp2aApp app, Database db, OnOperationFinishedHandler operationFinishedHandler)
|
||||
: base(ctx, operationFinishedHandler)
|
||||
{
|
||||
_ctx = ctx;
|
||||
_app = app;
|
||||
|
@@ -30,7 +30,7 @@ namespace keepass2android
|
||||
private readonly bool _dontSave;
|
||||
private readonly Activity _ctx;
|
||||
|
||||
public SetPassword(Activity ctx, IKp2aApp app, String password, String keyfile, OnFinish finish): base(ctx, finish) {
|
||||
public SetPassword(Activity ctx, IKp2aApp app, String password, String keyfile, OnOperationFinishedHandler operationFinishedHandler): base(ctx, operationFinishedHandler) {
|
||||
_ctx = ctx;
|
||||
_app = app;
|
||||
_password = password;
|
||||
@@ -38,8 +38,8 @@ namespace keepass2android
|
||||
_dontSave = false;
|
||||
}
|
||||
|
||||
public SetPassword(Activity ctx, IKp2aApp app, String password, String keyfile, OnFinish finish, bool dontSave)
|
||||
: base(ctx, finish)
|
||||
public SetPassword(Activity ctx, IKp2aApp app, String password, String keyfile, OnOperationFinishedHandler operationFinishedHandler, bool dontSave)
|
||||
: base(ctx, operationFinishedHandler)
|
||||
{
|
||||
_ctx = ctx;
|
||||
_app = app;
|
||||
@@ -73,18 +73,18 @@ namespace keepass2android
|
||||
pm.MasterKey = newKey;
|
||||
|
||||
// Save Database
|
||||
_onFinishToRun = new AfterSave(ActiveActivity, previousKey, previousMasterKeyChanged, pm, OnFinishToRun);
|
||||
SaveDb save = new SaveDb(_ctx, _app, _app.CurrentDb, OnFinishToRun, _dontSave);
|
||||
_operationFinishedHandler = new AfterSave(ActiveActivity, previousKey, previousMasterKeyChanged, pm, operationFinishedHandler);
|
||||
SaveDb save = new SaveDb(_ctx, _app, _app.CurrentDb, operationFinishedHandler, _dontSave);
|
||||
save.SetStatusLogger(StatusLogger);
|
||||
save.Run();
|
||||
}
|
||||
|
||||
private class AfterSave : OnFinish {
|
||||
private class AfterSave : OnOperationFinishedHandler {
|
||||
private readonly CompositeKey _backup;
|
||||
private readonly DateTime _previousKeyChanged;
|
||||
private readonly PwDatabase _db;
|
||||
|
||||
public AfterSave(Activity activity, CompositeKey backup, DateTime previousKeyChanged, PwDatabase db, OnFinish finish): base(activity, finish) {
|
||||
public AfterSave(Activity activity, CompositeKey backup, DateTime previousKeyChanged, PwDatabase db, OnOperationFinishedHandler operationFinishedHandler): base(activity, operationFinishedHandler) {
|
||||
_previousKeyChanged = previousKeyChanged;
|
||||
_backup = backup;
|
||||
_db = db;
|
||||
|
@@ -26,27 +26,27 @@ namespace keepass2android
|
||||
private readonly IKp2aApp _app;
|
||||
private readonly Activity _ctx;
|
||||
|
||||
public UpdateEntry(Activity ctx, IKp2aApp app, PwEntry oldE, PwEntry newE, OnFinish finish):base(ctx, finish) {
|
||||
public UpdateEntry(Activity ctx, IKp2aApp app, PwEntry oldE, PwEntry newE, OnOperationFinishedHandler operationFinishedHandler):base(ctx, operationFinishedHandler) {
|
||||
_ctx = ctx;
|
||||
_app = app;
|
||||
|
||||
_onFinishToRun = new AfterUpdate(ctx, oldE, newE, app, finish);
|
||||
_operationFinishedHandler = new AfterUpdate(ctx, oldE, newE, app, operationFinishedHandler);
|
||||
}
|
||||
|
||||
|
||||
public override void Run() {
|
||||
// Commit to disk
|
||||
SaveDb save = new SaveDb(_ctx, _app, _app.CurrentDb, OnFinishToRun);
|
||||
SaveDb save = new SaveDb(_ctx, _app, _app.CurrentDb, operationFinishedHandler);
|
||||
save.SetStatusLogger(StatusLogger);
|
||||
save.Run();
|
||||
}
|
||||
|
||||
private class AfterUpdate : OnFinish {
|
||||
private class AfterUpdate : OnOperationFinishedHandler {
|
||||
private readonly PwEntry _backup;
|
||||
private readonly PwEntry _updatedEntry;
|
||||
private readonly IKp2aApp _app;
|
||||
|
||||
public AfterUpdate(Activity activity, PwEntry backup, PwEntry updatedEntry, IKp2aApp app, OnFinish finish):base(activity, finish) {
|
||||
public AfterUpdate(Activity activity, PwEntry backup, PwEntry updatedEntry, IKp2aApp app, OnOperationFinishedHandler operationFinishedHandler):base(activity, operationFinishedHandler) {
|
||||
_backup = backup;
|
||||
_updatedEntry = updatedEntry;
|
||||
_app = app;
|
||||
|
@@ -228,7 +228,7 @@ namespace keepass2android
|
||||
newEntry.SetUuid(new PwUuid(true), true); // Create new UUID
|
||||
string strTitle = newEntry.Strings.ReadSafe(PwDefs.TitleField);
|
||||
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 ActionOnFinish(this, (success, message, activity) => ((ConfigureChildDatabasesActivity)activity).Update()));
|
||||
var addTask = new AddEntry(this, App.Kp2a.CurrentDb, App.Kp2a, newEntry,item.Entry.ParentGroup,new ActionOnOperationFinished(this, (success, message, activity) => ((ConfigureChildDatabasesActivity)activity).Update()));
|
||||
|
||||
ProgressTask pt = new ProgressTask(App.Kp2a, this, addTask);
|
||||
pt.Run();
|
||||
@@ -260,7 +260,7 @@ namespace keepass2android
|
||||
|
||||
private void Save(AutoExecItem item)
|
||||
{
|
||||
var addTask = new SaveDb(this, App.Kp2a, App.Kp2a.FindDatabaseForElement(item.Entry), new ActionOnFinish(this, (success, message, activity) => ((ConfigureChildDatabasesActivity)activity).Update()));
|
||||
var addTask = new SaveDb(this, App.Kp2a, App.Kp2a.FindDatabaseForElement(item.Entry), new ActionOnOperationFinished(this, (success, message, activity) => ((ConfigureChildDatabasesActivity)activity).Update()));
|
||||
|
||||
ProgressTask pt = new ProgressTask(App.Kp2a, this, addTask);
|
||||
pt.Run();
|
||||
@@ -367,7 +367,7 @@ namespace keepass2android
|
||||
{KeeAutoExecExt.ThisDeviceId, true}
|
||||
})));
|
||||
|
||||
var addTask = new AddEntry(this, db, App.Kp2a, newEntry, autoOpenGroup, new ActionOnFinish(this, (success, message, activity) => (activity as ConfigureChildDatabasesActivity)?.Update()));
|
||||
var addTask = new AddEntry(this, db, App.Kp2a, newEntry, autoOpenGroup, new ActionOnOperationFinished(this, (success, message, activity) => (activity as ConfigureChildDatabasesActivity)?.Update()));
|
||||
|
||||
ProgressTask pt = new ProgressTask(App.Kp2a, this, addTask);
|
||||
pt.Run();
|
||||
|
@@ -8,8 +8,8 @@ namespace keepass2android
|
||||
{
|
||||
private readonly string _filename;
|
||||
|
||||
public CreateNewFilename(Activity activity, OnFinish finish, string filename)
|
||||
: base(activity,finish)
|
||||
public CreateNewFilename(Activity activity, OnOperationFinishedHandler operationFinishedHandler, string filename)
|
||||
: base(activity,operationFinishedHandler)
|
||||
{
|
||||
_filename = filename;
|
||||
}
|
||||
|
@@ -75,7 +75,7 @@ namespace keepass2android
|
||||
|
||||
protected override void SaveFile(IOConnectionInfo ioc)
|
||||
{
|
||||
var task = new EntryActivity.WriteBinaryTask(_activity, App.Kp2a, new ActionOnFinish(_activity, (success, message, activity) =>
|
||||
var task = new EntryActivity.WriteBinaryTask(_activity, App.Kp2a, new ActionOnOperationFinished(_activity, (success, message, activity) =>
|
||||
{
|
||||
if (!success)
|
||||
App.Kp2a.ShowMessage(activity, message, MessageSeverity.Error);
|
||||
@@ -525,7 +525,7 @@ namespace keepass2android
|
||||
App.Kp2a.DirtyGroups.Add(parent);
|
||||
}
|
||||
|
||||
var saveTask = new SaveDb(this, App.Kp2a, App.Kp2a.FindDatabaseForElement(Entry), new ActionOnFinish(this, (success, message, activity) =>
|
||||
var saveTask = new SaveDb(this, App.Kp2a, App.Kp2a.FindDatabaseForElement(Entry), new ActionOnOperationFinished(this, (success, message, activity) =>
|
||||
{
|
||||
activity.SetResult(KeePass.ExitRefresh);
|
||||
activity.Finish();
|
||||
@@ -1266,7 +1266,7 @@ namespace keepass2android
|
||||
private readonly ProtectedBinary _data;
|
||||
private IOConnectionInfo _targetIoc;
|
||||
|
||||
public WriteBinaryTask(Activity activity, IKp2aApp app, OnFinish onFinish, ProtectedBinary data, IOConnectionInfo targetIoc) : base(activity, onFinish)
|
||||
public WriteBinaryTask(Activity activity, IKp2aApp app, OnOperationFinishedHandler onOperationFinishedHandler, ProtectedBinary data, IOConnectionInfo targetIoc) : base(activity, onOperationFinishedHandler)
|
||||
{
|
||||
_app = app;
|
||||
_data = data;
|
||||
@@ -1441,7 +1441,7 @@ namespace keepass2android
|
||||
return true;
|
||||
case Resource.Id.menu_delete:
|
||||
DeleteEntry task = new DeleteEntry(this, App.Kp2a, Entry,
|
||||
new ActionOnFinish(this, (success, message, activity) => { if (success) { RequiresRefresh(); Finish();}}));
|
||||
new ActionOnOperationFinished(this, (success, message, activity) => { if (success) { RequiresRefresh(); Finish();}}));
|
||||
task.Start();
|
||||
break;
|
||||
case Resource.Id.menu_toggle_pass:
|
||||
@@ -1504,9 +1504,9 @@ namespace keepass2android
|
||||
|
||||
//save the entry:
|
||||
|
||||
ActionOnFinish closeOrShowError = new ActionOnFinish(this, (success, message, activity) =>
|
||||
ActionOnOperationFinished closeOrShowError = new ActionOnOperationFinished(this, (success, message, activity) =>
|
||||
{
|
||||
OnFinish.DisplayMessage(this, message, true);
|
||||
OnOperationFinishedHandler.DisplayMessage(this, message, true);
|
||||
finishAction((EntryActivity)activity);
|
||||
});
|
||||
|
||||
|
@@ -521,22 +521,22 @@ namespace keepass2android
|
||||
|
||||
RunnableOnFinish runnable;
|
||||
|
||||
ActionOnFinish closeOrShowError = new ActionOnFinish(this, (success, message, activity) => {
|
||||
ActionOnOperationFinished closeOrShowError = new ActionOnOperationFinished(this, (success, message, activity) => {
|
||||
if (success)
|
||||
{
|
||||
activity?.Finish();
|
||||
} else
|
||||
{
|
||||
OnFinish.DisplayMessage(activity, message, true);
|
||||
OnOperationFinishedHandler.DisplayMessage(activity, message, true);
|
||||
//Re-initialize for editing:
|
||||
State.EditMode.InitializeEntry(State.Entry);
|
||||
}
|
||||
});
|
||||
//make sure we can close the EntryEditActivity activity even if the app went to background till we get to the OnFinish Action
|
||||
//make sure we can close the EntryEditActivity activity even if the app went to background till we get to the OnOperationFinishedHandler Action
|
||||
closeOrShowError.AllowInactiveActivity = true;
|
||||
|
||||
|
||||
ActionOnFinish afterAddEntry = new ActionOnFinish(this, (success, message, activity) =>
|
||||
ActionOnOperationFinished afterAddEntry = new ActionOnOperationFinished(this, (success, message, activity) =>
|
||||
{
|
||||
if (success && activity is EntryEditActivity entryEditActivity)
|
||||
AppTask.AfterAddNewEntry(entryEditActivity, newEntry);
|
||||
|
@@ -26,7 +26,7 @@ namespace keepass2android
|
||||
|
||||
protected override void SaveFile(IOConnectionInfo ioc)
|
||||
{
|
||||
var exportDb = new ExportDatabaseActivity.ExportDb(_activity, App.Kp2a, new ActionOnFinish(_activity, (success, message, activity) =>
|
||||
var exportDb = new ExportDatabaseActivity.ExportDb(_activity, App.Kp2a, new ActionOnOperationFinished(_activity, (success, message, activity) =>
|
||||
{
|
||||
if (!success)
|
||||
App.Kp2a.ShowMessage(activity, message, MessageSeverity.Error);
|
||||
@@ -99,7 +99,7 @@ namespace keepass2android
|
||||
private readonly FileFormatProvider _fileFormat;
|
||||
private IOConnectionInfo _targetIoc;
|
||||
|
||||
public ExportDb(Activity activity, IKp2aApp app, OnFinish onFinish, FileFormatProvider fileFormat, IOConnectionInfo targetIoc) : base(activity, onFinish)
|
||||
public ExportDb(Activity activity, IKp2aApp app, OnOperationFinishedHandler onOperationFinishedHandler, FileFormatProvider fileFormat, IOConnectionInfo targetIoc) : base(activity, onOperationFinishedHandler)
|
||||
{
|
||||
_app = app;
|
||||
this._fileFormat = fileFormat;
|
||||
|
@@ -103,7 +103,7 @@ namespace keepass2android
|
||||
}
|
||||
else
|
||||
{
|
||||
var task = new CreateNewFilename(_activity, new ActionOnFinish(_activity, (success, messageOrFilename, activity) =>
|
||||
var task = new CreateNewFilename(_activity, new ActionOnOperationFinished(_activity, (success, messageOrFilename, activity) =>
|
||||
{
|
||||
if (!success)
|
||||
{
|
||||
|
@@ -781,7 +781,7 @@ namespace keepass2android
|
||||
}
|
||||
else
|
||||
{
|
||||
var task = new CreateNewFilename(activity, new ActionOnFinish(activity, (success, messageOrFilename, newActivity) =>
|
||||
var task = new CreateNewFilename(activity, new ActionOnOperationFinished(activity, (success, messageOrFilename, newActivity) =>
|
||||
{
|
||||
if (!success)
|
||||
{
|
||||
|
@@ -224,7 +224,7 @@ namespace keepass2android
|
||||
{
|
||||
//yes
|
||||
ProgressTask pt = new ProgressTask(App.Kp2a, this,
|
||||
new AddTemplateEntries(this, App.Kp2a, new ActionOnFinish(this,
|
||||
new AddTemplateEntries(this, App.Kp2a, new ActionOnOperationFinished(this,
|
||||
(success, message, activity) => ((GroupActivity)activity)?.StartAddEntry())));
|
||||
pt.Run();
|
||||
},
|
||||
|
@@ -924,7 +924,7 @@ namespace keepass2android
|
||||
|
||||
|
||||
|
||||
var moveElement = new MoveElements(elementsToMove.ToList(), Group, this, App.Kp2a, new ActionOnFinish(this,
|
||||
var moveElement = new MoveElements(elementsToMove.ToList(), Group, this, App.Kp2a, new ActionOnOperationFinished(this,
|
||||
(success, message, activity) =>
|
||||
{
|
||||
((GroupBaseActivity)activity)?.StopMovingElements();
|
||||
@@ -1293,7 +1293,7 @@ namespace keepass2android
|
||||
|
||||
}
|
||||
|
||||
public class RefreshTask : OnFinish
|
||||
public class RefreshTask : OnOperationFinishedHandler
|
||||
{
|
||||
public RefreshTask(Handler handler, GroupBaseActivity act)
|
||||
: base(act, handler)
|
||||
@@ -1312,7 +1312,7 @@ namespace keepass2android
|
||||
}
|
||||
}
|
||||
}
|
||||
public class AfterDeleteGroup : OnFinish
|
||||
public class AfterDeleteGroup : OnOperationFinishedHandler
|
||||
{
|
||||
public AfterDeleteGroup(Handler handler, GroupBaseActivity act)
|
||||
: base(act, handler)
|
||||
@@ -1631,7 +1631,7 @@ namespace keepass2android
|
||||
}
|
||||
|
||||
|
||||
public void DeleteMultipleItems(GroupBaseActivity activity, List<IStructureItem> checkedItems, OnFinish onFinish, Kp2aApp app)
|
||||
public void DeleteMultipleItems(GroupBaseActivity activity, List<IStructureItem> checkedItems, OnOperationFinishedHandler onOperationFinishedHandler, Kp2aApp app)
|
||||
{
|
||||
if (checkedItems.Any() == false)
|
||||
return;
|
||||
@@ -1670,22 +1670,22 @@ namespace keepass2android
|
||||
dbIndex++;
|
||||
if (dbIndex == itemsForDatabases.Count)
|
||||
{
|
||||
onFinish.SetResult(true);
|
||||
onFinish.Run();
|
||||
onOperationFinishedHandler.SetResult(true);
|
||||
onOperationFinishedHandler.Run();
|
||||
return;
|
||||
}
|
||||
new DeleteMultipleItemsFromOneDatabase(activity, itemsForDatabases[dbIndex].Key,
|
||||
itemsForDatabases[dbIndex].Value, new ActionOnFinish(activeActivity, (b, s, activity1) => action(b, s, activity1)), app)
|
||||
itemsForDatabases[dbIndex].Value, new ActionOnOperationFinished(activeActivity, (b, s, activity1) => action(b, s, activity1)), app)
|
||||
.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
onFinish.SetResult(false, message, true, null);
|
||||
onOperationFinishedHandler.SetResult(false, message, true, null);
|
||||
}
|
||||
};
|
||||
|
||||
new DeleteMultipleItemsFromOneDatabase(activity, itemsForDatabases[dbIndex].Key,
|
||||
itemsForDatabases[dbIndex].Value, new ActionOnFinish(activity, (b, s, activity1) => action(b, s, activity1)), app)
|
||||
itemsForDatabases[dbIndex].Value, new ActionOnOperationFinished(activity, (b, s, activity1) => action(b, s, activity1)), app)
|
||||
.Start();
|
||||
}
|
||||
|
||||
|
@@ -1440,11 +1440,11 @@ namespace keepass2android
|
||||
MakePasswordMaskedOrVisible();
|
||||
|
||||
Handler handler = new Handler();
|
||||
OnFinish onFinish = new AfterLoad(handler, this, _ioConnection);
|
||||
OnOperationFinishedHandler onOperationFinishedHandler = new AfterLoad(handler, this, _ioConnection);
|
||||
LoadDb task = (KeyProviderTypes.Contains(KeyProviders.Otp))
|
||||
? new SaveOtpAuxFileAndLoadDb(App.Kp2a, _ioConnection, _loadDbFileTask, compositeKey, GetKeyProviderString(),
|
||||
onFinish, this, true, _makeCurrent)
|
||||
: new LoadDb(this, App.Kp2a, _ioConnection, _loadDbFileTask, compositeKey, GetKeyProviderString(), onFinish,true, _makeCurrent);
|
||||
onOperationFinishedHandler, this, true, _makeCurrent)
|
||||
: new LoadDb(this, App.Kp2a, _ioConnection, _loadDbFileTask, compositeKey, GetKeyProviderString(), onOperationFinishedHandler,true, _makeCurrent);
|
||||
_loadDbFileTask = null; // prevent accidental re-use
|
||||
|
||||
new ProgressTask(App.Kp2a, this, task).Run();
|
||||
@@ -1891,10 +1891,10 @@ namespace keepass2android
|
||||
// to retry with typing the full password, but that's intended to avoid showing the password to a
|
||||
// a potentially unauthorized user (feature request https://keepass2android.codeplex.com/workitem/274)
|
||||
Handler handler = new Handler();
|
||||
OnFinish onFinish = new AfterLoad(handler, this, _ioConnection);
|
||||
OnOperationFinishedHandler onOperationFinishedHandler = new AfterLoad(handler, this, _ioConnection);
|
||||
_performingLoad = true;
|
||||
LoadDb task = new LoadDb(this, App.Kp2a, _ioConnection, _loadDbFileTask, compositeKeyForImmediateLoad, GetKeyProviderString(),
|
||||
onFinish, false, _makeCurrent);
|
||||
onOperationFinishedHandler, false, _makeCurrent);
|
||||
_loadDbFileTask = null; // prevent accidental re-use
|
||||
new ProgressTask(App.Kp2a, this, task).Run();
|
||||
compositeKeyForImmediateLoad = null; //don't reuse or keep in memory
|
||||
@@ -2110,7 +2110,7 @@ namespace keepass2android
|
||||
Finish();
|
||||
}
|
||||
|
||||
private class AfterLoad : OnFinish {
|
||||
private class AfterLoad : OnOperationFinishedHandler {
|
||||
readonly PasswordActivity _act;
|
||||
private readonly IOConnectionInfo _ioConnection;
|
||||
|
||||
@@ -2255,7 +2255,7 @@ namespace keepass2android
|
||||
private readonly PasswordActivity _act;
|
||||
|
||||
|
||||
public SaveOtpAuxFileAndLoadDb(IKp2aApp app, IOConnectionInfo ioc, Task<MemoryStream> databaseData, CompositeKey compositeKey, string keyfileOrProvider, OnFinish finish, PasswordActivity act, bool updateLastUsageTimestamp, bool makeCurrent) : base(act, app, ioc, databaseData, compositeKey, keyfileOrProvider, finish,updateLastUsageTimestamp,makeCurrent)
|
||||
public SaveOtpAuxFileAndLoadDb(IKp2aApp app, IOConnectionInfo ioc, Task<MemoryStream> databaseData, CompositeKey compositeKey, string keyfileOrProvider, OnOperationFinishedHandler operationFinishedHandler, PasswordActivity act, bool updateLastUsageTimestamp, bool makeCurrent) : base(act, app, ioc, databaseData, compositeKey, keyfileOrProvider, operationFinishedHandler,updateLastUsageTimestamp,makeCurrent)
|
||||
{
|
||||
_act = act;
|
||||
}
|
||||
|
@@ -137,6 +137,7 @@
|
||||
<string name="NoDonationReminder_key">NoDonationReminder</string>
|
||||
|
||||
<string name="UseOfflineCache_key">UseOfflineCache</string>
|
||||
<string name="SyncOfflineCacheInBackground_key">SyncOfflineCacheInBackground_key</string>
|
||||
<string name="CreateBackups_key">CreateBackups_key</string>
|
||||
<string name="AcceptAllServerCertificates_key">AcceptAllServerCertificates</string>
|
||||
<string name="CheckForFileChangesOnSave_key">CheckForFileChangesOnSave</string>
|
||||
|
@@ -382,6 +382,8 @@
|
||||
<string name="NoDonationReminder_summary">I won\'t give you a dime or I have already donated. Don\'t ask for a donation, not even at the author\'s birthday.</string>
|
||||
<string name="UseOfflineCache_title">Database caching</string>
|
||||
<string name="UseOfflineCache_summary">Keep a copy of the database files in the app\'s cache directory. This allows to use databases even while the database file is not accessible.</string>
|
||||
<string name="SyncOfflineCacheInBackground_summary">When saving or loading, use the internal cache. Then synchronize with remote storage in a background process.</string>
|
||||
<string name="SyncOfflineCacheInBackground_title">Synchronize in background</string>
|
||||
<string name="CreateBackups_title">Local backups</string>
|
||||
<string name="CreateBackups_summary">Create a local backup copy after successfully loading a database.</string>
|
||||
<string name="UpdatingBackup">Updating local backup...</string>
|
||||
|
@@ -12,7 +12,17 @@
|
||||
android:title="@string/UseOfflineCache_title"
|
||||
android:key="@string/UseOfflineCache_key" />
|
||||
|
||||
<CheckBoxPreference
|
||||
|
||||
<CheckBoxPreference
|
||||
android:enabled="true"
|
||||
android:persistent="true"
|
||||
android:summary="@string/SyncOfflineCacheInBackground_summary"
|
||||
android:defaultValue="true"
|
||||
android:title="@string/SyncOfflineCacheInBackground_title"
|
||||
android:key="@string/SyncOfflineCacheInBackground_key" />
|
||||
|
||||
|
||||
<CheckBoxPreference
|
||||
android:enabled="true"
|
||||
android:persistent="true"
|
||||
android:summary="@string/CreateBackups_summary"
|
||||
|
@@ -88,21 +88,21 @@ namespace keepass2android
|
||||
|
||||
|
||||
|
||||
class AfterSave : OnFinish {
|
||||
private readonly FileOnFinish _finish;
|
||||
class AfterSave : OnOperationFinishedHandler {
|
||||
private readonly FileOnFinish _operationFinishedHandler;
|
||||
|
||||
readonly SetPasswordDialog _dlg;
|
||||
|
||||
public AfterSave(Activity activity, SetPasswordDialog dlg, FileOnFinish finish, Handler handler): base(activity, finish, handler) {
|
||||
_finish = finish;
|
||||
public AfterSave(Activity activity, SetPasswordDialog dlg, FileOnFinish operationFinishedHandler, Handler handler): base(activity, operationFinishedHandler, handler) {
|
||||
_operationFinishedHandler = operationFinishedHandler;
|
||||
_dlg = dlg;
|
||||
}
|
||||
|
||||
|
||||
public override void Run() {
|
||||
if ( Success ) {
|
||||
if ( _finish != null ) {
|
||||
_finish.Filename = _dlg.Keyfile;
|
||||
if ( _operationFinishedHandler != null ) {
|
||||
_operationFinishedHandler.Filename = _dlg.Keyfile;
|
||||
}
|
||||
FingerprintUnlockMode um;
|
||||
Enum.TryParse(PreferenceManager.GetDefaultSharedPreferences(_dlg.Context).GetString(App.Kp2a.CurrentDb.CurrentFingerprintModePrefKey, ""), out um);
|
||||
|
@@ -53,7 +53,7 @@ namespace keepass2android
|
||||
{
|
||||
var filestorage = App.Kp2a.GetFileStorage(App.Kp2a.CurrentDb.Ioc);
|
||||
RunnableOnFinish task;
|
||||
OnFinish onFinish = new ActionOnFinish(_activity, (success, message, activity) =>
|
||||
OnOperationFinishedHandler onOperationFinishedHandler = new ActionOnOperationFinished(_activity, (success, message, activity) =>
|
||||
{
|
||||
if (!String.IsNullOrEmpty(message))
|
||||
App.Kp2a.ShowMessage(activity, message, MessageSeverity.Error);
|
||||
@@ -65,7 +65,7 @@ namespace keepass2android
|
||||
if (App.Kp2a.CurrentDb?.OtpAuxFileIoc != null)
|
||||
{
|
||||
var task2 = new SyncOtpAuxFile(_activity, App.Kp2a.CurrentDb.OtpAuxFileIoc);
|
||||
task2.OnFinishToRun = new ActionOnFinish(_activity, (b, s, activeActivity) =>
|
||||
task2.operationFinishedHandler = new ActionOnOperationFinished(_activity, (b, s, activeActivity) =>
|
||||
{
|
||||
runAfterSuccess();
|
||||
});
|
||||
@@ -80,12 +80,12 @@ namespace keepass2android
|
||||
if (filestorage is CachingFileStorage)
|
||||
{
|
||||
|
||||
task = new SynchronizeCachedDatabase(_activity, App.Kp2a, onFinish);
|
||||
task = new SynchronizeCachedDatabase(_activity, App.Kp2a, onOperationFinishedHandler);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
task = new CheckDatabaseForChanges(_activity, App.Kp2a, onFinish);
|
||||
task = new CheckDatabaseForChanges(_activity, App.Kp2a, onOperationFinishedHandler);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -117,7 +117,7 @@ namespace keepass2android
|
||||
var previousUsername = db.KpDatabase.DefaultUserName;
|
||||
db.KpDatabase.DefaultUserName = e.NewValue.ToString();
|
||||
|
||||
SaveDb save = new SaveDb(Activity, App.Kp2a, App.Kp2a.CurrentDb, new ActionOnFinish(Activity, (success, message, activity) =>
|
||||
SaveDb save = new SaveDb(Activity, App.Kp2a, App.Kp2a.CurrentDb, new ActionOnOperationFinished(Activity, (success, message, activity) =>
|
||||
{
|
||||
if (!success)
|
||||
{
|
||||
@@ -145,7 +145,7 @@ namespace keepass2android
|
||||
pref.PreferenceClick += (sender, args) =>
|
||||
{
|
||||
ProgressTask pt = new ProgressTask(App.Kp2a, Activity,
|
||||
new AddTemplateEntries(Activity, App.Kp2a, new ActionOnFinish(Activity,
|
||||
new AddTemplateEntries(Activity, App.Kp2a, new ActionOnOperationFinished(Activity,
|
||||
delegate
|
||||
{
|
||||
pref.Enabled = false;
|
||||
@@ -183,7 +183,7 @@ namespace keepass2android
|
||||
String previousName = db.KpDatabase.Name;
|
||||
db.KpDatabase.Name = e.NewValue.ToString();
|
||||
|
||||
SaveDb save = new SaveDb(Activity, App.Kp2a, App.Kp2a.CurrentDb, new ActionOnFinish(Activity, (success, message, activity) =>
|
||||
SaveDb save = new SaveDb(Activity, App.Kp2a, App.Kp2a.CurrentDb, new ActionOnOperationFinished(Activity, (success, message, activity) =>
|
||||
{
|
||||
if (!success)
|
||||
{
|
||||
@@ -410,7 +410,7 @@ namespace keepass2android
|
||||
var previousCipher = db.KpDatabase.DataCipherUuid;
|
||||
db.KpDatabase.DataCipherUuid = new PwUuid(MemUtil.HexStringToByteArray((string)preferenceChangeEventArgs.NewValue));
|
||||
|
||||
SaveDb save = new SaveDb(Activity, App.Kp2a, App.Kp2a.CurrentDb, new ActionOnFinish(Activity, (success, message, activity) =>
|
||||
SaveDb save = new SaveDb(Activity, App.Kp2a, App.Kp2a.CurrentDb, new ActionOnOperationFinished(Activity, (success, message, activity) =>
|
||||
{
|
||||
if (!success)
|
||||
{
|
||||
@@ -1071,7 +1071,7 @@ namespace keepass2android
|
||||
|
||||
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 ActionOnFinish(Activity, (success, message, activity) =>
|
||||
SaveDb save = new SaveDb(Activity, App.Kp2a, App.Kp2a.CurrentDb, new ActionOnOperationFinished(Activity, (success, message, activity) =>
|
||||
{
|
||||
if (!success)
|
||||
{
|
||||
|
@@ -18,8 +18,8 @@ namespace keepass2android
|
||||
private readonly IKp2aApp _app;
|
||||
private IOConnectionInfo _targetIoc;
|
||||
|
||||
public ExportKeyfile(Activity activity, IKp2aApp app, OnFinish onFinish, IOConnectionInfo targetIoc) : base(
|
||||
activity, onFinish)
|
||||
public ExportKeyfile(Activity activity, IKp2aApp app, OnOperationFinishedHandler onOperationFinishedHandler, IOConnectionInfo targetIoc) : base(
|
||||
activity, onOperationFinishedHandler)
|
||||
{
|
||||
_app = app;
|
||||
_targetIoc = targetIoc;
|
||||
@@ -70,7 +70,7 @@ namespace keepass2android
|
||||
|
||||
protected override void SaveFile(IOConnectionInfo ioc)
|
||||
{
|
||||
var exportKeyfile = new ExportKeyfile(_activity, App.Kp2a, new ActionOnFinish(_activity,
|
||||
var exportKeyfile = new ExportKeyfile(_activity, App.Kp2a, new ActionOnOperationFinished(_activity,
|
||||
(success, message, activity) =>
|
||||
{
|
||||
if (!success)
|
||||
|
@@ -129,7 +129,7 @@ namespace keepass2android.settings
|
||||
|
||||
public abstract ulong ParamValue { get; set; }
|
||||
|
||||
private class AfterSave : OnFinish {
|
||||
private class AfterSave : OnOperationFinishedHandler {
|
||||
private readonly ulong _oldParamValue;
|
||||
private readonly Context _ctx;
|
||||
private readonly KdfNumberDialogPreference _pref;
|
||||
|
Reference in New Issue
Block a user