예제 #1
0
        private bool InitFingerprintUnlock()
        {
            Kp2aLog.Log("InitFingerprintUnlock");

            if (_fingerprintIdentifier != null)
            {
                Kp2aLog.Log("Already listening for fingerprint!");
                return(true);
            }


            var btn = FindViewById <ImageButton>(Resource.Id.fingerprintbtn);

            try
            {
                FingerprintUnlockMode um;
                Enum.TryParse(PreferenceManager.GetDefaultSharedPreferences(this).GetString(App.Kp2a.GetDbForQuickUnlock().CurrentFingerprintModePrefKey, ""), out um);
                btn.Visibility = (um != FingerprintUnlockMode.Disabled) ? ViewStates.Visible : ViewStates.Gone;

                if (um == FingerprintUnlockMode.Disabled)
                {
                    _fingerprintIdentifier = null;
                    return(false);
                }

                if (_fingerprintPermissionGranted)
                {
                    FingerprintModule fpModule = new FingerprintModule(this);
                    Kp2aLog.Log("fpModule.FingerprintManager.IsHardwareDetected=" + fpModule.FingerprintManager.IsHardwareDetected);
                    if (fpModule.FingerprintManager.IsHardwareDetected)                     //see FingerprintSetupActivity
                    {
                        _fingerprintIdentifier = new FingerprintDecryption(fpModule, App.Kp2a.GetDbForQuickUnlock().CurrentFingerprintPrefKey, this,
                                                                           App.Kp2a.GetDbForQuickUnlock().CurrentFingerprintPrefKey);
                    }
                }
                if ((_fingerprintIdentifier == null) && (!FingerprintDecryption.IsSetUp(this, App.Kp2a.GetDbForQuickUnlock().CurrentFingerprintPrefKey)))
                {
                    try
                    {
                        Kp2aLog.Log("trying Samsung Fingerprint API...");
                        _fingerprintIdentifier = new FingerprintSamsungIdentifier(this);
                        btn.Click += (sender, args) =>
                        {
                            if (_fingerprintIdentifier.Init())
                            {
                                _fingerprintIdentifier.StartListening(this, this);
                            }
                        };
                        Kp2aLog.Log("trying Samsung Fingerprint API...Seems to work!");
                    }
                    catch (Exception)
                    {
                        Kp2aLog.Log("trying Samsung Fingerprint API...failed.");
                        _fingerprintIdentifier = null;
                    }
                }
                if (_fingerprintIdentifier == null)
                {
                    FindViewById <ImageButton>(Resource.Id.fingerprintbtn).Visibility = ViewStates.Gone;
                    return(false);
                }
                btn.Tag = GetString(Resource.String.fingerprint_unlock_hint);

                if (_fingerprintIdentifier.Init())
                {
                    Kp2aLog.Log("successfully initialized fingerprint.");
                    btn.SetImageResource(Resource.Drawable.ic_fp_40px);
                    _fingerprintIdentifier.StartListening(this, this);
                    return(true);
                }
                else
                {
                    Kp2aLog.Log("failed to initialize fingerprint.");
                    HandleFingerprintKeyInvalidated();
                }
            }
            catch (Exception e)
            {
                Kp2aLog.Log("Error initializing Fingerprint Unlock: " + e);
                btn.SetImageResource(Resource.Drawable.ic_fingerprint_error);
                btn.Tag = "Error initializing Fingerprint Unlock: " + e;

                _fingerprintIdentifier = null;
            }
            return(false);
        }
예제 #2
0
 protected override void OnResume()
 {
     base.OnResume();
     Kp2aLog.Log("KeePass.OnResume");
     _design.ReapplyTheme();
 }
