10 Commits

Author SHA1 Message Date
StefanoMagrassi c744de9fb1 removed useless log messages - resolves #2 2016-01-05 12:18:53 +01:00
StefanoMagrassi e2dcccf17e Merge branch 'issue#2' 2016-01-05 12:16:41 +01:00
StefanoMagrassi d0f536a8b9 removed useless log messages from WP8 class 2016-01-05 12:16:00 +01:00
StefanoMagrassi ec45e6aabb removed useless log messages from iOS class 2016-01-05 12:13:26 +01:00
StefanoMagrassi c4009429a4 removed useless log message from Android class 2016-01-05 12:02:48 +01:00
StefanoMagrassi a4e55d33c7 updated version - resolves #1 2015-12-18 12:39:44 +01:00
StefanoMagrassi a6aaccb601 Merge branch 'issue#1' 2015-12-18 12:38:11 +01:00
StefanoMagrassi 0189a7b7bd Merge branch 'version_updater' into issue#1 2015-12-18 12:37:00 +01:00
StefanoMagrassi 4ca9499c95 added script to automate version update both in package.json and in plugin.xml 2015-12-18 12:36:45 +01:00
StefanoMagrassi 9182f20d32 changed repo name and plugin id 2015-12-18 12:17:02 +01:00
8 changed files with 104 additions and 91 deletions
+6
View File
@@ -3,6 +3,12 @@ This plugin (based on [devgeeks/Canvas2ImagePlugin](http://github.com/devgeeks/C
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).
## Alert
In order to be more consistent with the cordova naming convention, since version 2.0 the repository name and the cordova plugin id have changed to **cordova-base64-to-gallery** (issue #1).
Please uninstall the old version and reinstall the new one.
## Usage
Call the `cordova.base64ToGallery()` method using success and error callbacks and the id attribute or the element object of the canvas to save:
+13 -17
View File
@@ -1,22 +1,20 @@
{
"name": "cordova-base64-to-gallery",
"version": "1.0.1",
"version": "2.0.1",
"description": "Cordova plugin to save base64 data as a png image into the device",
"license": "MIT",
"scripts":
{
"scripts": {
"update": "node ./scripts/update_version",
"lint": "eslint www/base64ToGallery.js",
"test": "npm run lint",
"prepublish": "npm test"
},
"repository":
{
"repository": {
"type": "git",
"url": "git+https://github.com/Nexxa/base64ToGallery.git"
"url": "git+https://github.com/Nexxa/cordova-base64-to-gallery.git"
},
"bugs":
{
"url": "https://github.com/Nexxa/base64ToGallery/issues"
"bugs": {
"url": "https://github.com/Nexxa/cordova-base64-to-gallery/issues"
},
"engines": [
{
@@ -26,9 +24,8 @@
"node": ">=0.10"
}
],
"cordova":
{
"id": "it.nexxa.base64ToGallery",
"cordova": {
"id": "cordova-base64-to-gallery",
"platforms": [
"ios",
"android",
@@ -45,8 +42,7 @@
"cordova-android",
"cordova-wp8"
],
"author":
{
"author": {
"name": "StefanoMagrassi",
"email": "stefano.magrassi@gmail.com",
"url": "http://thinkwritedone.com"
@@ -58,8 +54,8 @@
"url": "http://www.tiegushi.com"
}
],
"devDependencies":
{
"eslint": "^1.10.3"
"devDependencies": {
"eslint": "1.10.3",
"libxmljs": "0.16.1"
}
}
+2 -5
View File
@@ -1,11 +1,8 @@
<plugin id="it.nexxa.base64ToGallery" version="1.0.1" xmlns:android="http://schemas.android.com/apk/res/android" xmlns="http://www.phonegap.com/ns/plugins/1.0">
<?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="2.0.1">
<name>base64ToGallery</name>
<engines>
<engine name="cordova" version=">=3.0.0" />
</engines>
<description>This plugin allows you to save base64 data as a png image into the device (iOS Photo Library, Android Gallery, WindowsPhone 8 Photo Album).</description>
<author>Tommy-Carlos Williams - tommy@devgeeks.org</author>
<author>Simba Zhang - solderzzc@gmail.com</author>
+19
View File
@@ -0,0 +1,19 @@
/*eslint-env node*/
// Modules
var fs = require('fs');
var libxml = require('libxmljs');
var pkg = require('../package.json');
// CONSTS
var CONFIG_FILE = 'plugin.xml';
var version = pkg.version;
var configContent = fs.readFileSync(CONFIG_FILE);
var configXML = libxml.parseXmlString(configContent);
var configVersion = configXML.root().attr('version');
// Set version
configVersion.value(version);
fs.writeFileSync(CONFIG_FILE, configXML.toString());
-5
View File
@@ -54,8 +54,6 @@ public class Base64ToGallery extends CordovaPlugin {
}
// Create the bitmap from the base64 string
Log.d("Base64ToGallery", base64);
byte[] decodedString = Base64.decode(base64, Base64.DEFAULT);
Bitmap bmp = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
@@ -99,9 +97,6 @@ public class Base64ToGallery extends CordovaPlugin {
+ c.get(Calendar.MINUTE)
+ c.get(Calendar.SECOND);
Log.i("Base64ToGallery", "Android version " + deviceVersion);
int check = deviceVersion.compareTo("2.3.3");
File folder;
-1
View File
@@ -7,7 +7,6 @@
// MIT Licensed
//
#import <Cordova/CDVPlugin.h>
@interface Base64ToGallery : CDVPlugin
+13 -12
View File
@@ -25,25 +25,27 @@
NSData* imageData = [NSData dataFromBase64String:[command.arguments objectAtIndex:0]];
UIImage* image = [[[UIImage alloc] initWithData:imageData] autorelease];
UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
}
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
{
CDVPluginResult* result = nil;
// Was there an error?
if (error != NULL)
{
// Show error message...
if (error != NULL) {
NSLog(@"ERROR: %@", error);
CDVPluginResult* result = [CDVPluginResult resultWithStatus: CDVCommandStatus_ERROR messageAsString:error.description];
result = [CDVPluginResult resultWithStatus: CDVCommandStatus_ERROR messageAsString:error.description];
[self.webView stringByEvaluatingJavaScriptFromString:[result toErrorCallbackString: self.callbackId]];
}
else // No errors
{
// Show message image successfully saved
NSLog(@"IMAGE SAVED!");
CDVPluginResult* result = [CDVPluginResult resultWithStatus: CDVCommandStatus_OK messageAsString:@"Image saved"];
// No errors
} else {
result = [CDVPluginResult resultWithStatus: CDVCommandStatus_OK];
[self.webView stringByEvaluatingJavaScriptFromString:[result toSuccessCallbackString: self.callbackId]];
}
}
@@ -54,5 +56,4 @@
[super dealloc];
}
@end
+1 -1
View File
@@ -37,7 +37,7 @@ public class Base64ToGallery : BaseCommand
if (picture.Name.Contains(fileName))
{
DispatchCommandResult(new PluginResult(PluginResult.Status.OK, "Image saved: " + picture.Name));
DispatchCommandResult(new PluginResult(PluginResult.Status.OK));
}
else
{