Exemple #1
0
        protected async override void OnAppearing()
        {
            base.OnAppearing();

            // fetch the demo credentials
            await ViewModel.LoadDemoCredentials();

            // pause for a moment before animations
            await Task.Delay(App.AnimationSpeed);

            // Sequentially animate the login buttons. ScaleTo() makes them "grow" from a singularity to the full button size.
            await SignInButton.ScaleTo(1, (uint)App.AnimationSpeed, Easing.SinIn);

            await SkipSignInButton.ScaleTo(1, (uint)App.AnimationSpeed, Easing.SinIn);

            // Using Task.WhenAll() allows these two animations to be run in parallel.
            await Task.WhenAll(new []
            {
                // FadeTo() modifies the Opacity property of the given VisualElements over a given duration.
                XamarinLogo.FadeTo(1, (uint)App.AnimationSpeed, Easing.SinIn),
                InfoButton.FadeTo(1, (uint)App.AnimationSpeed, Easing.SinIn)
            });

            Insights.Track(InsightsReportingConstants.PAGE_SPLASH);
        }
Exemple #2
0
 //Login to SkillSwap Website
 public void LoginStep(string userName, string password)
 {
     SignInButton.Click();
     EmailTextBox.SendKeys(userName);
     PasswordTextBox.SendKeys(password);
     LoginButton.Click();
 }
Exemple #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.login);

            //skip login
            //GoToMainPage(1);

            GoogleApiClient.Builder builder = new GoogleApiClient.Builder(this);
            builder.AddConnectionCallbacks(this);
            builder.AddOnConnectionFailedListener(this);
            builder.AddApi(PlusClass.API);
            builder.AddScope(PlusClass.ScopePlusProfile);
            builder.AddScope(PlusClass.ScopePlusLogin);
            googleApiClient = builder.Build();


            etEmail         = FindViewById <EditText>(Resource.Id.TextEmail);
            etPass          = FindViewById <EditText>(Resource.Id.TextPass);
            btnOK           = FindViewById <Button>(Resource.Id.buttonOk);
            btnGoogleSignIn = FindViewById <SignInButton>(Resource.Id.sign_in_button);


            btnOK.Click           += BtnOK_Click;
            btnGoogleSignIn.Click += BtnGoogleSignIn_Click;
        }
Exemple #4
0
        ///// <summary>
        ///// JQuery selector example
        ///// </summary>
        //public IWebElement LoginButton => WebDriver.FindElementByJQuery("input[name='btnSubmit']");

        public LoginPage BrittleLoginAsAdmin(string baseUrl, string password)
        {
            // https://crm422752.crm.dynamics.com/
            WebDriver.Navigate().GoToUrl(baseUrl);

            UserIdField.Clear();
            // sending a single quote is not possible with the Chrome Driver, it sends two single quotes!
            UserIdField.SendKeys("*****@*****.**");

            NextButton.Click();

            PasswordField.Clear();
            PasswordField.SendKeys(password);

            var wait = new WebDriverWait(WebDriver, TimeSpan.FromSeconds(5));

            wait.Until(f => f.FindElements(By.XPath("//div[@class='col-xs-24 no-padding-left-right button-container']/div/input")).FirstOrDefault());

            SignInButton = WebDriver.FindElements(By.Id("idSIButton9")).FirstOrDefault();
            SignInButton.Click();

            var staySignedInDialog = WebDriver.FindElement(By.XPath("//div[@role='heading']"));

            if (staySignedInDialog?.Text == "Stay signed in?")
            {
                wait = new WebDriverWait(WebDriver, TimeSpan.FromSeconds(5));
                wait.Until(f => f.FindElements(By.XPath("//div[@class='col-xs-24 no-padding-left-right button-container']/div/input")).FirstOrDefault());

                var noButton = WebDriver.FindElements(By.Id("idBtn_Back")).FirstOrDefault();
                noButton.Click();
            }

            return(this);
        }
        void ReleaseDesignerOutlets()
        {
            if (email != null)
            {
                email.Dispose();
                email = null;
            }

            if (password != null)
            {
                password.Dispose();
                password = null;
            }

            if (SignInButton != null)
            {
                SignInButton.Dispose();
                SignInButton = null;
            }

            if (SignUpButton != null)
            {
                SignUpButton.Dispose();
                SignUpButton = null;
            }
        }
