Ejemplo n.º 1
0
            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);
                    }

                    GroupActivity.Launch(_activity, _activity._appTask);
                    _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);
                    }
                }
            }
Ejemplo n.º 2
0
        internal void OnCreate(Application app)
        {
            FileDbHelper = new FileDbHelper(app);
            FileDbHelper.Open();

#if DEBUG
            foreach (UiStringKey key in Enum.GetValues(typeof(UiStringKey)))
            {
                GetResourceString(key);
            }
#endif
#if !EXCLUDE_TWOFISH
            CipherPool.GlobalPool.AddCipher(new TwofishCipherEngine());
#endif
        }
Ejemplo n.º 3
0
            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;

                        dbHelper.CreateFile(_ioc, Filename, true);
                    }

                    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);
                    }
                }
            }
Ejemplo n.º 4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            _design.ApplyTheme();
            base.OnCreate(savedInstanceState);


            Kp2aLog.Log("FileSelect.OnCreate");



            _dbHelper = App.Kp2a.FileDbHelper;
            SetContentView(Resource.Layout.file_selection);


            if (ShowRecentFiles())
            {
                _recentMode = true;


                FindViewById(Resource.Id.recent_files).Visibility = ViewStates.Visible;
                Android.Util.Log.Debug("KP2A", "Recent files visible");
            }
            else
            {
                FindViewById(Resource.Id.recent_files).Visibility = ViewStates.Invisible;
                Android.Util.Log.Debug("KP2A", "Recent files invisible");
#if NoNet
                ImageView imgView = FindViewById(Resource.Id.splashlogo) as ImageView;
                if (imgView != null)
                {
                    imgView.SetImageDrawable(Resources.GetDrawable(Resource.Drawable.splashlogo_offline));
                }
#endif
            }

            Button openFileButton = (Button)FindViewById(Resource.Id.start_open_file);

            EventHandler openFileButtonClick = (sender, e) =>
            {
                Intent intent = new Intent(this, typeof(SelectStorageLocationActivity));
                intent.PutExtra(FileStorageSelectionActivity.AllowThirdPartyAppGet, true);
                intent.PutExtra(FileStorageSelectionActivity.AllowThirdPartyAppSend, false);
                intent.PutExtra(SelectStorageLocationActivity.ExtraKeyWritableRequirements, (int)SelectStorageLocationActivity.WritableRequirements.WriteDesired);
                intent.PutExtra(FileStorageSetupDefs.ExtraIsForSave, false);
                StartActivityForResult(intent, RequestCodeSelectIoc);
            };
            openFileButton.Click += openFileButtonClick;

            //CREATE NEW
            Button       createNewButton      = (Button)FindViewById(Resource.Id.start_create);
            EventHandler createNewButtonClick = (sender, e) =>
            {
                //ShowFilenameDialog(false, true, true, Android.OS.Environment.ExternalStorageDirectory + GetString(Resource.String.default_file_path), "", Intents.RequestCodeFileBrowseForCreate)
                Intent i = new Intent(this, typeof(CreateDatabaseActivity));
                i.PutExtra("MakeCurrent", Intent.GetBooleanExtra("MakeCurrent", true));

                i.SetFlags(ActivityFlags.ForwardResult);
                StartActivity(i);
                Finish();
            };
            createNewButton.Click += createNewButtonClick;

            /*//CREATE + IMPORT
             *          Button createImportButton = (Button)FindViewById(Resource.Id.start_create_import);
             *          createImportButton.Click += (object sender, EventArgs e) =>
             *          {
             *                  openButton.Visibility = ViewStates.Gone;
             *                  createButton.Visibility = ViewStates.Visible;
             *                  enterFilenameDetails.Text = GetString(Resource.String.enter_filename_details_create_import);
             *                  enterFilenameDetails.Visibility = enterFilenameDetails.Text == "" ? ViewStates.Gone : ViewStates.Visible;
             *                  // Set the initial value of the filename
             *                  EditText filename = (EditText)FindViewById(Resource.Id.file_filename);
             *                  filename.Text = Android.OS.Environment.ExternalStorageDirectory + GetString(Resource.String.default_file_path);
             *
             *          };*/

            FindViewById <Switch>(Resource.Id.local_backups_switch).CheckedChange += (sender, args) => { FillData(); };

            FillData();

            if (savedInstanceState != null)
            {
                _recentMode = savedInstanceState.GetBoolean(BundleKeyRecentMode, _recentMode);
            }
        }