예제 #3
0
 protected override void OnDestroy()
 {
     Kp2aLog.Log("KeePass.OnDestroy" + IsFinishing.ToString());
     base.OnDestroy();
 }
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);

            if (resultCode == KeePass.ResultOkPasswordGenerator)
            {
                String generatedPassword = data.GetStringExtra("keepass2android.password.generated_password");
                FindViewById <TextView>(Resource.Id.entry_password).Text     = generatedPassword;
                FindViewById <TextView>(Resource.Id.entry_confpassword).Text = generatedPassword;
            }

            if (resultCode == KeePass.ExitFileStorageSelectionOk)
            {
                string protocolId = data.GetStringExtra("protocolId");
                if (protocolId == "content")
                {
                    Util.ShowBrowseDialog(this, RequestCodeDbFilename, true, true);
                }
                else
                {
                    FileSelectHelper fileSelectHelper = new FileSelectHelper(this, true, RequestCodeDbFilename)
                    {
                        DefaultExtension = "kdbx"
                    };
                    fileSelectHelper.OnOpen += (sender, info) =>
                    {
                        _ioc = info;
                        UpdateIocView();
                    };
                    App.Kp2a.GetFileStorage(protocolId).StartSelectFile(
                        new FileStorageSetupInitiatorActivity(this, OnActivityResult, s => fileSelectHelper.PerformManualFileSelect(s)),
                        true,
                        RequestCodeDbFilename,
                        protocolId);
                }
            }

            if (resultCode == Result.Ok)
            {
                if (requestCode == RequestCodeKeyFile)
                {
                    if (data.Data.Scheme == "content")
                    {
                        if ((int)Build.VERSION.SdkInt >= 19)
                        {
                            //try to take persistable permissions
                            try
                            {
                                Kp2aLog.Log("TakePersistableUriPermission");
                                var takeFlags = data.Flags
                                                & (ActivityFlags.GrantReadUriPermission
                                                   | ActivityFlags.GrantWriteUriPermission);
                                this.ContentResolver.TakePersistableUriPermission(data.Data, takeFlags);
                            }
                            catch (Exception e)
                            {
                                Kp2aLog.Log(e.ToString());
                            }
                        }
                    }


                    string filename = Util.IntentToFilename(data, this);
                    if (filename == null)
                    {
                        filename = data.DataString;
                    }


                    _keyfileFilename = ConvertFilenameToIocPath(filename);
                    FindViewById <TextView>(Resource.Id.keyfile_filename).Text = _keyfileFilename;
                    FindViewById(Resource.Id.keyfile_filename).Visibility      = ViewStates.Visible;
                }
                if (requestCode == RequestCodeDbFilename)
                {
                    if (data.Data.Scheme == "content")
                    {
                        if ((int)Build.VERSION.SdkInt >= 19)
                        {
                            //try to take persistable permissions
                            try
                            {
                                Kp2aLog.Log("TakePersistableUriPermission");
                                var takeFlags = data.Flags
                                                & (ActivityFlags.GrantReadUriPermission
                                                   | ActivityFlags.GrantWriteUriPermission);
                                this.ContentResolver.TakePersistableUriPermission(data.Data, takeFlags);
                            }
                            catch (Exception e)
                            {
                                Kp2aLog.Log(e.ToString());
                            }
                        }
                    }


                    string filename = Util.IntentToFilename(data, this);
                    if (filename == null)
                    {
                        filename = data.DataString;
                    }

                    bool fileExists = data.GetBooleanExtra("group.pals.android.lib.ui.filechooser.FileChooserActivity.result_file_exists", true);

                    if (fileExists)
                    {
                        _ioc = new IOConnectionInfo {
                            Path = ConvertFilenameToIocPath(filename)
                        };
                        UpdateIocView();
                    }
                    else
                    {
                        var task = new CreateNewFilename(this, new ActionOnFinish(this, (success, messageOrFilename, activity) =>
                        {
                            if (!success)
                            {
                                Toast.MakeText(activity, messageOrFilename, ToastLength.Long).Show();
                                return;
                            }
                            _ioc = new IOConnectionInfo {
                                Path = ConvertFilenameToIocPath(messageOrFilename)
                            };
                            ((CreateDatabaseActivity)activity)?.UpdateIocView();
                        }), filename);

                        new ProgressTask(App.Kp2a, this, task).Run();
                    }
                }
            }
            if (resultCode == (Result)FileStorageResults.FileUsagePrepared)
            {
                _ioc = new IOConnectionInfo();
                PasswordActivity.SetIoConnectionFromIntent(_ioc, data);
                UpdateIocView();
            }
            if (resultCode == (Result)FileStorageResults.FileChooserPrepared)
            {
                IOConnectionInfo ioc = new IOConnectionInfo();
                PasswordActivity.SetIoConnectionFromIntent(ioc, data);

                new FileSelectHelper(this, true, RequestCodeDbFilename)
                {
                    DefaultExtension = "kdbx"
                }
                .StartFileChooser(ioc.Path);
            }
        }
