Пример #1
0
            public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
            {
                if (container == null)
                {
                    // Currently in a layout without a container, so no reason to create our view.
                    return null;
                }

                RelativeLayout view = inflater.Inflate(Resource.Layout.TaskWebView, container, false) as RelativeLayout;
                view.SetOnTouchListener( this );

                WebLayout = new WebLayout( Rock.Mobile.PlatformSpecific.Android.Core.Context );
                WebLayout.LayoutParameters = new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent );
                WebLayout.SetBackgroundColor( Android.Graphics.Color.Black );

                view.AddView( WebLayout );

                ResultView = new UIResultView( view, new System.Drawing.RectangleF( 0, 0, NavbarFragment.GetContainerDisplayWidth( ), this.Resources.DisplayMetrics.HeightPixels ),
                    delegate
                    {
                        ResultView.Hide( );

                        if ( string.IsNullOrEmpty( Url ) == false )
                        {
                            WebLayout.LoadUrl( Url, PageLoaded );
                        }
                    } );

                return view;
            }
Пример #2
0
        public void TryFacebookBind( )
        {
            // if we aren't already trying to bind facebook
            if (BindingFacebook == false)
            {
                // go for it.
                BindingFacebook = true;

                RockMobileUser.Instance.BindFacebookAccount(delegate(string fromUri)
                {
                    (View as RelativeLayout).AddView(WebLayout);

                    WebLayout.ResetCookies( );

                    WebLayout.LoadUrl(fromUri, PrivateGeneralConfig.ExternalUrlToken,
                                      delegate(bool result, string forwardUrl)
                    {
                        // either way, wait for a facebook response
                        if (RockMobileUser.Instance.HasFacebookResponse(forwardUrl))
                        {
                            BindingFacebook = false;

                            SetUIState(LoginState.Trying);
                            (View as RelativeLayout).RemoveView(WebLayout);
                            RockMobileUser.Instance.FacebookCredentialResult(forwardUrl, BindComplete);

                            ProfileAnalytic.Instance.Trigger(ProfileAnalytic.Login, "Facebook");
                        }
                    });
                    //
                });
            }
        }
Пример #3
0
            void ProcessUrl( )
            {
                // make sure the page is still active. If they browsed away fast enough,
                // this will fire on the UI thread AFTER the fragment is destroyed.
                if (IsActive == true && string.IsNullOrEmpty(Url) == false)
                {
                    // do they want the impersonation token?
                    if (IncludeImpersonationToken)
                    {
                        // try to get it
                        MobileAppApi.TryGetImpersonationToken(
                            delegate(string impersonationToken)
                        {
                            // one more active check, because we fetched the Impersonation Token which
                            // suspended our thread and allowed the OS to potentially tear down this fragment.
                            if (IsActive == true)
                            {
                                // append the mobile platform
                                string fullUrl = Rock.Mobile.Util.Strings.Parsers.AddParamToURL(Url, PrivateGeneralConfig.MobilePlatform);

                                // if we got it, append it and load
                                if (string.IsNullOrEmpty(impersonationToken) == false)
                                {
                                    fullUrl += "&" + impersonationToken;
                                }

                                Console.WriteLine("Browsing to {0}", fullUrl);
                                WebLayout.LoadUrl(fullUrl, PrivateGeneralConfig.ExternalUrlToken, PageLoaded);
                            }
                        });
                    }
                    else
                    {
                        // no impersonation token requested. just load.
                        Console.WriteLine("Browsing to {0}", Url);
                        WebLayout.LoadUrl(Url, PrivateGeneralConfig.ExternalUrlToken, PageLoaded);
                    }
                }
            }
        public void TryFacebookBind( )
        {
            SetUIState( LoginState.Trying );

            // have our rock mobile user begin the facebook bind process
            RockMobileUser.Instance.BindFacebookAccount( delegate(string fromUri, Facebook.FacebookClient session) 
            {
                    // it's ready, so create a webView that will take them to the FBLogin page
                    WebLayout = new WebLayout( View.Frame );
                    WebLayout.DeleteCacheAndCookies( );

                    View.AddSubview( WebLayout.ContainerView );

                    // set it totally transparent so we can fade it in
                    WebLayout.ContainerView.BackgroundColor = UIColor.Black;
                    WebLayout.ContainerView.Layer.Opacity = 0.00f;
                    WebLayout.SetCancelButtonColor( ControlStylingConfig.TextField_PlaceholderTextColor );

                    // do a nice fade-in
                    SimpleAnimator_Float floatAnimator = new SimpleAnimator_Float( 0.00f, 1.00f, .25f, 
                        delegate(float percent, object value) 
                        {
                            WebLayout.ContainerView.Layer.Opacity = (float)value;
                        },
                        delegate 
                        {
                            // once faded in, begin loading the page
                            WebLayout.ContainerView.Layer.Opacity = 1.00f;

                            WebLayout.LoadUrl( fromUri, delegate(WebLayout.Result result, string url) 
                                {
                                    BlockerView.Hide( );

                                    // if fail/success comes in
                                    if( result != WebLayout.Result.Cancel )
                                    {
                                        // see if it's a valid facebook response

                                        // if an empty url was returned, it's NOT. Fail.
                                        if( string.IsNullOrEmpty( url ) == true )
                                        {
                                            WebLayout.ContainerView.RemoveFromSuperview( );
                                            BindComplete( false );
                                        }
                                        // otherwise, try to parse the response and move forward
                                        else if ( RockMobileUser.Instance.HasFacebookResponse( url, session ) )
                                        {
                                            // it is, continue the bind process
                                            WebLayout.ContainerView.RemoveFromSuperview( );
                                            RockMobileUser.Instance.FacebookCredentialResult( url, session, BindComplete );

                                            ProfileAnalytic.Instance.Trigger( ProfileAnalytic.Login, "Facebook" );
                                        }
                                    }
                                    else
                                    {
                                        // they pressed cancel, so simply cancel the attempt
                                        WebLayout.ContainerView.RemoveFromSuperview( );
                                        LoginComplete( System.Net.HttpStatusCode.ResetContent, "" );
                                    }
                                } );
                        });

                    floatAnimator.Start( );
            });
        }
