# 📱 FleetFlow Android Application Guide

This repository contains both a **Progressive Web App (PWA)** and a **Native Android Studio Project** (`android/`) for FleetFlow.

---

## 🚀 Option 1: Instant PWA Installation (Zero Setup, No Android Studio Needed)

Any driver, supervisor, or accountant can install FleetFlow directly on their Android phone in seconds:

1. **Connect your phone** to the same Wi-Fi network as your computer (or deploy FleetFlow to a live server/domain).
2. Open Chrome (or any mobile browser) on your Android phone and navigate to:
   ```
   http://<YOUR_PC_LOCAL_IP>/wep/
   ```
   *(Example: `http://192.168.1.105/wep/` — find your PC IP by running `ipconfig` in CMD/PowerShell).*
3. You will immediately see the bottom prompt: **"📲 Install FleetFlow Android App"**.
4. Tap **Install** (or tap Chrome Menu `⋮` -> **"Add to Home screen"** / **"Install app"**).
5. **Done!** The FleetFlow app icon will be added to your Android Home Screen and App Drawer.
   - Runs in **full-screen standalone mode** (no browser address bar).
   - Full access to **Camera** for Odometer OCR and Petrol Receipts.
   - High-accuracy **Live GPS Telematics** tracking.
   - Works offline with Service Worker caching (`sw.js`).

---

## 🛠️ Option 2: Native Android Studio Project (`.apk` / Google Play Store)

The `android/` directory is a complete, standalone Android Studio project.

### Project Structure
```
c:\wamp64\www\wep\
├── manifest.json              # Web App Manifest with icons & theme
├── sw.js                      # Offline Service Worker cache engine
├── assets/icons/              # High-res 192x192 & 512x512 app icons
├── capacitor.config.json      # Hybrid app configuration
└── android/                   # Native Android Studio Project
    ├── build.gradle           # Root Gradle build script
    ├── settings.gradle        # Gradle project settings
    ├── gradlew.bat            # Windows Gradle wrapper
    └── app/
        ├── build.gradle       # App module configuration (compileSdk 34)
        └── src/main/
            ├── AndroidManifest.xml # Permissions: GPS, Camera, Storage
            ├── java/com/fleetflow/logistics/
            │   └── MainActivity.java # WebView, Camera FileChooser, GPS
            └── res/           # Layouts, mipmap launcher icons, colors, styles
```

### Steps to Build APK in Android Studio:
1. Open **Android Studio**.
2. Select **Open** and choose the directory:
   ```
   c:\wamp64\www\wep\android
   ```
3. Allow Gradle to sync dependencies.
4. **Configure your Server URL**:
   - Open `app/src/main/java/com/fleetflow/logistics/MainActivity.java`.
   - Update line 49 with your server URL:
     ```java
     // For Android Emulator:
     private String appUrl = "http://10.0.2.2/wep/";

     // For Real Android Phone over Wi-Fi:
     private String appUrl = "http://192.168.1.XXX/wep/";

     // For Production Domain:
     private String appUrl = "https://your-fleetflow-domain.com/";
     ```
5. Click **Build > Build Bundle(s) / APK(s) > Build APK(s)**.
6. The compiled APK will be generated at:
   ```
   android/app/build/outputs/apk/debug/app-debug.apk
   ```
7. Transfer and install `app-debug.apk` onto any Android phone.

---

### ✨ Native Features Included
- **Zero-Latency Camera File Chooser**: Tapping "📸 Snap / Upload Photo" immediately invokes the native Android camera intent for instant odometer and fuel receipt scanning.
- **Auto-Granted Geolocation**: Directly bridges Android GPS runtime permissions to the browser telematics engine.
- **Pull-To-Refresh**: Native `SwipeRefreshLayout` for smooth gesture-based updates.
- **Hardware Acceleration**: Smooth animations, map rendering, and dial rendering.
