示例#1
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);
             *
             *          };*/

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

            FillData();

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