mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
feat: android openFile dialog title (#9600)
* feat: android openFile dialog title * types: update openFile types
This commit is contained in:
@@ -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);
|
||||
|
||||
3
packages/core/utils/index.d.ts
vendored
3
packages/core/utils/index.d.ts
vendored
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user