From 10f9f776ef455379ddbdca576f3823ac92283ce4 Mon Sep 17 00:00:00 2001 From: Tim Perry Date: Mon, 19 Sep 2016 08:27:53 -0700 Subject: [PATCH] updated versions and name --- README.md | 39 +++---------------------------- package.json | 18 +++++++------- plugin.xml | 9 ++++--- src/android/PermissionHelper.java | 2 +- src/android/Screenshot.java | 4 +++- src/ios/Screenshot.h | 3 ++- src/ios/Screenshot.m | 27 +++------------------ 7 files changed, 25 insertions(+), 77 deletions(-) diff --git a/README.md b/README.md index 2d93801..aa88960 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ cordova-screenshot ================== -[![NPM version](http://img.shields.io/npm/v/com.darktalker.cordova.screenshot.svg?style=flat)](https://www.npmjs.com/package/com.darktalker.cordova.screenshot) +[![NPM version](http://img.shields.io/npm/v/com.sharerevolution.cordova.screenshot.svg?style=flat)](https://www.npmjs.com/package/com.sharerevolution.cordova.screenshot) The Screenshot plugin allows your application to take screenshots of the current screen and save them into the phone. @@ -16,44 +16,11 @@ cordova plugin add https://github.com/gitawego/cordova-screenshot.git notice: in iOS, only jpg format is supported -in Android, the default WebView and [Crosswalk](https://crosswalk-project.org/documentation/cordova.html) are both supported +in Android, [Crosswalk](https://crosswalk-project.org/documentation/cordova.html) is supported ##usage -```js -navigator.screenshot.save(function(error,res){ - if(error){ - console.error(error); - }else{ - console.log('ok',res.filePath); - } -}); -``` -take screenshot with jpg and custom quality -```js -navigator.screenshot.save(function(error,res){ - if(error){ - console.error(error); - }else{ - console.log('ok',res.filePath); - } -},'jpg',50); -``` - -define a filename -```js -navigator.screenshot.save(function(error,res){ - if(error){ - console.error(error); - }else{ - console.log('ok',res.filePath); //should be path/to/myScreenshot.jpg - } -},'jpg',50,'myScreenShot'); -``` - -screenshot files are stored in /sdcard/Pictures for android. - take screenshot and get it as Data URI ```js navigator.screenshot.URI(function(error,res){ @@ -66,7 +33,7 @@ navigator.screenshot.URI(function(error,res){ },50); ``` -##usage in AngularJS +##usage in AngularJS TODO: update to use URI ```js .service('$cordovaScreenshot', ['$q', function ($q){ diff --git a/package.json b/package.json index 3ca7739..2da6c2c 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,9 @@ { - "name": "com.darktalker.cordova.screenshot", - "version": "0.1.5", - "description": "screenshot PhoneGap Plugin for Android", + "name": "com.sharerevolution.cordova.screenshot", + "version": "0.1.6", + "description": "screenshot Cordova Plugin for Android (Crosswalk) and iOS, only provides screenshot as URI, not as file.", "cordova": { - "id": "com.darktalker.cordova.screenshot", + "id": "com.sharerevolution.cordova.screenshot", "platforms": [ "android", "ios", @@ -12,7 +12,7 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/gitawego/cordova-screenshot.git" + "url": "git+https://github.com/perry2of5/cordova-screenshot.git" }, "keywords": [ "cordova", @@ -25,13 +25,13 @@ "engines": [ { "name": "cordova", - "version": ">=3.0.0" + "version": ">=6.0.0" } ], - "author": "Hongbo LU", + "author": "Tim Perry et. al. including Hongbo LU", "license": "MIT", "bugs": { - "url": "https://github.com/gitawego/cordova-screenshot/issues" + "url": "https://github.com/perry2of5/cordova-screenshot/issues" }, - "homepage": "https://github.com/gitawego/cordova-screenshot#readme" + "homepage": "https://github.com/perry2of5/cordova-screenshot#readme" } diff --git a/plugin.xml b/plugin.xml index a795c29..6b1d74b 100644 --- a/plugin.xml +++ b/plugin.xml @@ -1,5 +1,5 @@ - Screenshot @@ -8,7 +8,7 @@ cordova,screenshot https://github.com/gitawego/cordova-screenshot.git - + @@ -21,10 +21,9 @@ - - - + + diff --git a/src/android/PermissionHelper.java b/src/android/PermissionHelper.java index 8b3eea2..af38f9f 100644 --- a/src/android/PermissionHelper.java +++ b/src/android/PermissionHelper.java @@ -16,7 +16,7 @@ Licensed to the Apache Software Foundation (ASF) under one specific language governing permissions and limitations under the License. */ -package com.darktalker.cordova.screenshot; +package com.sharerevolution.cordova.screenshot; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; diff --git a/src/android/Screenshot.java b/src/android/Screenshot.java index acd8c55..9502db7 100644 --- a/src/android/Screenshot.java +++ b/src/android/Screenshot.java @@ -5,8 +5,10 @@ * @author Josemando Sobral * @created Jul 2nd, 2012. * improved by Hongbo LU + * changed 2016-09-02 by Tim Perry to remove save feature -- try to avoid prompting user for access to files + * when all I want is a screenshot of the current app. */ -package com.darktalker.cordova.screenshot; +package com.sharerevolution.cordova.screenshot; import android.Manifest; import android.content.Intent; diff --git a/src/ios/Screenshot.h b/src/ios/Screenshot.h index dbaff57..33aaa51 100644 --- a/src/ios/Screenshot.h +++ b/src/ios/Screenshot.h @@ -5,6 +5,8 @@ // Copyright 2010 The Angry Robot Zombie Factory. // - Converted to Cordova 1.6.1 by Josemando Sobral. // MIT licensed +// changed 2016-09-02 by Tim Perry to remove save feature -- try to avoid prompting user for access to files +// when all I want is a screenshot of the current app. // #import @@ -14,7 +16,6 @@ @interface Screenshot : CDVPlugin { } -//- (void)saveScreenshot:(NSArray*)arguments withDict:(NSDictionary*)options; - (void)saveScreenshot:(CDVInvokedUrlCommand*)command; - (void)getScreenshotAsURI:(CDVInvokedUrlCommand*)command; @end diff --git a/src/ios/Screenshot.m b/src/ios/Screenshot.m index f310e7c..cbceb6e 100644 --- a/src/ios/Screenshot.m +++ b/src/ios/Screenshot.m @@ -8,6 +8,9 @@ // // Modifications to support orientation change by @ffd8 // +// changed 2016-09-02 by Tim Perry to remove save feature -- try to avoid prompting user for access to files +// when all I want is a screenshot of the current app. +// #import #import "Screenshot.h" @@ -27,30 +30,6 @@ - (UIImage *)getScreenshot return img; } -- (void)saveScreenshot:(CDVInvokedUrlCommand*)command -{ - NSString *filename = [command.arguments objectAtIndex:2]; - NSNumber *quality = [command.arguments objectAtIndex:1]; - - NSString *path = [NSString stringWithFormat:@"%@.jpg",filename]; - NSString *jpgPath = [NSTemporaryDirectory() stringByAppendingPathComponent:path]; - - UIImage *image = [self getScreenshot]; - NSData *imageData = UIImageJPEGRepresentation(image,[quality floatValue]); - [imageData writeToFile:jpgPath atomically:NO]; - - CDVPluginResult* pluginResult = nil; - NSDictionary *jsonObj = [ [NSDictionary alloc] - initWithObjectsAndKeys : - jpgPath, @"filePath", - @"true", @"success", - nil - ]; - - pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:jsonObj]; - NSString* callbackId = command.callbackId; - [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId]; -} - (void) getScreenshotAsURI:(CDVInvokedUrlCommand*)command {