Search in sources :

Example 81 with FirebaseUser

use of com.google.firebase.auth.FirebaseUser in project FirebaseAuth-Android by jirawatee.

the class ManageUserActivity method onClick.

@Override
public void onClick(View view) {
    final FirebaseUser user = mAuth.getCurrentUser();
    switch(view.getId()) {
        case R.id.update_profile_button:
            if (validateForm()) {
                updateNameAndPhoto(user);
            }
            break;
        case R.id.update_email_button:
            if (validateEmail(mEditTextEmail)) {
                updateEmail(user);
            }
            break;
        case R.id.update_password_button:
            if (validatePassword()) {
                updatePassword(user);
            }
            break;
        case R.id.send_password_reset_button:
            if (validateEmail(mEditTextEmailReset)) {
                sendPasswordReset();
            }
            break;
        case R.id.delete_button:
            AlertDialog.Builder alert = new AlertDialog.Builder(this);
            alert.setMessage("Delete " + user.getEmail() + "?");
            alert.setCancelable(false);
            alert.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    deleteUser(user);
                }
            });
            alert.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    dialogInterface.dismiss();
                }
            });
            alert.show();
            break;
    }
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) FirebaseUser(com.google.firebase.auth.FirebaseUser)

Example 82 with FirebaseUser

use of com.google.firebase.auth.FirebaseUser in project FirebaseAuth-Android by jirawatee.

the class TwitterLoginActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Configure Twitter SDK
    TwitterAuthConfig authConfig = new TwitterAuthConfig(getString(R.string.twitter_consumer_key), getString(R.string.twitter_consumer_secret));
    Fabric.with(this, new Twitter(authConfig));
    // Inflate layout (must be done after Twitter is configured)
    setContentView(R.layout.activity_twitter);
    mImageView = findViewById(R.id.logo);
    mTextViewProfile = findViewById(R.id.profile);
    findViewById(R.id.button_twitter_signout).setOnClickListener(this);
    mAuth = FirebaseAuth.getInstance();
    mAuthListener = new FirebaseAuth.AuthStateListener() {

        @Override
        public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
            FirebaseUser user = firebaseAuth.getCurrentUser();
            if (user != null) {
                Log.d(TAG, "onAuthStateChanged:signed_in:" + user.getUid());
            } else {
                Log.d(TAG, "onAuthStateChanged:signed_out");
            }
            updateUI(user);
        }
    };
    // initialize_twitter_login
    mLoginButton = findViewById(R.id.button_twitter_login);
    mLoginButton.setCallback(new Callback<TwitterSession>() {

        @Override
        public void success(Result<TwitterSession> result) {
            Log.d(TAG, "twitterLogin:success" + result);
            handleTwitterSession(result.data);
        }

        @Override
        public void failure(TwitterException exception) {
            Log.w(TAG, "twitterLogin:failure", exception);
            updateUI(null);
        }
    });
}
Also used : TwitterSession(com.twitter.sdk.android.core.TwitterSession) Twitter(com.twitter.sdk.android.Twitter) TwitterAuthConfig(com.twitter.sdk.android.core.TwitterAuthConfig) FirebaseUser(com.google.firebase.auth.FirebaseUser) TwitterException(com.twitter.sdk.android.core.TwitterException) FirebaseAuth(com.google.firebase.auth.FirebaseAuth)

Example 83 with FirebaseUser

use of com.google.firebase.auth.FirebaseUser in project FirebaseAuth-Android by jirawatee.

the class FacebookLoginActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_facebook);
    mImageView = findViewById(R.id.logo);
    mTextViewProfile = findViewById(R.id.profile);
    findViewById(R.id.button_facebook_signout).setOnClickListener(this);
    mAuth = FirebaseAuth.getInstance();
    mAuthListener = new FirebaseAuth.AuthStateListener() {

        @Override
        public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
            FirebaseUser user = firebaseAuth.getCurrentUser();
            if (user != null) {
                Log.d(TAG, "onAuthStateChanged:signed_in:" + user.getUid());
            } else {
                Log.d(TAG, "onAuthStateChanged:signed_out");
            }
            updateUI(user);
        }
    };
    // Initialize Facebook Login button
    mCallbackManager = CallbackManager.Factory.create();
    LoginButton loginButton = findViewById(R.id.button_facebook_login);
    loginButton.setReadPermissions("email", "public_profile");
    loginButton.registerCallback(mCallbackManager, new FacebookCallback<LoginResult>() {

        @Override
        public void onSuccess(LoginResult loginResult) {
            Log.d(TAG, "facebook:onSuccess:" + loginResult);
            handleFacebookAccessToken(loginResult.getAccessToken());
        }

        @Override
        public void onCancel() {
            Log.d(TAG, "facebook:onCancel");
            updateUI(null);
        }

        @Override
        public void onError(FacebookException error) {
            Log.d(TAG, "facebook:onError", error);
            updateUI(null);
        }
    });
}
Also used : FacebookException(com.facebook.FacebookException) LoginResult(com.facebook.login.LoginResult) FirebaseUser(com.google.firebase.auth.FirebaseUser) LoginButton(com.facebook.login.widget.LoginButton) FirebaseAuth(com.google.firebase.auth.FirebaseAuth)

Example 84 with FirebaseUser

use of com.google.firebase.auth.FirebaseUser in project FirebaseAuth-Android by jirawatee.

the class PhoneAuthActivity method onStart.

@Override
public void onStart() {
    super.onStart();
    FirebaseUser currentUser = mAuth.getCurrentUser();
    updateUI(currentUser);
    if (mVerificationInProgress && validatePhoneNumber()) {
        startPhoneNumberVerification(mPhoneNumberField.getText().toString());
    }
}
Also used : FirebaseUser(com.google.firebase.auth.FirebaseUser)

Example 85 with FirebaseUser

use of com.google.firebase.auth.FirebaseUser in project PhotoBlog-Android-Blog-App by akshayejh.

the class LoginActivity method onStart.

@Override
protected void onStart() {
    super.onStart();
    FirebaseUser currentUser = mAuth.getCurrentUser();
    if (currentUser != null) {
        sendToMain();
    }
}
Also used : FirebaseUser(com.google.firebase.auth.FirebaseUser)

Aggregations

FirebaseUser (com.google.firebase.auth.FirebaseUser)100 AuthResult (com.google.firebase.auth.AuthResult)26 Intent (android.content.Intent)22 FirebaseAuth (com.google.firebase.auth.FirebaseAuth)16 DataSnapshot (com.google.firebase.database.DataSnapshot)12 DatabaseError (com.google.firebase.database.DatabaseError)12 OnFailureListener (com.google.android.gms.tasks.OnFailureListener)11 AuthCredential (com.google.firebase.auth.AuthCredential)11 DatabaseReference (com.google.firebase.database.DatabaseReference)11 ValueEventListener (com.google.firebase.database.ValueEventListener)11 View (android.view.View)10 Task (com.google.android.gms.tasks.Task)10 Button (android.widget.Button)9 NonNull (android.support.annotation.NonNull)8 OnCompleteListener (com.google.android.gms.tasks.OnCompleteListener)7 FirebaseAuthUserCollisionException (com.google.firebase.auth.FirebaseAuthUserCollisionException)7 TextView (android.widget.TextView)6 Test (org.junit.Test)6 Context (android.content.Context)5 SharedPreferences (android.content.SharedPreferences)5