Exemple #6
0
 private void ConfigureBtnSignInGplus()
 {
     btnGoogleSingIn = (SignInButton)FindViewById(Resource.Id.sign_in_button);
     btnGoogleSingIn.SetSize(SignInButton.SizeWide);
     btnGoogleSingIn.SetScopes(mGoogleSigninOptions.GetScopeArray());
     btnGoogleSingIn.Click += btnGoogleSingIn_Click;
 }
        protected override void InitBindings()
        {
            MainActivity.CurrentContext.RequestedOrientation = ScreenOrientation.Portrait;
            Bindings = new List <Binding>();
            Bindings.Add(this.SetBinding(() => ViewModel.UserNameInput, () => UsernameInput.Text, BindingMode.TwoWay));
            Bindings.Add(this.SetBinding(() => ViewModel.Authenticating, () => LoginPageLoadingSpinner.Visibility,
                                         BindingMode.OneWay)
                         .ConvertSourceToTarget(Converters.BoolToVisibility));
            Bindings.Add(this.SetBinding(() => ViewModel.PasswordInput, () => PasswordInput.Text, BindingMode.TwoWay));

            Bindings.Add(
                this.SetBinding(() => ViewModel.LogOutButtonVisibility,
                                () => LoginPageLogOutButton.Visibility).ConvertSourceToTarget(Converters.BoolToVisibility));

            PasswordInput.SetOnEditorActionListener(new OnEditorActionListener(action =>
            {
                if (action == ImeAction.Done)
                {
                    ViewModel.LogInCommand.Execute(null);
                }
                AndroidUtilities.HideKeyboard();
            }));

            LoginPageRegisterButton.SetOnClickListener(new OnClickListener(v => ViewModel.NavigateRegister.Execute(null)));
            LoginPageProblemsButton.SetOnClickListener(new OnClickListener(v => ViewModel.ProblemsCommand.Execute(null)));

            SignInButton.SetOnClickListener(new OnClickListener(v =>
            {
                ViewModel.LogInCommand.Execute(null);
                AndroidUtilities.HideKeyboard();
            }));
            LoginPageLogOutButton.SetOnClickListener(new OnClickListener(v => ViewModel.LogOutCommand.Execute(null)));
        }
 public void LoginIntoN11(string username, string password)
 {
     SignInButton.Click();
     EmailTextBox.SendKeys(username);
     PasswordBox.SendKeys(password);
     LoginButton.Click();
 }
Exemple #9
0
        protected override void SetupLayoutConstraints()
        {
            base.SetupLayoutConstraints();

            this.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            this.AddConstraints(
                BackgroundImage.FullSizeOf(this));

            this.AddConstraints(
                LoginField.AtTopOf(this, 220),
                LoginField.AtLeadingOf(this, 50),
                LoginField.AtTrailingOf(this, 50),
                LoginField.Height().EqualTo(Theme.Dimensions.TextFieldHeight),

                PasswordField.Below(LoginField, 12),
                PasswordField.WithSameLeading(LoginField),
                PasswordField.WithSameWidth(LoginField),
                PasswordField.WithSameHeight(LoginField),

                SignInButton.Below(PasswordField, 16),
                SignInButton.WithSameCenterX(this),
                SignInButton.Width().EqualTo(218),
                SignInButton.Height().EqualTo(44),

                ErrorMessageView.Above(LoginField, 36),
                ErrorMessageView.WithSameLeading(LoginField),
                ErrorMessageView.WithSameWidth(LoginField),

                ErrorMessageTriangleImage.Below(ErrorMessageView),
                ErrorMessageTriangleImage.WithSameCenterX(this));
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.login_activity);
            //return base.OnOptionsItemSelected(item);

            FirebaseApp.InitializeApp(this);
            _auth = FirebaseAuth.Instance;

            GoogleButton        = FindViewById <SignInButton>(Resource.Id.gButton);
            GoogleButton.Click += (object sender, System.EventArgs e) =>
            {
                var signGoogleintent = Auth.GoogleSignInApi.GetSignInIntent(_googleApiClient);

                StartActivityForResult(signGoogleintent, Constants.ActionResult.GoogleLoginResul);
            };

            FacebookButton = FindViewById <LoginButton>(Resource.Id.fButton);
            FacebookButton.SetReadPermissions("email", "public_profile");

            callbackManager = CallbackManagerFactory.Create();
            FacebookButton.RegisterCallback(callbackManager, this);

            _googleApiClient = LoginHelper.ConfigureGoogleSignIn(this);
        }
