# Pilot's Toolkit — Android

A collection of aviation utilities for flight crews, built with Kotlin and Jetpack Compose. Designed for practical cockpit use on Android devices.

**Not for operational use — verify all calculations independently.**

---

## Modules

- **Fuel Order Calculator** — Fuel quantity in US/imperial gallons and liters with ASTM D1250 Table 6B density correction and ambient temperature adjustment.
- **Pavement Strength / ESWL** — ACN/ACR calculation with PCN/PCR comparison, rigid/flexible pavement types, four subgrade categories. Reverse-solves maximum allowable weight when pavement is exceeded.
- **Crosswind Calculator** — Headwind, tailwind, and crosswind components from wind direction/speed and runway heading. Auto-formats five-digit wind input on focus loss.
- **Fuel Buckets** — Stage length vs. fuel burn schedule with slider interpolation. Supports operator-specific CSV and JSON profile import.
- **HF Frequencies** — Active ARINC HF assignments for Atlantic and Pacific with staleness indicator.
- **Passdown** — Crew changeover form with local storage, autocomplete, history, batch .ptz export, email compose via share intent, and tappable phone dialing.
- **Flight Level ↔ Meters** — ICAO meters-to-feet conversion table and China RVSM FLAS with directional filtering.
- **Crew Rest** — Augmented operations rest calculator for 3–4 pilots. Equal-division sequential rest rotation with lock toggle to prevent accidental edits mid-flight.

## Project Structure

```
app/src/main/
  assets/
    reference.json                    ← Flight levels, subgrade labels
    aircraft/
      G450.json                       ← Per-airframe data (auto-discovered)
      G500.json
      G650.json
      G700.json
  java/com/harshmallow/pilottoolkit/
    MainActivity.kt                   ← Entry point, DataLoader.init()
    data/
      AircraftData.kt                 ← Data classes, enums, calculations
      DataLoader.kt                   ← JSON parser from assets/
      FlightLevelData.kt              ← FlightLevelEntry class + DataLoader delegates
      FuelProfiles.kt                 ← Fuel profile storage (SharedPreferences)
    ui/
      PilotToolkitApp.kt              ← Navigation, tab bar, hamburger menu
      components/
        SharedComponents.kt           ← ToolkitTextField, ResultCard, ClearButton, etc.
      modules/
        FuelOrderModule.kt
        PavementModule.kt
        CrosswindModule.kt
        FuelBucketsModule.kt
        HFModule.kt
        PassdownModule.kt
        FlightLevelModule.kt
        CrewRestModule.kt
      theme/
        Color.kt                      ← ToolkitColors (light/dark palettes)
        Theme.kt                      ← ToolkitTheme composable
```

## Data Architecture

All aircraft and reference data lives in JSON files under `assets/`. The `DataLoader` singleton parses these at app startup.

- **`reference.json`** — Airframe-agnostic: meters-to-feet table (107 entries), China FLAS (50 entries), RVSM direction sets, pavement subgrade labels.
- **`aircraft/*.json`** — One file per airframe: weight limits, ESWL config (formula or thresholds), PCN/PCR linear regression coefficients, fuel bucket schedules. Auto-discovered from the directory — adding a new airframe is just dropping a JSON file in `assets/aircraft/`.

Each aircraft file loads independently. A malformed file is logged and skipped — it does not crash the app or affect other airframes.

## Storage

All persistent data uses `SharedPreferences`:

- Default aircraft selection
- Dark mode toggle
- Volume unit preference
- Passdown retention period
- Passdown records (JSON serialization)
- Autocomplete lookups (per field)
- Fuel profiles (per aircraft)

## Exchange Formats

- **`.ptz`** — Gzipped JSON array of passdown objects. Exported via `GZIPOutputStream`, imported via `GZIPInputStream`. Open format.
- **Fuel profile JSON** — Validated on import by `format: "pilot-toolkit-fuel-profile"` field.
- **Fuel profile CSV** — Two columns (stage length, fuel burn), optional header row.

## Dependencies

- Kotlin
- Jetpack Compose + Material3
- `org.json.JSONObject` (built-in Android)
- `java.util.zip.GZIPOutputStream` / `GZIPInputStream` (built-in Java)
- No third-party libraries beyond standard Android/Compose dependencies

## Build

Standard Android Studio project. Open the root directory in Android Studio, sync Gradle, and run.
