예제 #1
0
        /// <summary>
        /// Adjusts the container views based on how far along X they should move.
        /// Also updates the fade out view so it darkens or lightens as needed.
        /// </summary>
        /// <param name="xPos">X position.</param>
        void PanContainerViews(float xPos)
        {
            // there's a small chance of an exception being thrown
            // due to one of the below not being valid. Repro'ing this is not easy,
            // so the safer route is to just guard against all of them, and
            // worst case we'll skip a frame of animation

            if (DropShadowView != null &&
                View != null &&
                ActiveTaskFrame != null &&
                NavToolbar != null &&
                NavToolbar.ButtonLayout != null &&
                FadeOutFrame != null)
            {
                DropShadowView.SetX(xPos - DropShadowXOffset);
                View.SetX(xPos);
                ActiveTaskFrame.SetX(xPos);
                NavToolbar.ButtonLayout.SetX(xPos);
                FadeOutFrame.SetX(xPos);

                // now determine the alpha
                float maxSlide = Springboard.GetSpringboardDisplayWidth( );
                FadeOutFrame.Alpha = Math.Min(xPos / maxSlide, PrivatePrimaryContainerConfig.SlideDarkenAmount);
            }
        }
예제 #2
0
                protected void ReportException(string errorMsg, Exception e)
                {
                    Rock.Mobile.Threading.Util.PerformOnUIThread(delegate
                    {
                        FinishNotesCreation( );

                        // if we have more download attempts, use them before reporting
                        // an error to the user.
                        if (NoteDownloadRetries > 0)
                        {
                            NoteDownloadRetries--;

                            PrepareCreateNotes( );
                        }
                        else
                        {
                            if (e != null)
                            {
                                errorMsg += e.Message;
                            }

                            if (MobileApp.Shared.Network.RockLaunchData.Instance.Data.DeveloperModeEnabled == true)
                            {
                                Springboard.DisplayError("Note Error", errorMsg);
                            }
                            else
                            {
                                ResultView.Show(MessagesStrings.Error_Title,
                                                PrivateControlStylingConfig.Result_Symbol_Failed,
                                                MessagesStrings.Error_Message,
                                                GeneralStrings.Retry);
                            }
                        }
                    });
                }
예제 #3
0
        public void ToggleFullscreen(bool fullscreenEnabled)
        {
            // useful for when a video wants to be fullscreen
            if (fullscreenEnabled == true)
            {
                Navbar.Visibility = ViewStates.Gone;
                NavToolbar.ButtonLayout.Visibility = ViewStates.Gone;

                // if we're in landscape wide, ensure the springboard is closed while in fullscreen.
                if (MainActivity.IsLandscapeWide( ) == true)
                {
                    PanContainerViews(0);

                    Point displaySize = new Point();
                    Activity.WindowManager.DefaultDisplay.GetSize(displaySize);
                    float displayWidth = displaySize.X;
                    SetContainerWidth((int)displayWidth);
                }
            }
            else
            {
                Navbar.Visibility = ViewStates.Visible;
                NavToolbar.ButtonLayout.Visibility = ViewStates.Visible;

                // if we're in landscape wide, ensure the springboard is closed while in fullscreen.
                if (MainActivity.IsLandscapeWide( ) == true)
                {
                    PanContainerViews(Springboard.GetSpringboardDisplayWidth( ));
                    SetContainerWidth(GetCurrentContainerDisplayWidth( ));
                }
            }
        }
예제 #4
0
                bool CheckDebug( )
                {
                    bool debugKeyEntered = false;

                    if (RequestText.Text.ToLower( ).Trim( ) == "clear cache")
                    {
                        debugKeyEntered = true;

                        FileCache.Instance.CleanUp(true);
                        Springboard.DisplayError("Cache Cleared", "All cached items have been deleted");
                    }
                    else if (RequestText.Text.ToLower( ).Trim( ) == "developer")
                    {
                        debugKeyEntered = true;

                        MobileApp.Shared.Network.RockLaunchData.Instance.Data.DeveloperModeEnabled = !MobileApp.Shared.Network.RockLaunchData.Instance.Data.DeveloperModeEnabled;
                        Springboard.DisplayError("Developer Mode",
                                                 string.Format("Developer Mode has been toggled: {0}", MobileApp.Shared.Network.RockLaunchData.Instance.Data.DeveloperModeEnabled == true ? "ON" : "OFF"));
                    }
                    else if (RequestText.Text.ToLower( ).Trim( ) == "version")
                    {
                        debugKeyEntered = true;

                        Springboard.DisplayError("Current Version", GeneralConfig.Version.ToString( ));
                    }
                    else
                    {
                        // otherwise, see if our special UI caught it.
                        debugKeyEntered = UISpecial.Trigger(RequestText.Text.ToLower( ).Trim( ), View, this, ParentTask, null);
                    }

                    return(debugKeyEntered);
                }
예제 #5
0
        public void OnScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY)
        {
            // sanity check, as the events could be null.
            if (e1 != null && e2 != null)
            {
                // only allow it if we're NOT animating, the task is ok with us panning, and we're in portrait mode.
                if (Animating == false &&
                    ActiveTask.CanContainerPan( ) &&
                    Activity.Resources.Configuration.Orientation == Android.Content.Res.Orientation.Portrait)
                {
                    switch (Panning)
                    {
                    case PanState.Monitoring:
                    {
                        TotalPanY += Math.Abs(e2.RawY - e1.RawY);
                        TotalPanX += Math.Abs(e2.RawX - e1.RawX);

                        FrameCount++;

                        if (FrameCount > sNumPanTrackingFrames)
                        {
                            // decide how to proceed
                            Panning = PanState.None;

                            // put simply, if their total X was more than their total Y, well then,
                            // lets pan.
                            if (TotalPanX > TotalPanY)
                            {
                                Panning = PanState.Panning;

                                // mark where the panning began, so we can move the field appropriately
                                PanStartX = e2.RawX;

                                PanelOriginX = View.GetX( );
                            }
                            else
                            {
                                // Y was greater than X, so they probably intended to scroll, not pan.
                                Panning = PanState.None;
                            }
                        }
                        break;
                    }

                    case PanState.Panning:
                    {
                        distanceX = e2.RawX - PanStartX;

                        float xPos         = PanelOriginX + distanceX;
                        float revealAmount = Springboard.GetSpringboardDisplayWidth( );
                        xPos = Math.Max(0, Math.Min(xPos, revealAmount));

                        PanContainerViews(xPos);
                        break;
                    }
                    }
                }
            }
        }
