Skip to content

Commit

Permalink
TextWebView: allow to upload multiple attachements
Browse files Browse the repository at this point in the history
Signed-off-by: tobiasKaminsky <[email protected]>
  • Loading branch information
tobiasKaminsky authored and alperozturk96 committed Sep 12, 2024
1 parent 2f4dcbd commit 8248f5e
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import android.app.DownloadManager;
import android.content.ActivityNotFoundException;
import android.content.ClipData;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
Expand Down Expand Up @@ -36,6 +37,7 @@
import com.owncloud.android.utils.MimeTypeUtil;
import com.owncloud.android.utils.WebViewUtil;

import java.util.ArrayList;
import java.util.Optional;

import javax.inject.Inject;
Expand Down Expand Up @@ -200,7 +202,20 @@ protected void handleLocalFile(Intent data, int resultCode) {
return;
}

uploadMessage.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(resultCode, data));
if (data.getClipData() == null) {
// one file
uploadMessage.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(resultCode, data));
} else {
ArrayList<Uri> uris = new ArrayList<>();
// multiple files
for (int i = 0; i < data.getClipData().getItemCount(); i++) {
ClipData.Item item = data.getClipData().getItemAt(i);
uris.add(item.getUri());
}

uploadMessage.onReceiveValue(uris.toArray(new Uri[0]));
}

uploadMessage = null;
}

Expand Down

0 comments on commit 8248f5e

Please sign in to comment.