Ejemplo n.º 5
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            _design.ApplyTheme();
            base.OnCreate(savedInstanceState);


            Kp2aLog.Log("FileSelect.OnCreate");
            Kp2aLog.Log("FileSelect:apptask=" + Intent.GetStringExtra("KP2A_APPTASK"));

            if (Intent.Action == Intent.ActionSend)
            {
                AppTask = new SearchUrlTask {
                    UrlToSearchFor = Intent.GetStringExtra(Intent.ExtraText)
                };
            }
            else
            {
                //see PasswordActivity for an explanation
                if (Intent.Flags.HasFlag(ActivityFlags.LaunchedFromHistory))
                {
                    AppTask = new NullTask();
                }
                else
                {
                    AppTask = AppTask.GetTaskInOnCreate(savedInstanceState, Intent);
                }
            }


            _dbHelper = App.Kp2a.FileDbHelper;
            SetContentView(Resource.Layout.file_selection);


            if (ShowRecentFiles())
            {
                _recentMode = true;


                FindViewById(Resource.Id.recent_files).Visibility = ViewStates.Visible;
                Android.Util.Log.Debug("KP2A", "Recent files visible");
            }
            else
            {
                FindViewById(Resource.Id.recent_files).Visibility = ViewStates.Invisible;
                Android.Util.Log.Debug("KP2A", "Recent files invisible");
#if NoNet
                ImageView imgView = FindViewById(Resource.Id.splashlogo) as ImageView;
                if (imgView != null)
                {
                    imgView.SetImageDrawable(Resources.GetDrawable(Resource.Drawable.splashlogo_offline));
                }
#endif
            }

            Button openFileButton = (Button)FindViewById(Resource.Id.start_open_file);

            EventHandler openFileButtonClick = (sender, e) =>
            {
                Intent intent = new Intent(this, typeof(SelectStorageLocationActivity));
                intent.PutExtra(FileStorageSelectionActivity.AllowThirdPartyAppGet, true);
                intent.PutExtra(FileStorageSelectionActivity.AllowThirdPartyAppSend, false);
                intent.PutExtra(SelectStorageLocationActivity.ExtraKeyWritableRequirements, (int)SelectStorageLocationActivity.WritableRequirements.WriteDesired);
                intent.PutExtra(FileStorageSetupDefs.ExtraIsForSave, false);
                StartActivityForResult(intent, RequestCodeSelectIoc);
            };
            openFileButton.Click += openFileButtonClick;

            //CREATE NEW
            Button       createNewButton      = (Button)FindViewById(Resource.Id.start_create);
            EventHandler createNewButtonClick = (sender, e) =>
            {
                //ShowFilenameDialog(false, true, true, Android.OS.Environment.ExternalStorageDirectory + GetString(Resource.String.default_file_path), "", Intents.RequestCodeFileBrowseForCreate)
                Intent i = new Intent(this, typeof(CreateDatabaseActivity));
                this.AppTask.ToIntent(i);
                StartActivityForResult(i, 0);
            };
            createNewButton.Click += createNewButtonClick;

            /*//CREATE + IMPORT
             * Button createImportButton = (Button)FindViewById(Resource.Id.start_create_import);
             * createImportButton.Click += (object sender, EventArgs e) =>
             * {
             *      openButton.Visibility = ViewStates.Gone;
             *      createButton.Visibility = ViewStates.Visible;
             *      enterFilenameDetails.Text = GetString(Resource.String.enter_filename_details_create_import);
             *      enterFilenameDetails.Visibility = enterFilenameDetails.Text == "" ? ViewStates.Gone : ViewStates.Visible;
             *      // Set the initial value of the filename
             *      EditText filename = (EditText)FindViewById(Resource.Id.file_filename);
             *      filename.Text = Android.OS.Environment.ExternalStorageDirectory + GetString(Resource.String.default_file_path);
             *
             * };*/

            FillData();

            if (savedInstanceState != null)
            {
                AppTask     = AppTask.CreateFromBundle(savedInstanceState);
                _recentMode = savedInstanceState.GetBoolean(BundleKeyRecentMode, _recentMode);
            }
        }