예제 #6
0
        public void LayoutChanged( )
        {
            // if we just entered landscape wide mode
            if (MainActivity.IsLandscapeWide( ) == true)
            {
                // turn off the springboard button
                SpringboardRevealButton.Enabled = false;
                SpringboardRevealed             = true;

                // move the container over so the springboard is revealed
                PanContainerViews(Springboard.GetSpringboardDisplayWidth( ));

                // turn off the shadow
                FadeOutFrame.Alpha      = 0.0f;
                FadeOutFrame.Visibility = ViewStates.Invisible;

                // resize the containers to use the remaining width
                int containerWidth = GetCurrentContainerDisplayWidth( );

                SetContainerWidth(containerWidth);

                ToggleInputViewChecker(false);
            }
            // we're going back to portrait (or normal landscape)
            else
            {
                // enable the springboard reveal button
                SpringboardRevealed = false;

                // close the springboard
                PanContainerViews(0);
                FadeOutFrame.Visibility = ViewStates.Visible;

                // resize the containers to use the full device width
                Point displaySize = new Point( );
                Activity.WindowManager.DefaultDisplay.GetSize(displaySize);
                float displayWidth = displaySize.X;

                SetContainerWidth((int)displayWidth);

                // only allow the reveal button if the device is in portrait.
                if (MainActivity.IsPortrait( ))
                {
                    SpringboardRevealButton.Enabled = true;
                }
                else
                {
                    SpringboardRevealButton.Enabled = false;
                }
            }
        }
예제 #7
0
        void UIThread_LoginComplete(System.Net.HttpStatusCode code, string desc)
        {
            BlockerView.Hide(delegate
            {
                switch (code)
                {
                case System.Net.HttpStatusCode.OK:
                    {
                        // see if we should set their viewing campus
                        if (RockMobileUser.Instance.PrimaryFamily.CampusId.HasValue == true)
                        {
                            RockMobileUser.Instance.ViewingCampus = RockMobileUser.Instance.PrimaryFamily.CampusId.Value;
                        }

                        // if they have a profile picture, grab it.
                        RockMobileUser.Instance.TryDownloadProfilePicture(PrivateGeneralConfig.ProfileImageSize, ProfileImageComplete);

                        // update the UI
                        FadeLoginResult(true);
                        LoginResult.Field.Text = string.Format(LoginStrings.Success, RockMobileUser.Instance.PreferredName( ));

                        // start the timer, which will notify the springboard we're logged in when it ticks.
                        LoginSuccessfulTimer.Elapsed += (object sender, System.Timers.ElapsedEventArgs e) =>
                        {
                            // when the timer fires, notify the springboard we're done.
                            Rock.Mobile.Threading.Util.PerformOnUIThread(delegate
                            {
                                Springboard.ResignModelViewController(this, null);
                            });
                        };

                        LoginSuccessfulTimer.Start( );

                        break;
                    }

                default:
                    {
                        // if we couldn't get their profile, that should still count as a failed login.
                        SetUIState(LoginState.Out);

                        // failed to login for some reason
                        FadeLoginResult(true);
                        LoginResult.Field.Text = LoginStrings.Error_Unknown;

                        RockMobileUser.Instance.LogoutAndUnbind( );
                        break;
                    }
                }
            });
        }
예제 #8
0
        public void SubmitActionSheetClicked(object sender, UIButtonEventArgs e)
        {
            switch (e.ButtonIndex)
            {
            // submit
            case 0: Dirty = false; SubmitChanges( ); Springboard.ResignModelViewController(this, null); break;

            // No, don't submit
            case 1: Dirty = false; Springboard.ResignModelViewController(this, null); break;

            // cancel
            case 2: break;
            }
        }
예제 #9
0
        public void OnUp(MotionEvent e)
        {
            // if we were panning
            if (Panning == PanState.Panning)
            {
                float revealAmount = Springboard.GetSpringboardDisplayWidth( );
                if (SpringboardRevealed == false)
                {
                    // since the springboard wasn't revealed, require that they moved
                    // at least 1/5th the amount before opening it
                    if (View.GetX( ) > revealAmount * .20f)
                    {
                        RevealSpringboard(true);
                    }
                    else
                    {
                        RevealSpringboard(false);
                    }
                }
                else
                {
                    if (View.GetX( ) < revealAmount * .85f)
                    {
                        RevealSpringboard(false);
                    }
                    else
                    {
                        RevealSpringboard(true);
                    }
                }
            }
            else
            {
                // if the task should allowe input, reveal the nav bar
                if (ShouldTaskAllowInput( ) == true)
                {
                    // let the active task know that the user released input
                    ActiveTask.OnUp(e);
                }
                else if (ShouldSpringboardAllowInput( ) == true)
                {
                    // else close the springboard
                    RevealSpringboard(false);
                }
            }

            // no matter what, we're done panning
            Panning = PanState.None;
        }
예제 #10
0
        public void ProfileImageComplete(System.Net.HttpStatusCode code, string desc)
        {
            switch (code)
            {
            case System.Net.HttpStatusCode.OK:
            {
                // sweet! make the UI update.
                Rock.Mobile.Threading.Util.PerformOnUIThread(delegate { Springboard.UpdateProfilePic( ); });
                break;
            }

            default:
            {
                // bummer, we couldn't get their profile picture. Doesn't really matter...
                break;
            }
            }
        }
예제 #11
0
        public void RevealSpringboard(bool wantReveal)
        {
            if (!Animating)
            {
                Animating = true;

                int xOffset = wantReveal ? (int)Springboard.GetSpringboardDisplayWidth( ) : 0;

                // setup an animation from our current mask scale to the new one.
                XPosAnimator = ValueAnimator.OfInt((int)View.GetX( ), xOffset);

                XPosAnimator.AddUpdateListener(this);
                XPosAnimator.AddListener(new NavbarAnimationListener( )
                {
                    NavbarFragment = this
                });
                XPosAnimator.SetDuration((int)(PrivatePrimaryContainerConfig.SlideRate * 1000.0f));
                XPosAnimator.Start();
            }
        }
예제 #12
0
        void OnResultViewDone( )
        {
            switch (State)
            {
            case RegisterState.Success:
            {
                Springboard.ResignModelViewController(this, null);
                ScrollView.ScrollEnabled = true;
                State = RegisterState.None;
                break;
            }

            case RegisterState.Fail:
            {
                ResultView.Hide( );
                ScrollView.ScrollEnabled = true;
                State = RegisterState.None;
                break;
            }
            }
        }
예제 #13
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            Window.AddFlags(WindowManagerFlags.Fullscreen);

            Rock.Mobile.PlatformSpecific.Android.Core.Context = this;

            // default our app to protrait mode, and let the notes change it.
            if (SupportsLandscapeWide() && Rock.Mobile.PlatformSpecific.Android.Core.IsOrientationUnlocked())
            {
                RequestedOrientation = Android.Content.PM.ScreenOrientation.FullSensor;
            }
            else
            {
                RequestedOrientation = Android.Content.PM.ScreenOrientation.Portrait;
            }

            DisplayMetrics metrics = Resources.DisplayMetrics;

            Rock.Mobile.Util.Debug.WriteLine(string.Format("Android Device detected dpi: {0}", metrics.DensityDpi));

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

            // get the active task frame and give it to the springboard
            FrameLayout layout = FindViewById <FrameLayout>(Resource.Id.activetask);

            Rock.Mobile.UI.PlatformBaseUI.Init();
            MapsInitializer.Initialize(this);

            Springboard = FragmentManager.FindFragmentById(Resource.Id.springboard) as Springboard;
            Springboard.SetActiveTaskFrame(layout);

            // Register HockeyApp
            #if !DEBUG
            CrashManager.Register(this, App.Shared.SecuredValues.Droid_HockeyApp_Id, new HockeyCrashManagerSettings());
            MetricsManager.Register(Application, App.Shared.SecuredValues.Droid_HockeyApp_Id);
            #endif
        }
