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; }
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"); } }); // }); } }
public bool OnBackPressed( ) { if (WebLayout != null) { return(WebLayout.OnBackPressed( )); } return(false); }
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 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.GetCurrentContainerDisplayWidth( ), this.Resources.DisplayMetrics.HeightPixels), delegate { ResultView.Hide( ); if (string.IsNullOrEmpty(Url) == false) { ProcessUrl( ); } }); // get our power management control PowerManager pm = PowerManager.FromContext(Rock.Mobile.PlatformSpecific.Android.Core.Context); WakeLock = pm.NewWakeLock(WakeLockFlags.Full, "TaskWeb"); return(view); }
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( ); }); }
public override void OnDestroyView() { base.OnDestroyView(); WebLayout.Destroy( ); }
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; } View view = inflater.Inflate(Resource.Layout.Login, container, false); view.SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BackgroundColor ) ); view.SetOnTouchListener( this ); RelativeLayout navBar = view.FindViewById<RelativeLayout>( Resource.Id.navbar_relative_layout ); navBar.SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BackgroundColor ) ); RectangleF bounds = new System.Drawing.RectangleF( 0, 0, NavbarFragment.GetFullDisplayWidth( ), this.Resources.DisplayMetrics.HeightPixels ); BlockerView = new UIBlockerView( view, bounds ); LoginResultLayer = view.FindViewById<View>( Resource.Id.result_background ); ControlStyling.StyleBGLayer( LoginResultLayer ); LoginResultLayer.Alpha = 0.0f; LoginButton = view.FindViewById<Button>( Resource.Id.loginButton ); ControlStyling.StyleButton( LoginButton, LoginStrings.LoginButton, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize ); LoginButton.Click += (object sender, EventArgs e) => { TryRockBind( ); }; CancelButton = view.FindViewById<Button>( Resource.Id.cancelButton ); ControlStyling.StyleButton( CancelButton, GeneralStrings.Cancel, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize ); CancelButton.Background = null; CancelButton.Click += (object sender, EventArgs e) => { SpringboardParent.ModalFragmentDone( null ); }; TextView additionalOptions = view.FindViewById<TextView>( Resource.Id.additionalOptions ); ControlStyling.StyleUILabel( additionalOptions, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize ); additionalOptions.Text = LoginStrings.AdditionalOptions; TextView orTextView = view.FindViewById<TextView>( Resource.Id.orTextView ); ControlStyling.StyleUILabel( orTextView, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize ); orTextView.Text = LoginStrings.OrString; RegisterButton = view.FindViewById<Button>( Resource.Id.registerButton ); ControlStyling.StyleButton( RegisterButton, LoginStrings.RegisterButton, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize ); RegisterButton.Click += (object sender, EventArgs e ) => { SpringboardParent.ModalFragmentDone( null ); SpringboardParent.RegisterNewUser( ); }; // get the username field and background UsernameLayer = view.FindViewById<View>( Resource.Id.login_background ); ControlStyling.StyleBGLayer( UsernameLayer ); UsernameField = view.FindViewById<EditText>( Resource.Id.usernameText ); UserNameBGColor = ControlStylingConfig.BG_Layer_Color; ControlStyling.StyleTextField( UsernameField, LoginStrings.UsernamePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); View borderView = UsernameLayer.FindViewById<View>( Resource.Id.middle_border ); borderView.SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_BorderColor ) ); // get the password field and background PasswordLayer = view.FindViewById<View>( Resource.Id.password_background ); ControlStyling.StyleBGLayer( PasswordLayer ); PasswordField = view.FindViewById<EditText>( Resource.Id.passwordText ); PasswordBGColor = ControlStylingConfig.BG_Layer_Color; ControlStyling.StyleTextField( PasswordField, LoginStrings.PasswordPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); LoginResultLabel = view.FindViewById<TextView>( Resource.Id.loginResult ); ControlStyling.StyleUILabel( LoginResultLabel, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); // Setup the facebook button FacebookButton = view.FindViewById<ImageButton>( Resource.Id.facebookButton ); FacebookButton.Background = null; FacebookButton.Click += (object sender, EventArgs e ) => { TryFacebookBind( ); }; // invoke a webview 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 ); return view; }
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( ); }); }
public override void ViewDidLayoutSubviews( ) { base.ViewDidLayoutSubviews( ); nfloat headerHeight = 0; ScrollView.Bounds = View.Bounds; // see if there's a safe area due to this being a "notch" device nfloat safeAreaTopInset = 0; nfloat safeAreaBotInset = 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; safeAreaBotInset = UIApplication.SharedApplication.KeyWindow.SafeAreaInsets.Bottom; } // if there's no top safe area, there WILL be a header, so adjust for it. if (safeAreaTopInset == 0) { HeaderView.Frame = new CGRect(View.Frame.Left, 0, View.Frame.Width, StyledTextField.StyledFieldHeight); // setup the header shadow UIBezierPath shadowPath = UIBezierPath.FromRect(HeaderView.Bounds); HeaderView.Layer.MasksToBounds = false; HeaderView.Layer.ShadowColor = UIColor.Black.CGColor; HeaderView.Layer.ShadowOffset = new CoreGraphics.CGSize(0.0f, .0f); HeaderView.Layer.ShadowOpacity = .23f; HeaderView.Layer.ShadowPath = shadowPath.CGPath; // the logo may not exist if we're on a display with a notch if (LogoView != null) { LogoView.Layer.Position = new CoreGraphics.CGPoint((HeaderView.Bounds.Width - LogoView.Bounds.Width) / 2, 0); } headerHeight = HeaderView.Bounds.Height; // only move down the scrollview if there's a header ScrollView.Frame = new CGRect(View.Frame.Left, HeaderView.Frame.Bottom, View.Frame.Right, View.Frame.Bottom - headerHeight); } else { // otherwise, there's a safe area, so no header. We should therefore adjust the scrollview to be at the top of the window. ScrollView.Frame = new CGRect(View.Frame.Left, View.Frame.Top + safeAreaTopInset, View.Frame.Right, View.Frame.Bottom - (safeAreaBotInset + safeAreaTopInset)); } UserNameField.SetFrame(new CGRect(-10, View.Frame.Height * .10f, View.Frame.Width + 20, StyledTextField.StyledFieldHeight)); PasswordField.SetFrame(new CGRect(UserNameField.Background.Frame.Left, UserNameField.Background.Frame.Bottom, View.Frame.Width + 20, StyledTextField.StyledFieldHeight)); // use the facebook image's button width, as it looks good. nfloat buttonWidth = FBImageView.Bounds.Width; LoginButton.Frame = new CGRect((ScrollView.Bounds.Width - buttonWidth) / 2, PasswordField.Background.Frame.Bottom + 20, buttonWidth, ControlStyling.ButtonHeight); LoginResult.SetFrame(new CGRect(UserNameField.Background.Frame.Left, LoginButton.Frame.Bottom + 20, View.Frame.Width + 20, StyledTextField.StyledFieldHeight)); AdditionalOptions.Frame = new CGRect((View.Bounds.Width - AdditionalOptions.Bounds.Width) / 2, LoginResult.Background.Frame.Bottom + 10, AdditionalOptions.Bounds.Width, ControlStyling.ButtonHeight); // setup the "Forgot account, Register or Facebook" ForgotPasswordButton.Frame = new CGRect((View.Bounds.Width - buttonWidth) / 2, AdditionalOptions.Frame.Bottom + 5, buttonWidth, ControlStyling.ButtonHeight); RegisterButton.Frame = new CGRect((View.Bounds.Width - buttonWidth) / 2, ForgotPasswordButton.Frame.Bottom + 15, buttonWidth, ControlStyling.ButtonHeight); OrSpacerLabel.Frame = new CGRect((View.Bounds.Width - OrSpacerLabel.Bounds.Width) / 2, RegisterButton.Frame.Bottom + 5, OrSpacerLabel.Bounds.Width, FBImageView.Bounds.Height); FacebookLogin.Frame = new CGRect((View.Bounds.Width - FBImageView.Bounds.Width) / 2, OrSpacerLabel.Frame.Bottom + 5, FBImageView.Bounds.Width, FBImageView.Bounds.Height); // CancelButton.Frame = new CGRect((View.Frame.Width - CancelButton.Frame.Width) / 2, FacebookLogin.Frame.Bottom + 20, CancelButton.Frame.Width, CancelButton.Frame.Height); FBImageView.Layer.Position = new CoreGraphics.CGPoint(FacebookLogin.Bounds.Width / 2, FacebookLogin.Bounds.Height / 2); if (WebLayout != null) { WebLayout.LayoutChanged(new CGRect(0, 0, ScrollView.Frame.Width, ScrollView.Frame.Height)); } BlockerView.SetBounds(View.Frame.ToRectF( )); ScrollView.ContentSize = new CGSize(View.Bounds.Width, Math.Max(ScrollView.Bounds.Height * 1.02f, CancelButton.Frame.Bottom + 20 + headerHeight)); }
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); } View view = inflater.Inflate(Resource.Layout.Login, container, false); view.SetBackgroundColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BackgroundColor)); view.SetOnTouchListener(this); RelativeLayout navBar = view.FindViewById <RelativeLayout>(Resource.Id.navbar_relative_layout); navBar.SetBackgroundColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BackgroundColor)); RectangleF bounds = new System.Drawing.RectangleF(0, 0, NavbarFragment.GetFullDisplayWidth( ), this.Resources.DisplayMetrics.HeightPixels); BlockerView = new UIBlockerView(view, bounds); LoginResultLayer = view.FindViewById <View>(Resource.Id.result_background); ControlStyling.StyleBGLayer(LoginResultLayer); LoginResultLayer.Alpha = 0.0f; LoginButton = view.FindViewById <Button>(Resource.Id.loginButton); ControlStyling.StyleButton(LoginButton, LoginStrings.LoginButton, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize); LoginButton.Click += (object sender, EventArgs e) => { TryRockBind( ); }; CancelButton = view.FindViewById <Button>(Resource.Id.cancelButton); ControlStyling.StyleButton(CancelButton, GeneralStrings.Cancel, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize); CancelButton.Background = null; CancelButton.Click += (object sender, EventArgs e) => { SpringboardParent.ModalFragmentDone(null); }; TextView additionalOptions = view.FindViewById <TextView>(Resource.Id.additionalOptions); ControlStyling.StyleUILabel(additionalOptions, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize); additionalOptions.Text = LoginStrings.AdditionalOptions; TextView orTextView = view.FindViewById <TextView>(Resource.Id.orTextView); ControlStyling.StyleUILabel(orTextView, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize); orTextView.Text = LoginStrings.OrString; RegisterButton = view.FindViewById <Button>(Resource.Id.registerButton); ControlStyling.StyleButton(RegisterButton, LoginStrings.RegisterButton, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize); RegisterButton.Click += (object sender, EventArgs e) => { SpringboardParent.ModalFragmentDone(null); SpringboardParent.RegisterNewUser( ); }; ForgotPasswordButton = view.FindViewById <Button>(Resource.Id.forgotPasswordButton); ControlStyling.StyleButton(ForgotPasswordButton, LoginStrings.ForgotPasswordButton, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize); ForgotPasswordButton.Click += (object sender, EventArgs e) => { TaskWebFragment.HandleUrl(true, true, LoginConfig.ForgotPassword_Url, null, null); }; // get the username field and background UsernameLayer = view.FindViewById <View>(Resource.Id.login_background); ControlStyling.StyleBGLayer(UsernameLayer); UsernameField = view.FindViewById <EditText>(Resource.Id.usernameText); UserNameBGColor = ControlStylingConfig.BG_Layer_Color; ControlStyling.StyleTextField(UsernameField, LoginStrings.UsernamePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize); View borderView = UsernameLayer.FindViewById <View>(Resource.Id.middle_border); borderView.SetBackgroundColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BG_Layer_BorderColor)); // get the password field and background PasswordLayer = view.FindViewById <View>(Resource.Id.password_background); ControlStyling.StyleBGLayer(PasswordLayer); PasswordField = view.FindViewById <EditText>(Resource.Id.passwordText); PasswordBGColor = ControlStylingConfig.BG_Layer_Color; ControlStyling.StyleTextField(PasswordField, LoginStrings.PasswordPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize); LoginResultLabel = view.FindViewById <TextView>(Resource.Id.loginResult); ControlStyling.StyleUILabel(LoginResultLabel, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize); // Setup the facebook button FacebookButton = view.FindViewById <ImageButton>(Resource.Id.facebookButton); FacebookButton.Background = null; FacebookButton.Click += (object sender, EventArgs e) => { TryFacebookBind( ); }; // invoke a webview 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); return(view); }