Exemple #11
0
 public void Login(string username, string password)
 {
     UserName.Clear();
     UserName.SendKeys(username);
     Password.SendKeys(password);
     SignInButton.Click();
 }
Exemple #12
0
        private void InitComponent()
        {
            try
            {
                BackgroundImage        = FindViewById <ImageView>(Resource.Id.backgroundimage);
                LogoImage              = FindViewById <ImageView>(Resource.Id.logoimage);
                ForgetPasswordTextView = FindViewById <TextView>(Resource.Id.txt_forgot_pass);
                EmailEditText          = FindViewById <EditText>(Resource.Id.edt_email);
                PasswordEditText       = FindViewById <EditText>(Resource.Id.edt_password);
                LoginButton            = FindViewById <Button>(Resource.Id.SignInButton);
                ProgressBar            = FindViewById <ProgressBar>(Resource.Id.progressBar);
                FbLoginButton          = FindViewById <LoginButton>(Resource.Id.fblogin_button);
                GoogleSignInButton     = FindViewById <SignInButton>(Resource.Id.Googlelogin_button);
                RegisterLayout         = FindViewById <LinearLayout>(Resource.Id.tvRegister);

                if (AppSettings.DisplayImageOnLoginBackground)
                {
                    GlideImageLoader.LoadImage(this, AppSettings.URlImageOnLoginBackground, BackgroundImage, ImageStyle.CenterCrop, ImagePlaceholders.Drawable);
                }

                ProgressBar.Visibility = ViewStates.Invisible;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Exemple #13
0
 private void PasswordTextBox_Enter(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         SignInButton.Focus();
     }
 }
        protected override void OnElementChanged(ElementChangedEventArgs <GoogleSignInButton> e)
        {
            base.OnElementChanged(e);
            if (Control == null)
            {
                SignIn.SharedInstance.ClientID = this.Element.ClientIdiOS;
                SignInButton signInButton = new SignInButton();

                switch (this.Element.Size)
                {
                case GoogleSignInButton.SizeOptions.IconOnly:
                    signInButton.Style = ButtonStyle.IconOnly;
                    break;

                case GoogleSignInButton.SizeOptions.Wide:
                    signInButton.Style = ButtonStyle.Wide;
                    break;

                default:
                    signInButton.Style = ButtonStyle.Standard;
                    break;
                }

                SetNativeControl(signInButton);

                SignIn.SharedInstance.UIDelegate = new GoogleSignInUIDelegate();
                SignIn.SharedInstance.Delegate   = this;
            }
        }
Exemple #15
0
        private void PrepareGoogleSignIn()
        {
            GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultSignIn)
                                      .RequestEmail()
                                      .Build();

            _googleApiClient = new GoogleApiClient.Builder(this)
                               .EnableAutoManage(this, new GoogleConnectionFailedCallback()
            {
                Activity = this
            })
                               .AddApi(Auth.GOOGLE_SIGN_IN_API, gso)
                               .Build();

            googleSignInButton = FindViewById <SignInButton>(Resource.Id.signIn_GoogleSignInButton);

            for (int i = 0; i < googleSignInButton.ChildCount; i++)
            {
                View v = googleSignInButton.GetChildAt(i);

                if (v is TextView tv)
                {
                    tv.SetPadding(0, 0, 20, 0);
                    return;
                }
            }
        }
