feat: android openFile dialog title (#9600)

* feat: android openFile dialog title

* types: update openFile types
This commit is contained in:
Janos Hrubos
2021-10-06 17:48:52 +02:00
committed by GitHub
parent 2b2ce377e6
commit 77d2533798
2 changed files with 4 additions and 3 deletions

View File

@@ -81,7 +81,7 @@ function getMimeTypeNameFromExtension(filePath: string): string {
* @param {string} filePath
* @returns {boolean} whether opening the file succeeded or not
*/
export function openFile(filePath: string): boolean {
export function openFile(filePath: string, title: string = 'Open File...'): boolean {
const context = ad.getApplicationContext();
try {
// Ensure external storage is available
@@ -108,7 +108,7 @@ Applications cannot access internal storage of other application on Android (see
// Determine file mimetype & start creating intent
const mimeType = getMimeTypeNameFromExtension(filePath);
const intent = new android.content.Intent(android.content.Intent.ACTION_VIEW);
const chooserIntent = android.content.Intent.createChooser(intent, 'Open File...');
const chooserIntent = android.content.Intent.createChooser(intent, title);
intent.addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
chooserIntent.addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK);

View File

@@ -242,8 +242,9 @@ export function openUrl(url: string): boolean;
/**
* Opens file.
* @param filePath The file.
* @param title Optional title for Android. Default is: 'Open File...'
*/
export function openFile(filePath: string): boolean;
export function openFile(filePath: string, title?: string): boolean;
/**
* Escapes special regex symbols (., *, ^, $ and so on) in string in order to create a valid regex from it.