public SpringboardElement( SpringboardViewController controller, Task task, UIView backingView, string imageChar, string labelStr )
            {
                Task = task;

                // setup the backing view
                BackingView = backingView;
                BackingView.BackgroundColor = UIColor.Clear;

                //The button should look as follows:
                // [ X Text ]
                // To make sure the icons and text are all aligned vertically,
                // we will actually create a backing view that can highlight (the []s)
                // and place a logo view (the X), and a text view (the Text) on top.
                // Finally, we'll make the button clear with no text and place it over the
                // backing view.

                // Create the logo view containing the image.
                LogoView = new UILabel();
                LogoView.Text = imageChar;
                LogoView.Font = FontManager.GetFont( PrivateControlStylingConfig.Icon_Font_Primary, PrivateSpringboardConfig.Element_FontSize );
                LogoView.SizeToFit( );
                LogoView.BackgroundColor = UIColor.Clear;
                BackingView.AddSubview( LogoView );

                // Create the text, and populate it with the button's requested text, color and font.
                TextLabel = new UILabel();
                TextLabel.Text = labelStr;
                TextLabel.Font = FontManager.GetFont( ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize );
                TextLabel.BackgroundColor = UIColor.Clear;
                TextLabel.SizeToFit( );
                BackingView.AddSubview( TextLabel );

                // Create the seperator
                Seperator = new UIView( );
                Seperator.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_Color );
                BackingView.AddSubview( Seperator );

                // Create the button
                Button = new UIButton( UIButtonType.Custom );
                Button.Layer.AnchorPoint = CGPoint.Empty;
                Button.BackgroundColor = UIColor.Clear;
                Button.TouchUpInside += (object sender, EventArgs e) => 
                    {
                        controller.ActivateElement( this );
                    };
                BackingView.AddSubview( Button );


                // position the controls
                Button.Bounds = BackingView.Bounds;

                LogoView.Layer.Position = new CGPoint( PrivateSpringboardConfig.Element_LogoOffsetX_iOS, BackingView.Frame.Height / 2 );

                TextLabel.Layer.Position = new CGPoint( PrivateSpringboardConfig.Element_LabelOffsetX_iOS + ( TextLabel.Frame.Width / 2 ), BackingView.Frame.Height / 2 );

                Seperator.Frame = new CGRect( 0, 0, Button.Frame.Width, 1.0f );

                Deactivate( );
            }
 public NotesDetailsUIViewController( Task parentTask )
 {
     Task = parentTask;
 }
        protected TaskWebViewController ( string displayUrl, Task parentTask, bool includeImpersonationToken, bool disableIdleTimer, bool webviewControlsNavbar ) : base ( )
		{
            DisplayUrl = displayUrl;
            Task = parentTask;
            DisableIdleTimer = disableIdleTimer;
            WebviewControlsNavbar = webviewControlsNavbar;
            IncludeImpersonationToken = includeImpersonationToken;
		}
        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;
        }
        /// <summary>
        /// Handles taking a URL and either launching it externally or within a webView, with or without impersonation token info. (Showing an embedded web page OR launching Safari)
        /// </summary>
        public static void HandleUrl( bool launchExternalBrowser, bool includeImpersonationToken, string url, Task parentTask, UIViewController currController, bool disableIdleTimer, bool webViewControlsNavbar )
        {
            // do we launch them out of the app?
            if ( launchExternalBrowser == true )
            {
                // should we get the impersonation token?
                if ( includeImpersonationToken == true )
                {
                    MobileAppApi.TryGetImpersonationToken( 
                        delegate(string impersonationToken )
                        {
                            // put the platform we're running
                            string fullUrl = Rock.Mobile.Util.Strings.Parsers.AddParamToURL( url, PrivateGeneralConfig.MobilePlatform );

                            // build the full url with their preferred campus (since thats personal data)
                            fullUrl = Rock.Mobile.Util.Strings.Parsers.AddParamToURL( fullUrl, string.Format( PrivateGeneralConfig.RockCampusContext, App.Shared.Network.RockMobileUser.Instance.GetRelevantCampus( ) ) );

                            // URL encode the value
                            NSString encodedUrlString = fullUrl.UrlEncode( );

                            // if we got a token, append it
                            NSUrl encodedUrl = null;
                            if ( string.IsNullOrEmpty( impersonationToken ) == false )
                            {
                                encodedUrl = new NSUrl( encodedUrlString + "&" + impersonationToken );
                            }
                            else
                            {
                                encodedUrl = new NSUrl( encodedUrlString );
                            }

                            UIApplication.SharedApplication.OpenUrl( encodedUrl );
                        } );
                }
                else
                {
                    // first encode the url
                    NSString encodedUrlString = url.UrlEncode( );

                    UIApplication.SharedApplication.OpenUrl( new NSUrl( encodedUrlString ) );
                }
            }
            // they are using an embedded browser, so this is pretty simple
            else
            {
                TaskWebViewController viewController = new TaskWebViewController( url, parentTask, includeImpersonationToken, disableIdleTimer, webViewControlsNavbar );
                parentTask.PerformSegue( currController, viewController );
            }
        }