예제 #5
0
        public override void Run()
        {
            try
            {
                try
                {
                    //make sure the file data is stored in the recent files list even if loading fails
                    SaveFileData(_ioc, _keyfileOrProvider);


                    StatusLogger.UpdateMessage(UiStringKey.loading_database);
                    //get the stream data into a single stream variable (databaseStream) regardless whether its preloaded or not:
                    MemoryStream preloadedMemoryStream = _databaseData == null ? null : _databaseData.Result;
                    MemoryStream databaseStream;
                    if (preloadedMemoryStream != null)
                    {
                        databaseStream = preloadedMemoryStream;
                    }
                    else
                    {
                        using (Stream s = _app.GetFileStorage(_ioc).OpenFileForRead(_ioc))
                        {
                            databaseStream = new MemoryStream();
                            s.CopyTo(databaseStream);
                            databaseStream.Seek(0, SeekOrigin.Begin);
                        }
                    }

                    //ok, try to load the database. Let's start with Kdbx format and retry later if that is the wrong guess:
                    _format = new KdbxDatabaseFormat(KdbpFile.GetFormatToUse(_ioc));
                    TryLoad(databaseStream);



                    success = true;
                }
                catch (Exception e)
                {
                    this.Exception = e;
                    throw;
                }
            }
            catch (KeyFileException)
            {
                Kp2aLog.Log("KeyFileException");
                Finish(false,                 /*TODO Localize: use Keepass error text KPRes.KeyFileError (including "or invalid format")*/
                       _app.GetResourceString(UiStringKey.keyfile_does_not_exist), false, Exception);
            }
            catch (AggregateException e)
            {
                string message = e.Message;
                foreach (var innerException in e.InnerExceptions)
                {
                    message = innerException.Message;
                    // Override the message shown with the last (hopefully most recent) inner exception
                    Kp2aLog.LogUnexpectedError(innerException);
                }
                Finish(false, _app.GetResourceString(UiStringKey.ErrorOcurred) + " " + message, false, Exception);
                return;
            }
            catch (DuplicateUuidsException e)
            {
                Kp2aLog.Log(e.ToString());
                Finish(false, _app.GetResourceString(UiStringKey.DuplicateUuidsError) + " " + e.Message + _app.GetResourceString(UiStringKey.DuplicateUuidsErrorAdditional), false, Exception);
                return;
            }
            catch (Exception e)
            {
                if (!(e is InvalidCompositeKeyException))
                {
                    Kp2aLog.LogUnexpectedError(e);
                }
                Finish(false, _app.GetResourceString(UiStringKey.ErrorOcurred) + " " + e.Message, false, Exception);
                return;
            }
        }
예제 #6
0
 protected override void OnStart()
 {
     base.OnStart();
     Kp2aLog.Log(ClassName + ".OnStart");
 }
예제 #7
0
 protected override void OnDestroy()
 {
     base.OnDestroy();
     GC.Collect();
     Kp2aLog.Log(ClassName + ".OnDestroy" + IsFinishing.ToString());
 }
예제 #8
0
 protected override void OnPause()
 {
     base.OnPause();
     Kp2aLog.Log(ClassName + ".OnPause");
 }
예제 #9
0
 protected override void OnStop()
 {
     base.OnStop();
     Kp2aLog.Log(ClassName + ".OnStop");
     ProgressTask.RemoveActiveActivity(this);
 }
예제 #10
0
 protected override void OnStart()
 {
     ProgressTask.SetNewActiveActivity(this);
     base.OnStart();
     Kp2aLog.Log(ClassName + ".OnStart");
 }
