Merge branch 'issue#2'

This commit is contained in:
StefanoMagrassi 2016-01-05 12:16:41 +01:00
commit e2dcccf17e
4 changed files with 17 additions and 22 deletions

View File

@ -53,9 +53,7 @@ public class Base64ToGallery extends CordovaPlugin {
filePrefix = DEFAULT_FILE_PREFIX;
}
// Create the bitmap from the base64 string
Log.d("Base64ToGallery", base64);
// Create the bitmap from the base64 string
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;

View File

@ -7,7 +7,6 @@
// MIT Licensed
//
#import <Cordova/CDVPlugin.h>
@interface Base64ToGallery : CDVPlugin

View File

@ -25,26 +25,28 @@
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...
NSLog(@"ERROR: %@",error);
CDVPluginResult* result = [CDVPluginResult resultWithStatus: CDVCommandStatus_ERROR messageAsString:error.description];
if (error != NULL) {
NSLog(@"ERROR: %@", error);
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"];
[self.webView stringByEvaluatingJavaScriptFromString:[result toSuccessCallbackString: self.callbackId]];
// No errors
} else {
result = [CDVPluginResult resultWithStatus: CDVCommandStatus_OK];
[self.webView stringByEvaluatingJavaScriptFromString:[result toSuccessCallbackString: self.callbackId]];
}
}
@ -54,5 +56,4 @@
[super dealloc];
}
@end

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
{