[android] Import .gpx and .gpx.xml files from Google Files app

Signed-off-by: Alexander Borsuk <me@alex.bio>
This commit is contained in:
Alexander Borsuk 2024-03-15 00:23:25 +01:00 committed by Alexander Borsuk
parent f531ae6b2e
commit 4d967e24f5
2 changed files with 19 additions and 0 deletions

View file

@ -318,6 +318,18 @@
<data android:pathPattern="/.*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.kmb" />
<data android:pathPattern="/.*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.KMB" />
</intent-filter>
<!-- Catches .gpx and .gpx.xml files opened from Google Files app -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="content" />
<data android:host="*" />
<data android:mimeType="application/octet-stream" />
<data android:mimeType="application/xml" />
<data android:mimeType="text/xml" />
</intent-filter>
</activity>
<activity

View file

@ -457,6 +457,13 @@ public enum BookmarkManager
return filename;
}
// Samsung browser adds .xml extension to downloaded gpx files.
// Duplicate files have " (1).xml", " (2).xml" suffixes added.
final String gpxExt = ".gpx";
final int gpxStart = lowerCaseFilename.lastIndexOf(gpxExt);
if (gpxStart != -1)
return filename.substring(0, gpxStart + gpxExt.length());
// Try get guess extension from the mime type.
final String mime = resolver.getType(uri);
if (mime != null)