From e051831feb225d57e594d12be9439794624890cb Mon Sep 17 00:00:00 2001 From: Christian Agnoletto <124805531+Christian-Agnoletto-Jakala@users.noreply.github.com> Date: Wed, 21 Jun 2023 11:28:59 +0200 Subject: [PATCH 1/4] Update ReceiveSharingIntent.interfaces.ts Added clearFileNames to public methods --- src/ReceiveSharingIntent.interfaces.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ReceiveSharingIntent.interfaces.ts b/src/ReceiveSharingIntent.interfaces.ts index 241ba466..cddf048b 100644 --- a/src/ReceiveSharingIntent.interfaces.ts +++ b/src/ReceiveSharingIntent.interfaces.ts @@ -1,6 +1,7 @@ export interface IReceiveSharingIntent{ getReceivedFiles(handler: Function , errorHandler: Function, protocol: string ): void, + clearFileNames() :void, } export interface IUtils{ @@ -15,4 +16,4 @@ export interface IReturnData{ contentUri?: any | string, fileName?: any | string, extension?: any | string, -} \ No newline at end of file +} From e2db3567c714b2709beee4fad410495c93ac9cdb Mon Sep 17 00:00:00 2001 From: Christian Agnoletto <124805531+Christian-Agnoletto-Jakala@users.noreply.github.com> Date: Wed, 21 Jun 2023 11:33:16 +0200 Subject: [PATCH 2/4] Update ReceiveSharingIntent.ts --- src/ReceiveSharingIntent.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ReceiveSharingIntent.ts b/src/ReceiveSharingIntent.ts index 735c1916..d1dc92e6 100644 --- a/src/ReceiveSharingIntent.ts +++ b/src/ReceiveSharingIntent.ts @@ -36,6 +36,9 @@ class ReceiveSharingIntentModule implements IReceiveSharingIntent { this.isClear = true; } + clearFileNames() { + ReceiveSharingIntent.clearFileNames(); + } protected getFileNames(handler: Function, errorHandler: Function, url: string){ if(this.isIos){ @@ -54,4 +57,4 @@ class ReceiveSharingIntentModule implements IReceiveSharingIntent { } -export default ReceiveSharingIntentModule; \ No newline at end of file +export default ReceiveSharingIntentModule; From 5fbd45e93a50ab87bd34263f746717aff5eaa7f2 Mon Sep 17 00:00:00 2001 From: Christian Agnoletto <124805531+Christian-Agnoletto-Jakala@users.noreply.github.com> Date: Wed, 21 Jun 2023 11:35:55 +0200 Subject: [PATCH 3/4] Update ReceiveSharingIntentModule.java --- .../ReceiveSharingIntentModule.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/android/src/main/java/com/reactnativereceivesharingintent/ReceiveSharingIntentModule.java b/android/src/main/java/com/reactnativereceivesharingintent/ReceiveSharingIntentModule.java index f7521441..5b4a9c50 100644 --- a/android/src/main/java/com/reactnativereceivesharingintent/ReceiveSharingIntentModule.java +++ b/android/src/main/java/com/reactnativereceivesharingintent/ReceiveSharingIntentModule.java @@ -40,7 +40,6 @@ public void getFileNames(Promise promise){ if(mActivity == null) { return; } Intent intent = mActivity.getIntent(); receiveSharingIntentHelper.sendFileNames(reactContext, intent, promise); - mActivity.setIntent(null); } @ReactMethod @@ -48,7 +47,9 @@ public void clearFileNames(){ Activity mActivity = getCurrentActivity(); if(mActivity == null) { return; } Intent intent = mActivity.getIntent(); - receiveSharingIntentHelper.clearFileNames(intent); + if (intent != null) { + receiveSharingIntentHelper.clearFileNames(intent); + } } From ddcc2472e96b846b5d951a297e5d4ce535e73a2b Mon Sep 17 00:00:00 2001 From: Christian Agnoletto <124805531+Christian-Agnoletto-Jakala@users.noreply.github.com> Date: Wed, 21 Jun 2023 11:39:57 +0200 Subject: [PATCH 4/4] Update ReceiveSharingIntentHelper.java --- .../ReceiveSharingIntentHelper.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/android/src/main/java/com/reactnativereceivesharingintent/ReceiveSharingIntentHelper.java b/android/src/main/java/com/reactnativereceivesharingintent/ReceiveSharingIntentHelper.java index 69126eb9..4cb1b973 100644 --- a/android/src/main/java/com/reactnativereceivesharingintent/ReceiveSharingIntentHelper.java +++ b/android/src/main/java/com/reactnativereceivesharingintent/ReceiveSharingIntentHelper.java @@ -28,6 +28,9 @@ public ReceiveSharingIntentHelper(Application context){ @RequiresApi(api = Build.VERSION_CODES.KITKAT) public void sendFileNames(Context context, Intent intent, Promise promise){ + if (intent == null) { + promise.reject("error","Null intent."); + } try { String action = intent.getAction(); String type = intent.getType(); @@ -165,6 +168,7 @@ private String getMediaType(String url){ public void clearFileNames(Intent intent){ + if(intent == null) return; String type = intent.getType(); if(type == null) return; if (type.startsWith("text")) {