Example #1
0
        bool CheckDebug( )
        {
            bool debugKeyEntered = false;

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

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

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

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

            return(debugKeyEntered);
        }
        protected void Handle_LearnMore( )
        {
            // don't process the link if there's no ReferenceURL
            if (string.IsNullOrWhiteSpace(NewsItem.ReferenceURL) == false)
            {
                // if this is an app-url, then let the task (which forwards it to the springboard) handle it.
                if (SpringboardViewController.IsAppURL(NewsItem.ReferenceURL) == true)
                {
                    Task.HandleAppURL(NewsItem.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             = NewsItem.ReferenceURL;
                    bool   newsImpersonation   = NewsItem.IncludeImpersonationToken;
                    bool   newsExternalBrowser = NewsItem.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

                    TaskWebViewController.HandleUrl(newsExternalBrowser, newsImpersonation, newsUrl, Task, this, false, false, false);
                }
            }
        }
        public void UpdateBackButton( )
        {
            // if there are VCs in the stack
            if (SubNavigationController.ViewControllers.Length > 1)
            {
                // only allow back if we're in regular landscape or portrait mode
                bool allowBack = false;
                if (SpringboardViewController.IsLandscapeWide( ) == true || SpringboardViewController.IsDevicePortrait( ) == true)
                {
                    allowBack = true;
                }

                // OR, if there's a current task, ask it if there should be an override
                if (CurrentTask != null)
                {
                    // if they return true, read their override result.
                    bool overrideBackResult = false;
                    if (CurrentTask.WantOverrideBackButton(ref overrideBackResult))
                    {
                        allowBack = overrideBackResult;
                    }
                }
                SubNavToolbar.SetBackButtonEnabled(allowBack);
            }
            else
            {
                SubNavToolbar.SetBackButtonEnabled(false);
            }
        }
        public override void LayoutChanged()
        {
            base.LayoutChanged();

            // center the movie window.
            nfloat movieHeight = 0.00f;
            nfloat movieWidth  = View.Frame.Width;

            // if we have the movie size, correctly resize it
            if (MoviePlayer.NaturalSize.Width != 0 && MoviePlayer.NaturalSize.Height != 0)
            {
                // fit the video into the width of the view
                nfloat aspectRatio = MoviePlayer.NaturalSize.Height / MoviePlayer.NaturalSize.Width;
                movieWidth  = View.Frame.Width;
                movieHeight = movieWidth * aspectRatio;

                // if the height is still too large, scale the width down from what our height is
                if (movieHeight > View.Frame.Height)
                {
                    aspectRatio = MoviePlayer.NaturalSize.Width / MoviePlayer.NaturalSize.Height;

                    movieHeight = View.Frame.Height;
                    movieWidth  = View.Frame.Height * aspectRatio;
                }
            }
            else
            {
                // otherwise as a temporary measure, use half the viewing width
                movieWidth  = View.Frame.Width;
                movieHeight = View.Frame.Height;
            }

            // center the movie frame and activity indicator
            MoviePlayer.View.Frame = new CGRect((View.Frame.Width - movieWidth) / 2, (View.Frame.Height - movieHeight) / 2, movieWidth, movieHeight);

            ActivityIndicator.Layer.Position = new CGPoint((View.Frame.Width - ActivityIndicator.Frame.Width) / 2,
                                                           (View.Frame.Height - ActivityIndicator.Frame.Height) / 2);

            // landscape wide devices MAY show the nav toolbar
            if (SpringboardViewController.IsLandscapeWide( ) == true)
            {
                //Task.NavToolbar.RevealForTime( 3.0f );
                Task.NavToolbar.Reveal(true);
                Task.NavToolbar.SetBackButtonEnabled(true);
            }
            // landscape non-wide devices should not
            else if (SpringboardViewController.IsDeviceLandscape( ) == true)
            {
                Task.NavToolbar.Reveal(false);
            }
            else
            {
                //Task.NavToolbar.RevealForTime( 3.0f );
                Task.NavToolbar.Reveal(true);
                Task.NavToolbar.SetBackButtonEnabled(true);
            }

            ResultView.SetBounds(View.Frame.ToRectF( ));
        }
Example #5
0
        public override void LayoutChanged( )
        {
            base.LayoutChanged( );

            // get the orientation state. WE consider unknown- 1, profile 0, landscape 1,
            int orientationState = SpringboardViewController.IsDeviceLandscape( ) == true ? 1 : 0;

            // if the states are in disagreement, correct it
            if (OrientationState != orientationState)
            {
                OrientationState = orientationState;

                // get the offset scrolled before changing our frame (which will cause us to lose it)
                nfloat scrollOffsetPercent = UIScrollView.ContentOffset.Y / ( nfloat )Math.Max(1, UIScrollView.ContentSize.Height);

                //note: the frame height of the nav bar is what it CURRENTLY is, not what it WILL be after we rotate. So, when we go from Portrait to Landscape,
                // it says 40, but it's gonna be 32. Conversely, going back, we use 32 and it's actually 40, which causes us to start this view 8px too high.
                if (MobileApp.Shared.Network.RockLaunchData.Instance.Data.DeveloperModeEnabled == true)
                {
                    // add the refresh button if necessary
                    if (RefreshButton.Superview == null)
                    {
                        View.AddSubview(RefreshButton);
                    }

                    RefreshButton.Layer.Position = new CGPoint(View.Bounds.Width / 2, (RefreshButton.Frame.Height / 2));

                    UIScrollView.Frame          = new CGRect(0, 0, View.Bounds.Width, View.Bounds.Height - RefreshButton.Frame.Height);
                    UIScrollView.Layer.Position = new CGPoint(UIScrollView.Layer.Position.X, UIScrollView.Layer.Position.Y + RefreshButton.Frame.Bottom);
                }
                else
                {
                    // remove the refresh button if necessary
                    if (RefreshButton.Superview != null)
                    {
                        RefreshButton.RemoveFromSuperview( );
                    }

                    UIScrollView.Frame          = new CGRect(0, 0, View.Bounds.Width, View.Bounds.Height);
                    UIScrollView.Layer.Position = new CGPoint(UIScrollView.Layer.Position.X, UIScrollView.Layer.Position.Y);
                }

                Indicator.Layer.Position = new CGPoint(View.Bounds.Width / 2, View.Bounds.Height / 2);

                // re-create our notes with the new dimensions
                PrepareCreateNotes(scrollOffsetPercent, false);

                // since we're changing orientations, hide the tutorial screen
                AnimateTutorialScreen(false);

                ResultView.SetBounds(View.Bounds.ToRectF( ));
            }
        }
Example #6
0
        public void RevealSpringboard(bool wantReveal)
        {
            // only do something if there's a change
            //if( wantReveal != SpringboardRevealed )
            {
                // of course don't allow a change while we're animating it.
                if (Animating == false)
                {
                    Animating = true;

                    // Animate the front panel out
                    UIView.Animate(PrivatePrimaryContainerConfig.SlideRate, 0, UIViewAnimationOptions.CurveEaseInOut,
                                   new Action(
                                       delegate
                    {
                        float endPos = 0.0f;
                        if (wantReveal == true)
                        {
                            endPos = (float)PrivatePrimaryContainerConfig.SlideAmount_iOS;
                            DarkPanel.Layer.Opacity = PrivatePrimaryContainerConfig.SlideDarkenAmount;
                        }
                        else
                        {
                            endPos = 0.00f;
                            DarkPanel.Layer.Opacity = 0.0f;
                        }

                        float moveAmount    = (float)(endPos - View.Layer.Position.X);
                        View.Layer.Position = new CGPoint(View.Layer.Position.X + moveAmount, View.Layer.Position.Y);
                    })

                                   , new Action(
                                       delegate
                    {
                        Animating = false;

                        SpringboardRevealed = wantReveal;

                        // if the springboard is open, disable input on app stuff if the device doesn't support
                        // regular landscape
                        if (SpringboardViewController.IsLandscapeWide( ) == false)
                        {
                            Container.View.UserInteractionEnabled = !SpringboardRevealed;
                        }
                    })
                                   );
                }
            }
        }
Example #7
0
        public override void TouchesBegan(NSSet touches, UIEvent evt)
        {
            base.TouchesBegan(touches, evt);

            // only allow panning if the task is ok with it AND we're in portrait mode.
            if (CurrentTask.CanContainerPan(touches, evt) == true &&
                SpringboardViewController.IsDeviceLandscape( ) == false)
            {
                PanGesture.Enabled = true;
            }
            else
            {
                PanGesture.Enabled = false;
            }
        }
Example #8
0
        public override void TouchesEnded(TaskUIViewController taskUIViewController, NSSet touches, UIEvent evt)
        {
            base.TouchesEnded(taskUIViewController, touches, evt);

            // immediately hide the toolbar on the main page
            if (ActiveViewController == MainViewController)
            {
                NavToolbar.Reveal(false);
            }
            // allow it as long as it's the watch window in portrait mode or landscape wide mode.
            else if ((ActiveViewController as NotesWatchUIViewController) != null)
            {
                if (SpringboardViewController.IsLandscapeWide( ) || SpringboardViewController.IsDevicePortrait( ))
                {
                    //NavToolbar.RevealForTime( 3.0f );
                }
            }
        }
        public void LayoutChanging( )
        {
            UpdateBackButton( );

            if (SpringboardViewController.IsDeviceLandscape( ) == true)
            {
                EnableSpringboardRevealButton(false);
            }
            else
            {
                EnableSpringboardRevealButton(true);
            }

            if (CurrentTask != null)
            {
                CurrentTask.LayoutChanging( );
            }
        }
        public void RowClicked(int row)
        {
            if (row < News.Count)
            {
                // mark that they tapped this item.
                NewsAnalytic.Instance.Trigger(NewsAnalytic.Read, News[row].News.Title);

                if (News[row].News.SkipDetailsPage == true && string.IsNullOrEmpty(News[row].News.ReferenceURL) == false)
                {
                    // if this is an app-url, then let the task (which forwards it to the springboard) handle it.
                    if (SpringboardViewController.IsAppURL(News[row].News.ReferenceURL) == true)
                    {
                        Task.HandleAppURL(News[row].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             = News[row].News.ReferenceURL;
                        bool   newsImpersonation   = News[row].News.IncludeImpersonationToken;
                        bool   newsExternalBrowser = News[row].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

                        TaskWebViewController.HandleUrl(newsExternalBrowser, newsImpersonation, newsUrl, Task, this, false, false, false);
                    }
                }
                else
                {
                    NewsDetailsUIViewController viewController = new NewsDetailsUIViewController();
                    viewController.NewsItem = News[row].News;

                    Task.PerformSegue(this, viewController);
                }
            }
        }
Example #11
0
        public override void LayoutChanged( )
        {
            base.LayoutChanged( );

            // get the orientation state. WE consider unknown- 1, profile 0, landscape 1,
            int orientationState = SpringboardViewController.IsDeviceLandscape( ) == true ? 1 : 0;

            // if the states are in disagreement, correct it
            if (OrientationState != orientationState)
            {
                OrientationState = orientationState;

                BibleWebView.Frame          = new CGRect(0, 0, View.Bounds.Width, View.Bounds.Height);
                BibleWebView.Layer.Position = new CGPoint(BibleWebView.Layer.Position.X, BibleWebView.Layer.Position.Y);

                BlockerView.SetBounds(View.Bounds.ToRectF( ));
                ResultView.SetBounds(View.Bounds.ToRectF( ));
            }
        }
Example #12
0
        public void LayoutChanging( )
        {
            // for landscape regular, permanantly reveal the springboard
            if (SpringboardViewController.IsLandscapeWide( ) == true)
            {
                View.Frame = new CGRect(PrivatePrimaryContainerConfig.SlideAmount_iOS, 0, SpringboardViewController.TraitSize.Width - PrivatePrimaryContainerConfig.SlideAmount_iOS, SpringboardViewController.TraitSize.Height);

                SpringboardRevealed = true;
                Container.View.UserInteractionEnabled = true;

                DarkPanel.Hidden        = true;
                DarkPanel.Layer.Opacity = 0.0f;

                PanGesture.Enabled = false;
            }
            else
            {
                View.Frame = new CGRect(0, 0, SpringboardViewController.TraitSize.Width, SpringboardViewController.TraitSize.Height);

                DarkPanel.Hidden        = false;
                DarkPanel.Layer.Opacity = 0.0f;

                SpringboardRevealed = false;
                Container.View.UserInteractionEnabled = true;

                // only allow panning if we're in portrait. We COULD be going into normal Landscape
                if (SpringboardViewController.IsDevicePortrait( ) == true)
                {
                    PanGesture.Enabled = true;
                }
                else
                {
                    PanGesture.Enabled = false;
                }
            }

            DarkPanel.Bounds = View.Bounds;

            ApplyEdgeShadow( );

            Container.LayoutChanging( );
        }
Example #13
0
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            // Register HockeyApp
            #if !DEBUG
            var manager = BITHockeyManager.SharedHockeyManager;
            manager.Configure(App.Shared.SecuredValues.iOS_HockeyApp_Id);
            manager.CrashManager.CrashManagerStatus = BITCrashManagerStatus.AutoSend;
            manager.StartManager();
            manager.Authenticator.AuthenticateInstallation();
            #endif

            // create a new window instance based on the screen size. If we're a phone launched in landscape (only possible on the iPhone 6+),
            // force a portait layout.
            if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone && UIScreen.MainScreen.Bounds.Height < UIScreen.MainScreen.Bounds.Width)
            {
                window = new UIWindow(new CoreGraphics.CGRect(0, 0, UIScreen.MainScreen.Bounds.Height, UIScreen.MainScreen.Bounds.Width));
            }
            else
            {
                // for ipads or portait phones, use the default
                window = new UIWindow(UIScreen.MainScreen.Bounds);
            }

            // If you have defined a root view controller, set it here:
            Springboard = new SpringboardViewController( );
            window.RootViewController = Springboard;

            Rock.Mobile.Util.URL.Override.SetAppUrlOverrides(PrivateGeneralConfig.App_URL_Overrides);

            // make the window visible
            window.MakeKeyAndVisible( );

            // request the Playback category session
            NSError        error;
            AVAudioSession instance = AVAudioSession.SharedInstance();
            instance.SetCategory(new NSString("AVAudioSessionCategoryPlayback"), AVAudioSessionCategoryOptions.MixWithOthers, out error);
            instance.SetMode(new NSString("AVAudioSessionModeDefault"), out error);
            instance.SetActive(true, AVAudioSessionSetActiveOptions.NotifyOthersOnDeactivation, out error);

            return(true);
        }
