Add MBTiles file import functionality to offline maps#428
Merged
torlando-tech merged 3 commits intomainfrom Feb 16, 2026
Merged
Add MBTiles file import functionality to offline maps#428torlando-tech merged 3 commits intomainfrom
torlando-tech merged 3 commits intomainfrom
Conversation
Add the ability to import MBTiles files from external storage via the system file picker. Users can now tap the import button in the Offline Maps screen top bar to select an .mbtiles file, which gets copied to the app's offline_maps directory and registered in the database with metadata extracted from the file. https://claude.ai/code/session_014gmo6c1YmbBv1Lvi221nsE
Contributor
Greptile SummaryAdded MBTiles file import functionality to offline maps screen. Users can now import map files from device storage via a new FileOpen button in the top app bar. Key Changes:
Implementation Quality:
Confidence Score: 5/5
Important Files Changed
Flowchartflowchart TD
A[User clicks import button] --> B[File picker launches]
B --> C{User selects file?}
C -->|No| D[Cancel - no action]
C -->|Yes| E[importMbtilesFile called with URI]
E --> F[Set isImporting = true]
F --> G[Resolve destination file path]
G --> H[Check if filename exists]
H -->|Exists| I[Append counter suffix]
I --> H
H -->|Available| J[Copy file from URI to destination]
J --> K{Copy successful?}
K -->|No| L[Catch exception]
K -->|Yes| M[Validate MBTiles format]
M -->|Invalid| N[Delete copied file]
N --> L
M -->|Valid| O[Register in database via importOrphanedFile]
O --> P{Registration successful?}
P -->|No| L
P -->|Yes| Q[Show success message]
Q --> R[Set isImporting = false]
L --> S[Set error message]
S --> T[Clean up partial file if exists]
T --> R
R --> U[End]
D --> U
Last reviewed commit: f5be86e |
- Delete the copied MBTiles file in the catch block if DB registration via importOrphanedFile() fails, preventing orphaned files on disk - Replace throw IllegalStateException() with error() to satisfy detekt UseCheckOrError rule https://claude.ai/code/session_014gmo6c1YmbBv1Lvi221nsE
Contributor
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
…cleaned up Split importMbtilesFile into two withContext blocks: the first resolves the destination file path (and assigns destFile), the second performs the copy and validation. Previously, if the copy threw mid-stream, destFile remained null and the catch block could not delete the partial file on disk. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Owner
Author
|
@greptileai review |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds the ability to import MBTiles files directly into the offline maps feature, complementing the existing download functionality. Users can now select and import MBTiles files from their device storage through a new import button in the top app bar.
Key Changes
UI Updates
ViewModel Changes
importMbtilesFile(uri: Uri)function to handle MBTiles file imports from content URIsisImporting) and success messages (importSuccessMessage)OfflineMapStyleBuilder.isValidMBTiles()OfflineMapRegionRepository.importOrphanedFile()for database registrationFile Handling
Testing
Implementation Details
ActivityResultContracts.OpenDocument()for file selection.mbtilesextension if missinghttps://claude.ai/code/session_014gmo6c1YmbBv1Lvi221nsE