Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class RNFileViewerModule extends ReactContextBaseJavaModule {
private final ReactApplicationContext reactContext;
private static final String SHOW_OPEN_WITH_DIALOG = "showOpenWithDialog" ;
private static final String SHOW_STORE_SUGGESTIONS ="showAppsSuggestions";
private static final String FLAG_ACTIVITY_NEW_TASK ="intentFlagActivityNewTask"; // 2023-06-24 (JJ): Supporting intentFlagActivityNewTask in FileViewer.open options parameter
private static final String OPEN_EVENT = "RNFileViewerDidOpen";
private static final String DISMISS_EVENT = "RNFileViewerDidDismiss";
private static final Integer RN_FILE_VIEWER_REQUEST = 33341;
Expand All @@ -46,6 +47,7 @@ public void open(String path, Integer currentId, ReadableMap options) {
Uri contentUri = null;
Boolean showOpenWithDialog = options.hasKey(SHOW_OPEN_WITH_DIALOG) ? options.getBoolean(SHOW_OPEN_WITH_DIALOG) : false;
Boolean showStoreSuggestions = options.hasKey(SHOW_STORE_SUGGESTIONS) ? options.getBoolean(SHOW_STORE_SUGGESTIONS) : false;
Boolean intentFlagActivityNewTask = options.hasKey(FLAG_ACTIVITY_NEW_TASK) ? options.getBoolean(FLAG_ACTIVITY_NEW_TASK) : false; // 2023-06-24 (JJ): Supporting intentFlagActivityNewTask in FileViewer.open options parameter

if(path.startsWith("content://")) {
contentUri = Uri.parse(path);
Expand Down Expand Up @@ -80,6 +82,12 @@ public void open(String path, Integer currentId, ReadableMap options) {

shareIntent.setAction(Intent.ACTION_VIEW);
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

// 2023-06-24 (JJ): Supporting intentFlagActivityNewTask in FileViewer.open options parameter
if (intentFlagActivityNewTask) {
shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}

shareIntent.setDataAndType(contentUri, mimeType);
shareIntent.putExtra(Intent.EXTRA_STREAM, contentUri);
Intent intentActivity;
Expand Down
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ interface RNFileViewerOptions {
displayName?: string;
showAppsSuggestions?: boolean;
showOpenWithDialog?: boolean;
intentFlagActivityNewTask?: boolean; // 2023-06-24 (JJ): Supporting intentFlagActivityNewTask in FileViewer.open options parameter
onDismiss?(): any;
}

Expand Down