Example #14
0
 public void HandleTapGesture(UITapGestureRecognizer tap)
 {
     if (Note != null)
     {
         if (tap.State == UIGestureRecognizerState.Ended)
         {
             try
             {
                 if (Note.DidDoubleTap(tap.LocationInView(UIScrollView).ToPointF( )))
                 {
                     MobileApp.Shared.Network.RockMobileUser.Instance.UserNoteCreated = true;
                 }
             }
             catch (Exception e)
             {
                 // we know this exception is the too many notes one. Just show it.
                 SpringboardViewController.DisplayError("Messages", e.Message);
             }
         }
     }
 }
        public override void ViewDidLayoutSubviews()
        {
            // get the orientation state. WE consider unknown- 1, profile 0, landscape 1,
            int orientationState = SpringboardViewController.IsDeviceLandscape( ) == true ? 1 : 0;

            // if the states are in disagreement, correct it
            if (OrientationState != orientationState)
            {
                OrientationState = orientationState;

                Toolbar.Frame = new CGRect(0, View.Bounds.Height - 40, View.Bounds.Width, 40);

                NSString cancelLabel = new NSString(PrivateImageCropConfig.CropCancelButton_Text);
                CGSize   buttonSize  = cancelLabel.StringSize(CancelButton.Font);
                CancelButton.Bounds = new CGRect(0, 0, buttonSize.Width, buttonSize.Height);


                NSString editLabel = new NSString(PrivateImageCropConfig.CropOkButton_Text);
                buttonSize        = editLabel.StringSize(EditButton.Font);
                EditButton.Bounds = new CGRect(0, 0, buttonSize.Width, buttonSize.Height);

                ImageView.Frame = GetImageViewFrame( );

                ButtonContainer.Frame = new CGRect(0, View.Bounds.Height - 40, View.Bounds.Width, 40);
                CancelButton.Frame    = new CGRect((CancelButton.Frame.Width / 2), 0, CancelButton.Frame.Width, CancelButton.Frame.Height);
                EditButton.Frame      = new CGRect(ButtonContainer.Frame.Width - (EditButton.Frame.Width * 2.5f), 0, EditButton.Frame.Width, EditButton.Frame.Height);

                DisplayLayout( );

                // make sure we reset to editing mode
                if (CropMode.Editing != Mode)
                {
                    SetMode(CropMode.Editing);
                }
                else
                {
                    AnimateBlocker(true);
                }
            }
        }
