Skip to content
This repository was archived by the owner on Sep 11, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
544 changes: 544 additions & 0 deletions lib/cubits/map_download_cubit.dart

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions lib/cubits/navigation_availability_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ class NavigationAvailabilityCubit extends Cubit<NavigationAvailabilityState> {
static NavigationAvailabilityState watch(BuildContext context) =>
context.watch<NavigationAvailabilityCubit>().state;

Future<void> recheck() => _checkAndPublish();

Future<void> _checkAndPublish() async {
if (_checking) return;
_checking = true;
Expand Down
14 changes: 14 additions & 0 deletions lib/l10n/app_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@
"navSetupRoutingEngine": "Routing-Engine",
"navSetupNoRoutingBody": "Kartenanzeige und Routing sind unabhängig. Kartenkacheln können lokal (offline .mbtiles) oder online sein. Für Routing wird eine Valhalla-Engine benötigt — lokal (Routing-Karten erforderlich) oder ein Remote-Server.",
"navSetupScanForInstructions": "Für Anleitung scannen",
"navSetupDownloadButton": "Karten herunterladen",
"navSetupDownloadLocating": "Region wird erkannt...",
"navSetupDownloadProgress": "Herunterladen... {percent}%",
"navSetupDownloadInstalling": "Karten werden installiert...",
"navSetupDownloadDone": "Karten installiert. Navigationsdienste werden neu gestartet...",
"navSetupDownloadError": "Download fehlgeschlagen",
"navSetupDownloadWaitingGps": "Warte auf GPS-Signal...",
"navSetupDownloadNoInternet": "Keine Internetverbindung",
"navSetupDownloadUnsupported": "Keine Karten für Ihren Standort verfügbar",
"navSetupUpdateButton": "Karten aktualisieren",
"navSetupResumeButton": "Download fortsetzen",
"navSetupCheckingUpdates": "Suche nach Updates...",
"navSetupDownloadProgressBytes": "Herunterladen... {downloaded} / {total} MB",
"navSetupInsufficientSpace": "Nicht genügend Speicherplatz",
"menuEnterDestinationCode": "Zielcode eingeben",
"menuSavedLocations": "Gespeicherte Orte",
"menuSavedLocationsHeader": "GESPEICHERTE ORTE",
Expand Down
25 changes: 25 additions & 0 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,31 @@
"navSetupRoutingEngine": "Routing engine",
"navSetupNoRoutingBody": "Map display and routing are independent. Display tiles can be local (offline .mbtiles) or online. Routing requires a Valhalla engine — local (needs routing maps) or a remote server.",
"navSetupScanForInstructions": "Scan for setup instructions",
"navSetupDownloadButton": "Download maps",
"navSetupDownloadLocating": "Detecting your region...",
"navSetupDownloadProgress": "Downloading... {percent}%",
"@navSetupDownloadProgress": {
"placeholders": {
"percent": {"type": "int"}
}
},
"navSetupDownloadInstalling": "Installing maps...",
"navSetupDownloadDone": "Maps installed. Restarting navigation services...",
"navSetupDownloadError": "Download failed",
"navSetupDownloadWaitingGps": "Waiting for GPS fix...",
"navSetupDownloadNoInternet": "No internet connection",
"navSetupDownloadUnsupported": "No maps available for your location",
"navSetupUpdateButton": "Update maps",
"navSetupResumeButton": "Resume download",
"navSetupCheckingUpdates": "Checking for updates...",
"navSetupDownloadProgressBytes": "Downloading... {downloaded} / {total} MB",
"@navSetupDownloadProgressBytes": {
"placeholders": {
"downloaded": {"type": "String"},
"total": {"type": "String"}
}
},
"navSetupInsufficientSpace": "Not enough storage space",
"menuEnterDestinationCode": "Enter Destination Code",
"menuSavedLocations": "Saved Locations",
"menuSavedLocationsHeader": "SAVED LOCATIONS",
Expand Down
84 changes: 84 additions & 0 deletions lib/l10n/app_localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,90 @@ abstract class AppLocalizations {
/// **'Scan for setup instructions'**
String get navSetupScanForInstructions;

/// No description provided for @navSetupDownloadButton.
///
/// In en, this message translates to:
/// **'Download maps'**
String get navSetupDownloadButton;

/// No description provided for @navSetupDownloadLocating.
///
/// In en, this message translates to:
/// **'Detecting your region...'**
String get navSetupDownloadLocating;

/// No description provided for @navSetupDownloadProgress.
///
/// In en, this message translates to:
/// **'Downloading... {percent}%'**
String navSetupDownloadProgress(int percent);

/// No description provided for @navSetupDownloadInstalling.
///
/// In en, this message translates to:
/// **'Installing maps...'**
String get navSetupDownloadInstalling;

/// No description provided for @navSetupDownloadDone.
///
/// In en, this message translates to:
/// **'Maps installed. Restarting navigation services...'**
String get navSetupDownloadDone;

/// No description provided for @navSetupDownloadError.
///
/// In en, this message translates to:
/// **'Download failed'**
String get navSetupDownloadError;

/// No description provided for @navSetupDownloadWaitingGps.
///
/// In en, this message translates to:
/// **'Waiting for GPS fix...'**
String get navSetupDownloadWaitingGps;

/// No description provided for @navSetupDownloadNoInternet.
///
/// In en, this message translates to:
/// **'No internet connection'**
String get navSetupDownloadNoInternet;

/// No description provided for @navSetupDownloadUnsupported.
///
/// In en, this message translates to:
/// **'No maps available for your location'**
String get navSetupDownloadUnsupported;

/// No description provided for @navSetupUpdateButton.
///
/// In en, this message translates to:
/// **'Update maps'**
String get navSetupUpdateButton;

/// No description provided for @navSetupResumeButton.
///
/// In en, this message translates to:
/// **'Resume download'**
String get navSetupResumeButton;

/// No description provided for @navSetupCheckingUpdates.
///
/// In en, this message translates to:
/// **'Checking for updates...'**
String get navSetupCheckingUpdates;

/// No description provided for @navSetupDownloadProgressBytes.
///
/// In en, this message translates to:
/// **'Downloading... {downloaded} / {total} MB'**
String navSetupDownloadProgressBytes(String downloaded, String total);

/// No description provided for @navSetupInsufficientSpace.
///
/// In en, this message translates to:
/// **'Not enough storage space'**
String get navSetupInsufficientSpace;

/// No description provided for @menuEnterDestinationCode.
///
/// In en, this message translates to:
Expand Down
46 changes: 46 additions & 0 deletions lib/l10n/app_localizations_de.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,52 @@ class AppLocalizationsDe extends AppLocalizations {
@override
String get navSetupScanForInstructions => 'Für Anleitung scannen';

@override
String get navSetupDownloadButton => 'Karten herunterladen';

@override
String get navSetupDownloadLocating => 'Region wird erkannt...';

@override
String navSetupDownloadProgress(int percent) {
return 'Herunterladen... $percent%';
}

@override
String get navSetupDownloadInstalling => 'Karten werden installiert...';

@override
String get navSetupDownloadDone => 'Karten installiert. Navigationsdienste werden neu gestartet...';

@override
String get navSetupDownloadError => 'Download fehlgeschlagen';

@override
String get navSetupDownloadWaitingGps => 'Warte auf GPS-Signal...';

@override
String get navSetupDownloadNoInternet => 'Keine Internetverbindung';

@override
String get navSetupDownloadUnsupported => 'Keine Karten für Ihren Standort verfügbar';

@override
String get navSetupUpdateButton => 'Karten aktualisieren';

@override
String get navSetupResumeButton => 'Download fortsetzen';

@override
String get navSetupCheckingUpdates => 'Suche nach Updates...';

@override
String navSetupDownloadProgressBytes(String downloaded, String total) {
return 'Herunterladen... $downloaded / $total MB';
}

@override
String get navSetupInsufficientSpace => 'Nicht genügend Speicherplatz';

@override
String get menuEnterDestinationCode => 'Zielcode eingeben';

Expand Down
46 changes: 46 additions & 0 deletions lib/l10n/app_localizations_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,52 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get navSetupScanForInstructions => 'Scan for setup instructions';

@override
String get navSetupDownloadButton => 'Download maps';

@override
String get navSetupDownloadLocating => 'Detecting your region...';

@override
String navSetupDownloadProgress(int percent) {
return 'Downloading... $percent%';
}

@override
String get navSetupDownloadInstalling => 'Installing maps...';

@override
String get navSetupDownloadDone => 'Maps installed. Restarting navigation services...';

@override
String get navSetupDownloadError => 'Download failed';

@override
String get navSetupDownloadWaitingGps => 'Waiting for GPS fix...';

@override
String get navSetupDownloadNoInternet => 'No internet connection';

@override
String get navSetupDownloadUnsupported => 'No maps available for your location';

@override
String get navSetupUpdateButton => 'Update maps';

@override
String get navSetupResumeButton => 'Resume download';

@override
String get navSetupCheckingUpdates => 'Checking for updates...';

@override
String navSetupDownloadProgressBytes(String downloaded, String total) {
return 'Downloading... $downloaded / $total MB';
}

@override
String get navSetupInsufficientSpace => 'Not enough storage space';

@override
String get menuEnterDestinationCode => 'Enter Destination Code';

Expand Down
83 changes: 83 additions & 0 deletions lib/models/map_metadata.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import 'dart:convert';
import 'dart:io';

import 'package:path_provider/path_provider.dart';

class MapTileInfo {
final String digest;
final String publishedAt;
final int size;

const MapTileInfo({
required this.digest,
required this.publishedAt,
required this.size,
});

factory MapTileInfo.fromJson(Map<String, dynamic> json) => MapTileInfo(
digest: json['digest'] as String,
publishedAt: json['publishedAt'] as String,
size: json['size'] as int,
);

Map<String, dynamic> toJson() => {
'digest': digest,
'publishedAt': publishedAt,
'size': size,
};
}

class MapMetadata {
final String region;
final MapTileInfo? displayTiles;
final MapTileInfo? valhallaTiles;

const MapMetadata({
required this.region,
this.displayTiles,
this.valhallaTiles,
});

factory MapMetadata.fromJson(Map<String, dynamic> json) => MapMetadata(
region: json['region'] as String,
displayTiles: json['displayTiles'] != null
? MapTileInfo.fromJson(json['displayTiles'] as Map<String, dynamic>)
: null,
valhallaTiles: json['valhallaTiles'] != null
? MapTileInfo.fromJson(
json['valhallaTiles'] as Map<String, dynamic>)
: null,
);

Map<String, dynamic> toJson() => {
'region': region,
if (displayTiles != null) 'displayTiles': displayTiles!.toJson(),
if (valhallaTiles != null) 'valhallaTiles': valhallaTiles!.toJson(),
};

static Future<String> _metadataPath() async {
final appDir = await getApplicationDocumentsDirectory();
return '${appDir.path}/maps/metadata.json';
}

static Future<MapMetadata?> load() async {
try {
final path = await _metadataPath();
final file = File(path);
if (!await file.exists()) return null;
final json = jsonDecode(await file.readAsString()) as Map<String, dynamic>;
return MapMetadata.fromJson(json);
} catch (_) {
return null;
}
}

Future<void> save() async {
final path = await _metadataPath();
final file = File(path);
await file.parent.create(recursive: true);
final tmpFile = File('$path.tmp');
await tmpFile.writeAsString(jsonEncode(toJson()));
await tmpFile.rename(path);
}
}
Loading
Loading