Exemplo n.º 1
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();
            }
        }
Exemplo n.º 2
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();
            }
        }