Esempio n. 1
0
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);
            switch (resultCode)
            {
            case (Result)ResultOkIconPicker:
                State.SelectedIconId       = (PwIcon)data.Extras.GetInt(IconPickerActivity.KeyIconId, (int)PwIcon.Key);
                State.SelectedCustomIconId = PwUuid.Zero;
                String customIconIdString = data.Extras.GetString(IconPickerActivity.KeyCustomIconId);
                if (!String.IsNullOrEmpty(customIconIdString))
                {
                    State.SelectedCustomIconId = new PwUuid(MemUtil.HexStringToByteArray(customIconIdString));
                }
                State.SelectedIcon  = true;
                State.EntryModified = true;
                Reload();
                break;

            case KeePass.ResultOkPasswordGenerator:
                String generatedPassword = data.GetStringExtra("keepass2android.password.generated_password");

                byte[] password = StrUtil.Utf8.GetBytes(generatedPassword);
                State.Entry.Strings.Set(PwDefs.PasswordField, new ProtectedString(App.Kp2a.GetDb().KpDatabase.MemoryProtection.ProtectPassword,
                                                                                  password));
                MemUtil.ZeroByteArray(password);

                State.EntryModified = true;
                Reload();
                break;

            case Result.Ok:
                if (requestCode == Intents.RequestCodeFileBrowseForBinary)
                {
                    Uri uri = data.Data;
                    if (data.Data == null)
                    {
                        string s = Util.GetFilenameFromInternalFileChooser(data, this);
                        if (s == null)
                        {
                            Toast.MakeText(this, "No URI retrieved.", ToastLength.Short).Show();
                            return;
                        }
                        uri = Uri.Parse(s);
                    }
                    AddBinaryOrAsk(uri);
                }
                Reload();


                break;

            case Result.Canceled:
                Reload();
                break;
            }
        }