User Profile Setup
After a user successfully signs up or logs in for the first time, RideEase requires additional metadata to complete the profile. This process ensures that both riders and drivers have a verified identity and a valid contact method before accessing the main features of the application.
Profile Completion Workflow
The application automatically checks the user's profile status during the authentication flow. If the detailsSubmitted flag is set to false in Firestore, the user is redirected to the UserDetailsActivity.
1. Automatic Redirection
The AuthUtils utility provides a helper method to determine if a user needs to complete their profile setup.
AuthUtils.checkUserDetails(userId, new AuthUtils.UserDetailsCallback() {
@Override
public void onComplete(boolean hasDetails, String userId) {
if (!hasDetails) {
// Redirect to UserDetailsActivity
Intent intent = new Intent(context, UserDetailsActivity.class);
intent.putExtra("USER_ID", userId);
context.startActivity(intent);
}
}
@Override
public void onError(String error) {
// Handle error
}
});
2. Required Information
The UserDetailsActivity captures the following essential data points:
| Field | Description | Validation |
| :--- | :--- | :--- |
| Full Name | The user's legal name for display. | Required; cannot be empty. |
| Country Code | The international dialing prefix. | Must match pattern ^\+[1-9]\d{0,2}$ (e.g., +91). |
| Phone Number | The 10-digit mobile number. | Must be exactly 10 digits. |
Updating User Details
To submit profile information programmatically, use the AuthViewModel. This method updates the user's document in the users Firestore collection and sets the detailsSubmitted flag to true.
Method Signature
public void updateUserDetails(String userId, String fullName, String phoneNumber)
Usage Example
// Inside an Activity or Fragment
viewModel.updateUserDetails(
"firebase_user_id",
"John Doe",
"+91 9876543210"
);
// Observe the result to navigate to the Main Activity
viewModel.getAuthResult().observe(this, authResult -> {
if (authResult.isSuccess()) {
// Save local state and proceed
}
});
Phone Verification (Optional)
For enhanced security, RideEase includes a UserDetailsViewModel capable of handling Firebase Phone Authentication (OTP). This is typically used to verify the phone number provided during the profile setup.
Starting Verification
// Start the phone verification process
userDetailsViewModel.startPhoneVerification("+919876543210");
// Observe the verification ID sent by Firebase
userDetailsViewModel.getVerificationId().observe(this, verificationId -> {
// Proceed to OTP entry screen
});
Verifying the Code
Once the user receives the 6-digit OTP, it must be verified to update the user's isPhoneVerified status in the data model.
userDetailsViewModel.verifyPhoneCode(
verificationId,
"123456",
userId,
fullName,
phoneNumber
);
Data Persistence
Successfully submitted details are stored in the users collection in Firestore. The resulting User object follows this structure:
{
"userId": "uuid",
"userType": "rider|driver",
"fullName": "John Doe",
"email": "user@example.com",
"phoneNumber": "+91 9876543210",
"isPhoneVerified": true,
"detailsSubmitted": true
}
Additionally, the application saves a local preference to prevent unnecessary network checks on subsequent launches:
- Preference Key:
detailsSubmitted_{userId} - Preference File:
RideEasePrefs