Пример #5
0
        public void TryFacebookBind( )
        {
            SetUIState(LoginState.Trying);

            // have our rock mobile user begin the facebook bind process
            RockMobileUser.Instance.BindFacebookAccount(delegate(string fromUri)
            {
                // it's ready, so create a webView that will take them to the FBLogin page
                WebLayout = new WebLayout(ScrollView.Frame);
                WebLayout.DeleteCacheAndCookies( );

                ScrollView.AddSubview(WebLayout.ContainerView);

                // set it totally transparent so we can fade it in
                //WebLayout.ContainerView.BackgroundColor = UIColor.Green;
                WebLayout.ContainerView.Layer.Opacity = 0.00f;
                //WebLayout.SetCancelButtonColor( ControlStylingConfig.TextField_PlaceholderTextColor );
                WebLayout.LayoutChanged(new CGRect(0, 0, ScrollView.Frame.Width, ScrollView.Frame.Height));

                View.SetNeedsLayout( );

                // do a nice fade-in
                SimpleAnimator_Float floatAnimator = new SimpleAnimator_Float(0.00f, 1.00f, .25f,
                                                                              delegate(float percent, object value)
                {
                    WebLayout.ContainerView.Layer.Opacity = (float)value;
                },
                                                                              delegate
                {
                    // once faded in, begin loading the page
                    WebLayout.ContainerView.Layer.Opacity = 1.00f;

                    WebLayout.LoadUrl(fromUri, delegate(WebLayout.Result result, string url)
                    {
                        BlockerView.Hide( );

                        // if fail/success comes in
                        if (result != WebLayout.Result.Cancel)
                        {
                            // see if it's a valid facebook response

                            // if an empty url was returned, it's NOT. Fail.
                            if (string.IsNullOrEmpty(url) == true)
                            {
                                WebLayout.ContainerView.RemoveFromSuperview( );
                                BindComplete(false);
                            }
                            // otherwise, try to parse the response and move forward
                            else if (RockMobileUser.Instance.HasFacebookResponse(url))
                            {
                                // it is, continue the bind process
                                BlockerView.Show();

                                WebLayout.ContainerView.RemoveFromSuperview( );
                                RockMobileUser.Instance.FacebookCredentialResult(url, BindComplete);

                                ProfileAnalytic.Instance.Trigger(ProfileAnalytic.Login, "Facebook");
                            }
                        }
                        else
                        {
                            // they pressed cancel, so simply cancel the attempt
                            WebLayout.ContainerView.RemoveFromSuperview( );
                            LoginComplete(System.Net.HttpStatusCode.ResetContent, "");
                        }
                    });
                });

                floatAnimator.Start( );
            });
        }