예제 #11
0
 protected override void OnCreate(Bundle bundle)
 {
     base.OnCreate(bundle);
     Kp2aLog.Log(ClassName + ".OnCreate");
     Kp2aLog.Log(ClassName + ":apptask=" + Intent.GetStringExtra("KP2A_APP_TASK_TYPE"));
 }
        private void OnLockDatabase()
        {
            Kp2aLog.Log("Stopping clipboard service due to database lock");

            StopSelf();
        }
        public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
        {
            Kp2aLog.Log("Received intent to provide access to entry");

            _stopOnLockBroadcastReceiver = new StopOnLockBroadcastReceiver(this);
            IntentFilter filter = new IntentFilter();

            filter.AddAction(Intents.DatabaseLocked);
            RegisterReceiver(_stopOnLockBroadcastReceiver, filter);

            if ((intent.Action == Intents.ShowNotification) || (intent.Action == Intents.UpdateKeyboard))
            {
                String uuidBytes = intent.GetStringExtra(EntryActivity.KeyEntry);
                String searchUrl = intent.GetStringExtra(SearchUrlTask.UrlToSearchKey);

                PwUuid entryId = PwUuid.Zero;
                if (uuidBytes != null)
                {
                    entryId = new PwUuid(MemUtil.HexStringToByteArray(uuidBytes));
                }

                PwEntryOutput entry;
                try
                {
                    if ((App.Kp2a.GetDb().LastOpenedEntry != null) &&
                        (entryId.Equals(App.Kp2a.GetDb().LastOpenedEntry.Uuid)))
                    {
                        entry = App.Kp2a.GetDb().LastOpenedEntry;
                    }
                    else
                    {
                        entry = new PwEntryOutput(App.Kp2a.GetDb().Entries[entryId], App.Kp2a.GetDb().KpDatabase);
                    }
                }
                catch (Exception)
                {
                    //seems like restarting the service happened after closing the DB
                    StopSelf();
                    return(StartCommandResult.NotSticky);
                }

                if (intent.Action == Intents.ShowNotification)
                {
                    //first time opening the entry -> bring up the notifications
                    bool closeAfterCreate = intent.GetBooleanExtra(EntryActivity.KeyCloseAfterCreate, false);
                    DisplayAccessNotifications(entry, closeAfterCreate, searchUrl);
                }
                else                 //UpdateKeyboard
                {
#if !EXCLUDE_KEYBOARD
                    //this action is received when the data in the entry has changed (e.g. by plugins)
                    //update the keyboard data.
                    //Check if keyboard is (still) available
                    if (Keepass2android.Kbbridge.KeyboardData.EntryId == entry.Uuid.ToHexString())
                    {
                        MakeAccessibleForKeyboard(entry, searchUrl);
                    }
#endif
                }
            }
            if (intent.Action == Intents.CopyStringToClipboard)
            {
                TimeoutCopyToClipboard(intent.GetStringExtra(_stringtocopy));
            }
            if (intent.Action == Intents.ActivateKeyboard)
            {
                ActivateKp2aKeyboard();
            }
            if (intent.Action == Intents.ClearNotificationsAndData)
            {
                ClearNotifications();
            }


            return(StartCommandResult.RedeliverIntent);
        }
예제 #14
0
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);

            Kp2aLog.Log("StackBaseActivity.OnActivityResult " + resultCode + "/" + requestCode);

            AppTask.TryGetFromActivityResult(data, ref AppTask);

            if (requestCode == ReqCodeOpenNewDb)
            {
                switch ((int)resultCode)
                {
                case (int)Result.Ok:

                    string           iocString = data?.GetStringExtra("ioc");
                    IOConnectionInfo ioc       = IOConnectionInfo.UnserializeFromString(iocString);
                    if (App.Kp2a.TrySelectCurrentDb(ioc))
                    {
                        if (OpenAutoExecEntries(App.Kp2a.CurrentDb))
                        {
                            return;
                        }
                        LaunchingOther = true;
                        AppTask.CanActivateSearchViewOnStart = true;
                        AppTask.LaunchFirstGroupActivity(this);
                    }


                    break;

                case PasswordActivity.ResultSelectOtherFile:
                    StartFileSelect(true, true);
                    break;

                case (int)Result.Canceled:
                    if (App.Kp2a.OpenDatabases.Any() == false)
                    {
                        //don't open fileselect/password activity again
                        OnBackPressed();
                    }
                    break;

                default:
                    break;
                }

                return;
            }

            switch (resultCode)
            {
            case KeePass.ExitNormal:     // Returned to this screen using the Back key
                if (App.Kp2a.OpenDatabases.Count() == 1)
                {
                    OnBackPressed();
                }
                break;

            case KeePass.ExitLock:
                // The database has already been locked, and the quick unlock screen will be shown if appropriate
                break;

            case KeePass.ExitCloseAfterTaskComplete:
                // Do not lock the database
                SetResult(KeePass.ExitCloseAfterTaskComplete);
                if (!IsFinishing)
                {
                    Finish();
                }
                break;

            case KeePass.ExitClose:
                SetResult(KeePass.ExitClose);
                if (!IsFinishing)
                {
                    Finish();
                }
                break;

            case KeePass.ExitReloadDb:

                if (App.Kp2a.CurrentDb != null)
                {
                    //remember the composite key for reloading:
                    var compositeKey = App.Kp2a.CurrentDb.KpDatabase.MasterKey;
                    var ioc          = App.Kp2a.CurrentDb.Ioc;

                    //lock the database:
                    App.Kp2a.CloseDatabase(App.Kp2a.CurrentDb);

                    LaunchPasswordActivityForReload(ioc, compositeKey);
                }

                break;

            case KeePass.ExitLoadAnotherDb:
                StartFileSelect(true, true);
                break;
            }
        }