Exemple #16
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            //Set content View
            SetContentView(Resource.Layout.Main);
            btnLogin      = FindViewById <LoginButton>(Resource.Id.fblogin);
            btnIngresar   = FindViewById <Button>(Resource.Id.btnIngresar);
            btnRegister   = FindViewById <Button>(Resource.Id.btnRegister);
            oSignInButton = FindViewById <SignInButton>(Resource.Id.sign_in_button);
            txtPassword   = FindViewById <EditText>(Resource.Id.txtPassword);
            txtEmail      = FindViewById <EditText>(Resource.Id.txtEmail);

            btnIngresar.Click += BtnIngresar_Click;
            btnRegister.Click += delegate
            {
                StartActivity(typeof(RegisterActivity));
            };

            oSignInButton.Click += OSignInButton_Click;

            btnLogin.Click += delegate
            {
                if (AccessToken.CurrentAccessToken != null && Profile.CurrentProfile != null)
                {
                    ConfigurateFacebookData();
                    StartActivity(typeof(RegisterActivity));
                }
                else
                {
                    ConnectWithFacebook();
                }
            };
        }
Exemple #17
0
 private void Reset()
 {
     user.Text     = "";
     pass.Password = "";
     SignInButton.Focus();
     InvalidLogin.Visibility = Visibility.Hidden;
 }
 public RegistrationPage ClickOnSignInButton(Registration person)
 {
     WelcomeEmailInput.Clear();
     WelcomeEmailInput.SendKeys(person.EMail);
     SignInButton.Click();
     return(new RegistrationPage(driver));
 }
Exemple #19
0
 private void LogInForm_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         SignInButton.PerformClick();
     }
 }
        public void FillEmailForm(PracticeRegistrationModel user)
        {
            SignInButton.Click();
            EmailAddressField.SendKeys(user.EmailAddressField);
            CreateAccountButton.Click();
            RadioButton.Click();
            FirstName.SendKeys(user.FirstName);
            LastName.SendKeys(user.LastName);
            Password.SendKeys(user.Password);

            SelectElement date = new SelectElement(Date);

            date.SelectByValue("1");
            SelectElement month = new SelectElement(Month);

            month.SelectByValue("2");
            SelectElement year = new SelectElement(Year);

            year.SelectByValue("2010");

            Address.SendKeys(user.Address);
            City.SendKeys(user.City);

            SelectElement state = new SelectElement(State);

            state.SelectByValue("2");

            ZipCode.SendKeys(user.ZipCode);
            MobilePhone.SendKeys(user.MobilePhone);
            RegisterButton.Click();
        }
Exemple #21
0
        void ReleaseDesignerOutlets()
        {
            if (BlueLineHeight != null)
            {
                BlueLineHeight.Dispose();
                BlueLineHeight = null;
            }

            if (platformTop != null)
            {
                platformTop.Dispose();
                platformTop = null;
            }

            if (sign != null)
            {
                sign.Dispose();
                sign = null;
            }

            if (SignInButton != null)
            {
                SignInButton.Dispose();
                SignInButton = null;
            }

            if (SignInHeight != null)
            {
                SignInHeight.Dispose();
                SignInHeight = null;
            }
        }
Exemple #22
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            System.Diagnostics.Debug.WriteLine("In login page...");
            SetContentView(Resource.Layout.Login);
            mGoogleSignIn = FindViewById <SignInButton>(Resource.Id.sign_in_button);
            Android.Widget.Button b2 = FindViewById <Android.Widget.Button>(Resource.Id.button1);
            b2.Click += delegate
            {
                StartActivity(typeof(register));
            };

            mGoogleSignIn.Click += mGoogleSignIn_Click;

            GoogleApiClient.Builder builder = new GoogleApiClient.Builder(this);
            builder.AddConnectionCallbacks(this);
            builder.AddOnConnectionFailedListener(this);
            builder.AddApi(PlusClass.API);
            builder.AddScope(PlusClass.ScopePlusProfile);
            builder.AddScope(PlusClass.ScopePlusLogin);

            //Build our IGoogleApiClient
            mGoogleApiClient = builder.Build();
        }
        public LogInForm OpenLoginForm()
        {
            try
            {
                //Click Sign in button
                SignInButton.JSclick(_signInButtonBy);

                WaitTillElementIsVisible(_logInInputBy);

                if (RussianLanguageIsSelected.Displayed)
                {
                    RussianLanguageIsSelected.Click();
                    WaitTillElementIsVisible(_contentBy);
                    EnglishLanguage.Click();
                    WaitTillElementIsVisible(_nextButtonBy);
                }
            }
            catch (Exception ex)

            {
                Log.Error(ex, "Log in form was not opened");
            }

            return(new LogInForm());
        }
