Onboarding & Splash Logic
The RideEase app implements a sophisticated splash and onboarding sequence designed to provide a seamless entry point while ensuring all user data is synchronized before reaching the main dashboard. It leverages the modern Android 12+ SplashScreen API and Firebase Authentication to manage state.
Splash Screen Integration
The SplashActivity serves as the entry point of the application. On devices running Android 12 (API 31) and above, it utilizes the androidx.core.splashscreen library to manage the transition from the system-drawn splash screen to the application's UI.
Initialization
The splash screen is initialized before super.onCreate() to capture the starting window.
SplashScreen splashScreen = SplashScreen.installSplashScreen(this);
// Controls how long the splash icon remains on screen
splashScreen.setKeepOnScreenCondition(() -> keepSplashScreen);
The logic uses a boolean flag keepSplashScreen to hold the system splash screen until the Firebase Auth state and Firestore profile checks are completed.
Authentication & Navigation Logic
The application follows a strict logic flow to determine which screen the user should see next. This prevents unauthenticated access and ensures that both "Riders" and "Drivers" have completed their profiles before using the core services.
Navigation State Table
| User State | Navigation Target | Trigger |
| :--- | :--- | :--- |
| Not Logged In | SplashActivity (Onboarding UI) | User not found in Firebase or isLoggedIn pref is false. |
| Logged In (No Profile) | UserDetailsActivity | Firebase User exists, but detailsSubmitted in Firestore is false. |
| Logged In (Profile Complete) | MainActivity | Firebase User exists and detailsSubmitted is true. |
Auth Inconsistency Handling
The app automatically corrects inconsistent states. If SharedPreferences indicates a logged-in state but the Firebase session has expired, the app clears the local flag and directs the user to the onboarding UI.
Profile Validation
Before a user reaches the MainActivity, the app performs a remote check via AuthUtils.checkUserDetails. This ensures that even if a user clears their local app data, they are redirected to provide their name and phone number if those fields are missing in Firestore.
Usage: Manual Profile Check
You can use AuthUtils to verify a user's status manually if needed:
AuthUtils.checkUserDetails(userId, new AuthUtils.UserDetailsCallback() {
@Override
public void onComplete(boolean hasDetails, String userId) {
if (hasDetails) {
// Navigate to Main Dashboard
} else {
// Navigate to Profile Setup
}
}
@Override
public void onError(String error) {
// Handle network/permission errors
}
});
Onboarding Experience
For new users, the SplashActivity transforms into an onboarding screen.
- Visual Components: Displays a Lottie animation, the app tagline, and a "Let's Go" button.
- User Entry: Tapping "Let's Go" directs the user to the
LoginActivity. - Role Selection: During the subsequent Sign-up/Login process, users must select their role (Rider or Driver). This selection is validated against Firestore to prevent cross-role unauthorized logins (e.g., a Driver attempting to log in via the Rider portal).
Profile Completion (UserDetailsActivity)
If a user has authenticated via Email/Password but hasn't provided their personal details, they are gated by the UserDetailsActivity.
- Requirements: Full Name and a 10-digit Phone Number.
- Country Codes: Supports a pre-defined list of country codes (defaulting to +91).
- Persistence: Upon successful submission, a local flag
detailsSubmitted_{userId}is stored inRideEasePrefsto optimize future startups, though the remote Firestore value remains the "source of truth."