mirror of
https://github.com/goiarlabs/cordova-base64-to-gallery.git
synced 2024-10-06 17:22:10 +08:00
Merge branch 'issue#2'
This commit is contained in:
commit
e2dcccf17e
@ -53,9 +53,7 @@ public class Base64ToGallery extends CordovaPlugin {
|
|||||||
filePrefix = DEFAULT_FILE_PREFIX;
|
filePrefix = DEFAULT_FILE_PREFIX;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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;
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
// MIT Licensed
|
// MIT Licensed
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#import <Cordova/CDVPlugin.h>
|
#import <Cordova/CDVPlugin.h>
|
||||||
|
|
||||||
@interface Base64ToGallery : CDVPlugin
|
@interface Base64ToGallery : CDVPlugin
|
||||||
|
@ -25,26 +25,28 @@
|
|||||||
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) {
|
||||||
{
|
NSLog(@"ERROR: %@", error);
|
||||||
// Show error message...
|
|
||||||
NSLog(@"ERROR: %@",error);
|
result = [CDVPluginResult resultWithStatus: CDVCommandStatus_ERROR messageAsString:error.description];
|
||||||
CDVPluginResult* 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
|
||||||
|
@ -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
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user