-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
70 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/*************************************************************************** | ||
* Copyright (C) 2019-2024 by Stefan Kebekus, [email protected] * | ||
* Copyright (C) 2019-2025 by Stefan Kebekus, [email protected] * | ||
* Copyright (C) 2020 by Johannes Zellner, [email protected] * | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
|
@@ -82,6 +82,8 @@ public class MobileAdaptor extends de.akaflieg_freiburg.enroute.ShareActivity { | |
private static String AUTHORITY = "de.akaflieg_freiburg.enroute"; | ||
private static String TAG = "IntentLauncher"; | ||
|
||
private static final int PICK_FILE_REQUEST = 1; | ||
|
||
public MobileAdaptor() { | ||
m_instance = this; | ||
} | ||
|
@@ -441,6 +443,44 @@ private static boolean openInGoogleEarth(String geoUrl) { | |
return true; | ||
} | ||
|
||
/** | ||
* Open a file picker to select a file. | ||
* | ||
* This method opens a file picker to select a file of a given mime type. This is necessary | ||
* to work around a bug in Qt which does not allow to select files with a specific extension | ||
* and does not support remote files. | ||
* | ||
* https://bugreports.qt.io/browse/QTBUG-118154 | ||
* | ||
* @param mimeType the mime type of the file to select. | ||
* | ||
*/ | ||
public void openFilePicker(String mimeType) { | ||
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); | ||
intent.addCategory(Intent.CATEGORY_OPENABLE); | ||
if (!mimeType.isEmpty()) { | ||
intent.setType(mimeType); | ||
} else { | ||
intent.setType("*/*"); | ||
} | ||
startActivityForResult(intent, PICK_FILE_REQUEST); | ||
} | ||
|
||
/** Result of file picking | ||
*/ | ||
public static native void setFileReceived(String fileName); | ||
|
||
@Override | ||
protected void onActivityResult(int requestCode, int resultCode, Intent data) { | ||
if (requestCode == PICK_FILE_REQUEST && resultCode == RESULT_OK) { | ||
Uri uri = data.getData(); | ||
if (uri != null) { | ||
setFileReceived(uri.toString()); | ||
} | ||
} | ||
super.onActivityResult(requestCode, resultCode, data); | ||
} | ||
|
||
/** | ||
* create uri from file path. | ||
* | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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