Пример #1
0
        public void CommitRockSync( )
        {
            // Everything worked, so store all our values
            RockURL = TempRockUrl;

            RockAuthorizationKey = TempAuthKey;

            MaritalStatus = TempMaritalStatus;

            SchoolGrades = TempSchoolGrades;

            FamilyMemberChildGroupRole = TempChildRole;

            FamilyMemberAdultGroupRole = TempAdultRole;

            FirstTimeVisitAttrib = TempFirstTimeVisit;

            CanCheckInGroupRole = TempCanCheckInRole;

            AllowedCheckInByRole = TempAllowedCheckInByRole;

            ConfigurationTemplates = TempConfigurationTemplates;

            SetCampuses(TempCampuses);

            // permenantly update the api values.
            RockApi.SetRockURL(RockURL);
            RockApi.SetAuthorizationKey(RockAuthorizationKey);

            // stamp the version as well.
            Version = CURRENT_VERSION;
        }
Пример #2
0
                public RockNetworkManager( )
                {
                    RockApi.SetRockURL(Config.GeneralConfig.RockBaseUrl);
                    RockApi.SetAuthorizationKey(App.Shared.SecuredValues.RockMobileAppAuthorizationKey);

                    // make sure our built in news items have their images in the cache
                    RockLaunchData.Instance.TryCacheEmbeddedNewsImages( );

                    Requesting = false;
                }
        void Start( )
        {
            RockApi.SetRockURL(Config.Instance.RockURL);
            RockApi.SetAuthorizationKey(Config.Instance.RockAuthorizationKey);

            // get the initial config (this is where we call the new Update)
            Config.Instance.UpdateCurrentConfigurationDefinedValue(
                delegate(bool result)
            {
                // failure or not, hide the connection UI
                ProgressIndicator.Hidden           = true;
                ProgressIndicator.HidesWhenStopped = true;
                ProgressIndicator.StopAnimating( );

                ConnectingLabel.Hidden = true;

                if (result)
                {
                    // we're good to move on.

                    // first hide the FirstRun (in case it was showing)
                    if (FirstRunViewController != null)
                    {
                        FirstRunViewController.DismissViewController(true, null);
                    }

                    ApplyCurrentConfigSettings( );

                    // add the container, so that when we're done with the login it will already be there.
                    PushViewController(ContainerViewController, false);

                    DisplayLoginScreen(false);
                }
                else
                {
                    // display an error and return them to the first run screen.
                    DisplayFirstRun( );
                }
            });
        }
Пример #4
0
        public void TryBindToRockServer(string rockUrl, string authKey, OnComplete onComplete)
        {
            TempRockUrl = rockUrl;
            TempAuthKey = authKey;

            // this will let us use the url temporarily
            RockApi.SetRockURL(rockUrl);
            RockApi.SetAuthorizationKey(authKey);

            // get the config templates
            GetConfigTemplates(

                // capute the result callback
                delegate(bool result)
            {
                // restore the original URLs, so that they only update
                // if Commit is called.
                RockApi.SetRockURL(RockURL);
                RockApi.SetAuthorizationKey(RockAuthorizationKey);

                // now notify the original caller
                onComplete(result);
            });
        }