예제 #14
0
                public override bool OnDoubleTap(MotionEvent e)
                {
                    // a double tap CAN create a user note. If it did,
                    // we want to know that so we suppress further input until we receive
                    // TouchUp
                    try
                    {
                        DidGestureCreateNote = Note.DidDoubleTap(new System.Drawing.PointF(e.GetX( ), e.GetY( )));

                        // if the gesture did create a note, flag that so we don't show the tutorial anymore.
                        if (DidGestureCreateNote == true)
                        {
                            MobileApp.Shared.Network.RockMobileUser.Instance.UserNoteCreated = true;
                        }
                    }
                    catch (Exception ex)
                    {
                        Springboard.DisplayError("Notes", ex.Message);
                        DidGestureCreateNote = false;
                    }

                    return(true);
                }
예제 #15
0
                public override void OnClick(Android.App.Fragment source, int buttonId, object context = null)
                {
                    // only handle input if the springboard is closed
                    if (NavbarFragment.ShouldTaskAllowInput( ))
                    {
                        // decide what to do.
                        if (source == MainPage)
                        {
                            // on the main page, if the buttonId was -1, the user tapped the header,
                            // so we need to either go to the Watch or Take Notes page
                            if (buttonId == -1)
                            {
                                // the context is the button they clicked (watch or take notes)
                                int buttonChoice = (int)context;

                                // 0 is listen
                                if (buttonChoice == 0)
                                {
                                    ListenPage.MediaUrl = MainPage.SeriesEntries[0].Series.Messages[0].AudioUrl;
                                    ListenPage.ShareUrl = MainPage.SeriesEntries[0].Series.Messages[0].ShareUrl;
                                    ListenPage.Name     = MainPage.SeriesEntries[0].Series.Messages[0].Name;
                                    PresentFragment(ListenPage, true);
                                }
                                // 1 is watch
                                else if (buttonChoice == 1)
                                {
                                    WatchPage.MediaUrl = MainPage.SeriesEntries[0].Series.Messages[0].WatchUrl;
                                    WatchPage.ShareUrl = MainPage.SeriesEntries[0].Series.Messages[0].ShareUrl;
                                    WatchPage.Name     = MainPage.SeriesEntries[0].Series.Messages[0].Name;
                                    PresentFragment(WatchPage, true);
                                }
                                // 2 is read
                                else if (buttonChoice == 2)
                                {
                                    NotesPage.NoteUrl  = MainPage.SeriesEntries[0].Series.Messages[0].NoteUrl;
                                    NotesPage.NoteName = MainPage.SeriesEntries[0].Series.Messages[0].Name;

                                    PresentFragment(NotesPage, true);
                                }
                                // 3 is discussion guide
                                else if (buttonChoice == 3)
                                {
                                    DiscGuidePage.DiscGuideURL = MainPage.SeriesEntries[0].Series.Messages[0].DiscussionGuideUrl;
                                    PresentFragment(DiscGuidePage, true);
                                }
                            }
                            else
                            {
                                DetailsPage.Series = MainPage.SeriesEntries[buttonId].Series;
                                PresentFragment(DetailsPage, true);
                            }
                        }
                        else if (source == DetailsPage)
                        {
                            // the context is the button they clicked (watch or take notes)
                            int buttonChoice = (int)context;

                            // 0 is listen
                            if (buttonChoice == 0)
                            {
                                ListenPage.MediaUrl = DetailsPage.Series.Messages[buttonId].AudioUrl;
                                ListenPage.ShareUrl = DetailsPage.Series.Messages[buttonId].ShareUrl;
                                ListenPage.Name     = DetailsPage.Series.Messages[buttonId].Name;
                                PresentFragment(ListenPage, true);
                            }
                            // 1 is watch
                            else if (buttonChoice == 1)
                            {
                                WatchPage.MediaUrl = DetailsPage.Series.Messages[buttonId].WatchUrl;
                                WatchPage.ShareUrl = DetailsPage.Series.Messages[buttonId].ShareUrl;
                                WatchPage.Name     = DetailsPage.Series.Messages[buttonId].Name;
                                PresentFragment(WatchPage, true);
                            }
                            // 2 is read
                            else if (buttonChoice == 2)
                            {
                                NotesPage.NoteUrl  = DetailsPage.Series.Messages[buttonId].NoteUrl;
                                NotesPage.NoteName = DetailsPage.Series.Messages[buttonId].Name;

                                PresentFragment(NotesPage, true);
                            }
                            // 3 is discussion guide
                            else if (buttonChoice == 3)
                            {
                                DiscGuidePage.DiscGuideURL = DetailsPage.Series.Messages[buttonId].DiscussionGuideUrl;
                                PresentFragment(DiscGuidePage, true);
                            }
                        }
                        else if (source == NotesPage)
                        {
                            NotesFragment.UrlClickParams clickParams = (NotesFragment.UrlClickParams)context;

                            if (Springboard.IsAppURL(clickParams.Url) == true)
                            {
                                NavbarFragment.HandleAppURL(clickParams.Url);
                            }
                            else if (App.Shared.BibleRenderer.IsBiblePrefix(clickParams.Url))
                            {
                                BiblePassagePage            = new BiblePassageFragment(clickParams.Url);
                                BiblePassagePage.ParentTask = this;
                                PresentFragment(BiblePassagePage, true);
                            }
                            else
                            {
                                // the context is the activeURL to visit.
                                WebViewPage.DisableIdleTimer = true;
                                TaskWebFragment.HandleUrl(clickParams.UseExternalBrowser,
                                                          clickParams.UseImpersonationToken,
                                                          clickParams.Url,
                                                          this,
                                                          WebViewPage);
                            }
                        }
                        else if (source == DiscGuidePage)
                        {
                            // Discussion Guide page only has one button, so if it was clicked,
                            // let them view the guide.

                            WebViewPage.DisableIdleTimer = true;
                            TaskWebFragment.HandleUrl(true,
                                                      false,
                                                      DiscGuidePage.DiscGuideURL,
                                                      this,
                                                      WebViewPage);
                        }
                    }
                }
