Skip to content

Commit

Permalink
ShareIntentReceiverActivity - Filter media types to allow only images…
Browse files Browse the repository at this point in the history
… and videos
  • Loading branch information
Gerardo committed Dec 7, 2023
1 parent 7482ba3 commit c5f7c68
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,23 @@ private void downloadExternalMedia() {
if (Intent.ACTION_SEND_MULTIPLE.equals(getIntent().getAction())) {
ArrayList<Uri> externalUris = getIntent().getParcelableArrayListExtra((Intent.EXTRA_STREAM));
for (Uri uri : externalUris) {
mLocalMediaUris.add(MediaUtils.downloadExternalMedia(this, uri));
if (isAllowedMediaType(uri)) {
mLocalMediaUris.add(MediaUtils.downloadExternalMedia(this, uri));
}
}
} else if (Intent.ACTION_SEND.equals(getIntent().getAction())) {
Uri externalUri = getIntent().getParcelableExtra(Intent.EXTRA_STREAM);
mLocalMediaUris.add(MediaUtils.downloadExternalMedia(this, externalUri));
if (isAllowedMediaType(externalUri)) {
mLocalMediaUris.add(MediaUtils.downloadExternalMedia(this, externalUri));
}
}
}

private boolean isAllowedMediaType(@NonNull Uri uri) {
String filePath = MediaUtils.getRealPathFromURI(this, uri);
return MediaUtils.isValidImage(filePath) || MediaUtils.isVideo(filePath);
}

private void initShareFragment() {
ShareIntentReceiverFragment shareIntentReceiverFragment = ShareIntentReceiverFragment
.newInstance(!isSharingText(), loadLastUsedBlogLocalId());
Expand Down

0 comments on commit c5f7c68

Please sign in to comment.