Пример #5
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            View.BackgroundColor = Theme.GetColor(Config.Instance.VisualSettings.BackgroundColor);

            // Rock URL Title
            RockUrlTitle = new UILabel();
            RockUrlTitle.Layer.AnchorPoint = CGPoint.Empty;
            RockUrlTitle.Text = "Rock Server Address";
            Theme.StyleLabel(RockUrlTitle, Config.Instance.VisualSettings.LabelStyle);
            RockUrlTitle.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont(Settings.General_LightFont, Config.Instance.VisualSettings.MediumFontSize);
            RockUrlTitle.SizeToFit( );
            View.AddSubview(RockUrlTitle);

            // Rock URL Address
            RockUrlField = new UIInsetTextField( );
            RockUrlField.Layer.AnchorPoint = CGPoint.Empty;
            RockUrlField.Text = Config.Instance.RockURL;
            RockUrlField.AutocorrectionType     = UITextAutocorrectionType.No;
            RockUrlField.AutocapitalizationType = UITextAutocapitalizationType.None;
            RockUrlField.InputAssistantItem.LeadingBarButtonGroups  = null;
            RockUrlField.InputAssistantItem.TrailingBarButtonGroups = null;
            Theme.StyleTextField(RockUrlField, Config.Instance.VisualSettings.TextFieldStyle);
            RockUrlField.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont(Settings.General_RegularFont, Config.Instance.VisualSettings.MediumFontSize);
            View.AddSubview(RockUrlField);

            // Rock AuthKey Title
            RockAuthKeyTitle = new UILabel();
            RockAuthKeyTitle.Layer.AnchorPoint = CGPoint.Empty;
            RockAuthKeyTitle.Text = "Rock Authorization Key";
            Theme.StyleLabel(RockAuthKeyTitle, Config.Instance.VisualSettings.LabelStyle);
            RockAuthKeyTitle.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont(Settings.General_LightFont, Config.Instance.VisualSettings.MediumFontSize);
            RockAuthKeyTitle.SizeToFit( );
            View.AddSubview(RockAuthKeyTitle);

            // Rock AuthKey Field
            RockAuthKeyField = new UIInsetTextField( );
            RockAuthKeyField.Layer.AnchorPoint = CGPoint.Empty;
            RockAuthKeyField.TextColor         = UIColor.White;
            RockAuthKeyField.Text = Config.Instance.RockAuthorizationKey;
            RockAuthKeyField.AutocorrectionType     = UITextAutocorrectionType.No;
            RockAuthKeyField.AutocapitalizationType = UITextAutocapitalizationType.None;
            RockAuthKeyField.InputAssistantItem.LeadingBarButtonGroups  = null;
            RockAuthKeyField.InputAssistantItem.TrailingBarButtonGroups = null;
            Theme.StyleTextField(RockAuthKeyField, Config.Instance.VisualSettings.TextFieldStyle);
            RockAuthKeyField.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont(Settings.General_RegularFont, Config.Instance.VisualSettings.MediumFontSize);
            View.AddSubview(RockAuthKeyField);

            // setup the campus switch label
            CampusSwitchLabel = new UILabel( );
            CampusSwitchLabel.Layer.AnchorPoint = CGPoint.Empty;
            CampusSwitchLabel.Text = "Autodetect Campus";
            Theme.StyleLabel(CampusSwitchLabel, Config.Instance.VisualSettings.LabelStyle);
            CampusSwitchLabel.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont(Settings.General_LightFont, Config.Instance.VisualSettings.MediumFontSize);
            CampusSwitchLabel.SizeToFit( );
            View.AddSubview(CampusSwitchLabel);

            // default the campus switch to whatever the autodetect preference is
            CampusSwitch = new UISwitch( );
            CampusSwitch.Layer.AnchorPoint = CGPoint.Empty;
            CampusSwitch.OnTintColor       = Theme.GetColor(Config.Instance.VisualSettings.ToggleStyle.ActiveColor);
            CampusSwitch.On = Config.Instance.AutoDetectCampus;
            View.AddSubview(CampusSwitch);


            // Campus Label and Table
            CampusesLabel = new UILabel();
            CampusesLabel.Layer.AnchorPoint = CGPoint.Empty;
            CampusesLabel.Text = "Campus";
            Theme.StyleLabel(CampusesLabel, Config.Instance.VisualSettings.LabelStyle);
            CampusesLabel.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont(Settings.General_LightFont, Config.Instance.VisualSettings.MediumFontSize);
            CampusesLabel.SizeToFit( );
            View.AddSubview(CampusesLabel);

            CampusTableView = new UITableView();
            CampusTableView.Layer.AnchorPoint = CGPoint.Empty;
            CampusTableView.Source            = new CampusTableData()
            {
                Parent = this
            };
            CampusTableView.Layer.CornerRadius = 4;
            View.AddSubview(CampusTableView);


            // Template Label and Table
            TemplateLabel = new UILabel();
            TemplateLabel.Layer.AnchorPoint = CGPoint.Empty;
            TemplateLabel.Text = "Theme";
            Theme.StyleLabel(TemplateLabel, Config.Instance.VisualSettings.LabelStyle);
            TemplateLabel.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont(Settings.General_LightFont, Config.Instance.VisualSettings.MediumFontSize);
            TemplateLabel.SizeToFit( );
            View.AddSubview(TemplateLabel);

            TemplateTableView = new UITableView();
            TemplateTableView.Layer.AnchorPoint = CGPoint.Empty;
            TemplateTableView.Source            = new TemplateTableData()
            {
                Parent = this
            };
            TemplateTableView.Layer.CornerRadius = 4;
            View.AddSubview(TemplateTableView);


            Sync = UIButton.FromType(UIButtonType.System);
            Sync.Layer.AnchorPoint = CGPoint.Empty;
            Sync.SetTitle("Sync", UIControlState.Normal);
            Sync.SetTitleColor(UIColor.White, UIControlState.Normal);
            Theme.StyleButton(Sync, Config.Instance.VisualSettings.DefaultButtonStyle);
            Sync.SizeToFit( );
            View.AddSubview(Sync);

            SyncResultLabel = new UILabel();
            SyncResultLabel.Layer.AnchorPoint = CGPoint.Empty;
            SyncResultLabel.TextColor         = UIColor.White;
            SyncResultLabel.TextAlignment     = UITextAlignment.Center;
            SyncResultLabel.Font = SyncResultLabel.Font.WithSize(36);
            Theme.StyleLabel(SyncResultLabel, Config.Instance.VisualSettings.LabelStyle);
            View.AddSubview(SyncResultLabel);

            Cancel = UIButton.FromType(UIButtonType.System);
            Cancel.Layer.AnchorPoint = CGPoint.Empty;
            Cancel.SetTitle("Cancel", UIControlState.Normal);
            Theme.StyleButton(Cancel, Config.Instance.VisualSettings.DefaultButtonStyle);
            Cancel.SizeToFit( );
            View.AddSubview(Cancel);

            Save = UIButton.FromType(UIButtonType.System);
            Save.Layer.AnchorPoint = CGPoint.Empty;
            Save.SetTitle("Save", UIControlState.Normal);
            Theme.StyleButton(Save, Config.Instance.VisualSettings.PrimaryButtonStyle);
            Save.SetTitleColor(UIColor.LightGray, UIControlState.Disabled);
            Save.SizeToFit( );
            View.AddSubview(Save);

            BlockerView = new UIBlockerView(View, View.Bounds.ToRectF( ));

            // setup the Sync action
            Sync.TouchUpInside += (object sender, EventArgs e) =>
            {
                DownloadRockValues( );
            };

            RockUrlField.EditingDidBegin += (object sender, EventArgs e) =>
            {
                // if they start editing the text field, immediatley disable the submit button.
                // it will be enabled again when they tap Sync and we can verify they connected to Rock.
                ToggleSaveButton(false);

                // clear out lists which will effectively force the user to sync
                ClearLists( );
                CampusTableView.ReloadData( );
                TemplateTableView.ReloadData( );
            };

            RockAuthKeyField.EditingDidBegin += (object sender, EventArgs e) =>
            {
                ToggleSaveButton(false);

                // clear out lists which will effectively force the user to sync
                ClearLists( );
                CampusTableView.ReloadData( );
                TemplateTableView.ReloadData( );
            };

            RockUrlField.ShouldReturn += ( UITextField textField) =>
            {
                DownloadRockValues( );
                return(true);
            };

            Save.TouchUpInside += (object sender, EventArgs e) =>
            {
                ToggleSaveButton(false);

                BlockerView.BringToFront( );
                BlockerView.Show(delegate
                {
                    // officially save and switch over the server
                    Config.Instance.CommitRockSync( );

                    // take the new campus
                    if (CampusSwitch.On)
                    {
                        Config.Instance.AutoDetectCampus = true;
                    }
                    else
                    {
                        Config.Instance.AutoDetectCampus = false;
                    }

                    // go ahead and set the campus index to what they chose.
                    // If auto-detect is on, it'll override it next time they run
                    int campusIndex = CampusTableView.IndexPathForSelectedRow.Row;
                    Config.Instance.SelectedCampusIndex = campusIndex;

                    int templateIndex = TemplateTableView.IndexPathForSelectedRow.Row;
                    Config.Instance.SetConfigurationDefinedValue(ConfigurationTemplates[templateIndex],
                                                                 delegate(bool result)
                    {
                        BlockerView.Hide(delegate
                        {
                            if (result == true)
                            {
                                // it worked, so now apply the campus and URL
                                Rock.Mobile.Util.Debug.DisplayError("Settings Updated", "Please restart the app (double tap and flick to quit) to see changes.");

                                Parent.SettingsComplete( );
                            }
                            else
                            {
                                // setting the theme failed, but the server switch worked.
                                ToggleSaveButton(true);
                                DisplaySyncResult(Strings.General_Rock_ThemeFailed);
                            }
                        });
                    });
                });
            };

            Cancel.TouchUpInside += (object sender, EventArgs e) =>
            {
                // restore the rock URL
                RockApi.SetRockURL(Config.Instance.RockURL);

                Parent.SettingsComplete( );
            };
            //
        }