Exemple #1
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 OnElementChanged(ElementChangedEventArgs <GoogleSignInButton> e)
        {
            base.OnElementChanged(e);
            if (Control == null)
            {
                SignInButton signInButton = new SignInButton(Context);
                signInButton.SetColorScheme(SignInButton.ColorDark);

                switch (this.Element.Size)
                {
                case GoogleSignInButton.SizeOptions.IconOnly:
                    signInButton.SetSize(SignInButton.SizeIconOnly);
                    break;

                case GoogleSignInButton.SizeOptions.Wide:
                    signInButton.SetSize(SignInButton.SizeWide);
                    break;

                default:
                    signInButton.SetSize(SignInButton.SizeStandard);
                    break;
                }

                switch (this.Element.ColorScheme)
                {
                case GoogleSignInButton.ColorSchemeOptions.Dark:
                    signInButton.SetColorScheme(SignInButton.ColorDark);
                    break;

                default:
                    signInButton.SetColorScheme(SignInButton.ColorLight);
                    break;
                }

                signInButton.Click += SignInButton_Click;

                SetNativeControl(signInButton);
            }
        }
Exemple #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            ItemsFragment itemsFragment;

            itemsFragment = ((StockAppApplicaiton)this.Application).ItemsFragment;
            onSignIn      = itemsFragment;

            SetContentView(Resource.Layout.SignIn); // Create Layout

            if (savedInstanceState != null)
            {
                mIsResolving   = savedInstanceState.GetBoolean(KEY_IS_RESOLVING);
                mShouldResolve = savedInstanceState.GetBoolean(KEY_SHOULD_RESOLVE);
            }

            signInButton     = FindViewById(Resource.Id.sign_in_button) as SignInButton;
            mStatusText      = FindViewById(Resource.Id.status) as TextView;
            signOutButton    = FindViewById(Resource.Id.sign_out_button) as Button;
            disconnectButton = FindViewById(Resource.Id.disconnect_button) as Button;

            signOutButton.Click += async delegate
            {
                var result = await Auth.GoogleSignInApi.SignOut(mGoogleApiClient);

                UpdateUI(false);
                ((StockAppApplicaiton)this.Application).acct     = null;
                ((StockAppApplicaiton)this.Application).SignedIn = false;
                onSignIn.update();
            };

            disconnectButton.Click += async delegate
            {
                var result = await Auth.GoogleSignInApi.RevokeAccess(mGoogleApiClient);

                UpdateUI(false);
                ((StockAppApplicaiton)this.Application).acct     = null;
                ((StockAppApplicaiton)this.Application).SignedIn = false;
                onSignIn.update();
            };

            signInButton.Click += delegate {
                Console.WriteLine("I have been Clicked");
                Intent signInIntent = Auth.GoogleSignInApi.GetSignInIntent(mGoogleApiClient);
                Console.WriteLine("I have Created the Intent");
                StartActivityForResult(signInIntent, RC_SIGN_IN);
                Console.WriteLine("I have started the Activity");
            };
            signInButton.SetSize(SignInButton.SizeWide);
            signInButton.Enabled = false;

            gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultSignIn)
                  .RequestIdToken("50844503444-ufvgj1l9i07r57agtfegnt5tivsvu5b9.apps.googleusercontent.com")
                  .RequestEmail()
                  .Build();
            mGoogleApiClient = new GoogleApiClient.Builder(this)
                               .EnableAutoManage(this, this)
                               .AddApi(Auth.GOOGLE_SIGN_IN_API, gso)
                               .AddScope(new Scope(Scopes.Profile))
                               .Build();
        }