Exemple #24
0
        void ReleaseDesignerOutlets()
        {
            if (Password != null)
            {
                Password.Dispose();
                Password = null;
            }

            if (SignImage != null)
            {
                SignImage.Dispose();
                SignImage = null;
            }

            if (SignInButton != null)
            {
                SignInButton.Dispose();
                SignInButton = null;
            }

            if (SignUpButton != null)
            {
                SignUpButton.Dispose();
                SignUpButton = null;
            }

            if (UserName != null)
            {
                UserName.Dispose();
                UserName = null;
            }
        }
Exemple #25
0
        private async Task TrySignIn()
        {
            try
            {
                bool success = await ViewModel.SignInAsync();

                if (success)
                {
                    Analytics.TrackEvent("Sign in success");
                    ((App)Application.Current).NavigateToFirstPage(arguments, true);
                }
            }
            catch (BackendAuthenticationFailedException)
            {
                Analytics.TrackEvent("Sign in failed");
                var shakeAnimation = Window.Current.Compositor.CreateVector3KeyFrameAnimation();
                shakeAnimation.InsertKeyFrame(0.125f, new Vector3(-10.0f, 0.0f, 0.0f));
                shakeAnimation.InsertKeyFrame(0.375f, new Vector3(010.0f, 0.0f, 0.0f));
                shakeAnimation.InsertKeyFrame(0.625f, new Vector3(-10.0f, 0.0f, 0.0f));
                shakeAnimation.InsertKeyFrame(0.875f, new Vector3(010.0f, 0.0f, 0.0f));
                shakeAnimation.InsertKeyFrame(1.000f, new Vector3(000.0f, 0.0f, 0.0f));
                shakeAnimation.Duration = TimeSpan.FromMilliseconds(500);
                shakeAnimation.Target   = "Translation";
                SignInButton.StartAnimation(shakeAnimation);
            }
        }
Exemple #26
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_result);

            SignInButton.SetCommand("Click", Vm.BackToLoginCommand);
        }
 public void NavigateToRegPage(LoginPage loginPage)
 {
     loginPage.Navigate("http://automationpractice.com/index.php");
     SignInButton.Click();
     EmailInput.SendKeys("*****@*****.**");
     CreateAccountButton.Click();
 }
Exemple #28
0
 public HomePage LogIn(IWebDriver driver, string login, string password)
 {
     driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);
     InputLogin(login);
     InputPassword(password);
     SignInButton.Click();
     return(new HomePage());
 }
 public void ExistingUser()
 {
     SignInButton.Click();
     Thread.Sleep(1000);
     EnterEmail.SendKeys("*****@*****.**");
     EnterPassword.SendKeys("123qwe");
     Login.Submit();
 }