Example #16
0
        public bool ActivateTask(Task task)
        {
            // don't allow switching activites while we're animating.
            if (Animating == false)
            {
                Container.ActivateTask(task);

                // I don't think this call does anything, but getting this close to
                // shipping, i don't want to remove it.
                PopToRootViewController(false);

                // task activation should only close the springboard if our device isn't wide landscape
                if (SpringboardViewController.IsLandscapeWide( ) == false)
                {
                    RevealSpringboard(false);
                }

                return(true);
            }

            return(false);
        }
Example #17
0
        public override void TouchesEnded(NSSet touches, UIEvent evt)
        {
            Rock.Mobile.Util.Debug.WriteLine("Touches Ended");

            // for base.TouchesEnded, we do not want to call that FIRST if we're destroying the notes and switching to another page within the App.

            // if the tutorial is showing, all we want to do is hide it.
            // If we process input, it's possible they'll tap thru it to a URL, which will
            // switch pages and cause a lot of user confustion
            if (TutorialShowing( ))
            {
                AnimateTutorialScreen(false);
            }
            else
            {
                UITouch touch = touches.AnyObject as UITouch;
                if (touch != null)
                {
                    if (Note != null)
                    {
                        // should we visit a website?
                        bool urlLaunchesExternalBrowser = false;
                        bool urlUsesRockImpersonation   = false;

                        string activeUrl = Note.TouchesEnded(touch.LocationInView(UIScrollView).ToPointF( ), out urlLaunchesExternalBrowser, out urlUsesRockImpersonation);
                        if (string.IsNullOrEmpty(activeUrl) == false)
                        {
                            // see if the task should handle it (as in its a redirect within the app)
                            if (SpringboardViewController.IsAppURL(activeUrl) == true)
                            {
                                // HACK JHM 9-1-2017: We don't currently have the ability to transition from a landscape Note to a portrait Task.
                                // Because of that, they either need to be on an iPad, or have their phone in portrait mode. This isn't ideal,
                                // but without adding support for landscape->portrait, we don't have any other choice.
                                if (SpringboardViewController.SupportsLandscapeWide( ) == true || SpringboardViewController.IsDevicePortrait( ) == true)
                                {
                                    SaveNoteState(UIScrollView.ContentOffset.Y / ( nfloat )Math.Max(1, UIScrollView.ContentSize.Height));
                                    DestroyNotes( );

                                    // if the url uses the rock impersonation token, it's safe to assume they tapped the takeaway.
                                    if (urlUsesRockImpersonation)
                                    {
                                        MessageAnalytic.Instance.Trigger(MessageAnalytic.Takeaway, activeUrl);
                                    }

                                    Task.HandleAppURL(activeUrl);
                                }
                            }
                            else
                            {
                                // cleanup the notes before leaving
                                SaveNoteState(UIScrollView.ContentOffset.Y / ( nfloat )Math.Max(1, UIScrollView.ContentSize.Height));
                                DestroyNotes( );

                                // if not, it's either a websie or bible verse
                                Task.NavToolbar.Reveal(true);
                                Task.NavToolbar.SetBackButtonEnabled(true);

                                if (App.Shared.BibleRenderer.IsBiblePrefix(activeUrl))
                                {
                                    BiblePassageViewController viewController = new BiblePassageViewController(activeUrl, Task);
                                    Task.PerformSegue(this, viewController);
                                }
                                else
                                {
                                    TaskWebViewController.HandleUrl(urlLaunchesExternalBrowser, urlUsesRockImpersonation, activeUrl, Task, this, true, false, false);
                                }
                            }
                        }
                    }
                }

                // when a touch is released, re-enabled scrolling
                UIScrollView.ScrollEnabled = true;
            }

            // Process TouchesEnded AFTER handling locally- we need to do this
            // in case the Note above wants to switch to another activity within the app.
            base.TouchesEnded(touches, evt);
        }