Java Code Examples for com.google.android.gms.common.SignInButton#setOnClickListener()
The following examples show how to use
com.google.android.gms.common.SignInButton#setOnClickListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainActivity.java From identity-samples with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if (savedInstanceState != null) { mIsResolving = savedInstanceState.getBoolean(KEY_IS_RESOLVING, false); mCredential = savedInstanceState.getParcelable(KEY_CREDENTIAL); } // Build CredentialsClient and GoogleSignInClient, don't set account name buildClients(null); // Sign in button SignInButton signInButton = (SignInButton) findViewById(R.id.button_google_sign_in); signInButton.setSize(SignInButton.SIZE_WIDE); signInButton.setOnClickListener(this); // Other buttons findViewById(R.id.button_email_sign_in).setOnClickListener(this); findViewById(R.id.button_google_revoke).setOnClickListener(this); findViewById(R.id.button_google_sign_out).setOnClickListener(this); findViewById(R.id.button_email_save).setOnClickListener(this); }
Example 2
Source File: SignInActivity.java From codeexamples-android with Eclipse Public License 1.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sign_in); // Assign fields mSignInButton = (SignInButton) findViewById(R.id.sign_in_button); // Set click listeners mSignInButton.setOnClickListener(this); // Configure Google Sign In GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestIdToken(getString(R.string.default_web_client_id)) .requestEmail() .build(); mGoogleApiClient = new GoogleApiClient.Builder(this) // .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */) .addApi(Auth.GOOGLE_SIGN_IN_API, gso) .build(); // Initialize FirebaseAuth }
Example 3
Source File: SignInActivity.java From codelab-friendlychat-android with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sign_in); // Assign fields mSignInButton = (SignInButton) findViewById(R.id.sign_in_button); // Set click listeners mSignInButton.setOnClickListener(this); // Configure Google Sign In GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestIdToken(getString(R.string.default_web_client_id)) .requestEmail() .build(); mSignInClient = GoogleSignIn.getClient(this, gso); // Initialize FirebaseAuth }
Example 4
Source File: SignInActivity.java From codelab-friendlychat-android with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sign_in); // Assign fields mSignInButton = (SignInButton) findViewById(R.id.sign_in_button); // Set click listeners mSignInButton.setOnClickListener(this); // Configure Google Sign In GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestIdToken(getString(R.string.default_web_client_id)) .requestEmail() .build(); mSignInClient = GoogleSignIn.getClient(this, gso); // Initialize FirebaseAuth mFirebaseAuth = FirebaseAuth.getInstance(); }
Example 5
Source File: SignInActivity.java From codelab-friendlychat-android with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sign_in); // Assign fields mSignInButton = (SignInButton) findViewById(R.id.sign_in_button); // Set click listeners mSignInButton.setOnClickListener(this); // Configure Google Sign In GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestIdToken(getString(R.string.default_web_client_id)) .requestEmail() .build(); mSignInClient = GoogleSignIn.getClient(this, gso); // Initialize FirebaseAuth mFirebaseAuth = FirebaseAuth.getInstance(); }
Example 6
Source File: MainActivity.java From android-google-accounts with Apache License 2.0 | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_activity); mSignInButton = (SignInButton) findViewById(R.id.sign_in_button); mSignOutButton = (Button) findViewById(R.id.sign_out_button); mRevokeButton = (Button) findViewById(R.id.revoke_access_button); mStatus = (TextView) findViewById(R.id.sign_in_status); mSignInButton.setOnClickListener(this); mSignOutButton.setOnClickListener(this); mRevokeButton.setOnClickListener(this); if (savedInstanceState != null) { mSignInProgress = savedInstanceState.getInt(SAVED_PROGRESS, STATE_DEFAULT); } rebuildGoogleApiClient(); }
Example 7
Source File: SignInActivity.java From jterm-cswithandroid with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sign_in); // Assign fields mSignInButton = (SignInButton) findViewById(R.id.sign_in_button); // Set click listeners mSignInButton.setOnClickListener(this); // Configure Google Sign In GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestIdToken(getString(R.string.default_web_client_id)) .requestEmail() .build(); mGoogleApiClient = new GoogleApiClient.Builder(this) .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */) .addApi(Auth.GOOGLE_SIGN_IN_API, gso) .build(); // Initialize FirebaseAuth mFirebaseAuth = FirebaseAuth.getInstance(); }
Example 8
Source File: MainActivity.java From android-google-accounts with Apache License 2.0 | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_activity); mSignInButton = (SignInButton) findViewById(R.id.sign_in_button); mSignOutButton = (Button) findViewById(R.id.sign_out_button); mRevokeButton = (Button) findViewById(R.id.revoke_access_button); mStatus = (TextView) findViewById(R.id.sign_in_status); mSignInButton.setOnClickListener(this); mSignOutButton.setOnClickListener(this); mRevokeButton.setOnClickListener(this); if (isSignedIn()) { rebuildGoogleApiClient(); // TODO: This next IF statement temporarily deals with an issue where autoManage doesn't // call the onConnected callback after a Builder.build() when re-connecting after a // rotation change. Will remove when fixed. if (mGoogleApiClient != null && mGoogleApiClient.isConnected()) { onConnected(null); } } }
Example 9
Source File: MainActivity.java From android-credentials with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if (savedInstanceState != null) { mIsResolving = savedInstanceState.getBoolean(KEY_IS_RESOLVING, false); mCredential = savedInstanceState.getParcelable(KEY_CREDENTIAL); } // Build CredentialsClient and GoogleSignInClient, don't set account name buildClients(null); // Sign in button SignInButton signInButton = (SignInButton) findViewById(R.id.button_google_sign_in); signInButton.setSize(SignInButton.SIZE_WIDE); signInButton.setOnClickListener(this); // Other buttons findViewById(R.id.button_email_sign_in).setOnClickListener(this); findViewById(R.id.button_google_revoke).setOnClickListener(this); findViewById(R.id.button_google_sign_out).setOnClickListener(this); findViewById(R.id.button_email_save).setOnClickListener(this); }
Example 10
Source File: MainActivity.java From io2015-codelabs with Apache License 2.0 | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mSignInButton = (SignInButton) findViewById(R.id.sign_in_button); mSignOutButton = (Button) findViewById(R.id.sign_out_button); mRevokeButton = (Button) findViewById(R.id.revoke_access_button); mStatus = (TextView) findViewById(R.id.statuslabel); mSignInButton.setOnClickListener(this); mSignOutButton.setOnClickListener(this); mRevokeButton.setOnClickListener(this); mGoogleApiClient = buildGoogleApiClient(); }
Example 11
Source File: SignIn.java From easygoogle with Apache License 2.0 | 6 votes |
/** * Add a {@link SignInButton} to the current Activity/Fragment. When clicked, the button * will automatically make a call to {@link SignIn#signIn()}. * @param context the calling context. * @param container a ViewGroup into which the SignInButton should be placed as the first child. * @return the instantiated SignInButton, which can be customized further. */ public SignInButton createSignInButton(Context context, ViewGroup container) { // Create SignInButton and configure style SignInButton signInButton = new SignInButton(context); signInButton.setSize(SignInButton.SIZE_STANDARD); signInButton.setColorScheme(SignInButton.COLOR_DARK); // Make it start sign-in on click signInButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { signIn(); } }); // Add to the layout, return reference to the button for user styling container.addView(signInButton, 0); return signInButton; }
Example 12
Source File: SigninActivity.java From wmn-safety with MIT License | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_signin); final GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestIdToken(getString(R.string.default_web_client_id)) .requestEmail() .build(); mGoogleSigninClient = GoogleSignIn.getClient(this, gso); mHelpers = new Helpers(this); mFirebaseAuth = FirebaseAuth.getInstance(); FirebaseUser user = mFirebaseAuth.getCurrentUser(); if (user != null) { navigateToHome(); } mFirebaseDatabase = FirebaseDatabase.getInstance(); SignInButton mGoogleSignInButton = findViewById(R.id.sign_in_goggle_button); mGoogleSignInButton.setSize(SignInButton.SIZE_WIDE); mGoogleSignInButton.setColorScheme(SignInButton.COLOR_DARK); mEmailText = findViewById(R.id.sign_in_email_tv); mPasswordText = findViewById(R.id.sign_in_password_tv); mGoogleSignInButton.setOnClickListener(this); findViewById(R.id.sign_in_button).setOnClickListener(this); findViewById(R.id.sign_in_register_tv).setOnClickListener(this); findViewById(R.id.sign_in_forgot_pass_tv).setOnClickListener(this); }
Example 13
Source File: LoginFragment.java From androidpay-quickstart with Apache License 2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_login, container, false); SignInButton signInButton = (SignInButton) view.findViewById(R.id.sign_in_button); signInButton.setSize(SignInButton.SIZE_WIDE); signInButton.setOnClickListener(this); view.findViewById(R.id.button_login_bikestore).setOnClickListener(this); return view; }
Example 14
Source File: RNGoogleSigninButtonViewManager.java From google-signin with MIT License | 5 votes |
@Override protected SignInButton createViewInstance(final ThemedReactContext reactContext) { SignInButton button = new SignInButton(reactContext); button.setSize(SignInButton.SIZE_STANDARD); button.setColorScheme(SignInButton.COLOR_AUTO); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("RNGoogleSigninButtonClicked", null); } }); return button; }
Example 15
Source File: LoginActivity.java From TwrpBuilder with GNU General Public License v3.0 | 5 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); new FirebaseDBInstance(); FirebaseDBInstance.getDatabase(); auth = FirebaseAuth.getInstance(); setContentView(R.layout.activity_login); SignInButton gSignInButton = findViewById(R.id.google_signIn); if (auth.getCurrentUser() != null) { startActivity(new Intent(LoginActivity.this, MainActivity.class)); finish(); } GoogleSignInOptions googleSignInOptions = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestIdToken(getString(R.string.default_web_client_id)) .requestEmail() .build(); googleSignInClient = GoogleSignIn.getClient(this, googleSignInOptions); gSignInButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { signIn(); } }); }
Example 16
Source File: PlayActivity.java From firebase-android-client with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { ListView messageHistory; super.onCreate(savedInstanceState); setContentView(R.layout.activity_play); Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); DrawerLayout drawer = findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.addDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = findViewById(R.id.nav_view); channelMenu = navigationView.getMenu(); navigationView.setNavigationItemSelectedListener(this); initChannels(); GoogleSignInOptions.Builder gsoBuilder = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestIdToken(getString(R.string.default_web_client_id)) .requestEmail(); GoogleSignInOptions gso = gsoBuilder.build(); mGoogleApiClient = new GoogleApiClient.Builder(this) .enableAutoManage(this, this) .addApi(Auth.GOOGLE_SIGN_IN_API, gso) .build(); SignInButton signInButton = findViewById(R.id.sign_in_button); signInButton.setSize(SignInButton.SIZE_STANDARD); signInButton.setOnClickListener(this); channelLabel = findViewById(R.id.channelLabel); Button signOutButton = findViewById(R.id.sign_out_button); signOutButton.setOnClickListener(this); ImageButton microphoneButton = findViewById(R.id.microphone_button); microphoneButton.setOnClickListener(this); messages = new ArrayList<>(); messageAdapter = new SimpleAdapter(this, messages, android.R.layout.simple_list_item_2, new String[]{"message", "meta"}, new int[]{android.R.id.text1, android.R.id.text2}); messageHistory = findViewById(R.id.messageHistory); messageHistory.setOnItemClickListener(this); messageHistory.setAdapter(messageAdapter); messageText = findViewById(R.id.messageText); messageText.setOnKeyListener(this); fmt = new SimpleDateFormat("yy.MM.dd HH:mm z", Locale.US); status = findViewById(R.id.status); }
Example 17
Source File: SplashActivity.java From FChat with MIT License | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_splash); bindLogo(); customToast = new CustomToast(this); viewHelper = new ViewHelper(getApplicationContext()); viewHelper.clearNotofication(); // Assign fields signInButton = (SignInButton) findViewById(R.id.sign_in_button); loginProgress = (ProgressBar) findViewById(R.id.login_progress); // Set click listeners signInButton.setOnClickListener(v -> signIn()); GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestIdToken(getString(R.string.default_web_client_id)).requestEmail().build(); mGoogleApiClient = new GoogleApiClient.Builder(this) .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */) .addApi(Auth.GOOGLE_SIGN_IN_API, gso).build(); // Initialize FirebaseAuth mFirebaseAuth = FirebaseAuth.getInstance(); set = new SettingsAPI(this); if (getIntent().getStringExtra("mode") != null) { if (getIntent().getStringExtra("mode").equals("logout")) { mGoogleApiClient.connect(); mGoogleApiClient .registerConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() { @Override public void onConnected( @Nullable Bundle bundle) { mFirebaseAuth.signOut(); Auth.GoogleSignInApi.signOut(mGoogleApiClient); set.deleteAllSettings(); } @Override public void onConnectionSuspended(int i) { } }); } } if (!mGoogleApiClient.isConnecting()) { if (!set.readSetting(Constants.PREF_MY_ID).equals("na")) { signInButton.setVisibility(View.GONE); final Handler handler = new Handler(); handler.postDelayed(() -> { startActivity(new Intent(SplashActivity.this, MainActivity.class)); finish(); }, 3000); } } // for system bar in lollipop if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Tools.systemBarLolipop(this); } }
Example 18
Source File: BindingAdapters.java From ground-android with Apache License 2.0 | 4 votes |
@BindingAdapter("onClick") public static void bindGoogleSignOnButtonClick( SignInButton button, View.OnClickListener onClickCallback) { button.setOnClickListener(onClickCallback); }
Example 19
Source File: MainActivity.java From gplus-haiku-client-android with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setContentView(R.layout.activity_main); mDialog = new ProgressDialog(this); SignInButton signIn = (SignInButton) findViewById(R.id.button_sign_in); signIn.setOnClickListener(this); signIn.setSize(SignInButton.SIZE_WIDE); findViewById(R.id.button_sign_out).setOnClickListener(this); findViewById(R.id.button_disconnect).setOnClickListener(this); mHaikuPlusSession = HaikuSession.getSessionForServer(getApplicationContext()); mHaikuApi = HaikuClient.getInstance(this, mHaikuPlusSession); mVolley = VolleyContainer.getInstance(this); // Check the constants if (Constants.SERVER_CLIENT_ID.equals("YOUR_WEB_CLIENT_ID") || Constants.SERVER_URL.equals("YOUR_PUBLIC_SERVER_URL")) { throw new RuntimeException("Error: please configure SERVER_CLIENT_ID and " + "SERVER_URL in Constants.java"); } GoogleApiClient.Builder builder = new GoogleApiClient.Builder(this) .addOnConnectionFailedListener(this) .addConnectionCallbacks(this) .setAccountName(mHaikuPlusSession.getAccountName()) .requestServerAuthCode(Constants.SERVER_CLIENT_ID, this); // Add scopes for (String scope : Constants.SCOPES) { builder.addScope(new Scope(scope)); } // Add Google+ API with visible actions Plus.PlusOptions plusOptions = new Plus.PlusOptions.Builder() .addActivityTypes(Constants.ACTIONS) .build(); builder.addApi(Plus.API, plusOptions); mGoogleApiClient = builder.build(); if (savedInstanceState == null) { getFragmentManager().beginTransaction() .add(R.id.container, new StreamFragment(), STREAM_FRAG_TAG) .commit(); } String deepLinkId = PlusShare.getDeepLinkId(this.getIntent()); if (deepLinkId != null) { mDeepLink = HaikuDeepLink.fromString(deepLinkId); if (mDeepLink.getHaikuId() == null) { // If the ID is bad, just ignore the deeplink. mDeepLink = null; Log.d(TAG, "Got bad deeplink: " + deepLinkId); } else { showDialog(getString(R.string.loading_haiku)); mHaikuApi.fetchHaiku(mDeepLink.getHaikuId(), this); } } // Hide sign in button and load user if we have cached account name and session id if (mHaikuPlusSession.checkSessionState() == HaikuSession.State.HAS_SESSION) { setProgressBarIndeterminateVisibility(true); findViewById(R.id.signed_out_container).setVisibility(View.GONE); mHaikuApi.fetchCurrentUser(this); } }