Add local sharing
parent
fb3045d6c9
commit
bc5490ecdb
|
@ -114,6 +114,8 @@ public class NativeX {
|
||||||
return makeResponse(mDlService.shareUrl(URLDecoder.decode(parts[4], "UTF-8")));
|
return makeResponse(mDlService.shareUrl(URLDecoder.decode(parts[4], "UTF-8")));
|
||||||
} else if (path.matches("/api/share/blob/.+$")) {
|
} else if (path.matches("/api/share/blob/.+$")) {
|
||||||
return makeResponse(mDlService.shareBlobFromUrl(URLDecoder.decode(parts[4], "UTF-8")));
|
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");
|
throw new Exception("Not Found");
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
package gallery.memories.service;
|
package gallery.memories.service;
|
||||||
|
|
||||||
import android.app.DownloadManager;
|
import android.app.DownloadManager;
|
||||||
|
import android.content.ContentUris;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.provider.MediaStore;
|
||||||
import android.webkit.CookieManager;
|
import android.webkit.CookieManager;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
@ -108,6 +110,16 @@ public class DownloadService {
|
||||||
return true;
|
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) {
|
protected String getDownloadedFileURI(long downloadId) {
|
||||||
DownloadManager downloadManager = (DownloadManager) mActivity.getSystemService(Context.DOWNLOAD_SERVICE);
|
DownloadManager downloadManager = (DownloadManager) mActivity.getSystemService(Context.DOWNLOAD_SERVICE);
|
||||||
DownloadManager.Query query = new DownloadManager.Query();
|
DownloadManager.Query query = new DownloadManager.Query();
|
||||||
|
|
Loading…
Reference in New Issue