예제 #15
0
        protected override void OnCreate(Bundle bundle)
        {
            _design.ApplyTheme();
            base.OnCreate(bundle);

            //use FlagSecure to make sure the last (revealed) character of the password is not visible in recent apps
            if (PreferenceManager.GetDefaultSharedPreferences(this).GetBoolean(
                    GetString(Resource.String.ViewDatabaseSecure_key), true))
            {
                Window.SetFlags(WindowManagerFlags.Secure, WindowManagerFlags.Secure);
            }

            _ioc = App.Kp2a.GetDbForQuickUnlock().Ioc;

            if (_ioc == null)
            {
                Finish();
                return;
            }

            SetContentView(Resource.Layout.QuickUnlock);

            var toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.mytoolbar);

            SetSupportActionBar(toolbar);

            var collapsingToolbar = FindViewById <CollapsingToolbarLayout>(Resource.Id.collapsing_toolbar);

            collapsingToolbar.SetTitle(GetString(Resource.String.QuickUnlock_prefs));

            if (App.Kp2a.GetDbForQuickUnlock().KpDatabase.Name != "")
            {
                FindViewById(Resource.Id.filename_label).Visibility       = ViewStates.Visible;
                ((TextView)FindViewById(Resource.Id.filename_label)).Text = App.Kp2a.GetDbForQuickUnlock().KpDatabase.Name;
            }
            else
            {
                if (
                    PreferenceManager.GetDefaultSharedPreferences(this)
                    .GetBoolean(GetString(Resource.String.RememberRecentFiles_key),
                                Resources.GetBoolean(Resource.Boolean.RememberRecentFiles_default)))
                {
                    ((TextView)FindViewById(Resource.Id.filename_label)).Text = App.Kp2a.GetFileStorage(_ioc).GetDisplayName(_ioc);
                }
                else
                {
                    ((TextView)FindViewById(Resource.Id.filename_label)).Text = "*****";
                }
            }


            TextView txtLabel = (TextView)FindViewById(Resource.Id.QuickUnlock_label);

            _quickUnlockLength = App.Kp2a.QuickUnlockKeyLength;

            if (PreferenceManager.GetDefaultSharedPreferences(this)
                .GetBoolean(GetString(Resource.String.QuickUnlockHideLength_key), false))
            {
                txtLabel.Text = GetString(Resource.String.QuickUnlock_label_secure);
            }
            else
            {
                txtLabel.Text = GetString(Resource.String.QuickUnlock_label, new Java.Lang.Object[] { _quickUnlockLength });
            }


            EditText pwd = (EditText)FindViewById(Resource.Id.QuickUnlock_password);

            pwd.SetEms(_quickUnlockLength);
            Util.MoveBottomBarButtons(Resource.Id.QuickUnlock_buttonLock, Resource.Id.QuickUnlock_button, Resource.Id.bottom_bar, this);

            Button btnUnlock = (Button)FindViewById(Resource.Id.QuickUnlock_button);

            btnUnlock.Click += (object sender, EventArgs e) =>
            {
                OnUnlock(_quickUnlockLength, pwd);
            };



            Button btnLock = (Button)FindViewById(Resource.Id.QuickUnlock_buttonLock);

            btnLock.Text   = btnLock.Text.Replace("ß", "ss");
            btnLock.Click += (object sender, EventArgs e) =>
            {
                App.Kp2a.Lock(false);
                Finish();
            };
            pwd.EditorAction += (sender, args) =>
            {
                if ((args.ActionId == ImeAction.Done) || ((args.ActionId == ImeAction.ImeNull) && (args.Event.Action == KeyEventActions.Down)))
                {
                    OnUnlock(_quickUnlockLength, pwd);
                }
            };

            _intentReceiver = new QuickUnlockBroadcastReceiver(this);
            IntentFilter filter = new IntentFilter();

            filter.AddAction(Intents.DatabaseLocked);
            RegisterReceiver(_intentReceiver, filter);

            if ((int)Build.VERSION.SdkInt >= 23)
            {
                Kp2aLog.Log("requesting fingerprint permission");
                RequestPermissions(new[] { Manifest.Permission.UseFingerprint }, FingerprintPermissionRequestCode);
            }
            else
            {
            }
        }
 protected override void OnPause()
 {
     Kp2aLog.Log("SwitchImeActivity.OnPause");
     base.OnPause();
     Finish();
 }
