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;
}
}
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);
}
});
}
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);
}
});
}
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());
}
}
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();
}
}
Aggregations