Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow multiple time retrieve the list of shared files #171

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
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 @@ -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();
Expand Down Expand Up @@ -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")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,16 @@ public void getFileNames(Promise promise){
if(mActivity == null) { return; }
Intent intent = mActivity.getIntent();
receiveSharingIntentHelper.sendFileNames(reactContext, intent, promise);
mActivity.setIntent(null);
}

@ReactMethod
public void clearFileNames(){
Activity mActivity = getCurrentActivity();
if(mActivity == null) { return; }
Intent intent = mActivity.getIntent();
receiveSharingIntentHelper.clearFileNames(intent);
if (intent != null) {
receiveSharingIntentHelper.clearFileNames(intent);
}
}


Expand Down
3 changes: 2 additions & 1 deletion src/ReceiveSharingIntent.interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

export interface IReceiveSharingIntent{
getReceivedFiles(handler: Function , errorHandler: Function, protocol: string ): void,
clearFileNames() :void,
}

export interface IUtils{
Expand All @@ -15,4 +16,4 @@ export interface IReturnData{
contentUri?: any | string,
fileName?: any | string,
extension?: any | string,
}
}
5 changes: 4 additions & 1 deletion src/ReceiveSharingIntent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand All @@ -54,4 +57,4 @@ class ReceiveSharingIntentModule implements IReceiveSharingIntent {

}

export default ReceiveSharingIntentModule;
export default ReceiveSharingIntentModule;