예제 #16
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();


            // setup the fake header
            HeaderView = new UIView( );
            View.AddSubview(HeaderView);
            HeaderView.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BackgroundColor);

            // set the title image for the bar if there's no safe area defined. (A safe area is like, say, the notch for iPhone X)
            nfloat safeAreaTopInset = 0;

            // Make sure they're on iOS 11 before checking for insets. This is only needed for iPhone X anyways, which shipped with iOS 11.
            if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
            {
                safeAreaTopInset = UIApplication.SharedApplication.KeyWindow.SafeAreaInsets.Top;
            }

            if (safeAreaTopInset == 0)
            {
                string imagePath = NSBundle.MainBundle.BundlePath + "/" + PrivatePrimaryNavBarConfig.LogoFile_iOS;
                LogoView = new UIImageView(new UIImage(imagePath));
                LogoView.Layer.AnchorPoint = CGPoint.Empty;
                LogoView.SizeToFit( );
                HeaderView.AddSubview(LogoView);
            }

            ScrollView       = new UIScrollViewWrapper();
            ScrollView.Frame = new CGRect(View.Frame.Left, HeaderView.Frame.Bottom, View.Frame.Width, View.Frame.Height - HeaderView.Frame.Height);
            View.AddSubview(ScrollView);
            ScrollView.Parent = this;

            // logged in sanity check.
            //if( RockMobileUser.Instance.LoggedIn == true ) throw new Exception("A user cannot be logged in when registering. How did you do this?" );

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

            //setup styles
            View.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BackgroundColor);

            UserNameText = new StyledTextField();
            ScrollView.AddSubview(UserNameText.Background);
            UserNameText.Field.AutocapitalizationType = UITextAutocapitalizationType.None;
            UserNameText.Field.AutocorrectionType     = UITextAutocorrectionType.No;
            ControlStyling.StyleTextField(UserNameText.Field, RegisterStrings.UsernamePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ControlStyling.StyleBGLayer(UserNameText.Background);

            PasswordText = new StyledTextField();
            ScrollView.AddSubview(PasswordText.Background);
            PasswordText.Field.AutocapitalizationType = UITextAutocapitalizationType.None;
            PasswordText.Field.AutocorrectionType     = UITextAutocorrectionType.No;
            PasswordText.Field.SecureTextEntry        = true;
            ControlStyling.StyleTextField(PasswordText.Field, RegisterStrings.PasswordPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ControlStyling.StyleBGLayer(PasswordText.Background);

            ConfirmPasswordText = new StyledTextField();
            ScrollView.AddSubview(ConfirmPasswordText.Background);
            ConfirmPasswordText.Field.SecureTextEntry = true;
            ControlStyling.StyleTextField(ConfirmPasswordText.Field, RegisterStrings.ConfirmPasswordPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ControlStyling.StyleBGLayer(ConfirmPasswordText.Background);

            NickNameText = new StyledTextField();
            ScrollView.AddSubview(NickNameText.Background);
            NickNameText.Field.AutocapitalizationType = UITextAutocapitalizationType.Words;
            NickNameText.Field.AutocorrectionType     = UITextAutocorrectionType.No;
            ControlStyling.StyleTextField(NickNameText.Field, RegisterStrings.NickNamePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ControlStyling.StyleBGLayer(NickNameText.Background);

            LastNameText = new StyledTextField();
            ScrollView.AddSubview(LastNameText.Background);
            LastNameText.Field.AutocapitalizationType = UITextAutocapitalizationType.Words;
            LastNameText.Field.AutocorrectionType     = UITextAutocorrectionType.No;
            ControlStyling.StyleTextField(LastNameText.Field, RegisterStrings.LastNamePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ControlStyling.StyleBGLayer(LastNameText.Background);

            EmailText = new StyledTextField();
            ScrollView.AddSubview(EmailText.Background);
            EmailText.Field.AutocapitalizationType = UITextAutocapitalizationType.None;
            EmailText.Field.AutocorrectionType     = UITextAutocorrectionType.No;
            ControlStyling.StyleTextField(EmailText.Field, RegisterStrings.EmailPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ControlStyling.StyleBGLayer(EmailText.Background);

            CellPhoneText = new StyledTextField();
            ScrollView.AddSubview(CellPhoneText.Background);
            CellPhoneText.Field.AutocapitalizationType = UITextAutocapitalizationType.None;
            CellPhoneText.Field.AutocorrectionType     = UITextAutocorrectionType.No;
            ControlStyling.StyleTextField(CellPhoneText.Field, RegisterStrings.CellPhonePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ControlStyling.StyleBGLayer(CellPhoneText.Background);

            DoneButton = UIButton.FromType(UIButtonType.System);
            ScrollView.AddSubview(DoneButton);
            ControlStyling.StyleButton(DoneButton, RegisterStrings.RegisterButton, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            DoneButton.SizeToFit( );


            CancelButton = UIButton.FromType(UIButtonType.System);
            ScrollView.AddSubview(CancelButton);
            CancelButton.SetTitleColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.TextField_PlaceholderTextColor), UIControlState.Normal);
            CancelButton.SetTitle(GeneralStrings.Cancel, UIControlState.Normal);
            CancelButton.SizeToFit( );


            // Allow the return on username and password to start
            // the login process
            NickNameText.Field.ShouldReturn += TextFieldShouldReturn;
            LastNameText.Field.ShouldReturn += TextFieldShouldReturn;

            EmailText.Field.ShouldReturn += TextFieldShouldReturn;

            // If submit is pressed with dirty changes, prompt the user to save them.
            DoneButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                RegisterUser( );

                HideKeyboard( );
            };

            // On logout, make sure the user really wants to log out.
            CancelButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                // if there were changes, create an action sheet for them to confirm.
                UIAlertController actionSheet = UIAlertController.Create(RegisterStrings.ConfirmCancelReg,
                                                                         null,
                                                                         UIAlertControllerStyle.ActionSheet);

                if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
                {
                    actionSheet.PopoverPresentationController.SourceView = CancelButton;
                    actionSheet.PopoverPresentationController.SourceRect = CancelButton.Bounds;
                }

                UIAlertAction yesAction = UIAlertAction.Create(GeneralStrings.Yes, UIAlertActionStyle.Destructive, delegate
                {
                    Springboard.ResignModelViewController(this, null);
                });
                actionSheet.AddAction(yesAction);


                // let them cancel, too
                UIAlertAction cancelAction = UIAlertAction.Create(GeneralStrings.Cancel, UIAlertActionStyle.Cancel, delegate { });
                actionSheet.AddAction(cancelAction);

                PresentViewController(actionSheet, true, null);
            };

            ResultView = new UIResultView(ScrollView, View.Frame.ToRectF( ), OnResultViewDone);
        }
예제 #17
0
 public override UIStatusBarStyle PreferredStatusBarStyle()
 {
     return(Springboard.PreferredStatusBarStyle( ));
 }
예제 #18
0
 public override bool PrefersStatusBarHidden()
 {
     return(Springboard.PrefersStatusBarHidden());
 }
예제 #19
0
 public override UIInterfaceOrientationMask GetSupportedInterfaceOrientations( )
 {
     return(Springboard.GetSupportedInterfaceOrientations( ));
 }
예제 #20
0
 public override bool ShouldAutorotate()
 {
     return(Springboard.ShouldAutorotate());
 }
예제 #21
0
                public override void OnClick(Android.App.Fragment source, int buttonId, object context = null)
                {
                    // only handle input if the springboard is closed
                    if (NavbarFragment.ShouldTaskAllowInput( ))
                    {
                        // if the main page had a VALID news item clicked, go to it
                        if (source == MainPage && buttonId < News.Count)
                        {
                            // mark that they tapped this item.
                            NewsAnalytic.Instance.Trigger(NewsAnalytic.Read, MainPage.News[buttonId].News.Title);

                            // either take them to the details page, or skip it and go straight to Learn More.
                            if (MainPage.News[buttonId].News.SkipDetailsPage == true && string.IsNullOrEmpty(MainPage.News[buttonId].News.ReferenceURL) == false)
                            {
                                if (Springboard.IsAppURL(MainPage.News[buttonId].News.ReferenceURL) == true)
                                {
                                    NavbarFragment.HandleAppURL(MainPage.News[buttonId].News.ReferenceURL);
                                }
                                else
                                {
                                    // copy the news item's relevant members. That way, if we're running in debug,
                                    // and they want to override the news item, we can do that below.
                                    string newsUrl             = MainPage.News[buttonId].News.ReferenceURL;
                                    bool   newsImpersonation   = MainPage.News[buttonId].News.IncludeImpersonationToken;
                                    bool   newsExternalBrowser = MainPage.News[buttonId].News.ReferenceUrlLaunchesBrowser;

                                    // If we're running a debug build, see if we should override the news
                                    #if DEBUG
                                    if (DebugConfig.News_Override_Item == true)
                                    {
                                        newsUrl             = DebugConfig.News_Override_ReferenceURL;
                                        newsImpersonation   = DebugConfig.News_Override_IncludeImpersonationToken;
                                        newsExternalBrowser = DebugConfig.News_Override_ReferenceUrlLaunchesBrowser;
                                    }
                                    #endif

                                    TaskWebFragment.HandleUrl(newsExternalBrowser, newsImpersonation, newsUrl, this, WebFragment);
                                }
                            }
                            else
                            {
                                // store the news index they chose so we can manage the 'tap details' page.
                                DetailsPage.SetNewsInfo(MainPage.News[buttonId].News.Title,
                                                        MainPage.News[buttonId].News.Description,
                                                        MainPage.News[buttonId].News.GetDeveloperInfo( ),
                                                        MainPage.News[buttonId].News.ReferenceURL,
                                                        MainPage.News[buttonId].News.ReferenceUrlLaunchesBrowser,
                                                        MainPage.News[buttonId].News.IncludeImpersonationToken,
                                                        MainPage.News[buttonId].News.ImageName,
                                                        MainPage.News[buttonId].News.ImageURL);

                                PresentFragment(DetailsPage, true);
                            }
                        }
                        else if (source == DetailsPage)
                        {
                            // otherwise visit the reference URL
                            if (buttonId == Resource.Id.news_details_launch_url || buttonId == Resource.Id.news_details_header_image_button)
                            {
                                // if this is an app url, handle it internally
                                if (Springboard.IsAppURL(DetailsPage.ReferenceURL) == true)
                                {
                                    NavbarFragment.HandleAppURL(DetailsPage.ReferenceURL);
                                }
                                else
                                {
                                    // copy the news item's relevant members. That way, if we're running in debug,
                                    // and they want to override the news item, we can do that below.
                                    string newsUrl             = DetailsPage.ReferenceURL;
                                    bool   newsImpersonation   = DetailsPage.IncludeImpersonationToken;
                                    bool   newsExternalBrowser = DetailsPage.ReferenceURLLaunchesBrowser;

                                    // If we're running a debug build, see if we should override the news
                                    #if DEBUG
                                    if (DebugConfig.News_Override_Item == true)
                                    {
                                        newsUrl             = DebugConfig.News_Override_ReferenceURL;
                                        newsImpersonation   = DebugConfig.News_Override_IncludeImpersonationToken;
                                        newsExternalBrowser = DebugConfig.News_Override_ReferenceUrlLaunchesBrowser;
                                    }
                                    #endif

                                    TaskWebFragment.HandleUrl(newsExternalBrowser, newsImpersonation, newsUrl, this, WebFragment);
                                }
                            }
                        }
                    }
                }
예제 #22
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            RefreshProfileTimer           = new System.Timers.Timer();
            RefreshProfileTimer.AutoReset = true;
            RefreshProfileTimer.Interval  = 300 * 1000; // every 5 minutes
            RefreshProfileTimer.Elapsed  += (object sender, System.Timers.ElapsedEventArgs e) =>
            {
                Rock.Mobile.Threading.Util.PerformOnUIThread(
                    delegate
                {
                    RefreshProfile( );
                });
            };

            // setup the fake header
            HeaderView = new UIView( );
            View.AddSubview(HeaderView);

            HeaderView.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BackgroundColor);

            // set the title image for the bar if there's no safe area defined. (A safe area is like, say, the notch for iPhone X)
            nfloat safeAreaTopInset = 0;

            // Make sure they're on iOS 11 before checking for insets. This is only needed for iPhone X anyways, which shipped with iOS 11.
            if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
            {
                safeAreaTopInset = UIApplication.SharedApplication.KeyWindow.SafeAreaInsets.Top;
            }

            if (safeAreaTopInset == 0)
            {
                string imagePath = NSBundle.MainBundle.BundlePath + "/" + PrivatePrimaryNavBarConfig.LogoFile_iOS;
                LogoView = new UIImageView(new UIImage(imagePath));
                LogoView.SizeToFit( );
                LogoView.Layer.AnchorPoint = CGPoint.Empty;
                HeaderView.AddSubview(LogoView);
            }

            ScrollView = new UIScrollViewWrapper();

            View.AddSubview(ScrollView);
            ScrollView.Parent = this;

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

            //setup styles
            View.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BackgroundColor);

            NickName = new StyledTextField();
            ScrollView.AddSubview(NickName.Background);

            ControlStyling.StyleTextField(NickName.Field, ProfileStrings.NickNamePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ControlStyling.StyleBGLayer(NickName.Background);
            NickName.Field.AutocapitalizationType = UITextAutocapitalizationType.Words;
            NickName.Field.AutocorrectionType     = UITextAutocorrectionType.No;
            NickName.Field.EditingDidBegin       += (sender, e) => { Dirty = true; };

            LastName = new StyledTextField();

            LastName.Field.AutocapitalizationType = UITextAutocapitalizationType.Words;
            LastName.Field.AutocorrectionType     = UITextAutocorrectionType.No;
            ControlStyling.StyleTextField(LastName.Field, ProfileStrings.LastNamePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ControlStyling.StyleBGLayer(LastName.Background);
            LastName.Field.EditingDidBegin += (sender, e) => { Dirty = true; };

            Email = new StyledTextField();
            ScrollView.AddSubview(Email.Background);
            Email.Field.AutocapitalizationType = UITextAutocapitalizationType.None;
            Email.Field.AutocorrectionType     = UITextAutocorrectionType.No;
            ScrollView.AddSubview(LastName.Background);
            ControlStyling.StyleTextField(Email.Field, ProfileStrings.EmailPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ControlStyling.StyleBGLayer(Email.Background);
            Email.Field.EditingDidBegin += (sender, e) => { Dirty = true; };

            CellPhone = new StyledTextField();
            ScrollView.AddSubview(CellPhone.Background);
            CellPhone.Field.AutocapitalizationType = UITextAutocapitalizationType.None;
            CellPhone.Field.AutocorrectionType     = UITextAutocorrectionType.No;
            ControlStyling.StyleTextField(CellPhone.Field, ProfileStrings.CellPhonePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ControlStyling.StyleBGLayer(CellPhone.Background);
            CellPhone.Field.EditingDidBegin += (sender, e) => { Dirty = true; };


            Street = new StyledTextField();
            ScrollView.AddSubview(Street.Background);
            Street.Field.AutocapitalizationType = UITextAutocapitalizationType.Words;
            Street.Field.AutocorrectionType     = UITextAutocorrectionType.No;
            ControlStyling.StyleTextField(Street.Field, ProfileStrings.StreetPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ControlStyling.StyleBGLayer(Street.Background);
            Street.Field.EditingDidBegin += (sender, e) => { Dirty = true; };

            City = new StyledTextField();
            ScrollView.AddSubview(City.Background);
            City.Field.AutocapitalizationType = UITextAutocapitalizationType.Words;
            City.Field.AutocorrectionType     = UITextAutocorrectionType.No;
            ControlStyling.StyleTextField(City.Field, ProfileStrings.CityPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ControlStyling.StyleBGLayer(City.Background);
            City.Field.EditingDidBegin += (sender, e) => { Dirty = true; };

            State = new StyledTextField();
            ScrollView.AddSubview(State.Background);
            State.Field.AutocapitalizationType = UITextAutocapitalizationType.Words;
            State.Field.AutocorrectionType     = UITextAutocorrectionType.No;
            ControlStyling.StyleTextField(State.Field, ProfileStrings.StatePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ControlStyling.StyleBGLayer(State.Background);
            State.Field.EditingDidBegin += (sender, e) => { Dirty = true; };

            Zip = new StyledTextField();
            ScrollView.AddSubview(Zip.Background);
            Zip.Field.AutocapitalizationType = UITextAutocapitalizationType.None;
            Zip.Field.AutocorrectionType     = UITextAutocorrectionType.No;
            ControlStyling.StyleTextField(Zip.Field, ProfileStrings.ZipPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ControlStyling.StyleBGLayer(Zip.Background);
            Zip.Field.EditingDidBegin += (sender, e) => { Dirty = true; };


            // Gender
            Gender = new StyledTextField();
            ScrollView.AddSubview(Gender.Background);
            Gender.Field.UserInteractionEnabled = false;
            ControlStyling.StyleTextField(Gender.Field, ProfileStrings.GenderPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ControlStyling.StyleBGLayer(Gender.Background);

            GenderButton = new UIButton( );
            ScrollView.AddSubview(GenderButton);
            GenderButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                // don't allow multiple pickers
                if (GenderPicker.Revealed == false && BirthdatePicker.Revealed == false)
                {
                    HideKeyboard( );

                    // if they have a gender selected, default to that.
                    if (string.IsNullOrWhiteSpace(Gender.Field.Text) == false)
                    {
                        ((UIPickerView)GenderPicker.Picker).Select(RockLaunchData.Instance.Data.Genders.IndexOf(Gender.Field.Text) - 1, 0, false);
                    }

                    GenderPicker.TogglePicker(true);
                }
            };
            //

            // Birthday
            Birthdate = new StyledTextField( );
            ScrollView.AddSubview(Birthdate.Background);
            Birthdate.Field.UserInteractionEnabled = false;
            ControlStyling.StyleTextField(Birthdate.Field, ProfileStrings.BirthdatePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ControlStyling.StyleBGLayer(Birthdate.Background);

            BirthdayButton = new UIButton( );
            ScrollView.AddSubview(BirthdayButton);
            BirthdayButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                // don't allow multiple pickers
                if (GenderPicker.Revealed == false && BirthdatePicker.Revealed == false)
                {
                    HideKeyboard( );

                    // setup the default date time to display
                    DateTime initialDate = DateTime.Now;
                    if (string.IsNullOrWhiteSpace(Birthdate.Field.Text) == false)
                    {
                        initialDate = DateTime.Parse(Birthdate.Field.Text);
                    }

                    ((UIDatePicker)BirthdatePicker.Picker).Date = initialDate.DateTimeToNSDate( );
                    BirthdatePicker.TogglePicker(true);
                }
            };
            //


            // setup the home campus chooser
            HomeCampus = new StyledTextField( );
            ScrollView.AddSubview(HomeCampus.Background);
            HomeCampus.Field.UserInteractionEnabled = false;
            ControlStyling.StyleTextField(HomeCampus.Field, ProfileStrings.CampusPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ControlStyling.StyleBGLayer(HomeCampus.Background);

            HomeCampusButton = new UIButton( );
            ScrollView.AddSubview(HomeCampusButton);
            HomeCampusButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                UIAlertController actionSheet = UIAlertController.Create(ProfileStrings.SelectCampus_SourceTitle,
                                                                         ProfileStrings.SelectCampus_SourceDescription,
                                                                         UIAlertControllerStyle.ActionSheet);

                // if the device is a tablet, anchor the menu
                if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
                {
                    actionSheet.PopoverPresentationController.SourceView = HomeCampusButton;
                    actionSheet.PopoverPresentationController.SourceRect = HomeCampusButton.Bounds;
                }

                // for each campus, create an entry in the action sheet, and its callback will assign
                // that campus index to the user's viewing preference
                for (int i = 0; i < RockLaunchData.Instance.Data.Campuses.Count; i++)
                {
                    UIAlertAction campusAction = UIAlertAction.Create(RockLaunchData.Instance.Data.Campuses[i].Name, UIAlertActionStyle.Default, delegate(UIAlertAction obj)
                    {
                        // update the home campus text and flag as dirty
                        HomeCampus.Field.Text = obj.Title;
                        Dirty = true;
                    });

                    actionSheet.AddAction(campusAction);
                }

                // let them cancel, too
                UIAlertAction cancelAction = UIAlertAction.Create(GeneralStrings.Cancel, UIAlertActionStyle.Cancel, delegate { });
                actionSheet.AddAction(cancelAction);

                PresentViewController(actionSheet, true, null);
            };

            DoneButton = new UIButton( );
            ScrollView.AddSubview(DoneButton);
            ControlStyling.StyleButton(DoneButton, ProfileStrings.DoneButtonTitle, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            DoneButton.SizeToFit( );

            LogoutButton = new UIButton( );
            ScrollView.AddSubview(LogoutButton);
            LogoutButton.SetTitleColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.TextField_PlaceholderTextColor), UIControlState.Normal);
            LogoutButton.SetTitle(ProfileStrings.LogoutButtonTitle, UIControlState.Normal);
            LogoutButton.SizeToFit( );


            // setup the pickers
            UILabel genderPickerLabel = new UILabel( );

            ControlStyling.StyleUILabel(genderPickerLabel, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            genderPickerLabel.Text = ProfileStrings.SelectGenderLabel;

            GenderPicker = new PickerAdjustManager(View, ScrollView, genderPickerLabel, Gender.Background);
            UIPickerView genderPicker = new UIPickerView();

            genderPicker.Model = new GenderPickerModel()
            {
                Parent = this
            };
            GenderPicker.SetPicker(genderPicker);


            UILabel birthdatePickerLabel = new UILabel( );

            ControlStyling.StyleUILabel(birthdatePickerLabel, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            birthdatePickerLabel.Text = ProfileStrings.SelectBirthdateLabel;
            BirthdatePicker           = new PickerAdjustManager(View, ScrollView, birthdatePickerLabel, Birthdate.Background);

            UIDatePicker datePicker = new UIDatePicker();

            datePicker.SetValueForKey(UIColor.White, new NSString("textColor"));
            datePicker.Mode          = UIDatePickerMode.Date;
            datePicker.MinimumDate   = new DateTime(1900, 1, 1).DateTimeToNSDate( );
            datePicker.MaximumDate   = DateTime.Now.DateTimeToNSDate( );
            datePicker.ValueChanged += (object sender, EventArgs e) =>
            {
                NSDate pickerDate = ((UIDatePicker)sender).Date;
                Birthdate.Field.Text = string.Format("{0:MMMMM dd yyyy}", pickerDate.NSDateToDateTime( ));
            };
            BirthdatePicker.SetPicker(datePicker);


            // Allow the return on username and password to start
            // the login process
            NickName.Field.ShouldReturn += TextFieldShouldReturn;
            LastName.Field.ShouldReturn += TextFieldShouldReturn;

            Email.Field.ShouldReturn += TextFieldShouldReturn;

            // If submit is pressed with dirty changes, prompt the user to save them.
            DoneButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                // dont' allow changes while the profile is refreshing.
                if (RefreshingProfile == false)
                {
                    if (GenderPicker.Revealed == false && BirthdatePicker.Revealed == false)
                    {
                        if (Dirty == true)
                        {
                            // make sure the input is valid before asking them what they want to do.
                            if (ValidateInput( ))
                            {
                                // if there were changes, create an action sheet for them to confirm.
                                UIAlertController actionSheet = UIAlertController.Create(ProfileStrings.SubmitChangesTitle,
                                                                                         null,
                                                                                         UIAlertControllerStyle.ActionSheet);

                                if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
                                {
                                    actionSheet.PopoverPresentationController.SourceView = DoneButton;
                                    actionSheet.PopoverPresentationController.SourceRect = DoneButton.Bounds;
                                }

                                UIAlertAction submitAction = UIAlertAction.Create(GeneralStrings.Yes, UIAlertActionStyle.Default, delegate
                                {
                                    Dirty = false; SubmitChanges( ); Springboard.ResignModelViewController(this, null);
                                });
                                actionSheet.AddAction(submitAction);

                                UIAlertAction noSubmitAction = UIAlertAction.Create(GeneralStrings.No, UIAlertActionStyle.Destructive, delegate
                                {
                                    Dirty = false; Springboard.ResignModelViewController(this, null);
                                });
                                actionSheet.AddAction(noSubmitAction);

                                // let them cancel, too
                                UIAlertAction cancelAction = UIAlertAction.Create(GeneralStrings.Cancel, UIAlertActionStyle.Cancel, delegate { });
                                actionSheet.AddAction(cancelAction);

                                PresentViewController(actionSheet, true, null);
                            }
                        }
                        else
                        {
                            Springboard.ResignModelViewController(this, null);
                        }
                    }
                    else
                    {
                        GenderPicker.TogglePicker(false);
                        BirthdatePicker.TogglePicker(false);
                        Dirty = true;
                    }
                }
            };

            // On logout, make sure the user really wants to log out.
            LogoutButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                // don't allow changes while the profile is refreshing
                if (RefreshingProfile == false)
                {
                    if (GenderPicker.Revealed == false && BirthdatePicker.Revealed == false)
                    {
                        // if they tap logout, and confirm it
                        UIAlertController actionSheet = UIAlertController.Create(ProfileStrings.LogoutTitle,
                                                                                 null,
                                                                                 UIAlertControllerStyle.ActionSheet);

                        if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
                        {
                            actionSheet.PopoverPresentationController.SourceView = LogoutButton;
                            actionSheet.PopoverPresentationController.SourceRect = LogoutButton.Bounds;
                        }

                        UIAlertAction logoutAction = UIAlertAction.Create(GeneralStrings.Yes, UIAlertActionStyle.Destructive, delegate
                        {
                            // then log them out.
                            RockMobileUser.Instance.LogoutAndUnbind( );

                            Springboard.ResignModelViewController(this, null);
                        });
                        actionSheet.AddAction(logoutAction);

                        // let them cancel, too
                        UIAlertAction cancelAction = UIAlertAction.Create(GeneralStrings.Cancel, UIAlertActionStyle.Cancel, delegate { });
                        actionSheet.AddAction(cancelAction);

                        PresentViewController(actionSheet, true, null);
                    }
                    else
                    {
                        GenderPicker.TogglePicker(false);
                        BirthdatePicker.TogglePicker(false);
                        Dirty = true;
                    }
                }
            };

            ResultView = new UIResultView(ScrollView, View.Bounds.ToRectF( ),
                                          delegate
            {
                Springboard.ResignModelViewController(this, null);
            });

            Dirty = false;

            // logged in sanity check.
            if (RockMobileUser.Instance.LoggedIn == false)
            {
                throw new Exception("A user must be logged in before viewing a profile. How did you do this?");
            }
        }
예제 #23
0
 public override UIInterfaceOrientationMask GetSupportedInterfaceOrientations()
 {
     // insist they stay in portait on iPhones
     return(Springboard.GetSupportedInterfaceOrientations( ));
 }
예제 #24
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

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

            View.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BackgroundColor);

            ScrollView                   = new UIScrollViewWrapper();
            ScrollView.Parent            = this;
            ScrollView.Layer.AnchorPoint = CGPoint.Empty;
            ScrollView.Bounds            = View.Bounds;
            //ScrollView.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor( 0x0000FFFF );
            View.AddSubview(ScrollView);

            UserNameField = new StyledTextField();
            ScrollView.AddSubview(UserNameField.Background);

            UserNameField.Field.AutocapitalizationType = UITextAutocapitalizationType.None;
            UserNameField.Field.AutocorrectionType     = UITextAutocorrectionType.No;
            ControlStyling.StyleTextField(UserNameField.Field, LoginStrings.UsernamePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ControlStyling.StyleBGLayer(UserNameField.Background);
            UserNameField.Field.ShouldReturn += (textField) =>
            {
                textField.ResignFirstResponder();

                TryRockBind();
                return(true);
            };

            PasswordField = new StyledTextField();
            ScrollView.AddSubview(PasswordField.Background);
            PasswordField.Field.AutocorrectionType = UITextAutocorrectionType.No;
            PasswordField.Field.SecureTextEntry    = true;

            ControlStyling.StyleTextField(PasswordField.Field, LoginStrings.PasswordPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ControlStyling.StyleBGLayer(PasswordField.Background);
            PasswordField.Field.ShouldReturn += (textField) =>
            {
                textField.ResignFirstResponder();

                TryRockBind();
                return(true);
            };

            // obviously attempt a login if login is pressed
            LoginButton = UIButton.FromType(UIButtonType.System);
            ScrollView.AddSubview(LoginButton);
            ControlStyling.StyleButton(LoginButton, LoginStrings.LoginButton, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            LoginButton.SizeToFit( );
            LoginButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                if (RockMobileUser.Instance.LoggedIn == true)
                {
                    RockMobileUser.Instance.LogoutAndUnbind( );

                    SetUIState(LoginState.Out);
                }
                else
                {
                    TryRockBind();
                }
            };

            // if they forgot their password, kick them out to the forgot password page
            ForgotPasswordButton = UIButton.FromType(UIButtonType.System);
            ScrollView.AddSubview(ForgotPasswordButton);
            ControlStyling.StyleButton(ForgotPasswordButton, LoginStrings.ForgotPasswordButton, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ForgotPasswordButton.SizeToFit( );
            ForgotPasswordButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                TaskWebViewController.HandleUrl(true, true, LoginConfig.ForgotPassword_Url, null, null, false, false, false);
            };

            AdditionalOptions = new UILabel( );
            ScrollView.AddSubview(AdditionalOptions);
            ControlStyling.StyleUILabel(AdditionalOptions, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize);
            AdditionalOptions.Text      = LoginStrings.AdditionalOptions;
            AdditionalOptions.TextColor = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.TextField_PlaceholderTextColor);
            AdditionalOptions.SizeToFit( );

            OrSpacerLabel = new UILabel( );
            ScrollView.AddSubview(OrSpacerLabel);
            ControlStyling.StyleUILabel(OrSpacerLabel, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize);
            OrSpacerLabel.TextColor = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.TextField_PlaceholderTextColor);
            OrSpacerLabel.Text      = LoginStrings.OrString;
            OrSpacerLabel.SizeToFit( );

            RegisterButton = UIButton.FromType(UIButtonType.System);
            ScrollView.AddSubview(RegisterButton);
            ControlStyling.StyleButton(RegisterButton, LoginStrings.RegisterButton, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            //RegisterButton.BackgroundColor = UIColor.Clear;
            RegisterButton.SizeToFit( );
            RegisterButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                Springboard.RegisterNewUser( );
            };

            // setup the result
            LoginResult = new StyledTextField( );
            ScrollView.AddSubview(LoginResult.Background);

            ControlStyling.StyleTextField(LoginResult.Field, "", ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize);
            ControlStyling.StyleBGLayer(LoginResult.Background);
            LoginResult.Field.UserInteractionEnabled = false;
            LoginResult.Field.TextAlignment          = UITextAlignment.Center;

            // setup the facebook button
            FacebookLogin = new UIButton( );
            ScrollView.AddSubview(FacebookLogin);
            string imagePath = NSBundle.MainBundle.BundlePath + "/" + "facebook_login.png";

            FBImageView = new UIImageView(new UIImage(imagePath));

            FacebookLogin.SetTitle("", UIControlState.Normal);
            FacebookLogin.AddSubview(FBImageView);
            FacebookLogin.Layer.CornerRadius = 4;
            FBImageView.Layer.CornerRadius   = 4;

            FacebookLogin.TouchUpInside += (object sender, EventArgs e) =>
            {
                TryFacebookBind();
            };

            // If cancel is pressed, notify the springboard we're done.
            CancelButton = UIButton.FromType(UIButtonType.System);
            ScrollView.AddSubview(CancelButton);
            CancelButton.SetTitleColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.Label_TextColor), UIControlState.Normal);
            CancelButton.SetTitle(GeneralStrings.Cancel, UIControlState.Normal);
            CancelButton.SizeToFit( );
            CancelButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                // don't allow canceling while we wait for a web request.
                if (LoginState.Trying != State)
                {
                    Springboard.ResignModelViewController(this, null);
                }
            };


            // set the title image for the bar if there's no safe area defined. (A safe area is like, say, the notch for iPhone X)
            nfloat safeAreaTopInset = 0;

            // Make sure they're on iOS 11 before checking for insets. This is only needed for iPhone X anyways, which shipped with iOS 11.
            if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
            {
                safeAreaTopInset = UIApplication.SharedApplication.KeyWindow.SafeAreaInsets.Top;
            }

            // setup the fake header if they're not on a device with save zones (iphone x)
            if (safeAreaTopInset == 0)
            {
                HeaderView = new UIView( );
                View.AddSubview(HeaderView);
                HeaderView.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BackgroundColor);

                imagePath = NSBundle.MainBundle.BundlePath + "/" + PrivatePrimaryNavBarConfig.LogoFile_iOS;
                LogoView  = new UIImageView(new UIImage(imagePath));
                LogoView.SizeToFit( );
                LogoView.Layer.AnchorPoint = CGPoint.Empty;

                HeaderView.AddSubview(LogoView);
                HeaderView.SizeToFit( );
            }
        }
예제 #25
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            View.BackgroundColor = UIColor.Black;

            // set the image
            ImageView = new UIImageView( );
            ImageView.BackgroundColor = UIColor.Black;
            ImageView.ContentMode     = UIViewContentMode.ScaleAspectFit;
            View.AddSubview(ImageView);


            // create our cropper
            CropView = new UIView( );
            CropView.BackgroundColor    = UIColor.Clear;
            CropView.Layer.BorderColor  = UIColor.White.CGColor;
            CropView.Layer.BorderWidth  = 1;
            CropView.Layer.CornerRadius = 4;
            View.AddSubview(CropView);


            // create our fullscreen blocker. It needs to be HUGE so we can center the
            // masked part
            FullscreenBlocker = new UIView();
            FullscreenBlocker.BackgroundColor  = UIColor.Black;
            FullscreenBlocker.Layer.Opacity    = 0.00f;
            FullscreenBlocker.Bounds           = new CGRect(0, 0, 10000, 10000);
            FullscreenBlocker.AutoresizingMask = UIViewAutoresizing.None;
            View.AddSubview(FullscreenBlocker);

            FullscreenBlockerMask          = new CAShapeLayer();
            FullscreenBlockerMask.FillRule = CAShapeLayer.FillRuleEvenOdd;
            FullscreenBlocker.Layer.Mask   = FullscreenBlockerMask;


            // create our bottom toolbar
            Toolbar = new UIToolbar( );

            // create the cancel button
            NSString cancelLabel = new NSString(PrivateImageCropConfig.CropCancelButton_Text);

            CancelButton      = new UIButton(UIButtonType.System);
            CancelButton.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont(PrivateControlStylingConfig.Icon_Font_Secondary, PrivateImageCropConfig.CropCancelButton_Size);
            CancelButton.SetTitle(cancelLabel.ToString( ), UIControlState.Normal);

            CancelButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                // if cancel was pressed while editing, cancel this entire operation
                if (CropMode.Editing == Mode)
                {
                    Springboard.ResignModelViewController(this, null);
                    Mode = CropMode.None;
                }
                else
                {
                    SetMode(CropMode.Editing);
                }
            };

            // create the edit button
            NSString editLabel = new NSString(PrivateImageCropConfig.CropOkButton_Text);

            EditButton      = new UIButton(UIButtonType.System);
            EditButton.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont(PrivateControlStylingConfig.Icon_Font_Secondary, PrivateImageCropConfig.CropOkButton_Size);
            EditButton.SetTitle(editLabel.ToString( ), UIControlState.Normal);
            EditButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Right;

            EditButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                if (Mode == CropMode.Previewing)
                {
                    // confirm we're done
                    Springboard.ResignModelViewController(this, CroppedImage);
                    Mode = CropMode.None;
                }
                else
                {
                    SetMode(CropMode.Previewing);
                }
            };

            // create a container that will allow us to align the buttons
            ButtonContainer = new UIView( );
            ButtonContainer.AddSubview(EditButton);
            ButtonContainer.AddSubview(CancelButton);

            CancelButton.BackgroundColor = UIColor.Clear;

            EditButton.BackgroundColor = UIColor.Clear;

            Toolbar.SetItems(new UIBarButtonItem[] { new UIBarButtonItem(ButtonContainer) }, false);
            View.AddSubview(Toolbar);
        }