rename ProgressTask => BlockingOperationRunner
This commit is contained in:
@@ -25,10 +25,10 @@ namespace keepass2android
|
||||
/// <summary>
|
||||
/// Class to run a task while a progress dialog is shown
|
||||
/// </summary>
|
||||
public class ProgressTask
|
||||
public class BlockingOperationRunner
|
||||
{
|
||||
//for handling Activity recreation situations, we need access to the currently active task. It must hold that there is no more than one active task.
|
||||
private static ProgressTask _currentTask = null;
|
||||
private static BlockingOperationRunner _currentTask = null;
|
||||
|
||||
public static void SetNewActiveActivity(Activity activeActivity)
|
||||
{
|
||||
@@ -79,7 +79,7 @@ namespace keepass2android
|
||||
private Activity _activeActivity, _previouslyActiveActivity;
|
||||
private ProgressDialogStatusLogger _progressDialogStatusLogger;
|
||||
|
||||
public ProgressTask(IKp2aApp app, Activity activity, OperationWithFinishHandler task)
|
||||
public BlockingOperationRunner(IKp2aApp app, Activity activity, OperationWithFinishHandler task)
|
||||
{
|
||||
_activeActivity = activity;
|
||||
_task = task;
|
||||
@@ -127,7 +127,7 @@ namespace keepass2android
|
||||
public void Run(bool allowOverwriteCurrentTask = false)
|
||||
{
|
||||
if ((!allowOverwriteCurrentTask) && (_currentTask != null))
|
||||
throw new System.Exception("Cannot start another ProgressTask while ProgressTask is already running! " + _task.GetType().Name + "/" + _currentTask._task.GetType().Name);
|
||||
throw new System.Exception("Cannot start another BlockingOperationRunner while BlockingOperationRunner is already running! " + _task.GetType().Name + "/" + _currentTask._task.GetType().Name);
|
||||
_currentTask = this;
|
||||
|
||||
// Show process dialog
|
||||
@@ -145,11 +145,11 @@ namespace keepass2android
|
||||
}
|
||||
|
||||
private class AfterTask : OnOperationFinishedHandler {
|
||||
readonly ProgressTask _progressTask;
|
||||
readonly BlockingOperationRunner _blockingOperationRunner;
|
||||
|
||||
public AfterTask (Activity activity, OnOperationFinishedHandler operationFinishedHandler, Handler handler, ProgressTask pt): base(activity, operationFinishedHandler, handler)
|
||||
public AfterTask (Activity activity, OnOperationFinishedHandler operationFinishedHandler, Handler handler, BlockingOperationRunner pt): base(activity, operationFinishedHandler, handler)
|
||||
{
|
||||
_progressTask = pt;
|
||||
_blockingOperationRunner = pt;
|
||||
}
|
||||
|
||||
public override void Run() {
|
||||
@@ -160,12 +160,12 @@ namespace keepass2android
|
||||
// Remove the progress dialog
|
||||
Handler.Post(delegate
|
||||
{
|
||||
_progressTask._progressDialog.Dismiss();
|
||||
_blockingOperationRunner._progressDialog.Dismiss();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
_progressTask._progressDialog.Dismiss();
|
||||
_blockingOperationRunner._progressDialog.Dismiss();
|
||||
}
|
||||
_currentTask = null;
|
||||
|
@@ -131,14 +131,14 @@ namespace keepass2android
|
||||
(dlgSender, dlgEvt) =>
|
||||
{
|
||||
DeletePermanently = true;
|
||||
ProgressTask pt = new ProgressTask(App, Ctx, this);
|
||||
BlockingOperationRunner pt = new BlockingOperationRunner(App, Ctx, this);
|
||||
pt.Run();
|
||||
|
||||
},
|
||||
(dlgSender, dlgEvt) =>
|
||||
{
|
||||
DeletePermanently = false;
|
||||
ProgressTask pt = new ProgressTask(App, Ctx, this);
|
||||
BlockingOperationRunner pt = new BlockingOperationRunner(App, Ctx, this);
|
||||
pt.Run();
|
||||
},
|
||||
(dlgSender, dlgEvt) => { },
|
||||
@@ -153,7 +153,7 @@ namespace keepass2android
|
||||
QuestionNoRecycleResourceId,
|
||||
(dlgSender, dlgEvt) =>
|
||||
{
|
||||
ProgressTask pt = new ProgressTask(App, Ctx, this);
|
||||
BlockingOperationRunner pt = new BlockingOperationRunner(App, Ctx, this);
|
||||
pt.Run();
|
||||
},
|
||||
null,
|
||||
|
@@ -230,7 +230,7 @@ namespace keepass2android
|
||||
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()));
|
||||
|
||||
ProgressTask pt = new ProgressTask(App.Kp2a, this, addTask);
|
||||
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, this, addTask);
|
||||
pt.Run();
|
||||
|
||||
}
|
||||
@@ -262,7 +262,7 @@ namespace keepass2android
|
||||
{
|
||||
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);
|
||||
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, this, addTask);
|
||||
pt.Run();
|
||||
}
|
||||
|
||||
@@ -369,7 +369,7 @@ namespace keepass2android
|
||||
|
||||
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);
|
||||
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, this, addTask);
|
||||
pt.Run();
|
||||
}
|
||||
|
||||
|
@@ -214,7 +214,7 @@ namespace keepass2android
|
||||
|
||||
// Create the new database
|
||||
CreateDb create = new CreateDb(App.Kp2a, this, _ioc, new LaunchGroupActivity(_ioc, this), false, newKey, makeCurrent);
|
||||
ProgressTask createTask = new ProgressTask(
|
||||
BlockingOperationRunner createTask = new BlockingOperationRunner(
|
||||
App.Kp2a,
|
||||
this, create);
|
||||
createTask.Run();
|
||||
|
@@ -81,7 +81,7 @@ namespace keepass2android
|
||||
App.Kp2a.ShowMessage(activity, message, MessageSeverity.Error);
|
||||
}
|
||||
), ((EntryActivity)_activity).Entry.Binaries.Get(_binaryToSave), ioc);
|
||||
ProgressTask pt = new ProgressTask(App.Kp2a, _activity, task);
|
||||
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, _activity, task);
|
||||
pt.Run();
|
||||
|
||||
}
|
||||
@@ -482,7 +482,7 @@ namespace keepass2android
|
||||
Entry.Touch(true);
|
||||
RequiresRefresh();
|
||||
UpdateEntry update = new UpdateEntry(this, App.Kp2a, backupEntry, Entry, null);
|
||||
ProgressTask pt = new ProgressTask(App.Kp2a, this, update);
|
||||
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, this, update);
|
||||
pt.Run();
|
||||
}
|
||||
FillData();
|
||||
@@ -531,7 +531,7 @@ namespace keepass2android
|
||||
activity.Finish();
|
||||
}));
|
||||
|
||||
ProgressTask pt = new ProgressTask(App.Kp2a, this, saveTask);
|
||||
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, this, saveTask);
|
||||
pt.Run();
|
||||
}
|
||||
|
||||
@@ -1513,7 +1513,7 @@ namespace keepass2android
|
||||
|
||||
OperationWithFinishHandler runnable = new UpdateEntry(this, App.Kp2a, initialEntry, newEntry, closeOrShowError);
|
||||
|
||||
ProgressTask pt = new ProgressTask(App.Kp2a, this, runnable);
|
||||
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, this, runnable);
|
||||
pt.Run();
|
||||
|
||||
}
|
||||
|
@@ -547,7 +547,7 @@ namespace keepass2android
|
||||
} else {
|
||||
runnable = new UpdateEntry(this, App.Kp2a, initialEntry, newEntry, closeOrShowError);
|
||||
}
|
||||
ProgressTask pt = new ProgressTask(App.Kp2a, act, runnable);
|
||||
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, act, runnable);
|
||||
pt.Run();
|
||||
|
||||
|
||||
|
@@ -35,7 +35,7 @@ namespace keepass2android
|
||||
activity.Finish();
|
||||
}
|
||||
), _ffp, ioc);
|
||||
ProgressTask pt = new ProgressTask(App.Kp2a, _activity, exportDb);
|
||||
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, _activity, exportDb);
|
||||
pt.Run();
|
||||
|
||||
}
|
||||
|
@@ -115,7 +115,7 @@ namespace keepass2android
|
||||
|
||||
}), filename);
|
||||
|
||||
new ProgressTask(App.Kp2a, _activity, task).Run();
|
||||
new BlockingOperationRunner(App.Kp2a, _activity, task).Run();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@@ -793,7 +793,7 @@ namespace keepass2android
|
||||
|
||||
}), filename);
|
||||
|
||||
new ProgressTask(App.Kp2a, activity, task).Run();
|
||||
new BlockingOperationRunner(App.Kp2a, activity, task).Run();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -223,7 +223,7 @@ namespace keepass2android
|
||||
(o, args) =>
|
||||
{
|
||||
//yes
|
||||
ProgressTask pt = new ProgressTask(App.Kp2a, this,
|
||||
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, this,
|
||||
new AddTemplateEntries(this, App.Kp2a, new ActionOnOperationFinished(this,
|
||||
(success, message, activity) => ((GroupActivity)activity)?.StartAddEntry())));
|
||||
pt.Run();
|
||||
|
@@ -213,7 +213,7 @@ namespace keepass2android
|
||||
task = new EditGroup(this, App.Kp2a, groupName, (PwIcon)groupIconId, groupCustomIconId, App.Kp2a.FindGroup(groupUuid),
|
||||
new RefreshTask(handler, this));
|
||||
}
|
||||
ProgressTask pt = new ProgressTask(App.Kp2a, act, task);
|
||||
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, act, task);
|
||||
pt.Run();
|
||||
}
|
||||
|
||||
@@ -931,7 +931,7 @@ namespace keepass2android
|
||||
if (!String.IsNullOrEmpty(message))
|
||||
App.Kp2a.ShowMessage(activity, message, MessageSeverity.Error);
|
||||
}));
|
||||
var progressTask = new ProgressTask(App.Kp2a, this, moveElement);
|
||||
var progressTask = new BlockingOperationRunner(App.Kp2a, this, moveElement);
|
||||
progressTask.Run();
|
||||
|
||||
}
|
||||
@@ -1486,7 +1486,7 @@ namespace keepass2android
|
||||
var copyTask = new CopyEntry((GroupBaseActivity)Activity, App.Kp2a, (PwEntry)checkedItems.First(),
|
||||
new GroupBaseActivity.RefreshTask(handler, ((GroupBaseActivity)Activity)), App.Kp2a.CurrentDb);
|
||||
|
||||
ProgressTask pt = new ProgressTask(App.Kp2a, Activity, copyTask);
|
||||
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, Activity, copyTask);
|
||||
pt.Run();
|
||||
break;
|
||||
|
||||
|
@@ -104,7 +104,7 @@ namespace keepass2android
|
||||
|
||||
protected override void OnStart()
|
||||
{
|
||||
ProgressTask.SetNewActiveActivity(this);
|
||||
BlockingOperationRunner.SetNewActiveActivity(this);
|
||||
base.OnStart();
|
||||
Kp2aLog.Log(ClassName + ".OnStart" + " " + ID);
|
||||
}
|
||||
@@ -136,7 +136,7 @@ namespace keepass2android
|
||||
{
|
||||
base.OnStop();
|
||||
Kp2aLog.Log(ClassName + ".OnStop" + " " + ID);
|
||||
ProgressTask.RemoveActiveActivity(this);
|
||||
BlockingOperationRunner.RemoveActiveActivity(this);
|
||||
}
|
||||
|
||||
protected override void OnSaveInstanceState(Bundle outState)
|
||||
|
@@ -1447,7 +1447,7 @@ namespace keepass2android
|
||||
: 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();
|
||||
new BlockingOperationRunner(App.Kp2a, this, task).Run();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -1896,7 +1896,7 @@ namespace keepass2android
|
||||
LoadDb task = new LoadDb(this, App.Kp2a, _ioConnection, _loadDbFileTask, compositeKeyForImmediateLoad, GetKeyProviderString(),
|
||||
onOperationFinishedHandler, false, _makeCurrent);
|
||||
_loadDbFileTask = null; // prevent accidental re-use
|
||||
new ProgressTask(App.Kp2a, this, task).Run();
|
||||
new BlockingOperationRunner(App.Kp2a, this, task).Run();
|
||||
compositeKeyForImmediateLoad = null; //don't reuse or keep in memory
|
||||
|
||||
}
|
||||
|
@@ -73,7 +73,7 @@ namespace keepass2android
|
||||
}
|
||||
|
||||
SetPassword sp = new SetPassword(_activity, App.Kp2a, pass, keyfile, new AfterSave(_activity, this, null, new Handler()));
|
||||
ProgressTask pt = new ProgressTask(App.Kp2a, _activity, sp);
|
||||
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, _activity, sp);
|
||||
pt.Run();
|
||||
};
|
||||
|
||||
|
@@ -69,7 +69,7 @@ namespace keepass2android
|
||||
{
|
||||
runAfterSuccess();
|
||||
});
|
||||
new ProgressTask(App.Kp2a, activity, task2).Run(true);
|
||||
new BlockingOperationRunner(App.Kp2a, activity, task2).Run(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -91,7 +91,7 @@ namespace keepass2android
|
||||
|
||||
|
||||
|
||||
var progressTask = new ProgressTask(App.Kp2a, _activity, task);
|
||||
var progressTask = new BlockingOperationRunner(App.Kp2a, _activity, task);
|
||||
progressTask.Run();
|
||||
|
||||
}
|
||||
|
@@ -673,7 +673,7 @@ namespace keepass2android
|
||||
/// <summary>
|
||||
/// Shows all non-dismissed progress dialogs.
|
||||
/// If there are multiple progressDialogs active, they all will be showing.
|
||||
/// There probably will never be multiple dialogs at the same time because only one ProgressTask can run at a time.
|
||||
/// There probably will never be multiple dialogs at the same time because only one BlockingOperationRunner can run at a time.
|
||||
/// Even if multiple dialogs show at the same time, it shouldn't be too much of an issue
|
||||
/// because they are just progress indicators.
|
||||
/// </summary>
|
||||
|
@@ -126,7 +126,7 @@ namespace keepass2android
|
||||
App.Kp2a.ShowMessage(activity, message, MessageSeverity.Error);
|
||||
}
|
||||
}));
|
||||
ProgressTask pt = new ProgressTask(App.Kp2a, Activity, save);
|
||||
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, Activity, save);
|
||||
pt.Run();
|
||||
};
|
||||
}
|
||||
@@ -144,7 +144,7 @@ namespace keepass2android
|
||||
{
|
||||
pref.PreferenceClick += (sender, args) =>
|
||||
{
|
||||
ProgressTask pt = new ProgressTask(App.Kp2a, Activity,
|
||||
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, Activity,
|
||||
new AddTemplateEntries(Activity, App.Kp2a, new ActionOnOperationFinished(Activity,
|
||||
delegate
|
||||
{
|
||||
@@ -197,7 +197,7 @@ namespace keepass2android
|
||||
App.Kp2a.UpdateOngoingNotification();
|
||||
}
|
||||
}));
|
||||
ProgressTask pt = new ProgressTask(App.Kp2a, Activity, save);
|
||||
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, Activity, save);
|
||||
pt.Run();
|
||||
};
|
||||
}
|
||||
@@ -421,7 +421,7 @@ namespace keepass2android
|
||||
preferenceChangeEventArgs.Preference.Summary =
|
||||
CipherPool.GlobalPool.GetCipher(db.KpDatabase.DataCipherUuid).DisplayName;
|
||||
}));
|
||||
ProgressTask pt = new ProgressTask(App.Kp2a, Activity, save);
|
||||
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, Activity, save);
|
||||
pt.Run();
|
||||
}
|
||||
|
||||
@@ -1082,7 +1082,7 @@ namespace keepass2android
|
||||
UpdateKdfScreen();
|
||||
|
||||
}));
|
||||
ProgressTask pt = new ProgressTask(App.Kp2a, Activity, save);
|
||||
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, Activity, save);
|
||||
pt.Run();
|
||||
|
||||
}
|
||||
|
@@ -81,7 +81,7 @@ namespace keepass2android
|
||||
activity.Finish();
|
||||
}
|
||||
), ioc);
|
||||
ProgressTask pt = new ProgressTask(App.Kp2a, _activity, exportKeyfile);
|
||||
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, _activity, exportKeyfile);
|
||||
pt.Run();
|
||||
|
||||
}
|
||||
|
@@ -114,7 +114,7 @@ namespace keepass2android.settings
|
||||
|
||||
Handler handler = new Handler();
|
||||
SaveDb save = new SaveDb((Activity)Context, App.Kp2a, App.Kp2a.CurrentDb, new AfterSave((Activity)Context, handler, oldValue, this));
|
||||
ProgressTask pt = new ProgressTask(App.Kp2a, (Activity)Context, save);
|
||||
BlockingOperationRunner pt = new BlockingOperationRunner(App.Kp2a, (Activity)Context, save);
|
||||
pt.Run();
|
||||
});
|
||||
db.SetNegativeButton(Android.Resource.String.Cancel, ((sender, args) => { }));
|
||||
|
Reference in New Issue
Block a user