use of com.google.firebase.auth.FirebaseUser in project FirebaseAuth-Android by jirawatee.
the class EmailPasswordActivity method onClick.
@Override
public void onClick(View v) {
switch(v.getId()) {
case R.id.email_create_account_button:
createAccount(mEdtEmail.getText().toString(), mEdtPassword.getText().toString());
break;
case R.id.email_sign_in_button:
signIn(mEdtEmail.getText().toString(), mEdtPassword.getText().toString());
break;
case R.id.sign_out_button:
signOut();
break;
case R.id.verify_button:
findViewById(R.id.verify_button).setEnabled(false);
final FirebaseUser firebaseUser = mAuth.getCurrentUser();
firebaseUser.sendEmailVerification().addOnCompleteListener(this, new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
Toast.makeText(EmailPasswordActivity.this, "Verification email sent to " + firebaseUser.getEmail(), Toast.LENGTH_LONG).show();
} else {
Toast.makeText(EmailPasswordActivity.this, task.getException().getMessage(), Toast.LENGTH_LONG).show();
}
findViewById(R.id.verify_button).setEnabled(true);
}
});
break;
}
}
use of com.google.firebase.auth.FirebaseUser in project FirebaseAuth-Android by jirawatee.
the class GoogleSignInActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_google);
mImageView = findViewById(R.id.logo);
mTextViewProfile = findViewById(R.id.profile);
SignInButton signInButton = findViewById(R.id.sign_in_button);
signInButton.setSize(SignInButton.SIZE_WIDE);
signInButton.setOnClickListener(this);
findViewById(R.id.sign_out_button).setOnClickListener(this);
findViewById(R.id.disconnect_button).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, this).addApi(Auth.GOOGLE_SIGN_IN_API, gso).build();
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);
}
};
}
use of com.google.firebase.auth.FirebaseUser in project GogoNew by kuldeep725.
the class Login method onStart.
@Override
public void onStart() {
super.onStart();
// new MapsActivity().showInternetStatus();
// Check if user is signed in (non-null) and update UI accordingly.
FirebaseUser currentUser = mAuth.getCurrentUser();
mAuth.addAuthStateListener(new FirebaseAuth.AuthStateListener() {
@Override
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
}
});
if (currentUser != null) {
Intent i = new Intent(Login.this, MapsActivity.class);
startActivity(i);
finish();
}
}
use of com.google.firebase.auth.FirebaseUser in project GogoNew by kuldeep725.
the class MapsActivity method onStart.
@Override
public void onStart() {
super.onStart();
Log.d(TAG, "onStart fired ..............");
if (!checkPermissions()) {
requestPermissions();
}
FirebaseAuth mAuth = FirebaseAuth.getInstance();
FirebaseUser currentUser = mAuth.getCurrentUser();
if (currentUser == null) {
Intent i = new Intent(MapsActivity.this, Login.class);
startActivity(i);
finish();
}
showInternetStatus();
SharedPreferences loginPrefs = getSharedPreferences("userId", MODE_PRIVATE);
userEmail = loginPrefs.getString("email", "User id");
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
View headerView = navigationView.getHeaderView(0);
TextView tv = (TextView) headerView.findViewById(R.id.user_id);
tv.setText(userEmail);
SharedPreferences prefs = getSharedPreferences("onStop", MODE_PRIVATE);
// boolean floatingClickable = prefs.getBoolean(floatingClickableState, Boolean.TRUE);
radiobuttonId = prefs.getInt(radioButtonString, 0);
flagSendOrCancel = prefs.getInt("flagSendOrCancel", 0);
int bus = prefs.getInt(whichBus, 0);
theKey = prefs.getString(keyString, null);
pickMeRadioButtonId = prefs.getInt("pickMeRadioButton", -1);
minName = prefs.getString(minNameStr, null);
Log.e(TAG, "onStart-> pickMeRadioButtonId = " + pickMeRadioButtonId);
Log.d(TAG, "flagSendOrCancel" + " = " + flagSendOrCancel);
Log.d(TAG, "radiobuttonId" + " = " + radiobuttonId);
Log.d(TAG, whichBus + " = " + bus);
Log.d(TAG, "theKey = " + theKey);
Log.d(TAG, "minName = " + minName);
checkBusSelection = radiobuttonId;
BUS = prefs.getString("pickMeBus", null);
if (BUS == null) {
BUS = "b" + checkBusSelection;
}
if (flagSendOrCancel != 0) {
floatingButton.setImageResource(R.drawable.ic_cancel_white_24dp);
floatingButton.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.myRed)));
pickMeDone = true;
}
if (checkPermissions()) {
mGoogleApiClient.connect();
Log.e(TAG, "mGoogleApiClient is connected");
} else {
Log.e(TAG, "mGoogleApiClient is not connected");
}
mDatabase.addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
Log.d(TAG, "dataSnapshot.getKey() = " + dataSnapshot.getKey());
Log.d(TAG, "dataSnapshot.getChildrenCount() = " + dataSnapshot.getChildrenCount());
/*check whether onChildAdded has already run once**/
if (flagOnChild == 1)
return;
noOfBuses = dataSnapshot.getChildrenCount();
Log.d(TAG, "noOfBuses = " + noOfBuses);
// Log.d(TAG, "String s = " + s);
createRadioButtons();
if (radiobuttonId != 0) {
// Log.d(TAG, "MAKING radiobutton setChecked(true)...");
radiobutton = (RadioButton) findViewById(radiobuttonId);
Log.d(TAG, "radiobutton @onStart = " + radiobutton.toString());
radiobutton.setTextColor(Color.parseColor(primeColorString));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
radiobutton.setBackground(getDrawable(R.drawable.underline));
} else {
radiobutton.setPaintFlags(radiobutton.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
}
radiobutton.setClickable(true);
radiobutton.setChecked(false);
lastButton = radiobutton;
Log.d(TAG, "checkbusSelection = " + checkBusSelection);
}
if (pickMeRadioButtonId != -1) {
pickMeRadioButton = (RadioButton) findViewById(pickMeRadioButtonId);
pickMeRadioButton.setTypeface(Typeface.DEFAULT_BOLD);
pickMeRadioButton.setTextColor(getResources().getColor(R.color.primeColor));
}
flagOnChild = 1;
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
use of com.google.firebase.auth.FirebaseUser in project quickstart-android by firebase.
the class PhoneAuthFragment method onStart.
@Override
public void onStart() {
super.onStart();
// Check if user is signed in (non-null) and update UI accordingly.
FirebaseUser currentUser = mAuth.getCurrentUser();
updateUI(currentUser);
if (mVerificationInProgress && validatePhoneNumber()) {
startPhoneNumberVerification(mBinding.fieldPhoneNumber.getText().toString());
}
}
Aggregations