Bundle shelter data in APK and add shared versioning

- Add scripts/fetch-shelters.sh: downloads Geonorge data, converts
  UTM33N→WGS84 via PWA script, copies to both Android assets and
  PWA public dirs
- Bundle pre-processed shelters.json (556 shelters) in APK assets
  so the app works immediately on first launch with no network
- ShelterRepository.seedFromAsset(): seeds Room DB from bundled
  JSON on first launch, marks as stale so network refresh is
  attempted in the background
- MainActivity.loadData(): seeds from asset before trying network,
  always attempts background refresh when data is stale
- Add version.properties (1.1.0, versionCode=2) as single source
  of truth for versioning
- build.gradle.kts reads version from properties file and exposes
  via BuildConfig
- Bump PWA version to 1.1.0 to match

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Ole-Morten Duesund 2026-03-08 18:33:38 +01:00
commit d0460cd686
7 changed files with 4584 additions and 9 deletions

39
scripts/fetch-shelters.sh Executable file
View file

@ -0,0 +1,39 @@
#!/usr/bin/env bash
# Downloads shelter data from Geonorge, converts UTM33N → WGS84 via the PWA
# script, and copies the result to both Android assets and PWA public dirs.
#
# Usage: ./scripts/fetch-shelters.sh
# Requires: bun (or node + tsx)
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
PWA_SCRIPT="$PROJECT_ROOT/pwa/scripts/fetch-shelters.ts"
PWA_OUTPUT="$PROJECT_ROOT/pwa/public/data/shelters.json"
ANDROID_ASSETS="$PROJECT_ROOT/app/src/main/assets"
ANDROID_OUTPUT="$ANDROID_ASSETS/shelters.json"
# Ensure output dirs exist
mkdir -p "$(dirname "$PWA_OUTPUT")"
mkdir -p "$ANDROID_ASSETS"
echo "==> Fetching shelter data from Geonorge..."
# Run the PWA conversion script (download ZIP, convert UTM→WGS84, output JSON)
bun run "$PROJECT_ROOT/pwa/scripts/fetch-shelters.ts"
if [ ! -f "$PWA_OUTPUT" ]; then
echo "ERROR: PWA script did not produce $PWA_OUTPUT"
exit 1
fi
SHELTER_COUNT=$(python3 -c "import json; print(len(json.load(open('$PWA_OUTPUT'))))" 2>/dev/null || echo "?")
echo "==> Generated $SHELTER_COUNT shelters"
# Copy to Android assets
cp "$PWA_OUTPUT" "$ANDROID_OUTPUT"
echo "==> Copied to $ANDROID_OUTPUT"
echo "==> Done. Shelter data ready for both platforms."