/// <summary>
        /// Android method called first when an activity is launched.
        /// Sets up the activity with current settings.
        /// </summary>
        /// <param name="savedInstanceState">Bundle containing data passed from calling activity</param>
        protected override void OnCreate(Bundle savedInstanceState)
        {
            try
            {
                base.OnCreate(savedInstanceState);

                // Set our view from the "main" layout resource
                SetContentView(Resource.Layout.Settings);

                settingsControl = new SettingsControl();
                profiles        = settingsControl.GetSettingsProfiles();

                txtProfiles                = FindViewById <TextView>(Resource.Id.txtProfiles);
                txtProfiles.Click         += delegate { EnableCustomProfiles(); };
                spinProfiles               = FindViewById <Spinner>(Resource.Id.spinProfiles);
                spinProfiles.Adapter       = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerDropDownItem, profiles.Select(x => x.ProfileName).ToList());
                spinProfiles.ItemSelected += delegate { PopulateForm(profiles[spinProfiles.SelectedItemPosition]); };
                edtBackendUrl              = FindViewById <EditText>(Resource.Id.edtBackendUrl);
                edtBackendTimeout          = FindViewById <EditText>(Resource.Id.edtBackendTimeout);
                edtDomain         = FindViewById <EditText>(Resource.Id.edtDomain);
                edtUsername       = FindViewById <EditText>(Resource.Id.edtUsername);
                edtPassword       = FindViewById <EditText>(Resource.Id.edtPassword);
                edtFragmentSize   = FindViewById <EditText>(Resource.Id.edtFragmentSize);
                chkIsTestInstance = FindViewById <CheckBox>(Resource.Id.chkTestInstance);
                txtProfileName    = FindViewById <TextView>(Resource.Id.txtProfileName);
                edtProfileName    = FindViewById <EditText>(Resource.Id.edtProfileName);
                linButtons        = FindViewById <LinearLayout>(Resource.Id.linButtons);
                btnSave           = FindViewById <Button>(Resource.Id.btnSave);
                btnSave.Click    += delegate { SaveProfile(); };
                btnCancel         = FindViewById <Button>(Resource.Id.btnCancel);
                btnCancel.Click  += delegate { PopulateForm(currentProfile); };
                btnDelete         = FindViewById <Button>(Resource.Id.btnDelete);
                btnDelete.Click  += delegate { DeleteCustomProfile(); };

                SettingToast = new Toast(this.ApplicationContext);
                Window.SetSoftInputMode(SoftInput.StateAlwaysHidden);

                currentProfile = settingsControl.GetCurrentSettings();

                var settingsIndex = profiles.FindIndex(x => x.ProfileName == currentProfile.ProfileName);

                if (settingsIndex >= 0)
                {
                    spinProfiles.SetSelection(profiles.FindIndex(x => x.ProfileName == currentProfile.ProfileName));
                }
                else
                {
                    spinProfiles.SetSelection(0);
                }
            }
            catch (Exception e)
            {
                Log.Info("MobuAndroid", "Error while setting up settings activity.", e.Message);
                Finish();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Sets up references to UI components, controls and settings.
        /// </summary>
        private void SetupActivity()
        {
            try
            {
                RequestWindowFeature(WindowFeatures.NoTitle);
                SetContentView(Resource.Layout.Update);

                barProgressInner      = FindViewById <ProgressBar>(Resource.Id.barProgressInner);
                barProgressOuter      = FindViewById <ProgressBar>(Resource.Id.barProgressOuter);
                txtCompletedFragments = FindViewById <TextView>(Resource.Id.txtFragments);
                txtPercentage         = FindViewById <TextView>(Resource.Id.txtPercentage);
                txtTime = FindViewById <TextView>(Resource.Id.txtTime);
                txtPackageDescription = FindViewById <TextView>(Resource.Id.txtPackageDescription);
                txtUpdateMessage      = FindViewById <TextView>(Resource.Id.txtUpdateMessage);


                barProgressInner.Visibility      = ViewStates.Invisible;
                barProgressOuter.Visibility      = ViewStates.Invisible;
                txtCompletedFragments.Visibility = ViewStates.Invisible;
                txtPercentage.Visibility         = ViewStates.Invisible;
                txtTime.Visibility = ViewStates.Invisible;

                barProgressInner.Progress  = 0;
                barProgressOuter.Progress  = 0;
                txtCompletedFragments.Text = "0 / 0";
                txtPercentage.Text         = "0 %";
                txtTime.Text = "0 ms";

                settingsControl = new SettingsControl();

                if (settingsControl.CurrentSettingsExist())
                {
                    settings = settingsControl.GetCurrentSettings();
                }
                else
                {
                    AlertDialog.Builder alert = new AlertDialog.Builder(this);
                    alert.SetTitle("No Settings");
                    alert.SetMessage("No settings profile has been setup in Mobu. Please select a settings profile in Mobu to allow updates.");
                    alert.SetNeutralButton("OK", (senderAlert, args) => { EndActivity(); });

                    Dialog dialog = alert.Create();
                    dialog.Show();
                    return;
                }

                webServiceControl = new WebServiceControl(settings);
                fileControl       = new FileControl();
            }
            catch (Exception e)
            {
                Log.Info("MobuAndroid", "Error while setting up update activity.", e.Message);
                EndActivity();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Sets up references to UI components, controls and settings.
        /// </summary>
        void SetupActivity()
        {
            try
            {
                txtInstance      = FindViewById <TextView>(Resource.Id.txtMobuInstance);
                txtServiceStatus = FindViewById <TextView>(Resource.Id.txtMobuWebStatus);
                linAppList       = FindViewById <LinearLayout>(Resource.Id.linAppList);
                linAppList.RemoveAllViewsInLayout();

                settingsControl = new SettingsControl();


                if (!settingsControl.SettingsProfilesExist() || !settingsControl.CurrentSettingsExist())
                {
                    settingsControl.GenerateDefaultSettings();
                }

                ProcessOldSettings();

                if (!settingsControl.CurrentSettingsExist())
                {
                    var profiles = settingsControl.GetSettingsProfiles();
                    settings = profiles.First();
                    settingsControl.SaveCurrentSettings(settings);
                }
                else
                {
                    settings = settingsControl.GetCurrentSettings();
                }

                webServiceControl = new WebServiceControl(settings);

                if (settings.IsTestInstance)
                {
                    txtInstance.SetBackgroundResource(Resource.Drawable.ContainerBackgroundRed);
                    txtInstance.Text = "Instance: Test";
                }
                else
                {
                    txtInstance.SetBackgroundResource(Resource.Drawable.ContainerBackground);
                    txtInstance.Text = "Instance: Production";
                }

                busy = false;
                serviceIsReachable = false;
                serviceStatus      = "Status: Waiting";
                statusIndicator    = ".";
                packages           = new List <PackageDetails>();

                RunUiIndicator();
                RunUpdateServiceStatus();
                RunUpdateStatus();
                RunAutomaticRefresh();

                AccuirePermissions();
            }
            catch (Exception e)
            {
                Log.Info("MobuAndroid", "Error while setting up main activity.", e.Message);
                FinishAndRemoveTask();
            }
        }