Exemplo n.º 1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            _button = FindViewById <PlusOneButton>(Resource.Id.plus_button);
            _button.PlusOneClickEvent += _button_PlusOneClickEvent;
        }
Exemplo n.º 2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.plus_one_activity);

            /*
             * The {@link PlusOneButton} can be configured in code, but in this example we
             * have set the parameters in the layout.
             *
             * Example:
             * mPlusOneSmallButton.setAnnotation(PlusOneButton.ANNOTATION_INLINE);
             * mPlusOneSmallButton.setSize(PlusOneButton.SIZE_MEDIUM);
             */
            mPlusOneSmallButton    = FindViewById <PlusOneButton> (Resource.Id.plus_one_small_button);
            mPlusOneMediumButton   = FindViewById <PlusOneButton> (Resource.Id.plus_one_medium_button);
            mPlusOneTallButton     = FindViewById <PlusOneButton> (Resource.Id.plus_one_tall_button);
            mPlusOneStandardButton = FindViewById <PlusOneButton> (Resource.Id.plus_one_standard_button);
            mPlusOneStandardButtonWithAnnotation = FindViewById <PlusOneButton> (Resource.Id.plus_one_standard_ann_button);

            if (Build.VERSION.SdkInt >= BuildVersionCodes.Honeycomb)
            {
                ActionBar.SetDisplayHomeAsUpEnabled(true);
            }
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        override protected void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(R.Layout.plus_one_activity);

            // The +1 button does not require scopes.
            mPlusClient = new PlusClient.Builder(this, this, this)
                          .ClearScopes()
                          .Build();

            // The PlusOneButton can be configured in code, but in this example we
            // have set the parameters in the layout.
            // Example:
            // mPlusOneSmallButton.setAnnotation(PlusOneButton.ANNOTATION_INLINE);
            // mPlusOneSmallButton.setSize(PlusOneButton.SIZE_MEDIUM);
            mPlusOneSmallButton    = (PlusOneButton)FindViewById(R.Id.plus_one_small_button);
            mPlusOneMediumButton   = (PlusOneButton)FindViewById(R.Id.plus_one_medium_button);
            mPlusOneTallButton     = (PlusOneButton)FindViewById(R.Id.plus_one_tall_button);
            mPlusOneStandardButton = (PlusOneButton)FindViewById(R.Id.plus_one_standard_button);
            mPlusOneStandardButtonWithAnnotation = (PlusOneButton)FindViewById(R.Id.plus_one_standard_ann_button);
        }
Exemplo n.º 5
0
      override protected void OnCreate(Bundle savedInstanceState)
      {
         base.OnCreate(savedInstanceState);
         SetContentView(R.Layout.plus_one_activity);

         // The +1 button does not require scopes.
         mPlusClient = new PlusClient.Builder(this, this, this)
          .ClearScopes()
          .Build();

         // The PlusOneButton can be configured in code, but in this example we
         // have set the parameters in the layout.
         // Example:
         // mPlusOneSmallButton.setAnnotation(PlusOneButton.ANNOTATION_INLINE);
         // mPlusOneSmallButton.setSize(PlusOneButton.SIZE_MEDIUM);
         mPlusOneSmallButton = (PlusOneButton)FindViewById(R.Id.plus_one_small_button);
         mPlusOneMediumButton = (PlusOneButton)FindViewById(R.Id.plus_one_medium_button);
         mPlusOneTallButton = (PlusOneButton)FindViewById(R.Id.plus_one_tall_button);
         mPlusOneStandardButton = (PlusOneButton)FindViewById(R.Id.plus_one_standard_button);
         mPlusOneStandardButtonWithAnnotation = (PlusOneButton)FindViewById(R.Id.plus_one_standard_ann_button);
      }
Exemplo n.º 6
0
        protected override void OnCreate (Bundle savedInstanceState) 
        {
            base.OnCreate (savedInstanceState);

            SetContentView (Resource.Layout.plus_one_activity);

            /*
         * The {@link PlusOneButton} can be configured in code, but in this example we
         * have set the parameters in the layout.
         *
         * Example:
         * mPlusOneSmallButton.setAnnotation(PlusOneButton.ANNOTATION_INLINE);
         * mPlusOneSmallButton.setSize(PlusOneButton.SIZE_MEDIUM);
         */
            mPlusOneSmallButton = FindViewById<PlusOneButton> (Resource.Id.plus_one_small_button);
            mPlusOneMediumButton = FindViewById<PlusOneButton> (Resource.Id.plus_one_medium_button);
            mPlusOneTallButton = FindViewById<PlusOneButton> (Resource.Id.plus_one_tall_button);
            mPlusOneStandardButton = FindViewById<PlusOneButton> (Resource.Id.plus_one_standard_button);
            mPlusOneStandardButtonWithAnnotation = FindViewById<PlusOneButton> (Resource.Id.plus_one_standard_ann_button);

            if (Build.VERSION.SdkInt >= BuildVersionCodes.Honeycomb) {
                ActionBar.SetDisplayHomeAsUpEnabled (true);
            }
        }
Exemplo n.º 7
0
        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);
            mIsLogVerbose = true;

            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 = GoogleApiAvailability.Instance.IsGooglePlayServicesAvailable(this);
                    if (available != ConnectionResult.Success)
                    {
                        ShowDialog(DIALOG_GET_GOOGLE_PLAY_SERVICES);
                        return;
                    }

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

            mPlusButton        = FindViewById <PlusOneButton>(Resource.Id.plus_button);
            mPlusButton.Click += MPlusButton_Click;

            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);
            }
        }
Exemplo n.º 8
0
        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);
        }