Fix GPX file picker on Android 13+ and transport selection bug #450

Open
betodealmeida wants to merge 1 commit from betodealmeida/fix-gpx-file-picker-android13 into master
betodealmeida commented 2025-12-28 01:10:20 +01:00 (Migrated from github.com)

Summary

  • Fix GPX file selection on Android 13+ by using ACTION_OPEN_DOCUMENT without restrictive MIME type filters
  • Add file extension validation to ensure only .gpx files are accepted
  • Fix transport spinner bug that was causing errors when selecting a transport mode

Problem

On Android 13+, GPX files were visible in the file picker but could not be selected. This was because:

  1. The previous implementation used Intent.createChooser() which interferes with the Storage Access Framework
  2. GPX files may have various MIME types (application/gpx+xml, application/octet-stream, text/xml, etc.) that didn't match the filter

Additionally, selecting a transport mode (Boat, Walk, etc.) caused an error due to a typo using read.getSelectedItemPosition() instead of transport.getSelectedItemPosition().

Changes

  • Use ACTION_OPEN_DOCUMENT with CATEGORY_OPENABLE and proper permission flags
  • Remove MIME type restrictions (GPX files have inconsistent MIME types across devices)
  • Add isGpxFile() method to validate file extension after selection
  • Add trip_invalid_file_type string resource for user-friendly error message
  • Fix transport spinner variable name typo

Test plan

  • Create a Trip post on Android 13+ device
  • Tap "Load GPX" and verify GPX files are selectable
  • Verify non-GPX files show "Please select a GPX file (.gpx)" error
  • Select a transport mode and verify the Trip posts successfully
## Summary - Fix GPX file selection on Android 13+ by using `ACTION_OPEN_DOCUMENT` without restrictive MIME type filters - Add file extension validation to ensure only `.gpx` files are accepted - Fix transport spinner bug that was causing errors when selecting a transport mode ## Problem On Android 13+, GPX files were visible in the file picker but could not be selected. This was because: 1. The previous implementation used `Intent.createChooser()` which interferes with the Storage Access Framework 2. GPX files may have various MIME types (`application/gpx+xml`, `application/octet-stream`, `text/xml`, etc.) that didn't match the filter Additionally, selecting a transport mode (Boat, Walk, etc.) caused an error due to a typo using `read.getSelectedItemPosition()` instead of `transport.getSelectedItemPosition()`. ## Changes - Use `ACTION_OPEN_DOCUMENT` with `CATEGORY_OPENABLE` and proper permission flags - Remove MIME type restrictions (GPX files have inconsistent MIME types across devices) - Add `isGpxFile()` method to validate file extension after selection - Add `trip_invalid_file_type` string resource for user-friendly error message - Fix transport spinner variable name typo ## Test plan - [ ] Create a Trip post on Android 13+ device - [ ] Tap "Load GPX" and verify GPX files are selectable - [ ] Verify non-GPX files show "Please select a GPX file (.gpx)" error - [ ] Select a transport mode and verify the Trip posts successfully
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin betodealmeida/fix-gpx-file-picker-android13:betodealmeida/fix-gpx-file-picker-android13
git switch betodealmeida/fix-gpx-file-picker-android13

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch master
git merge --no-ff betodealmeida/fix-gpx-file-picker-android13
git switch betodealmeida/fix-gpx-file-picker-android13
git rebase master
git switch master
git merge --ff-only betodealmeida/fix-gpx-file-picker-android13
git switch betodealmeida/fix-gpx-file-picker-android13
git rebase master
git switch master
git merge --no-ff betodealmeida/fix-gpx-file-picker-android13
git switch master
git merge --squash betodealmeida/fix-gpx-file-picker-android13
git switch master
git merge --ff-only betodealmeida/fix-gpx-file-picker-android13
git switch master
git merge betodealmeida/fix-gpx-file-picker-android13
git push origin master
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
inhji/indiepass-android!450
No description provided.