activity_login.xml
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#F9F9F9"
android:padding="16dp">

<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
app:cardCornerRadius="8dp"
app:cardElevation="4dp">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Login/Register"
android:textSize="24sp"
android:textStyle="bold"
android:textColor="#3498db"
android:fontFamily="sans-serif-medium" />

<EditText
android:id="@+id/phoneEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Phone Number"
android:inputType="phone"
android:fontFamily="sans-serif-medium" />

<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#ccc"
android:layout_marginBottom="16dp" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<Button
android:id="@+id/registerButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Register"
android:backgroundTint="#f1c40f"
android:textColor="#ffffff"
android:padding="16dp"
android:fontFamily="sans-serif-medium" />

<Button
android:id="@+id/loginButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Login"
android:backgroundTint="#3498db"
android:textColor="#ffffff"
android:padding="16dp"
android:fontFamily="sans-serif-medium" />

</LinearLayout>

<TextView
android:id="@+id/messageTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:textColor="#2ecc71"
android:layout_marginTop="16dp"
android:fontFamily="sans-serif-medium" />
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="gone" />


</LinearLayout>

</androidx.cardview.widget.CardView>

</LinearLayout>

LoginActivity
package com.example.gpay;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat;

import com.google.firebase.FirebaseApp;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.firestore.DocumentSnapshot;
import com.google.firebase.firestore.FirebaseFirestore;

public class LoginActivity extends AppCompatActivity {

private FirebaseAuth mAuth;
private FirebaseFirestore db;

private EditText phoneEditText;
private Button registerButton, loginButton;
private TextView messageTextView;
private ProgressBar progressBar;
private ImageView loadingImageView;
private AnimatedVectorDrawableCompat loadingAnimation;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FirebaseApp.initializeApp(this);
setContentView(R.layout.activity_login);

mAuth = FirebaseAuth.getInstance();
db = FirebaseFirestore.getInstance();

phoneEditText = findViewById(R.id.phoneEditText);
registerButton = findViewById(R.id.registerButton);
loginButton = findViewById(R.id.loginButton);
messageTextView = findViewById(R.id.messageTextView);
progressBar = findViewById(R.id.progressBar);


createDummyAccounts();

registerButton.setOnClickListener(v -> {
String phone = phoneEditText.getText().toString();
if (phone.isEmpty()) {
messageTextView.setText("Please enter phone number");
} else {
showLoading(true);
registerUser(phone);
}
});

loginButton.setOnClickListener(v -> {
String phone = phoneEditText.getText().toString();
if (phone.isEmpty()) {
messageTextView.setText("Please enter phone number");
} else {
showLoading(true);
loginUser(phone);
}
});
}

private void showLoading(boolean show) {
if (show) {
progressBar.setVisibility(View.VISIBLE);
} else {
progressBar.setVisibility(View.GONE);
}
}

private void registerUser(String phone) {
db.collection("users").document(phone)
.get()
.addOnCompleteListener(task -> {
if (task.isSuccessful()) {
DocumentSnapshot document = task.getResult();
if (!document.exists()) {
User user = new User(phone, 0); // Register with zero balance
db.collection("users").document(phone).set(user)
.addOnSuccessListener(aVoid -> {
showLoading(false);
messageTextView.setText("User registered successfully.");
phoneEditText.setText("");
})
.addOnFailureListener(e -> {
showLoading(false);
messageTextView.setText("Error registering user: " + e.getMessage());
});
} else {
showLoading(false);
messageTextView.setText("User already exists.");
}
} else {
showLoading(false);
messageTextView.setText("Error checking user existence.");
}
});
}

private void createDummyAccounts() {
User user1 = new User("1234567890", 100.0); // User 1 with $100
User user2 = new User("0987654321", 50.0); // User 2 with $50

db.collection("users").document(user1.getPhoneNum()).set(user1)
.addOnSuccessListener(aVoid -> {
System.out.println("Dummy user 1 created.");
})
.addOnFailureListener(e -> {
System.out.println("Error creating dummy user 1: " + e.getMessage());
});

db.collection("users").document(user2.getPhoneNum()).set(user2)
.addOnSuccessListener(aVoid -> {
System.out.println("Dummy user 2 created.");
})
.addOnFailureListener(e -> {
System.out.println("Error creating dummy user 2: " + e.getMessage());
});
}

private void loginUser(String phone) {
db.collection("users").document(phone)
.get()
.addOnCompleteListener(task -> {
if (task.isSuccessful()) {
DocumentSnapshot document = task.getResult();
if (document.exists()) {
showLoading(false);
Intent intent = new Intent(LoginActivity.this, TransferActivity.class);
intent.putExtra("phoneNum", phone);
startActivity(intent);
finish(); // Close LoginActivity
} else {
showLoading(false);
messageTextView.setText("Login failed. User not found.");
}
} else {
showLoading(false);
messageTextView.setText("Error logging in. Try again.");
}
});
}
}
enhance the look and feel of login ui of my application make necessary changes and give me FULL CODE