Java Code Examples for com.google.android.gms.common.SignInButton#setSize()

The following examples show how to use com.google.android.gms.common.SignInButton#setSize() . 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 vote down vote up
@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: MainActivity.java    From android-credentials with Apache License 2.0 6 votes vote down vote up
@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 3
Source File: SignIn.java    From easygoogle with Apache License 2.0 6 votes vote down vote up
/**
 * 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 4
Source File: SigninActivity.java    From wmn-safety with MIT License 5 votes vote down vote up
@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 5
Source File: SignInActivity.java    From google-services with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Views
    mStatusTextView = findViewById(R.id.status);

    // Button listeners
    findViewById(R.id.sign_in_button).setOnClickListener(this);
    findViewById(R.id.sign_out_button).setOnClickListener(this);
    findViewById(R.id.disconnect_button).setOnClickListener(this);

    // [START configure_signin]
    // Configure sign-in to request the user's ID, email address, and basic
    // profile. ID and basic profile are included in DEFAULT_SIGN_IN.
    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestEmail()
            .build();
    // [END configure_signin]

    // [START build_client]
    // Build a GoogleSignInClient with the options specified by gso.
    mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
    // [END build_client]

    // [START customize_button]
    // Set the dimensions of the sign-in button.
    SignInButton signInButton = findViewById(R.id.sign_in_button);
    signInButton.setSize(SignInButton.SIZE_STANDARD);
    signInButton.setColorScheme(SignInButton.COLOR_LIGHT);
    // [END customize_button]
}
 
Example 6
Source File: SignInActivityWithDrive.java    From google-services with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Views
    mStatusTextView = findViewById(R.id.status);

    // Button listeners
    findViewById(R.id.sign_in_button).setOnClickListener(this);
    findViewById(R.id.sign_out_button).setOnClickListener(this);
    findViewById(R.id.disconnect_button).setOnClickListener(this);

    // [START configure_signin]
    // Configure sign-in to request the user's ID, email address, and basic
    // profile. ID and basic profile are included in DEFAULT_SIGN_IN.
    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestScopes(new Scope(Scopes.DRIVE_APPFOLDER))
            .requestEmail()
            .build();
    // [END configure_signin]

    // [START build_client]
    // Build a GoogleSignInClient with access to the Google Sign-In API and the
    // options specified by gso.
    mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
    // [END build_client]

    // [START customize_button]
    // Customize sign-in button. The sign-in button can be displayed in
    // multiple sizes.
    SignInButton signInButton = findViewById(R.id.sign_in_button);
    signInButton.setSize(SignInButton.SIZE_STANDARD);
    // [END customize_button]
}
 
Example 7
Source File: RestApiActivity.java    From google-services with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Views
    mStatusTextView = findViewById(R.id.status);
    mDetailTextView = findViewById(R.id.detail);

    // Button listeners
    findViewById(R.id.sign_in_button).setOnClickListener(this);
    findViewById(R.id.sign_out_button).setOnClickListener(this);

    // For this example we don't need the disconnect button
    findViewById(R.id.disconnect_button).setVisibility(View.GONE);

    // Restore instance state
    if (savedInstanceState != null) {
        mAccount = savedInstanceState.getParcelable(KEY_ACCOUNT);
    }

    // Configure sign-in to request the user's ID, email address, basic profile,
    // and readonly access to contacts.
    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestScopes(new Scope(CONTACTS_SCOPE))
            .requestEmail()
            .build();

    mGoogleSignInClient = GoogleSignIn.getClient(this, gso);

    // Show a standard Google Sign In button. If your application does not rely on Google Sign
    // In for authentication you could replace this with a "Get Google Contacts" button
    // or similar.
    SignInButton signInButton = findViewById(R.id.sign_in_button);
    signInButton.setSize(SignInButton.SIZE_STANDARD);
}
 
Example 8
Source File: RNGoogleSigninButtonViewManager.java    From google-signin with MIT License 5 votes vote down vote up
@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 9
Source File: LoginFragment.java    From androidpay-quickstart with Apache License 2.0 5 votes vote down vote up
@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 10
Source File: PlayActivity.java    From firebase-android-client with Apache License 2.0 4 votes vote down vote up
@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 11
Source File: RNGoogleSigninButtonViewManager.java    From google-signin with MIT License 4 votes vote down vote up
@ReactProp(name = "size")
public void setSize(SignInButton button, int size) {
    button.setSize(size);
}
 
Example 12
Source File: MainActivity.java    From gplus-haiku-client-android with Apache License 2.0 4 votes vote down vote up
@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);
    }
}