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

@ -54,8 +54,6 @@ public class Base64ToGallery extends CordovaPlugin {
} }
// Create the bitmap from the base64 string // Create the bitmap from the base64 string
Log.d("Base64ToGallery", base64);
byte[] decodedString = Base64.decode(base64, Base64.DEFAULT); byte[] decodedString = Base64.decode(base64, Base64.DEFAULT);
Bitmap bmp = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length); Bitmap bmp = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
@ -99,9 +97,6 @@ public class Base64ToGallery extends CordovaPlugin {
+ c.get(Calendar.MINUTE) + c.get(Calendar.MINUTE)
+ c.get(Calendar.SECOND); + c.get(Calendar.SECOND);
Log.i("Base64ToGallery", "Android version " + deviceVersion);
int check = deviceVersion.compareTo("2.3.3"); int check = deviceVersion.compareTo("2.3.3");
File folder; File folder;

View File

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

View File

@ -25,25 +25,27 @@
NSData* imageData = [NSData dataFromBase64String:[command.arguments objectAtIndex:0]]; NSData* imageData = [NSData dataFromBase64String:[command.arguments objectAtIndex:0]];
UIImage* image = [[[UIImage alloc] initWithData:imageData] autorelease]; 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 - (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
{ {
CDVPluginResult* result = nil;
// Was there an error? // Was there an error?
if (error != NULL) if (error != NULL) {
{
// Show error message...
NSLog(@"ERROR: %@", error); 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]]; [self.webView stringByEvaluatingJavaScriptFromString:[result toErrorCallbackString: self.callbackId]];
}
else // No errors // No errors
{ } else {
// Show message image successfully saved
NSLog(@"IMAGE SAVED!"); result = [CDVPluginResult resultWithStatus: CDVCommandStatus_OK];
CDVPluginResult* result = [CDVPluginResult resultWithStatus: CDVCommandStatus_OK messageAsString:@"Image saved"];
[self.webView stringByEvaluatingJavaScriptFromString:[result toSuccessCallbackString: self.callbackId]]; [self.webView stringByEvaluatingJavaScriptFromString:[result toSuccessCallbackString: self.callbackId]];
} }
} }
@ -54,5 +56,4 @@
[super dealloc]; [super dealloc];
} }
@end @end

View File

@ -37,7 +37,7 @@ public class Base64ToGallery : BaseCommand
if (picture.Name.Contains(fileName)) if (picture.Name.Contains(fileName))
{ {
DispatchCommandResult(new PluginResult(PluginResult.Status.OK, "Image saved: " + picture.Name)); DispatchCommandResult(new PluginResult(PluginResult.Status.OK));
} }
else else
{ {