From 77d253379802487007c138ca025ac21f9bece002 Mon Sep 17 00:00:00 2001 From: Janos Hrubos <33330538+janoshrubos@users.noreply.github.com> Date: Wed, 6 Oct 2021 17:48:52 +0200 Subject: [PATCH] feat: android openFile dialog title (#9600) * feat: android openFile dialog title * types: update openFile types --- packages/core/utils/index.android.ts | 4 ++-- packages/core/utils/index.d.ts | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/core/utils/index.android.ts b/packages/core/utils/index.android.ts index 98f1fdb4f..827068c4b 100644 --- a/packages/core/utils/index.android.ts +++ b/packages/core/utils/index.android.ts @@ -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); diff --git a/packages/core/utils/index.d.ts b/packages/core/utils/index.d.ts index ec047b899..339da5019 100644 --- a/packages/core/utils/index.d.ts +++ b/packages/core/utils/index.d.ts @@ -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.