Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bd3e0f299f | ||
|
|
c0b74c2a75 | ||
|
|
80aa06a6a1 | ||
|
|
771674d948 | ||
|
|
51093d00b8 | ||
|
|
ee4e96a1da | ||
|
|
8590d54633 | ||
|
|
fa0558ea75 | ||
|
|
d270bcb1a6 |
@@ -1,4 +1,4 @@
|
||||
# Cordova base64ToGallery Plugin
|
||||
# :warning: DISCONTINUED - Cordova base64ToGallery Plugin
|
||||
This plugin (based on [devgeeks/Canvas2ImagePlugin](http://github.com/devgeeks/Canvas2ImagePlugin)) allows you to save base64 data as a png image into the device (iOS Photo Library, Android Gallery or WindowsPhone 8 Photo Album).
|
||||
|
||||
The plugin is a kind of fork of the [solderzzc/Base64ImageSaverPlugin](https://github.com/solderzzc/Base64ImageSaverPlugin) but with a cleaner history (a.k.a: no tags from Canvas2ImagePlugin repo) and a newer iOS implementation.
|
||||
|
||||
1196
package-lock.json
generated
Normal file
1196
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
10
package.json
10
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cordova-base64-to-gallery",
|
||||
"version": "4.1.2",
|
||||
"name": "@goiarlabs/cordova-base64-to-gallery",
|
||||
"version": "6.0.0-falopa",
|
||||
"description": "Cordova plugin to save base64 data as a png image into the device",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
@@ -12,10 +12,10 @@
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/Nexxa/cordova-base64-to-gallery.git"
|
||||
"url": "git+https://github.com/@goiarlabs/cordova-base64-to-gallery.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/Nexxa/cordova-base64-to-gallery/issues"
|
||||
"url": "https://github.com/@goiarlabs/cordova-base64-to-gallery/issues"
|
||||
},
|
||||
"engines": [
|
||||
{
|
||||
@@ -26,7 +26,7 @@
|
||||
}
|
||||
],
|
||||
"cordova": {
|
||||
"id": "cordova-base64-to-gallery",
|
||||
"id": "@goiarlabs/cordova-base64-to-gallery",
|
||||
"platforms": [
|
||||
"ios",
|
||||
"android",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<plugin xmlns:android="http://schemas.android.com/apk/res/android" xmlns="http://www.phonegap.com/ns/plugins/1.0" id="cordova-base64-to-gallery" version="4.1.2">
|
||||
<plugin xmlns:android="http://schemas.android.com/apk/res/android" xmlns="http://www.phonegap.com/ns/plugins/1.0" id="cordova-base64-to-gallery" version="4.1.3">
|
||||
|
||||
<engines>
|
||||
<engine name="cordova-ios" version=">=3.8.0" />
|
||||
|
||||
@@ -89,22 +89,10 @@ public class Base64ToGallery extends CordovaPlugin {
|
||||
|
||||
int check = deviceVersion.compareTo("2.3.3");
|
||||
|
||||
File folder;
|
||||
File folder = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
|
||||
|
||||
/*
|
||||
* File path = Environment.getExternalStoragePublicDirectory(
|
||||
* Environment.DIRECTORY_PICTURES ); //this throws error in Android
|
||||
* 2.2
|
||||
*/
|
||||
if (check >= 1) {
|
||||
folder = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
|
||||
|
||||
if (!folder.exists()) {
|
||||
folder.mkdirs();
|
||||
}
|
||||
|
||||
} else {
|
||||
folder = Environment.getExternalStorageDirectory();
|
||||
if (!folder.exists()) {
|
||||
folder.mkdirs();
|
||||
}
|
||||
|
||||
File imageFile = new File(folder, prefix + date + ".png");
|
||||
|
||||
@@ -62,7 +62,13 @@
|
||||
if(cameraRoll){
|
||||
// add the image to camera roll
|
||||
UIImage * savedImage = [UIImage imageWithContentsOfFile:imagePath];
|
||||
UIImageWriteToSavedPhotosAlbum(savedImage, self, @selector(thisImage:hasBeenSavedInPhotoAlbumWithError:usingContextInfo:), nil);
|
||||
UIImageWriteToSavedPhotosAlbum(savedImage, self,
|
||||
@selector(thisImage:hasBeenSavedInPhotoAlbumWithError:onImagePath:),
|
||||
(void *) CFBridgingRetain(imagePath));
|
||||
} else {
|
||||
// send back the image path of the saved image
|
||||
CDVPluginResult * pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:imagePath];
|
||||
[self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackId];
|
||||
}
|
||||
|
||||
}else{
|
||||
@@ -79,14 +85,18 @@
|
||||
}];
|
||||
}
|
||||
|
||||
-(void)thisImage:(UIImage *)image hasBeenSavedInPhotoAlbumWithError:(NSError *)error usingContextInfo:(void*)ctxInfo{
|
||||
if (error) {
|
||||
CDVPluginResult * pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Error saving Image to Gallery, check Permissions"];
|
||||
[self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackId];
|
||||
} else {
|
||||
CDVPluginResult * pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString: @"Image Saved to Gallery"];
|
||||
[self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackId];
|
||||
-(void)thisImage:(UIImage *)image hasBeenSavedInPhotoAlbumWithError:(NSError *)error onImagePath:(void*)bridgedImagePath{
|
||||
if (error) {
|
||||
CDVPluginResult * pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Error saving Image to Gallery, check Permissions"];
|
||||
[self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackId];
|
||||
} else {
|
||||
// retrieve bridged image path and release it to get the image path
|
||||
NSString *imagePath = (NSString *) CFBridgingRelease(bridgedImagePath);
|
||||
|
||||
// send the image path back to the js callback
|
||||
CDVPluginResult * pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:imagePath];
|
||||
[self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackId];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user