Signup and LoginForm with firebase Auth

 Signup Form frontEnd

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".Signup">

<ImageView
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_width="200dp"
android:layout_height="200dp"
android:scaleType="fitCenter"
android:src="@drawable/welcome" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Welcome back!"
android:textColor="@color/black"
android:textAlignment="center"
android:textSize="30dp"
android:textStyle="bold"
/>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Log in to your existant account of Q Allure"
android:textColor="@color/textcolor"
android:textAlignment="center"
android:textSize="15dp"
android:textStyle="normal"
/>


<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_margin="10dp"
android:layout_height="wrap_content">


<EditText
android:id="@+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:layout_marginBottom="30dp"
android:drawableLeft="@drawable/user"
android:background="@drawable/input_border"
android:padding="20dp"
android:textColor="#1C84FF"
android:textStyle="bold"
android:inputType="textPersonName"
android:hint="krish@gmail.com"
/>

<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:textColor="#1C84FF"
android:textStyle="bold"
android:drawableLeft="@drawable/user"
android:background="@drawable/input_border"
android:padding="20dp"
android:inputType="numberPassword"
android:hint="Password"
/>

<TextView
android:id="@+id/forgot_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Forgot Password"
android:layout_marginTop="10dp"
android:textColor="#DF000000"
android:textSize="15dp"
android:layout_gravity="right"
/>

<Button
android:id="@+id/signup"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:text="Signup"
android:padding="15dp"
android:background="@drawable/checkout_button"
android:layout_marginTop="20dp"
android:layout_gravity="center"
/>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Or Connect Using"
android:layout_marginTop="10dp"
android:textAlignment="center"
android:textColor="@color/textcolor"
android:textSize="20dp"
/>

<LinearLayout
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dp"
>
<Button
android:id="@+id/signupwithGoogle"
android:layout_width="200dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Google"
android:padding="15dp"
android:backgroundTint="@color/google"
android:layout_gravity="center"
/>

<Button
android:id="@+id/signupwithfacebook"
android:layout_width="200dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Login In"
android:padding="15dp"
android:backgroundTint="@color/facebook"
android:layout_gravity="center"
/>

</LinearLayout>


<TextView
android:id="@+id/signins"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sign In"
android:layout_gravity="right"
/>
</LinearLayout>

</LinearLayout>

Signup Form Backend

        binding.signins.setOnClickListener(v->{
startActivity(new Intent(signup.this,LoginActivity.class));
});


binding.signup.setOnClickListener(v->{
Email = binding.email.getText().toString();
Password = binding.password.getText().toString();
if(Email.isEmpty()){
Toast.makeText(this, "Email Can't be Blank", Toast.LENGTH_SHORT).show();
}else if(Password.isEmpty()){
Toast.makeText(this, "Password Can't be Blank", Toast.LENGTH_SHORT).show();
}else{
mAuth.createUserWithEmailAndPassword(Email, Password)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
Toast.makeText(Signup.this, "Successfully Register", Toast.LENGTH_SHORT).show();
startActivity(new Intent(Signup.this,LoginActivity.class));
} else {
// If sign in fails, display a message to the user.
Toast.makeText(Signup.this, "Authentication failed.",
Toast.LENGTH_SHORT).show();
// updateUI(null);
}
}
});
}

});

Login Form Frontend

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".LoginActivity">

<ImageView
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_width="200dp"
android:layout_height="200dp"
android:scaleType="fitCenter"
android:src="@drawable/welcome" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Welcome back!"
android:textColor="@color/black"
android:textAlignment="center"
android:textSize="30dp"
android:textStyle="bold"
/>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Log in to your existant account of Q Allure"
android:textColor="@color/textcolor"
android:textAlignment="center"
android:textSize="15dp"
android:textStyle="normal"
/>


<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_margin="10dp"
android:layout_height="wrap_content">


<EditText
android:id="@+id/Loginemail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:layout_marginBottom="30dp"
android:drawableLeft="@drawable/user"
android:background="@drawable/input_border"
android:padding="20dp"
android:textColor="#1C84FF"
android:textStyle="bold"
android:inputType="textPersonName"
android:hint="krish@gmail.com"
/>

<EditText
android:id="@+id/Loginpassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:textColor="#1C84FF"
android:textStyle="bold"
android:drawableLeft="@drawable/user"
android:background="@drawable/input_border"
android:padding="20dp"
android:inputType="numberPassword"
android:hint="Password"
/>

<TextView
android:id="@+id/forgot_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Forgot Password"
android:layout_marginTop="10dp"
android:textColor="#DF000000"
android:textSize="15dp"
android:layout_gravity="right"
/>

<Button
android:id="@+id/Login"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:text="Login In"
android:padding="15dp"
android:background="@drawable/checkout_button"
android:layout_marginTop="20dp"
android:layout_gravity="center"
/>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Or Connect Using"
android:layout_marginTop="10dp"
android:textAlignment="center"
android:textColor="@color/textcolor"
android:textSize="20dp"
/>

<LinearLayout
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="10dp"
>
<Button
android:id="@+id/LoginwithGoogle"
android:layout_width="200dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Google"
android:layout_margin="10dp"
android:padding="15dp"
android:backgroundTint="@color/google"
android:layout_gravity="center"
/>

<Button
android:id="@+id/Loginwithfacebook"
android:layout_width="200dp"
android:layout_weight="1"
android:layout_margin="10dp"
android:layout_height="wrap_content"
android:text="Login In"
android:padding="15dp"
android:backgroundTint="@color/facebook"
android:layout_gravity="center"
/>

</LinearLayout>

</LinearLayout>

</LinearLayout>

Login Form Backend

mAuth = FirebaseAuth.getInstance();

binding.Login.setOnClickListener(v->{
email = binding.Loginemail.getText().toString();
password = binding.Loginpassword.getText().toString();
if(email.isEmpty()){
Toast.makeText(this, "Email Can't be Blank", Toast.LENGTH_SHORT).show();
}else if(password.isEmpty()){
Toast.makeText(this, "Password Can't be Blank", Toast.LENGTH_SHORT).show();
}else{
mAuth.signInWithEmailAndPassword(email, password)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
Toast.makeText(LoginActivity.this, "Successfully Login", Toast.LENGTH_SHORT).show();
startActivity(new Intent(LoginActivity.this,MainActivity.class));
} else {
// If sign in fails, display a message to the user.
Toast.makeText(LoginActivity.this, "Please Enter a correct email and password.",
Toast.LENGTH_SHORT).show();
}
}
});

}

});














Comments