예제 #17
0
 public override void OnTerminate()
 {
     base.OnTerminate();
     Kp2aLog.Log("Terminating application");
     Kp2a.OnTerminate();
 }
예제 #18
0
 protected override void OnResume()
 {
     base.OnResume();
     Kp2aLog.Log("Resuming QueryCredentialsActivity");
 }
예제 #19
0
 protected override void OnCreate(Bundle bundle)
 {
     base.OnCreate(bundle);
     Kp2aLog.Log(ClassName + ".OnCreate");
 }
예제 #20
0
 protected override void OnStart()
 {
     base.OnStart();
     Kp2aLog.Log("Starting QueryCredentialsActivity");
 }
예제 #21
0
 protected override void OnPause()
 {
     base.OnPause();
     TimeoutHelper.Pause(this);
     Kp2aLog.Log(ClassName + ".OnPause");
 }
        public bool HandleActivityResult(Activity activity, int requestCode, Result resultCode, Intent data)
        {
            if (requestCode != _requestCode)
            {
                return(false);
            }

            if (resultCode == KeePass.ExitFileStorageSelectionOk)
            {
                string protocolId = data.GetStringExtra("protocolId");
                if (protocolId == "content")
                {
                    Util.ShowBrowseDialog(activity, _requestCode, _isForSave, _tryGetPermanentAccess);
                }
                else
                {
                    App.Kp2a.GetFileStorage(protocolId).StartSelectFile(
                        new FileStorageSetupInitiatorActivity(activity, (i, result, arg3) => HandleActivityResult(activity, i, result, arg3), s => PerformManualFileSelect(s)),
                        _isForSave,
                        _requestCode,
                        protocolId);
                }
            }

            if (resultCode == Result.Ok)
            {
                if (data.Data.Scheme == "content")
                {
                    if ((int)Build.VERSION.SdkInt >= 19)
                    {
                        //try to take persistable permissions
                        try
                        {
                            Kp2aLog.Log("TakePersistableUriPermission");
                            var takeFlags = data.Flags
                                            & (ActivityFlags.GrantReadUriPermission
                                               | ActivityFlags.GrantWriteUriPermission);
                            activity.ContentResolver.TakePersistableUriPermission(data.Data, takeFlags);
                        }
                        catch (Exception e)
                        {
                            Kp2aLog.Log(e.ToString());
                        }
                    }
                }


                string filename = Util.IntentToFilename(data, activity);
                if (filename == null)
                {
                    filename = data.DataString;
                }

                bool fileExists = data.GetBooleanExtra("group.pals.android.lib.ui.filechooser.FileChooserActivity.result_file_exists", true);

                if (fileExists)
                {
                    var ioc = new IOConnectionInfo {
                        Path = ConvertFilenameToIocPath(filename)
                    };
                    IocSelected(activity, ioc);
                }
                else
                {
                    var task = new CreateNewFilename(activity, new ActionOnFinish(activity, (success, messageOrFilename, newActivity) =>
                    {
                        if (!success)
                        {
                            Toast.MakeText(newActivity, messageOrFilename, ToastLength.Long).Show();
                            return;
                        }
                        var ioc = new IOConnectionInfo {
                            Path = ConvertFilenameToIocPath(messageOrFilename)
                        };
                        IocSelected(newActivity, ioc);
                    }), filename);

                    new ProgressTask(App.Kp2a, activity, task).Run();
                }
            }


            if (resultCode == (Result)FileStorageResults.FileUsagePrepared)
            {
                var ioc = new IOConnectionInfo();
                Util.SetIoConnectionFromIntent(ioc, data);
                IocSelected(null, ioc);
            }
            if (resultCode == (Result)FileStorageResults.FileChooserPrepared)
            {
                IOConnectionInfo ioc = new IOConnectionInfo();
                Util.SetIoConnectionFromIntent(ioc, data);
                StartFileChooser(ioc.Path);
            }
            return(true);
        }