private void MoveKeyfileToInternalFolder() { Func <Action> copyAndReturnPostExecute = () => { try { CompositeKey masterKey = App.Kp2a.GetDb().KpDatabase.MasterKey; var sourceIoc = ((KcpKeyFile)masterKey.GetUserKey(typeof(KcpKeyFile))).Ioc; var newIoc = ImportFileToInternalDirectory(sourceIoc); ((KcpKeyFile)masterKey.GetUserKey(typeof(KcpKeyFile))).ResetIoc(newIoc); var keyfileString = IOConnectionInfo.SerializeToString(newIoc); App.Kp2a.StoreOpenedFileAsRecent(App.Kp2a.GetDb().Ioc, keyfileString); return(() => { UpdateImportKeyfilePref(); var builder = new AlertDialog.Builder(Activity); builder .SetMessage(Resource.String.KeyfileMoved); builder.SetPositiveButton(Android.Resource.String.Ok, (sender, args) => { }); builder.Show(); }); } catch (Exception e) { return(() => { Toast.MakeText(Activity, App.Kp2a.GetResourceString(UiStringKey.ErrorOcurred) + " " + e.Message, ToastLength.Long).Show(); }); } }; new SimpleLoadingDialog(Activity, GetString(Resource.String.CopyingFile), false, copyAndReturnPostExecute ).Execute(); }
protected override void OnSaveInstanceState(Bundle outState) { base.OnSaveInstanceState(outState); outState.PutAll(State); if (_selectedIoc != null) { outState.PutString(BundleKeySelectedIoc, IOConnectionInfo.SerializeToString(_selectedIoc)); } }
public override void Run() { if (Success) { // Update the ongoing notification App.Kp2a.UpdateOngoingNotification(); if (PreferenceManager.GetDefaultSharedPreferences(_activity).GetBoolean(_activity.GetString(Resource.String.RememberRecentFiles_key), _activity.Resources.GetBoolean(Resource.Boolean.RememberRecentFiles_default))) { // Add to recent files FileDbHelper dbHelper = App.Kp2a.FileDbHelper; //TODO: getFilename always returns "" -> bug? dbHelper.CreateFile(_ioc, Filename); } Intent data = new Intent(); data.PutExtra("ioc", IOConnectionInfo.SerializeToString(_ioc)); _activity.SetResult(Result.Ok, data); _activity.Finish(); } else { DisplayMessage(_activity); try { App.Kp2a.GetFileStorage(_ioc).Delete(_ioc); } catch (Exception e) { //not nice, but not a catastrophic failure if we can't delete the file: Kp2aLog.Log("couldn't delete file after failure! " + e); } } }