Exemple #30
0
        public void NavigationEmailForm(AutomationPracticeRegistrationModel user)
        {
            SignInButton.Click();
            EmailAddressField.SendKeys(user.EmailAddressField);
            CreateAccountButton.Click();

            Driver.ScrollTo(EmailField);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            View.BackgroundColor = UIColor.White;

            btnSignIn = new SignInButton () {
                Frame = new RectangleF (85, 176, 151, 48)
            };

            View.AddSubview (btnSignIn);
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.Main);
            imageLoader = new ImageLoader (this);
            progressDialog = new ProgressDialog (this);
            progressDialog.Indeterminate = true;
            progressDialog.SetMessage ("Connecting");

            plusClient = new PlusClient.Builder(this, this, this).Build();

            googleLoginButton = FindViewById<SignInButton> (Resource.Id.sign_in_button);
            plusOneButton = FindViewById<PlusOneButton> (Resource.Id.plus_one_button);

            var logoutButton = FindViewById<Button> (Resource.Id.logout_button);
            logoutButton.Click += (sender, e) => {
                if(!plusClient.IsConnected || plusClient.IsConnecting)
                    return;

                plusClient.RevokeAccessAndDisconnect(this);
            };

            googleLoginButton.Click += (sender, e) => {
                if(plusClient.IsConnected || plusClient.IsConnecting)
                    return;

                progressDialog.Show();

                if (connectionResult == null) {
                    plusClient.Connect();
                }
                else{
                    ResolveLogin(connectionResult);
                }
            };

            plusClient.RegisterConnectionCallbacks (this);
            plusClient.IsConnectionFailedListenerRegistered (this);
        }
        protected override void OnCreate (Bundle savedInstanceState)
        {
            base.OnCreate (savedInstanceState);
            // If you want to understand the life cycle more, you can use below command to turn on
            // verbose logging for this Activity on your testing device:
            // adb shell setprop log.tag.SignInActivity VERBOSE
            mIsLogVerbose = Android.Util.Log.IsLoggable (TAG, Android.Util.LogPriority.Verbose);

            SetContentView (Resource.Layout.sign_in_activity);

            restoreState (savedInstanceState);

            logVerbose ("Activity onCreate, creating new GoogleApiClient");

            mGoogleApiClient = buildGoogleApiClient (false);

            mSignInStatus = FindViewById<TextView> (Resource.Id.sign_in_status);
            mSignInButton = FindViewById<SignInButton> (Resource.Id.sign_in_button);
            mSignInButton.Click += (sender, e) => {
                if (!mGoogleApiClient.IsConnecting) {
                    int available = GooglePlayServicesUtil.IsGooglePlayServicesAvailable (this);
                    if (available != ConnectionResult.Success) {
                        ShowDialog (DIALOG_GET_GOOGLE_PLAY_SERVICES);
                        return;
                    }

                    mSignInClicked = true;
                    mSignInStatus.Text = GetString (Resource.String.signing_in_status);
                    resolveSignInError ();
                }
            };

            mServerAuthCodeDisabledLabel = FindViewById<TextView> (Resource.Id.server_auth_code_disabled);
            mServerAuthCodeResetButton = FindViewById<View> (Resource.Id.server_auth_code_reset_button);
            mServerAuthCodeResetButton.Click += (sender, e) => {
                mServerAuthCodeRequired.Set (true);
            };
            if (!isUsingOfflineAccess ()) {
                mServerAuthCodeDisabledLabel.Visibility = ViewStates.Visible;
                mServerAuthCodeResetButton.Visibility = ViewStates.Gone;
            } else {
                mServerAuthCodeDisabledLabel.Visibility = ViewStates.Gone;
                mServerAuthCodeResetButton.Visibility = ViewStates.Visible;
            }

            mSignOutButton = FindViewById<View> (Resource.Id.sign_out_button);
            mSignOutButton.Click += (sender, e) => {
                if (mGoogleApiClient.IsConnected)
                    mGoogleApiClient.ClearDefaultAccountAndReconnect ();
            };
            mRevokeAccessButton = FindViewById (Resource.Id.revoke_access_button);
            mRevokeAccessButton.Click += async delegate {
                mServerAuthCodeRequired.Set (true);
                if (mGoogleApiClient.IsConnected) {
                    var result = await PlusClass.AccountApi.RevokeAccessAndDisconnectAsync (mGoogleApiClient);

                    if (result.IsSuccess) {
                        mSignInStatus.SetText (Resource.String.revoke_access_status);
                    } else {
                        mSignInStatus.SetText (Resource.String.revoke_access_error_status);
                    }
                    mGoogleApiClient.Reconnect ();
                       
                    updateButtons (false /* isSignedIn */);
                }
            };

            mScopeSelector = FindViewById<ToggleButton> (Resource.Id.scope_selection_toggle);
            mScopeSelector.CheckedChange += (sender, e) => {
                mGoogleApiClient.Disconnect ();
                // Since we changed the configuration, the cached connection result is no longer
                // valid.
                mConnectionResult = null;
                mGoogleApiClient = buildGoogleApiClient (e.IsChecked);
                mGoogleApiClient.Connect ();
            };


            if (Build.VERSION.SdkInt >= BuildVersionCodes.Honeycomb) {
                ActionBar.SetDisplayHomeAsUpEnabled (true);
            }
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Splash);

            signInBtn = FindViewById<SignInButton>(Resource.Id.splash_signIn);
            signInBtn.SetOnClickListener(this);
            signInBtn.Enabled = false;

            loadingText = FindViewById<TextView>(Resource.Id.splash_loading);

            apiClient = new GoogleApiClientBuilder(this)
                .AddConnectionCallbacks(this)
                .AddOnConnectionFailedListener(this)
                .AddApi(PlusClass.API)
                .AddScope(PlusClass.ScopePlusProfile).Build();

            signOut = Intent.GetBooleanExtra("signOut", false);
            revokeAccess = Intent.GetBooleanExtra("revokeGoogle", false);

            ThreadPool.QueueUserWorkItem(o => AttemptLoad());
        }
        public override void ViewWillAppear(bool animated)
        {
            this.Email.Background = UIImage.FromFile ("./Assets/input.png");
            this.Password.Background = UIImage.FromFile ("./Assets/input.png");
            this.Login.SetBackgroundImage (UIImage.FromFile ("./Assets/buttonlong.png"), UIControlState.Normal);

            this.Email.LeftView = new UIView (new RectangleF (0, 0, 5, 30));
            this.Email.LeftViewMode = UITextFieldViewMode.Always;
            this.Password.LeftView = new UIView (new RectangleF (0, 0, 5, 30));
            this.Password.LeftViewMode = UITextFieldViewMode.Always;

            var button = new UIBarButtonItem ("Back", UIBarButtonItemStyle.Plain, null);
            var custom = new UIButton (new RectangleF (0, 0, 26, 15));
            custom.SetBackgroundImage(UIImage.FromFile("./Assets/back.png"), UIControlState.Normal);
            custom.TouchUpInside += (sender, e) => NavigationController.PopViewControllerAnimated (true);
            button.CustomView = custom;

            this.NavigationItem.LeftBarButtonItem = button;
            this.NavigationController.SetNavigationBarHidden (false, false);

            // FACEBOOK LOGIN
            fbLogin = new FBLoginView (AppDelegate.Permissions);
            FacebookView.AddSubview (fbLogin);
            fbLogin.SizeToFit ();

            fbLogin.FetchedUserInfo += (object sender, FBLoginViewUserInfoEventArgs e) => {
                if (FBSession.ActiveSession.IsOpen) {
                    var model = new FacebookProfile { Id = long.Parse (e.User.Id), Name = e.User.Name,
                        first_name = e.User.FirstName, last_name = e.User.LastName,
                        Birthday = e.User.Birthday, Email = e.User.ObjectForKey ("email").ToString (), UserName = e.User.Username
                    };
                    var request = new RestRequest ();
                    request.RequestFinished += (object sendr, RequestEndedArgs ev) => {
                        var jsonId = (int)JsonConvert.DeserializeObject (ev.Result, typeof(int));
                        InvokeOnMainThread (delegate {
                            AppDelegate.SaveProfileId(jsonId);
                            var tabbar = new MainTabController();
                            UIApplication.SharedApplication.Delegate.Window.RootViewController = tabbar;
                        });
                    };
                    request.Send (RequestConfig.Facebook, "POST", model);
                }
            };

            fbLogin.ShowingLoggedOutUser += (object sender, EventArgs e) => {
                Console.WriteLine(e.ToString());
            };
            fbLogin.ShowingLoggedInUser += (object sender, EventArgs e) => {
                Console.WriteLine("Logged in.");
            };

            // GOOGLE LOGIN
            var signIn = SignIn.SharedInstance;
            signIn.ClientId = AppDelegate.GoogleClientId;
            signIn.Scopes = new [] { PlusConstants.AuthScopePlusLogin, PlusConstants.AuthScopePlusMe,
                                    "https://www.googleapis.com/auth/userinfo.profile",
                                    "https://www.googleapis.com/auth/userinfo.email" };
            signIn.ShouldFetchGoogleUserEmail = true;
            signIn.ShouldFetchGoogleUserId = true;

            signIn.Finished += (object sender, SignInDelegateFinishedEventArgs e) => {
                if(e.Error != null) {
                    InvokeOnMainThread(delegate {
                        new UIAlertView("Error.", "Could not sign in.", null, "Ok", null).Show();
                    });
                }
                else {
                    var request = new RestRequest();
                    request.RequestFinished += (object sendr, RequestEndedArgs ev) => {
                        var data = (GoogleClient)JsonConvert.DeserializeObject(ev.Result, typeof(GoogleClient));
                        var request2 = new RestRequest();
                        request2.RequestFinished += (object sndr, RequestEndedArgs evnt) => {
                            var jsonId = (int)JsonConvert.DeserializeObject (evnt.Result, typeof(int));
                            InvokeOnMainThread (delegate {
                                AppDelegate.SaveProfileId(jsonId);
                                var tabbar = new MainTabController();
                                UIApplication.SharedApplication.Delegate.Window.RootViewController = tabbar;
                            });
                        };
                        request2.Send(RequestConfig.Google, "POST", data);
                    };
                    request.Send(String.Format(RequestConfig.GoogleFetch, Uri.EscapeDataString(signIn.Authentication.AccessToken)), "GET");
                }
            };

            var signInButton = new SignInButton ();
            GoogleView.AddSubview (signInButton);
            signInButton.Frame = new RectangleF (0, 0, GoogleView.Frame.Size.Width - 8, GoogleView.Frame.Size.Height);
            signInButton.SizeToFit ();
        }
		/* 
		 * Achievements
		"10 Hits","CgkIl8Dgls4FEAIQAg"
		"20 Hits","CgkIl8Dgls4FEAIQAw"
		"50 hits","CgkIl8Dgls4FEAIQBA"
		"100 Hits","CgkIl8Dgls4FEAIQBQ"
		"200 Hits","CgkIl8Dgls4FEAIQBg"
		*/

		/*
		 * Leaderboards
		"Top Scores","CgkIl8Dgls4FEAIQBw"
		*/

		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

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

			signInLayout = FindViewById<LinearLayout> (Resource.Id.signinlayout);
			controlsLayout = FindViewById<LinearLayout> (Resource.Id.controlslayout);

			signInButton = FindViewById<SignInButton> (Resource.Id.signin);
			signInButton.Click += (object sender, EventArgs e) => {
				if (helper != null && helper.SignedOut) {
					helper.SignIn ();
				}
			};

			signOutButton = FindViewById<Button> (Resource.Id.signout);
			signOutButton.Click += (object sender, EventArgs e) => {
				if (helper != null && !helper.SignedOut) {
					helper.SignOut ();
					signInLayout.Visibility = ViewStates.Visible;
					controlsLayout.Visibility = ViewStates.Gone;
				}
			};

			awardAchievementButton = FindViewById<Button> (Resource.Id.awardachievement);
			achievementCode = FindViewById<EditText> (Resource.Id.achievementcode);

			awardAchievementButton.Click += (object sender, EventArgs e) => {
				if (helper != null && !helper.SignedOut) {
					helper.UnlockAchievement(achievementCode.Text);
				}
			};

			showAchievements = FindViewById<Button> (Resource.Id.showachievement);
			showAchievements.Click += (object sender, EventArgs e) => {
				if (helper != null && !helper.SignedOut) {
					helper.ShowAchievements();
				}
			};

			leaderboardCode = FindViewById<EditText> (Resource.Id.leaderboardcode);
			score = FindViewById<EditText> (Resource.Id.score);

			showAllLeaderboards = FindViewById<Button> (Resource.Id.showallleaderboards);
			showAllLeaderboards.Click += (object sender, EventArgs e) => {
				if (helper != null && !helper.SignedOut) {
					helper.ShowAllLeaderBoardsIntent();
				}
			};

			showLeaderboard = FindViewById<Button> (Resource.Id.showleaderboard);
			showLeaderboard.Click += (object sender, EventArgs e) => {
				if (helper != null && !helper.SignedOut) {
					var code = leaderboardCode.Text;
					helper.ShowLeaderBoardIntentForLeaderboard(code);
				}
			};

			submitScore = FindViewById<Button> (Resource.Id.submitscore);
			submitScore.Click += (object sender, EventArgs e) => {
				if (helper != null && !helper.SignedOut) {
					var code = leaderboardCode.Text;
					var value = int.Parse(score.Text);
					helper.SubmitScore(code, value);
				}
			};
				
			InitializeServices ();

		}