Search in sources :

Example 76 with FirebaseUser

use of com.google.firebase.auth.FirebaseUser in project BloodHub by kazijehangir.

the class SplashActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splash_screen);
    mAuth = FirebaseAuth.getInstance();
    FirebaseUser currentUser = mAuth.getCurrentUser();
    if (currentUser != null) {
        setView(currentUser.getUid(), currentUser.getEmail());
    } else {
        setContentView(R.layout.activity_fscreen);
        Button button = (Button) findViewById(R.id.button1);
        button.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                Intent intent = new Intent(SplashActivity.this, EmergencyRequestActivity.class);
                startActivity(intent);
            }
        });
        Button button1 = (Button) findViewById(R.id.button2);
        button1.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                Intent intent = new Intent(SplashActivity.this, LoginActivity.class);
                startActivity(intent);
            }
        });
    }
}
Also used : Button(android.widget.Button) Intent(android.content.Intent) FirebaseUser(com.google.firebase.auth.FirebaseUser) View(android.view.View)

Example 77 with FirebaseUser

use of com.google.firebase.auth.FirebaseUser in project Quizly by sebastianjs12.

the class StudentHomepage method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.student_homepage);
    firebaseAuth = FirebaseAuth.getInstance();
    if (firebaseAuth.getCurrentUser() == null) {
        finish();
        Intent i = new Intent(StudentHomepage.this, MainActivity.class);
        startActivity(i);
    }
    FirebaseUser user = firebaseAuth.getCurrentUser();
    textViewStudentEmail = (TextView) findViewById(R.id.textViewStudentEmail);
    textViewStudentEmail.setText("Welcome " + user.getDisplayName());
}
Also used : Intent(android.content.Intent) FirebaseUser(com.google.firebase.auth.FirebaseUser)

Example 78 with FirebaseUser

use of com.google.firebase.auth.FirebaseUser in project Firebase-Helper by AtifAbbAsi19.

the class FireBaseHelper method deleteFirebaseUserAuthAccount.

public static void deleteFirebaseUserAuthAccount(Context context, String email, String password) {
    final FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
    // Get auth credentials from the user for re-authentication. The example below shows
    // email and password credentials but there are multiple possible providers,
    // such as GoogleAuthProvider or FacebookAuthProvider.
    AuthCredential credential = EmailAuthProvider.getCredential(email, password);
    // Prompt the user to re-provide their sign-in credentials
    user.reauthenticate(credential).addOnCompleteListener(new OnCompleteListener<Void>() {

        @Override
        public void onComplete(@NonNull Task<Void> task) {
            user.delete().addOnCompleteListener(new OnCompleteListener<Void>() {

                @Override
                public void onComplete(@NonNull Task<Void> task) {
                    if (task.isSuccessful()) {
                    // Log.d(LOG_TAG, "User account deleted.");
                    }
                }
            });
        }
    });
}
Also used : AuthCredential(com.google.firebase.auth.AuthCredential) OnCompleteListener(com.google.android.gms.tasks.OnCompleteListener) Task(com.google.android.gms.tasks.Task) UploadTask(com.google.firebase.storage.UploadTask) NonNull(android.support.annotation.NonNull) FirebaseUser(com.google.firebase.auth.FirebaseUser)

Example 79 with FirebaseUser

use of com.google.firebase.auth.FirebaseUser in project UniPool by divya21raj.

the class LoginActivity method dummyInitFinalCurrentUser.

private void dummyInitFinalCurrentUser(FirebaseUser user) throws ParseException {
    HashMap<String, Float> dummyLambdaMap = new HashMap<>();
    dummyLambdaMap.put("123", 0f);
    GenLocation dummyGenLocation = new GenLocation("dummy", "dummy", 0d, 0d);
    TripEntry dummyTripEntry = new TripEntry("dummy", "dummyId", "DummyUser", "12:00", "1/11/12", dummyGenLocation, dummyGenLocation, dummyLambdaMap);
    HashMap<String, TripEntry> dummyUserEntries = new HashMap<>();
    dummyUserEntries.put("dummy", dummyTripEntry);
    HashMap<String, TripEntry> dummyRequestSent = new HashMap<>();
    dummyRequestSent.put(dummyTripEntry.getEntry_id(), dummyTripEntry);
    ArrayList<String> dummyUserIdList = new ArrayList<>();
    dummyUserIdList.add("dummy");
    HashMap<String, ArrayList<String>> dummyRequestReceived = new HashMap<>();
    dummyRequestReceived.put("dummy", dummyUserIdList);
    Message dummyMessage = new Message("dummy", "", "", "dummy", "dummy", 1L);
    ArrayList<Message> dummyMessages = new ArrayList<>();
    dummyMessages.add(dummyMessage);
    PairUp dummyPairUp = new PairUp("dummydummy", "dummy", "dummy", "dummy", dummyUserIdList);
    HashMap<String, PairUp> dummyPairUps = new HashMap<>();
    dummyPairUps.put("dummy", dummyPairUp);
    String deviceToken = FirebaseInstanceId.getInstance().getToken();
    String url = "";
    Uri photoUrl = user.getPhotoUrl();
    if (photoUrl != null)
        url = photoUrl.toString();
    finalCurrentUser = new User(user.getUid(), user.getDisplayName(), url, dummyUserEntries, dummyRequestSent, dummyRequestReceived, deviceToken, true, dummyPairUps);
}
Also used : User(garbagecollectors.com.unipool.User) FirebaseUser(com.google.firebase.auth.FirebaseUser) BaseActivity.finalCurrentUser(garbagecollectors.com.unipool.activities.BaseActivity.finalCurrentUser) Message(garbagecollectors.com.unipool.Message) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) TripEntry(garbagecollectors.com.unipool.TripEntry) Uri(android.net.Uri) PairUp(garbagecollectors.com.unipool.PairUp) GenLocation(garbagecollectors.com.unipool.GenLocation)

Example 80 with FirebaseUser

use of com.google.firebase.auth.FirebaseUser in project ARD by MobileApplicationsClub.

the class AuthActivity method updateUserInfo.

/**
 * Send relevant info of current user to firebase.
 *
 * @param firebaseAuth Firebase auth object to use.
 * @param parentRef    Reference to add/update child into.
 * @return boolean true if result was updated successfully, false otherwise.
 */
public boolean updateUserInfo(@NonNull final FirebaseAuth firebaseAuth, @NonNull final DatabaseReference parentRef) {
    final FirebaseUser firebaseUser = firebaseAuth.getCurrentUser();
    if (firebaseUser == null) {
        return false;
    }
    final String uid = firebaseUser.getUid();
    final String name = firebaseUser.getDisplayName();
    final String email = firebaseUser.getEmail();
    final String photoUrl;
    final Uri uri = firebaseUser.getPhotoUrl();
    if (uri == null) {
        photoUrl = "";
    } else {
        photoUrl = uri.toString();
    }
    final DatabaseReference userDb = parentRef.child(uid);
    userDb.child(UserItemKeys.FDR_USERS_NAME).setValue(name);
    userDb.child(UserItemKeys.FDR_USERS_EMAIL).setValue(email);
    userDb.child(UserItemKeys.FDR_USERS_PHOTO_URL).setValue(photoUrl);
    return true;
}
Also used : DatabaseReference(com.google.firebase.database.DatabaseReference) FirebaseUser(com.google.firebase.auth.FirebaseUser) Uri(android.net.Uri)

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