use of com.google.firebase.auth.FirebaseAuth in project NPSmiles by bmcglynn1.
the class LoginAuth method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login_auth);
setTitle("Login");
mAuth = FirebaseAuth.getInstance();
mAuthListener = new FirebaseAuth.AuthStateListener() {
@Override
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
FirebaseUser user = firebaseAuth.getCurrentUser();
if (user != null) {
// User is signed in
Log.d(TAG, "onAuthStateChanged:signed_in:" + user.getUid());
} else {
// User is signed out
Log.d(TAG, "onAuthStateChanged:signed_out");
}
// ...
}
};
final EditText emailText = (EditText) findViewById(R.id.emailEditText);
final EditText passwordText = (EditText) findViewById(R.id.passwordEditText);
Button loginButton = (Button) findViewById(R.id.loginButton);
loginButton.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v) {
if (emailText.getText().toString().length() != 0 && passwordText.getText().toString().length() != 0) {
signIn(emailText.getText().toString(), passwordText.getText().toString());
}
}
});
findViewById(R.id.relativeLayoutLogin).setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getWindow().getDecorView().getRootView().getWindowToken(), 0);
return true;
}
});
}
use of com.google.firebase.auth.FirebaseAuth in project Pepper_v0 by SamDaQueen.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// loading the default fragment
loadFragment(new CategoryFragment());
BottomNavigationView navigation = findViewById(R.id.navigation);
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
Bundle bundle = getIntent().getBundleExtra("items");
if (bundle != null)
arrayList = bundle.getParcelableArrayList("order");
// Firebase Authentication
mUsername = ANONYMOUS;
mFirebaseAuth = FirebaseAuth.getInstance();
mAuthStateListener = new FirebaseAuth.AuthStateListener() {
@Override
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
FirebaseUser user = firebaseAuth.getCurrentUser();
if (user != null) {
// user signed in
onSignedInInitialize(user.getDisplayName());
} else {
// user signed out
onSignedOutCleanup();
startActivityForResult(AuthUI.getInstance().createSignInIntentBuilder().setIsSmartLockEnabled(false).setAvailableProviders(Arrays.asList(new AuthUI.IdpConfig.GoogleBuilder().build(), new AuthUI.IdpConfig.EmailBuilder().build(), new AuthUI.IdpConfig.PhoneBuilder().build())).setLogo(R.drawable.pepper_500px).build(), RC_SIGN_IN);
}
}
};
}
use of com.google.firebase.auth.FirebaseAuth in project Grupp by tmoronta1208.
the class UserProfileActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_user_profile);
toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
mAuth = FirebaseAuth.getInstance();
mPager = findViewById(R.id.pager);
mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
mPager.setAdapter(mPagerAdapter);
context = this;
activity = this;
floatingActionMenu = findViewById(R.id.floatingaction_menu);
creatEvent = findViewById(R.id.create_event_mini);
creatEvent.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(UserProfileActivity.this, CreateEventActivity.class));
}
});
addPerson = findViewById(R.id.add_group_mini);
addPerson.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// startActivity(new Intent(UserProfileActivity.this, AddPersonActivity.class));
UPCreateGroupFragment upCreateGroupFragment = new UPCreateGroupFragment();
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.addToBackStack("Grupp Details Fragment").replace(R.id.drawer_layout, upCreateGroupFragment);
fragmentTransaction.commit();
}
});
mAuthListner = new FirebaseAuth.AuthStateListener() {
@Override
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
if (mAuth.getCurrentUser() == null) {
startActivity(new Intent(UserProfileActivity.this, LoginActivity.class));
}
}
};
pushEventInviteNotifications();
// new InviteNotifications("test", "notification", getApplicationContext());
}
use of com.google.firebase.auth.FirebaseAuth in project Grupp by tmoronta1208.
the class EditProfileActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_edit_profile);
saveBtn = findViewById(R.id.edit_profile_save_button);
ageGroup = findViewById(R.id.radio_group_age);
budgetGroup = findViewById(R.id.radio_group_budget);
radiusGroup = findViewById(R.id.radio_group_radius);
firstName = findViewById(R.id.edit_profile_firstname);
lastName = findViewById(R.id.edit_profile_lastname);
zipCode = findViewById(R.id.edit_profile_zip_code);
mAuth = FirebaseAuth.getInstance();
rootRef = FirebaseDatabase.getInstance().getReference();
publicUserReference = rootRef.child(PUBLIC_USER);
privateUserReference = rootRef.child(PRIVATE_USER);
privateUserLocationReference = rootRef.child(PRIVATE_USER);
userIconReference = rootRef.child(USER_ICON);
currentUser = mAuth.getCurrentUser();
currentUserID = currentUser.getUid();
currentUserEmail = currentUser.getEmail();
radioGroupSelection();
mAuthListener = new FirebaseAuth.AuthStateListener() {
@Override
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
if (currentUser != null) {
// User is signed in
Log.d(TAG, "onAuthStateChanged:signed_in:" + currentUser.getUid());
// Toast.makeText(EditProfileActivity.this, "Successfully signed in with: " + currentUser.getEmail(), Toast.LENGTH_SHORT).show();
} else {
// User is signed out
Log.d(TAG, "onAuthStateChanged:signed_out");
// Toast.makeText(EditProfileActivity.this, "Successfully signed out.", Toast.LENGTH_SHORT).show();
}
}
};
ValueEventListener valueEventListener = new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
privateUser = dataSnapshot.child(currentUserID).getValue(PrivateUser.class);
privateUserLocation = dataSnapshot.child(currentUserID).getValue(PrivateUserLocation.class);
publicUser = dataSnapshot.child(currentUserID).getValue(PublicUser.class);
userIcon = dataSnapshot.child(currentUserID).getValue(UserIcon.class);
iconUrl = userIcon.getIcon_url();
Log.d(TAG, "onDataChange: Added information to database: \n" + dataSnapshot.getValue());
}
@Override
public void onCancelled(DatabaseError error) {
// Failed to read value
Log.w(TAG, "Failed to read value.", error.toException());
}
};
publicUserReference.addValueEventListener(valueEventListener);
privateUserReference.addValueEventListener(valueEventListener);
privateUserLocationReference.addValueEventListener(valueEventListener);
userIconReference.addListenerForSingleValueEvent(valueEventListener);
saveBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
saveToDatabase();
}
});
// /////////////////////////////////////////
/**
* code below needs to be place in the launch of the app so the user can give location
* permission beforehand.
*/
LocationManager locationManager = (LocationManager) getSystemService(this.LOCATION_SERVICE);
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, new String[] { android.Manifest.permission.ACCESS_FINE_LOCATION, android.Manifest.permission.ACCESS_COARSE_LOCATION }, 1020);
share_location = true;
return;
}
/* Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
lat = location.getLatitude();
lng = location.getLongitude();*/
}
use of com.google.firebase.auth.FirebaseAuth in project BloodHub by kazijehangir.
the class AppointmentsFragment method fetchData.
// Getting data from database
public void fetchData() {
FirebaseAuth mAuth = FirebaseAuth.getInstance();
FirebaseUser user = mAuth.getCurrentUser();
db.orderByChild("userid").equalTo(user.getUid()).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
appointments.clear();
keys.clear();
for (DataSnapshot child : dataSnapshot.getChildren()) {
Appointment appointment = child.getValue(Appointment.class);
appointments.add(appointment);
keys.add(child.getKey());
}
numAppointments.setText("Appointments: " + appointments.size());
mAdapter.notifyDataSetChanged();
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
return;
}
Aggregations