diff --git a/app/src/main/java/gallery/memories/NativeX.java b/app/src/main/java/gallery/memories/NativeX.java index 254a1a79..4ce1a016 100644 --- a/app/src/main/java/gallery/memories/NativeX.java +++ b/app/src/main/java/gallery/memories/NativeX.java @@ -114,6 +114,8 @@ public class NativeX { return makeResponse(mDlService.shareUrl(URLDecoder.decode(parts[4], "UTF-8"))); } else if (path.matches("/api/share/blob/.+$")) { return makeResponse(mDlService.shareBlobFromUrl(URLDecoder.decode(parts[4], "UTF-8"))); + } else if (path.matches("/api/share/local/\\d+$")) { + return makeResponse(mDlService.shareLocal(Long.parseLong(parts[4]))); } throw new Exception("Not Found"); diff --git a/app/src/main/java/gallery/memories/service/DownloadService.java b/app/src/main/java/gallery/memories/service/DownloadService.java index 29384809..59151410 100644 --- a/app/src/main/java/gallery/memories/service/DownloadService.java +++ b/app/src/main/java/gallery/memories/service/DownloadService.java @@ -1,10 +1,12 @@ package gallery.memories.service; import android.app.DownloadManager; +import android.content.ContentUris; import android.content.Context; import android.content.Intent; import android.database.Cursor; import android.net.Uri; +import android.provider.MediaStore; import android.webkit.CookieManager; import android.widget.Toast; @@ -108,6 +110,16 @@ public class DownloadService { return true; } + public Boolean shareLocal(final long id) throws Exception { + Uri uri = ContentUris.withAppendedId(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, id); + Intent intent = new Intent(Intent.ACTION_SEND); + intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); + intent.setType(mActivity.getContentResolver().getType(uri)); + intent.putExtra(Intent.EXTRA_STREAM, uri); + mActivity.startActivity(Intent.createChooser(intent, null)); + return true; + } + protected String getDownloadedFileURI(long downloadId) { DownloadManager downloadManager = (DownloadManager) mActivity.getSystemService(Context.DOWNLOAD_SERVICE); DownloadManager.Query query = new DownloadManager.Query();