From 3cf5e5a97afe8fc7877b528cf19130bef0d68bad Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 10 Sep 2020 14:35:21 +0200 Subject: build the app --- .../cordova-plugin-x-socialsharing/.npmignore | 3 + .../cordova-plugin-x-socialsharing/.travis.yml | 4 + .../plugins/cordova-plugin-x-socialsharing/LICENSE | 19 ++ .../plugins/cordova-plugin-x-socialsharing/MIT | 21 -- .../cordova-plugin-x-socialsharing/README.md | 35 +- .../cordova-plugin-x-socialsharing/package.json | 66 +++- .../cordova-plugin-x-socialsharing/plugin.xml | 22 +- .../screenshots/screenshot-android-share.png | Bin 142454 -> 0 bytes .../screenshots/screenshot-ios6-share.png | Bin 48752 -> 0 bytes .../screenshots/screenshot-ios7-ipad-share.png | Bin 47118 -> 0 bytes .../screenshots/screenshot-ios7-share.png | Bin 342109 -> 0 bytes .../screenshots/screenshot-wp8-share.jpg | Bin 33347 -> 0 bytes .../screenshots/screenshots-ios7-shareconfig.png | Bin 183133 -> 0 bytes .../android/nl/xservices/plugins/FileProvider.java | 5 + .../nl/xservices/plugins/SocialSharing.java | 36 +- .../src/android/res/xml/sharing_paths.xml | 11 + .../src/ios/NSString+SSURLEncoding.h | 5 + .../src/ios/NSString+SSURLEncoding.m | 30 ++ .../src/ios/NSString+URLEncoding.h | 5 - .../src/ios/NSString+URLEncoding.m | 30 -- .../src/ios/SocialSharing.m | 80 +++-- .../src/windows/SocialSharingProxy.js | 17 +- .../src/wp8/Newtonsoft.Json.dll | Bin 0 -> 374784 bytes .../tests/plugin.xml | 13 - .../cordova-plugin-x-socialsharing/tests/test.js | 363 --------------------- .../www/SocialSharing.js | 20 +- .../plugins/es6-promise-plugin/CHANGELOG.md | 9 + StoneIsland/plugins/es6-promise-plugin/LICENSE | 21 ++ StoneIsland/plugins/es6-promise-plugin/README.md | 36 ++ .../plugins/es6-promise-plugin/package.json | 51 +++ StoneIsland/plugins/es6-promise-plugin/plugin.xml | 27 ++ .../plugins/es6-promise-plugin/www/promise.js | 10 + StoneIsland/plugins/fetch.json | 24 +- StoneIsland/plugins/ios.json | 6 + 34 files changed, 463 insertions(+), 506 deletions(-) create mode 100644 StoneIsland/plugins/cordova-plugin-x-socialsharing/.npmignore create mode 100644 StoneIsland/plugins/cordova-plugin-x-socialsharing/.travis.yml create mode 100644 StoneIsland/plugins/cordova-plugin-x-socialsharing/LICENSE delete mode 100644 StoneIsland/plugins/cordova-plugin-x-socialsharing/MIT delete mode 100644 StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-android-share.png delete mode 100644 StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-ios6-share.png delete mode 100644 StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-ios7-ipad-share.png delete mode 100644 StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-ios7-share.png delete mode 100644 StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-wp8-share.jpg delete mode 100644 StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshots-ios7-shareconfig.png create mode 100644 StoneIsland/plugins/cordova-plugin-x-socialsharing/src/android/nl/xservices/plugins/FileProvider.java create mode 100644 StoneIsland/plugins/cordova-plugin-x-socialsharing/src/android/res/xml/sharing_paths.xml create mode 100644 StoneIsland/plugins/cordova-plugin-x-socialsharing/src/ios/NSString+SSURLEncoding.h create mode 100644 StoneIsland/plugins/cordova-plugin-x-socialsharing/src/ios/NSString+SSURLEncoding.m delete mode 100644 StoneIsland/plugins/cordova-plugin-x-socialsharing/src/ios/NSString+URLEncoding.h delete mode 100644 StoneIsland/plugins/cordova-plugin-x-socialsharing/src/ios/NSString+URLEncoding.m create mode 100755 StoneIsland/plugins/cordova-plugin-x-socialsharing/src/wp8/Newtonsoft.Json.dll delete mode 100644 StoneIsland/plugins/cordova-plugin-x-socialsharing/tests/plugin.xml delete mode 100644 StoneIsland/plugins/cordova-plugin-x-socialsharing/tests/test.js create mode 100644 StoneIsland/plugins/es6-promise-plugin/CHANGELOG.md create mode 100644 StoneIsland/plugins/es6-promise-plugin/LICENSE create mode 100644 StoneIsland/plugins/es6-promise-plugin/README.md create mode 100644 StoneIsland/plugins/es6-promise-plugin/package.json create mode 100644 StoneIsland/plugins/es6-promise-plugin/plugin.xml create mode 100644 StoneIsland/plugins/es6-promise-plugin/www/promise.js (limited to 'StoneIsland/plugins') diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/.npmignore b/StoneIsland/plugins/cordova-plugin-x-socialsharing/.npmignore new file mode 100644 index 00000000..b9691135 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-x-socialsharing/.npmignore @@ -0,0 +1,3 @@ +.idea +screenshots +tests \ No newline at end of file diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/.travis.yml b/StoneIsland/plugins/cordova-plugin-x-socialsharing/.travis.yml new file mode 100644 index 00000000..b9af4c58 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-x-socialsharing/.travis.yml @@ -0,0 +1,4 @@ +language: node_js +sudo: false +node_js: + - "4.2" diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/LICENSE b/StoneIsland/plugins/cordova-plugin-x-socialsharing/LICENSE new file mode 100644 index 00000000..7aa3caf0 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-x-socialsharing/LICENSE @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/MIT b/StoneIsland/plugins/cordova-plugin-x-socialsharing/MIT deleted file mode 100644 index f932f6d9..00000000 --- a/StoneIsland/plugins/cordova-plugin-x-socialsharing/MIT +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2014-2016 Eddy Verbruggen - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/README.md b/StoneIsland/plugins/cordova-plugin-x-socialsharing/README.md index 52e5515c..7ab40f21 100644 --- a/StoneIsland/plugins/cordova-plugin-x-socialsharing/README.md +++ b/StoneIsland/plugins/cordova-plugin-x-socialsharing/README.md @@ -205,14 +205,14 @@ Example: share a PDF file from the local www folder: ### Sharing directly to.. -####Twitter +#### Twitter ```html ``` -####Facebook +#### Facebook ```html ``` @@ -234,7 +234,7 @@ Whitelisting Facebook in your app's .plist: ``` -####Instagram +#### Instagram ```html ``` @@ -266,7 +266,7 @@ Don't pass in an image on iOS because that can't be sent to someone directly unf On Android pass in the phone number of the person you want to send a message to (untested at the moment). -####SMS +#### SMS Note that on Android, SMS via Hangouts may not behave correctly ```html @@ -277,7 +277,7 @@ Note that on Android, SMS via Hangouts may not behave correctly ``` -####Email +#### Email Code inspired by the [EmailComposer plugin](https://github.com/katzer/cordova-plugin-email-composer), note that this is not supported on the iOS 8 simulator (an alert will be shown if your try to). ```js window.plugins.socialsharing.shareViaEmail( @@ -419,6 +419,23 @@ Here's the list of available activities you can disable : - com.apple.UIKit.activity.AddToReadingList - com.apple.UIKit.activity.AirDrop +#### Web Share API + +Chrome is introducing a new [Web Share API](https://github.com/WICG/web-share) to share data. + +```js +navigator.share({ + 'title': 'Optional title', + 'text': 'Optional message', + 'url': 'http://www.myurl.com' +}).then(function() { + console.log('Successful share'); +}).catch(function(error) { + console.log('Error sharing:', error) +}); +``` + +It doesn't provide all the options that the other share methods do but it is spec compliant. ## 4b. Usage on Windows Phone The available methods on WP8 are: `available`, `canShareViaEmail`, `share`, `shareViaEmail` and `shareViaSMS`. @@ -496,7 +513,7 @@ This is a stright forward approach - you just manually edit the .plist file - ei There is a plugin designed specifically to address query schema whitelisting. You can find the plugin and how to use it [here](https://www.npmjs.com/package/cordova-plugin-queries-schemes). In general, after installation, you can change plugin.xml file under the plugin subfolder within the plugins directory of your project to add the required schemas. Here again though, you have to edit an additional file and should take care not to overwrite it when making changes to your project. ### Use Custom Config plugin -The Custom Config plugin ([here](https://github.com/dpa99c/cordova-custom-config)) allows you to add configuration to your platforms "native" configuration files (e.g. .plist or AndroidManifest.xml) through the project's main config.xml file. +The Custom Config plugin ([here](https://github.com/dpa99c/cordova-custom-config)) allows you to add configuration to your platforms "native" configuration files (e.g. .plist or AndroidManifest.xml) through the project's main config.xml file. To address query schema issue, after installaing the plugin you can edit the iOS platform section of your config.xml (in the project main folder) to include the required entries: @@ -506,11 +523,11 @@ To address query schema issue, after installaing the plugin you can edit the iOS version="0.9.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> - + - + - + diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/package.json b/StoneIsland/plugins/cordova-plugin-x-socialsharing/package.json index 62e6a1c0..b06fe392 100644 --- a/StoneIsland/plugins/cordova-plugin-x-socialsharing/package.json +++ b/StoneIsland/plugins/cordova-plugin-x-socialsharing/package.json @@ -1,19 +1,53 @@ { - "name": "cordova-plugin-x-socialsharing", - "version": "5.1.3", - "description": "Share text, images (and other files), or a link via the native sharing widget of your device. Android is fully supported, as well as iOS 6 and up. WP8 has somewhat limited support.", + "_from": "cordova-plugin-x-socialsharing@~5.1.3", + "_id": "cordova-plugin-x-socialsharing@5.1.8", + "_inBundle": false, + "_integrity": "sha1-Q5odL0c2YnYogm5Rla5Tm1TmJIo=", + "_location": "/cordova-plugin-x-socialsharing", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "cordova-plugin-x-socialsharing@~5.1.3", + "name": "cordova-plugin-x-socialsharing", + "escapedName": "cordova-plugin-x-socialsharing", + "rawSpec": "~5.1.3", + "saveSpec": null, + "fetchSpec": "~5.1.3" + }, + "_requiredBy": [ + "/" + ], + "_resolved": "https://registry.npmjs.org/cordova-plugin-x-socialsharing/-/cordova-plugin-x-socialsharing-5.1.8.tgz", + "_shasum": "439a1d2f4736627628826e5195ae539b54e6248a", + "_spec": "cordova-plugin-x-socialsharing@~5.1.3", + "_where": "/Users/user/Sites/stone-island/StoneIsland", + "author": { + "name": "Eddy Verbruggen - @EddyVerbruggen" + }, + "bugs": { + "url": "https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin/issues" + }, + "bundleDependencies": false, "cordova": { "id": "cordova-plugin-x-socialsharing", "platforms": [ "ios", "android", - "wp8" + "wp8", + "windows", + "web" ] }, - "repository": { - "type": "git", - "url": "git+https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin.git" - }, + "deprecated": false, + "description": "Share text, images (and other files), or a link via the native sharing widget of your device. Android is fully supported, as well as iOS 6 and up. WP8 has somewhat limited support.", + "engines": [ + { + "name": "cordova", + "version": ">=3.0.0" + } + ], + "homepage": "https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin#readme", "keywords": [ "Social", "Share", @@ -26,21 +60,17 @@ "Pocket", "LinkedIn", "cordova", + "WebShare", "ecosystem:cordova", "cordova-ios", "cordova-android", "cordova-windows" ], - "engines": [ - { - "name": "cordova", - "version": ">=3.0.0" - } - ], - "author": "Eddy Verbruggen - @EddyVerbruggen", "license": "MIT", - "bugs": { - "url": "https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin/issues" + "name": "cordova-plugin-x-socialsharing", + "repository": { + "type": "git", + "url": "git+https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin.git" }, - "homepage": "https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin#readme" + "version": "5.1.8" } diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/plugin.xml b/StoneIsland/plugins/cordova-plugin-x-socialsharing/plugin.xml index 0a367427..cb4bf8bf 100755 --- a/StoneIsland/plugins/cordova-plugin-x-socialsharing/plugin.xml +++ b/StoneIsland/plugins/cordova-plugin-x-socialsharing/plugin.xml @@ -2,7 +2,7 @@ + version="5.1.8"> SocialSharing @@ -25,6 +25,8 @@ + + @@ -39,8 +41,8 @@ - - + + @@ -61,7 +63,17 @@ + + + + + + + + + + @@ -75,11 +87,11 @@ - + - + diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-android-share.png b/StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-android-share.png deleted file mode 100644 index f3ab135f..00000000 Binary files a/StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-android-share.png and /dev/null differ diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-ios6-share.png b/StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-ios6-share.png deleted file mode 100644 index 63b0b4c5..00000000 Binary files a/StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-ios6-share.png and /dev/null differ diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-ios7-ipad-share.png b/StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-ios7-ipad-share.png deleted file mode 100644 index 640c94f8..00000000 Binary files a/StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-ios7-ipad-share.png and /dev/null differ diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-ios7-share.png b/StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-ios7-share.png deleted file mode 100644 index 7545d10d..00000000 Binary files a/StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-ios7-share.png and /dev/null differ diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-wp8-share.jpg b/StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-wp8-share.jpg deleted file mode 100644 index 0ced2eb5..00000000 Binary files a/StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-wp8-share.jpg and /dev/null differ diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshots-ios7-shareconfig.png b/StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshots-ios7-shareconfig.png deleted file mode 100644 index 3afe5fef..00000000 Binary files a/StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshots-ios7-shareconfig.png and /dev/null differ diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/android/nl/xservices/plugins/FileProvider.java b/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/android/nl/xservices/plugins/FileProvider.java new file mode 100644 index 00000000..ef862604 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/android/nl/xservices/plugins/FileProvider.java @@ -0,0 +1,5 @@ +package nl.xservices.plugins; + + +public class FileProvider extends android.support.v4.content.FileProvider { +} \ No newline at end of file diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/android/nl/xservices/plugins/SocialSharing.java b/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/android/nl/xservices/plugins/SocialSharing.java index 8de31da8..faa96ced 100644 --- a/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/android/nl/xservices/plugins/SocialSharing.java +++ b/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/android/nl/xservices/plugins/SocialSharing.java @@ -34,6 +34,8 @@ import java.util.TimerTask; import java.util.regex.Matcher; import java.util.regex.Pattern; +import nl.xservices.plugins.FileProvider; + public class SocialSharing extends CordovaPlugin { private static final String ACTION_AVAILABLE_EVENT = "available"; @@ -81,10 +83,10 @@ public class SocialSharing extends CordovaPlugin { } else if (ACTION_SHARE_VIA_TWITTER_EVENT.equals(action)) { return doSendIntent(callbackContext, args.getString(0), args.getString(1), args.getJSONArray(2), args.getString(3), "twitter", null, false, true); } else if (ACTION_SHARE_VIA_FACEBOOK_EVENT.equals(action)) { - return doSendIntent(callbackContext, args.getString(0), args.getString(1), args.getJSONArray(2), args.getString(3), "com.facebook.katana", null, false, true); + return doSendIntent(callbackContext, args.getString(0), args.getString(1), args.getJSONArray(2), args.getString(3), "com.facebook.katana", null, false, true, "com.facebook.composer.shareintent"); } else if (ACTION_SHARE_VIA_FACEBOOK_WITH_PASTEMESSAGEHINT.equals(action)) { this.pasteMessage = args.getString(4); - return doSendIntent(callbackContext, args.getString(0), args.getString(1), args.getJSONArray(2), args.getString(3), "com.facebook.katana", null, false, true); + return doSendIntent(callbackContext, args.getString(0), args.getString(1), args.getJSONArray(2), args.getString(3), "com.facebook.katana", null, false, true, "com.facebook.composer.shareintent"); } else if (ACTION_SHARE_VIA_WHATSAPP_EVENT.equals(action)) { if (notEmpty(args.getString(4))) { return shareViaWhatsAppDirectly(callbackContext, args.getString(0), args.getString(1), args.getJSONArray(2), args.getString(3), args.getString(4)); @@ -169,6 +171,7 @@ public class SocialSharing extends CordovaPlugin { } } catch (Exception e) { callbackContext.error(e.getMessage()); + return; } // this was added to start the intent in a new window as suggested in #300 to prevent crashes upon return @@ -214,6 +217,19 @@ public class SocialSharing extends CordovaPlugin { ); } + private boolean doSendIntent( + final CallbackContext callbackContext, + final String msg, + final String subject, + final JSONArray files, + final String url, + final String appPackageName, + final String chooserTitle, + final boolean peek, + final boolean boolResult) { + return doSendIntent(callbackContext, msg, subject, files, url, appPackageName, chooserTitle, peek, boolResult, null); + } + private boolean doSendIntent( final CallbackContext callbackContext, final String msg, @@ -223,7 +239,8 @@ public class SocialSharing extends CordovaPlugin { final String appPackageName, final String chooserTitle, final boolean peek, - final boolean boolResult) { + final boolean boolResult, + final String appName) { final CordovaInterface mycordova = cordova; final CordovaPlugin plugin = this; @@ -243,6 +260,7 @@ public class SocialSharing extends CordovaPlugin { Uri fileUri = null; for (int i = 0; i < files.length(); i++) { fileUri = getFileUriAndSetType(sendIntent, dir, files.getString(i), subject, i); + fileUri = FileProvider.getUriForFile(webView.getContext(), cordova.getActivity().getPackageName()+".sharing.provider", new File(fileUri.getPath())); if (fileUri != null) { fileUris.add(fileUri); } @@ -295,7 +313,7 @@ public class SocialSharing extends CordovaPlugin { packageName = items[0]; passedActivityName = items[1]; } - final ActivityInfo activity = getActivity(callbackContext, sendIntent, packageName); + final ActivityInfo activity = getActivity(callbackContext, sendIntent, packageName, appName); if (activity != null) { if (peek) { callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK)); @@ -369,6 +387,8 @@ public class SocialSharing extends CordovaPlugin { String localImage = image; if (image.endsWith("mp4") || image.endsWith("mov") || image.endsWith("3gp")){ sendIntent.setType("video/*"); + } else if (image.endsWith("mp3")) { + sendIntent.setType("audio/x-mpeg"); } else { sendIntent.setType("image/*"); } @@ -432,7 +452,7 @@ public class SocialSharing extends CordovaPlugin { final String encodedImg = image.substring(image.indexOf(";base64,") + 8); sendIntent.setType(fileType); saveFile(Base64.decode(encodedImg, Base64.DEFAULT), dir, sanitizeFilename(fileName)); - localImage = "file://" + dir + "/" + fileName; + localImage = "file://" + dir + "/" + sanitizeFilename(fileName); } else if (!image.startsWith("file://")) { throw new IllegalArgumentException("URL_NOT_SUPPORTED"); } else { @@ -649,12 +669,14 @@ public class SocialSharing extends CordovaPlugin { return null; } - private ActivityInfo getActivity(final CallbackContext callbackContext, final Intent shareIntent, final String appPackageName) { + private ActivityInfo getActivity(final CallbackContext callbackContext, final Intent shareIntent, final String appPackageName, final String appName) { final PackageManager pm = webView.getContext().getPackageManager(); List activityList = pm.queryIntentActivities(shareIntent, 0); for (final ResolveInfo app : activityList) { if ((app.activityInfo.packageName).contains(appPackageName)) { - return app.activityInfo; + if (appName == null || (app.activityInfo.name).contains(appName)) { + return app.activityInfo; + } } } // no matching app found diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/android/res/xml/sharing_paths.xml b/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/android/res/xml/sharing_paths.xml new file mode 100644 index 00000000..278084a2 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/android/res/xml/sharing_paths.xml @@ -0,0 +1,11 @@ + + + + + + + \ No newline at end of file diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/ios/NSString+SSURLEncoding.h b/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/ios/NSString+SSURLEncoding.h new file mode 100644 index 00000000..71447b60 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/ios/NSString+SSURLEncoding.h @@ -0,0 +1,5 @@ +#import + +@interface NSString (SSURLEncoding) +@property (readonly) NSString *URLEncodedString; +@end diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/ios/NSString+SSURLEncoding.m b/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/ios/NSString+SSURLEncoding.m new file mode 100644 index 00000000..c8e746d3 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/ios/NSString+SSURLEncoding.m @@ -0,0 +1,30 @@ +#import "NSString+SSURLEncoding.h" + +@implementation NSString (SSURLEncoding) +- (NSString*)URLEncodedString +{ + NSString* result = (NSString *)CFBridgingRelease( + CFURLCreateStringByAddingPercentEscapes( + kCFAllocatorDefault, + (CFStringRef)self, + CFSTR("#%"), // don't escape these + NULL, // allow escaping these + kCFStringEncodingUTF8 + ) + ); + + // we may have a URL with more than one '#' now - which iOS doesn't allow, so escape all but the first one + NSArray *parts = [result componentsSeparatedByString:@"#"]; + NSString *finalResult = parts[0]; + for (int i=1; i - -@interface NSString (URLEncoding) -@property (readonly) NSString *URLEncodedString; -@end diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/ios/NSString+URLEncoding.m b/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/ios/NSString+URLEncoding.m deleted file mode 100644 index b737626c..00000000 --- a/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/ios/NSString+URLEncoding.m +++ /dev/null @@ -1,30 +0,0 @@ -#import "NSString+URLEncoding.h" - -@implementation NSString (URLEncoding) -- (NSString*)URLEncodedString -{ - NSString* result = (NSString *)CFBridgingRelease( - CFURLCreateStringByAddingPercentEscapes( - kCFAllocatorDefault, - (CFStringRef)self, - CFSTR("#%"), // don't escape these - NULL, // allow escaping these - kCFStringEncodingUTF8 - ) - ); - - // we may have a URL with more than one '#' now - which iOS doesn't allow, so escape all but the first one - NSArray *parts = [result componentsSeparatedByString:@"#"]; - NSString *finalResult = parts[0]; - for (int i=1; i #import #import @@ -137,7 +137,7 @@ static NSString *const kShareOptionUrl = @"url"; #pragma GCC diagnostic ignored "-Wdeprecated-declarations" [activityVC setCompletionHandler:^(NSString *activityType, BOOL completed) { [self cleanupStoredFiles]; - NSDictionary * result = @{@"completed":@(completed), @"app":activityType}; + NSDictionary * result = @{@"completed":@(completed), @"app":activityType == nil ? @"" : activityType}; CDVPluginResult * pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:result]; [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; }]; @@ -361,21 +361,43 @@ static NSString *const kShareOptionUrl = @"url"; NSURL *file = [self getFile:path]; NSData* data = [fileManager contentsAtPath:file.path]; + if (!data) { + CDVPluginResult * pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"invalid attachment"]; + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; + return; + } + NSString* fileName; NSString* mimeType; NSString* basename = [self getBasenameFromAttachmentPath:path]; - if ([basename hasPrefix:@"data:"]) { - mimeType = (NSString*)[[[basename substringFromIndex:5] componentsSeparatedByString: @";"] objectAtIndex:0]; - fileName = @"attachment."; - fileName = [fileName stringByAppendingString:(NSString*)[[mimeType componentsSeparatedByString: @"/"] lastObject]]; - NSString *base64content = (NSString*)[[basename componentsSeparatedByString: @","] lastObject]; - data = [SocialSharing dataFromBase64String:base64content]; - } else { - fileName = [basename pathComponents].lastObject; - mimeType = [self getMimeTypeFromFileExtension:[basename pathExtension]]; - } - [self.globalMailComposer addAttachmentData:data mimeType:mimeType fileName:fileName]; + //Find data anywhere in string + NSRange rangeData = [basename rangeOfString:@"data:"]; + if (rangeData.location == NSNotFound) + { + fileName = [basename pathComponents].lastObject; + mimeType = [self getMimeTypeFromFileExtension:[basename pathExtension]]; + } + else + { + mimeType = (NSString*)[[[basename substringFromIndex:rangeData.location+rangeData.length] componentsSeparatedByString: @";"] objectAtIndex:0]; + + //Find df anywhere in string + NSRange rangeDF = [basename rangeOfString:@"df:"]; + //If not found fallback to default name + if (rangeDF.location == NSNotFound) { + fileName = @"attachment."; + fileName = [fileName stringByAppendingString:(NSString*)[[mimeType componentsSeparatedByString: @"/"] lastObject]]; + } else { + //Found, apply name + fileName = (NSString*)[[[basename substringFromIndex:rangeDF.location+rangeDF.length] componentsSeparatedByString: @";"] objectAtIndex:0]; + } + + + NSString *base64content = (NSString*)[[basename componentsSeparatedByString: @","] lastObject]; + data = [SocialSharing dataFromBase64String:base64content]; + } + [self.globalMailComposer addAttachmentData:data mimeType:mimeType fileName:fileName]; } } @@ -479,7 +501,7 @@ static NSString *const kShareOptionUrl = @"url"; _command = command; [self.commandDelegate runInBackground:^{ picker.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; - [[self getTopMostViewController] presentViewController:picker animated:YES completion:nil]; + [[self getTopMostViewController] presentViewController:picker animated:NO completion:nil]; }]; } else { CDVPluginResult * pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"not available"]; @@ -694,6 +716,7 @@ static NSString *const kShareOptionUrl = @"url"; -(NSURL*)getFile: (NSString *)fileName { NSURL *file = nil; if (fileName != (id)[NSNull null]) { + NSRange rangeData = [fileName rangeOfString:@"data:"]; if ([fileName hasPrefix:@"http"]) { NSURL *url = [NSURL URLWithString:fileName]; NSData *fileData = [NSData dataWithContentsOfURL:url]; @@ -706,14 +729,27 @@ static NSString *const kShareOptionUrl = @"url"; } else if ([fileName hasPrefix:@"file://"]) { // stripping the first 6 chars, because the path should start with / instead of file:// file = [NSURL fileURLWithPath:[fileName substringFromIndex:6]]; - } else if ([fileName hasPrefix:@"data:"]) { - // using a base64 encoded string - // extract some info from the 'fileName', which is for example: data:text/calendar;base64, - NSString *fileType = (NSString*)[[[fileName substringFromIndex:5] componentsSeparatedByString: @";"] objectAtIndex:0]; - fileType = (NSString*)[[fileType componentsSeparatedByString: @"/"] lastObject]; - NSString *base64content = (NSString*)[[fileName componentsSeparatedByString: @","] lastObject]; - NSData *fileData = [SocialSharing dataFromBase64String:base64content]; - file = [NSURL fileURLWithPath:[self storeInFile:[NSString stringWithFormat:@"%@.%@", @"file", fileType] fileData:fileData]]; + } else if (rangeData.location != NSNotFound ){ + //If found "data:" + NSString *fileType = (NSString*)[[[fileName substringFromIndex:rangeData.location+rangeData.length] componentsSeparatedByString: @";"] objectAtIndex:0]; + + NSString* attachmentName; + //Find df anywhere in string + NSRange rangeDF = [fileName rangeOfString:@"df:"]; + //If not found fallback to default name + if (rangeDF.location == NSNotFound) { + attachmentName = @"attachment."; + attachmentName = [attachmentName stringByAppendingString:(NSString*)[[fileType componentsSeparatedByString: @"/"] lastObject]]; + } else { + //Found, apply name + attachmentName = (NSString*)[[[fileName substringFromIndex:rangeDF.location+rangeDF.length] componentsSeparatedByString: @";"] objectAtIndex:0]; + } + + + NSString *base64content = (NSString*)[[fileName componentsSeparatedByString: @","] lastObject]; + NSData* data = [SocialSharing dataFromBase64String:base64content]; + file = [NSURL fileURLWithPath:[self storeInFile:attachmentName fileData:data]]; + } else { // assume anywhere else, on the local filesystem file = [NSURL fileURLWithPath:fileName]; diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/windows/SocialSharingProxy.js b/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/windows/SocialSharingProxy.js index ff257d52..b52fa12f 100644 --- a/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/windows/SocialSharingProxy.js +++ b/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/windows/SocialSharingProxy.js @@ -1,4 +1,4 @@ -var cordova = require('cordova'); +var cordova = require('cordova'); module.exports = { share: function (win, fail, args) { @@ -10,7 +10,7 @@ module.exports = { var fileOrFileArray = args[2]; //Web link var url = args[3]; - + var folder = Windows.Storage.ApplicationData.current.temporaryFolder; var getExtension = function (strBase64) { @@ -49,7 +49,7 @@ module.exports = { var deferral = e.request.getDeferral(); var storageItems = []; var filesCount = fileOrFileArray.length; - + var completeFile = function () { if (!--filesCount) { storageItems.length && e.request.data.setStorageItems(storageItems); @@ -60,7 +60,7 @@ module.exports = { for (var i = 0; i < fileOrFileArray.length; i++) { var file = fileOrFileArray[i]; - if (file.indexOf("data:") >= 0) { + if (file.indexOf("data:") >= 0) { var fileName = getFileName(i, getExtension(file)); var buffer = Windows.Security.Cryptography.CryptographicBuffer.decodeFromBase64String(file.split(',')[1]); if (buffer) { @@ -162,6 +162,15 @@ module.exports = { } catch (err) { fail(err); } + }, + + shareViaSMS: function (win, fail, args) { + var chatMessage = new Windows.ApplicationModel.Chat.ChatMessage(); + chatMessage.body = args[0].message; + if (!!args[1]) { + chatMessage.recipients.push(args[1]); + } + Windows.ApplicationModel.Chat.ChatMessageManager.showComposeSmsMessageAsync(chatMessage).done(win, fail); } }; diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/wp8/Newtonsoft.Json.dll b/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/wp8/Newtonsoft.Json.dll new file mode 100755 index 00000000..b8194284 Binary files /dev/null and b/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/wp8/Newtonsoft.Json.dll differ diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/tests/plugin.xml b/StoneIsland/plugins/cordova-plugin-x-socialsharing/tests/plugin.xml deleted file mode 100644 index 1ccb2217..00000000 --- a/StoneIsland/plugins/cordova-plugin-x-socialsharing/tests/plugin.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - SocialSharing Tests - Nicolas Oliver - MIT - - - \ No newline at end of file diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/tests/test.js b/StoneIsland/plugins/cordova-plugin-x-socialsharing/tests/test.js deleted file mode 100644 index ad1a8229..00000000 --- a/StoneIsland/plugins/cordova-plugin-x-socialsharing/tests/test.js +++ /dev/null @@ -1,363 +0,0 @@ -/** - * Jasmine Based test suites - * - * Several of SocialSharing APIs cannot be automatically tested, because - * they depend on user interaction in order to call success or fail - * handlers. For most of them, there is a basic test that assert the presence of - * the API. - * - * There are some cases that test automation can be applied, i.e in "canShareVia", - * "canShareViaEmail" and "available" methods. For those cases, there is some level - * of automatic test coverage. - */ -exports.defineAutoTests = function () { - 'use strict'; - - describe('socialsharing', function () { - it('should be defined', function () { - expect(window.plugins.socialsharing).toBeDefined(); - }); - - describe('share', function () { - it('should be defined', function () { - expect(window.plugins.socialsharing.share).toBeDefined(); - }); - - it('should be a function', function () { - expect(typeof window.plugins.socialsharing.share).toEqual('function'); - }); - }); - - describe('shareVia', function () { - it('should be defined', function () { - expect(window.plugins.socialsharing.shareVia).toBeDefined(); - }); - - it('should be a function', function () { - expect(typeof window.plugins.socialsharing.shareVia).toEqual('function'); - }); - }); - - describe('shareViaTwitter', function () { - it('should be defined', function () { - expect(window.plugins.socialsharing.shareViaTwitter).toBeDefined(); - }); - - it('should be a function', function () { - expect(typeof window.plugins.socialsharing.shareViaTwitter).toEqual('function'); - }); - }); - - describe('shareViaFacebook', function () { - it('should be defined', function () { - expect(window.plugins.socialsharing.shareViaFacebook).toBeDefined(); - }); - - it('should be a function', function () { - expect(typeof window.plugins.socialsharing.shareViaFacebook).toEqual('function'); - }); - }); - - describe('shareViaFacebookWithPasteMessageHint', function () { - it('should be defined', function () { - expect(window.plugins.socialsharing.shareViaFacebookWithPasteMessageHint).toBeDefined(); - }); - - it('should be a function', function () { - expect(typeof window.plugins.socialsharing.shareViaFacebookWithPasteMessageHint).toEqual('function'); - }); - }); - - describe('shareViaWhatsApp', function () { - it('should be defined', function () { - expect(window.plugins.socialsharing.shareViaWhatsApp).toBeDefined(); - }); - - it('should be a function', function () { - expect(typeof window.plugins.socialsharing.shareViaWhatsApp).toEqual('function'); - }); - }); - - describe('shareViaSMS', function () { - it('should be defined', function () { - expect(window.plugins.socialsharing.shareViaSMS).toBeDefined(); - }); - - it('should be a function', function () { - expect(typeof window.plugins.socialsharing.shareViaSMS).toEqual('function'); - }); - }); - - describe('shareViaEmail', function () { - it('should be defined', function () { - expect(window.plugins.socialsharing.shareViaEmail).toBeDefined(); - }); - - it('should be a function', function () { - expect(typeof window.plugins.socialsharing.shareViaEmail).toEqual('function'); - }); - }); - - describe('canShareVia', function () { - it('should be defined', function () { - expect(window.plugins.socialsharing.canShareVia).toBeDefined(); - }); - - it('should be a function', function () { - expect(typeof window.plugins.socialsharing.canShareVia).toEqual('function'); - }); - - it('should always call callback or error function', function (done) { - function onSuccess(data){ - expect(data).not.toEqual(null); - done(); - } - - function onError(error){ - expect(error).not.toEqual(null); - done(); - } - - window.plugins.socialsharing.canShareVia('dummytarget','dummymessage', null, null, null, onSuccess, onError); - }); - }); - - describe('canshareViaEmail', function(){ - it('should be defined', function () { - expect(window.plugins.socialsharing.canShareViaEmail).toBeDefined(); - }); - - it('should be a function', function () { - expect(typeof window.plugins.socialsharing.canShareViaEmail).toEqual('function'); - }); - - it('should always call callback or error function', function (done) { - function onSuccess(data){ - expect(data).not.toEqual(null); - done(); - } - - function onError(error){ - expect(error).not.toEqual(null); - done(); - } - - window.plugins.socialsharing.canShareViaEmail(onSuccess, onError); - }); - }); - - describe('availabe', function(){ - it('should be defined', function () { - expect(window.plugins.socialsharing.available).toBeDefined(); - }); - - it('should be a function', function () { - expect(typeof window.plugins.socialsharing.available).toEqual('function'); - }); - - it('should return a boolean when called', function(done){ - window.plugins.socialsharing.available(function(isAvailable) { - expect(typeof isAvailable).toEqual('boolean'); - done(); - }); - }); - }); - }); -}; - -/** - * Manual tests suites - * - * Some actions buttons to execute SocialSharing plugin methods - */ -exports.defineManualTests = function (contentEl, createActionButton) { - 'use strict'; - - /** helper function to log messages in the log div element */ - function logMessage(message, color) { - var log = document.getElementById('info'), - logLine = document.createElement('div'); - - if (color) { - logLine.style.color = color; - } - - logLine.innerHTML = message; - log.appendChild(logLine); - } - - /** helper function to clear the log div element */ - function clearLog() { - var log = document.getElementById('info'); - log.innerHTML = ''; - } - - /** helper function to declare a not implemented test */ - function testNotImplemented(testName) { - return function () { - console.error(testName, 'test not implemented'); - }; - } - - /** init method called on deviceready event */ - function init() {} - - /** object to hold properties and configs */ - var TestSuite = {}; - - TestSuite.getCanShareViaTarget = function(){ - return document.getElementById('inputCanShareVia').value; - }; - - TestSuite.$markup = '' + - '
' + - 'Available Tests' + - - '

Available

' + - '
' + - 'Expected result: Should log if the plugin is available or not' + - '
' + - - '
' + - 'Share Tests' + - - '

Share Message

' + - '
' + - 'Expected result: Should display share widget, and the message to share should contain "Message body"' + - - '

Share Message with Subject

' + - '
' + - 'Expected result: Should display share widget, and the message to share should contain "Message body", and the subject should be "Message subject"' + - - '

Share Link

' + - '' + - 'Expected result: Should display share widget, and the message to share should contain "http://www.x-services.nl"' + - - '

Share Message with Link

' + - '' + - 'Expected result: Should display share widget, and the message to share should contain "Message body http://www.x-services.nl"' + - - '

Share Image

' + - '
' + - 'Expected result: Should display share widget, and the message to share should contain an image' + - - '

Share Image in base 64

' + - '
' + - 'Expected result: Should display share widget, and the message to share should contain an image. The image is encoded in base 64' + - - '

Share Image with Message

' + - '
' + - 'Expected result: Should display share widget, and the message to share should contain "Message body" and an image' + - - '

Share Image with Message and Link

' + - '' + - 'Expected result: Should display share widget, and the message to share should contain "Message body http://www.x-services.nl" and an image' + - - '

Share Image with Message, Subject and Link

' + - '' + - 'Expected result: Should display share widget, and the message to share should contain "Message body http://www.x-services.nl", "Message subject" as subject, and an image' + - '
' + - - '
' + - 'Can Share Tests' + - - 'Target:
' + - - '

Can Share via

' + - '
' + - 'Expected result: should log OK if can share, or should log a list of available share targets' + - - '

Can Share via Email

' + - '
' + - 'Expected result: should log OK if can share' + - '
' + - ''; - - contentEl.innerHTML = '
' + TestSuite.$markup; - - createActionButton('availabe', function () { - clearLog(); - window.plugins.socialsharing.available(function(isAvailable) { - var message = 'is this plugin available? '; - message += isAvailable? 'Yes' : 'No'; - - logMessage(message, isAvailable? 'green' : 'red'); - }); - }, 'buttonIsAvailable'); - - createActionButton('share message', function () { - window.plugins.socialsharing.share('Message body'); - }, 'buttonShareMessage'); - - createActionButton('share message and subject', function () { - window.plugins.socialsharing.share('Message body', 'Message subject'); - }, 'buttonShareMessageWithSubject'); - - createActionButton('share link', function () { - window.plugins.socialsharing.share(null, null, null, 'http://www.x-services.nl'); - }, 'buttonShareLink'); - - createActionButton('share message and link', function () { - window.plugins.socialsharing.share('Message body', null, null, 'http://www.x-services.nl'); - }, 'buttonShareMessageAndLink'); - - createActionButton('share image', function () { - window.plugins.socialsharing.share(null, null, 'https://www.google.nl/images/srpr/logo4w.png', null); - }, 'buttonShareImage'); - - createActionButton('share image base 64', function () { - window.plugins.socialsharing.share(null, 'Android filename', 'data:image/png;base64,R0lGODlhDAAMALMBAP8AAP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAUKAAEALAAAAAAMAAwAQAQZMMhJK7iY4p3nlZ8XgmNlnibXdVqolmhcRQA7', null); - }, 'buttonShareImageBase64'); - - createActionButton('share message with image', function () { - window.plugins.socialsharing.share('Message body', null, 'https://www.google.nl/images/srpr/logo4w.png', null); - }, 'buttonShareMessageImage'); - - createActionButton('share message, image, and link', function () { - window.plugins.socialsharing.share('Message body', null, 'https://www.google.nl/images/srpr/logo4w.png', 'http://www.x-services.nl'); - }, 'buttonShareMessageImageLink'); - - createActionButton('share message, subject, image, and link', function () { - window.plugins.socialsharing.share('Message body', 'Message subject', 'https://www.google.nl/images/srpr/logo4w.png', 'http://www.x-services.nl'); - }, 'buttonShareMessageSubjectImageLink'); - - createActionButton('can share via', function () { - var target = TestSuite.getCanShareViaTarget(); - - if(!target){ - console.error('must have a canShareVia target'); - } - else { - clearLog(); - window.plugins.socialsharing.canShareVia(target, 'msg', null, null, null, function(e){ - console.log('canShareVia success, see log for more information'); - logMessage('canShareVia: ' + e,'green'); - }, function(e){ - console.error('canShareVia fail, see log for more information'); - var message = "Share targets
"; - - message += "
    "; - - e.forEach(function(target){ - message += "
  • " + target + "
  • "; - }); - - message += "
"; - logMessage(message,'red'); - }); - } - }, 'buttonCanShareVia'); - - createActionButton('can share via email', function () { - clearLog(); - window.plugins.socialsharing.canShareViaEmail(function(e){ - console.log('canShareViaEmail success, see log for more information'); - logMessage('canShareViaEmail: ' + e,'green'); - }, function(e){ - console.error('canShareViaEmail fail, see log for more information'); - logMessage('canShareViaEmail: ' + e,'red'); - }); - }, 'buttonCanShareViaEmail'); - - document.addEventListener('deviceready', init, false); -}; diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/www/SocialSharing.js b/StoneIsland/plugins/cordova-plugin-x-socialsharing/www/SocialSharing.js index 3fc9bb92..eea2a762 100644 --- a/StoneIsland/plugins/cordova-plugin-x-socialsharing/www/SocialSharing.js +++ b/StoneIsland/plugins/cordova-plugin-x-socialsharing/www/SocialSharing.js @@ -28,6 +28,23 @@ SocialSharing.prototype.shareWithOptions = function (options, successCallback, e cordova.exec(successCallback, this._getErrorCallback(errorCallback, "shareWithOptions"), "SocialSharing", "shareWithOptions", [options]); }; +SocialSharing.prototype.shareW3C = function (sharedata) { + return new Promise(function(resolve, reject) { + var options = { + subject: sharedata.title, + message: sharedata.text, + url: sharedata.url + }; + if(sharedata.hasOwnProperty('title') || + sharedata.hasOwnProperty('text') || + sharedata.hasOwnProperty('url')) { + cordova.exec(resolve, reject, "SocialSharing", "shareWithOptions", [options]); + } else { + reject(); + } + }); +}; + SocialSharing.prototype.share = function (message, subject, fileOrFileArray, url, successCallback, errorCallback) { cordova.exec(successCallback, this._getErrorCallback(errorCallback, "share"), "SocialSharing", "share", [message, subject, this._asArray(fileOrFileArray), url]); }; @@ -116,7 +133,8 @@ SocialSharing.install = function () { } window.plugins.socialsharing = new SocialSharing(); + navigator.share = window.plugins.socialsharing.shareW3C; return window.plugins.socialsharing; }; -cordova.addConstructor(SocialSharing.install); \ No newline at end of file +cordova.addConstructor(SocialSharing.install); diff --git a/StoneIsland/plugins/es6-promise-plugin/CHANGELOG.md b/StoneIsland/plugins/es6-promise-plugin/CHANGELOG.md new file mode 100644 index 00000000..231dd35a --- /dev/null +++ b/StoneIsland/plugins/es6-promise-plugin/CHANGELOG.md @@ -0,0 +1,9 @@ +# 4.2.2 / 2017-12-27 + +* updated to es6-promise 4.2.2 +* added browser platform support + +# 4.1.1 / 2017-09-12 + +* updated to es6-promise 4.1.1 +* updated build script diff --git a/StoneIsland/plugins/es6-promise-plugin/LICENSE b/StoneIsland/plugins/es6-promise-plugin/LICENSE new file mode 100644 index 00000000..8a4d435c --- /dev/null +++ b/StoneIsland/plugins/es6-promise-plugin/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014-15 Vlad Stirbu + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/StoneIsland/plugins/es6-promise-plugin/README.md b/StoneIsland/plugins/es6-promise-plugin/README.md new file mode 100644 index 00000000..e8cb30f9 --- /dev/null +++ b/StoneIsland/plugins/es6-promise-plugin/README.md @@ -0,0 +1,36 @@ +# PromisesPlugin + +ES6-Promises polyfill for Cordova/PhoneGap + +# Motivation + +The web view components on Cordova supported platforms lack suport for ES6 Promise. A polyfill library bundled with the plugin fixes the limitation. However, as more plugin use promises, the application developer using these plugins will end up with multiple promise polyfill libraries. + +This plugin attempts to fix this situation by providing a Promise polyfill so that other plugins can rely on this functionality. + +# How to use + +Configure your plugin's plugin.xml by adding this dependency: + +``` + +``` + +Cordova CLI takes care to install PromisesPlugin automatically: + +``` +$ cordova plugins add {yourPlugin} + +> Installing "{yourPlugin}" for {platform} +> Installing "es6-promise-plugin" for {platform} +``` + +This is all. ```window.Promise``` is available for use in your plugin. + +# Credits + +This plugin wraps [es6-promise](https://github.com/jakearchibald/es6-promise) in a Cordova/PhoneGap friendly way. + +# License + +The plugin is available under MIT license. diff --git a/StoneIsland/plugins/es6-promise-plugin/package.json b/StoneIsland/plugins/es6-promise-plugin/package.json new file mode 100644 index 00000000..44d89413 --- /dev/null +++ b/StoneIsland/plugins/es6-promise-plugin/package.json @@ -0,0 +1,51 @@ +{ + "_from": "es6-promise-plugin", + "_id": "es6-promise-plugin@4.2.2", + "_inBundle": false, + "_integrity": "sha512-uoA4aVplXI9oqUYJFBAVRwAqIN9/n9JgrTAUGX3qPbnSZVE5yY1+6/MsoN5f4xsaPO62WjPHOdtts6okMN6tNA==", + "_location": "/es6-promise-plugin", + "_phantomChildren": {}, + "_requested": { + "type": "tag", + "registry": true, + "raw": "es6-promise-plugin", + "name": "es6-promise-plugin", + "escapedName": "es6-promise-plugin", + "rawSpec": "", + "saveSpec": null, + "fetchSpec": "latest" + }, + "_requiredBy": [ + "#DEV:/", + "#USER" + ], + "_resolved": "https://registry.npmjs.org/es6-promise-plugin/-/es6-promise-plugin-4.2.2.tgz", + "_shasum": "cfa0cc1383d91f999a62a2bbf4bd97bec305e0ac", + "_spec": "es6-promise-plugin", + "_where": "/Users/user/work/stone-island/StoneIsland", + "author": "", + "bugs": { + "url": "https://github.com/vstirbu/PromisesPlugin/issues" + }, + "bundleDependencies": false, + "dependencies": {}, + "deprecated": false, + "description": "ES6-Promises polyfill for Cordova/PhoneGap", + "devDependencies": { + "browserify": "^14.4.0", + "es6-promise": "^4.2.2" + }, + "ecosystem": "cordova", + "homepage": "https://github.com/vstirbu/PromisesPlugin#readme", + "license": "MIT", + "main": "www/promise.js", + "name": "es6-promise-plugin", + "repository": { + "type": "git", + "url": "git+https://github.com/vstirbu/PromisesPlugin.git" + }, + "scripts": { + "build": "./build" + }, + "version": "4.2.2" +} diff --git a/StoneIsland/plugins/es6-promise-plugin/plugin.xml b/StoneIsland/plugins/es6-promise-plugin/plugin.xml new file mode 100644 index 00000000..ee32c3ca --- /dev/null +++ b/StoneIsland/plugins/es6-promise-plugin/plugin.xml @@ -0,0 +1,27 @@ + + + Promise + Vlad Stirbu + MIT + es6-promise,polyfill + + + A polyfill for ES6-style Promises, tracking npm es6-promise + + + + + + + + + + + + + + + diff --git a/StoneIsland/plugins/es6-promise-plugin/www/promise.js b/StoneIsland/plugins/es6-promise-plugin/www/promise.js new file mode 100644 index 00000000..4f8a0f41 --- /dev/null +++ b/StoneIsland/plugins/es6-promise-plugin/www/promise.js @@ -0,0 +1,10 @@ +/*! + * @overview es6-promise - a tiny implementation of Promises/A+. + * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald) + * @license Licensed under MIT license + * See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE + * @version v4.2.2+97478eb6 + */ + +!function t(e,n,r){function o(u,s){if(!n[u]){if(!e[u]){var c="function"==typeof require&&require;if(!s&&c)return c(u,!0);if(i)return i(u,!0);var f=new Error("Cannot find module '"+u+"'");throw f.code="MODULE_NOT_FOUND",f}var a=n[u]={exports:{}};e[u][0].call(a.exports,function(t){var n=e[u][1][t];return o(n?n:t)},a,a.exports,t,e,n,r)}return n[u].exports}for(var i="function"==typeof require&&require,u=0;ut;t+=2){var e=te[t],n=te[t+1];e(n),te[t]=void 0,te[t+1]=void 0}H=0}function p(){try{var e=t,n=e("vertx");return I=n.runOnLoop||n.runOnContext,c()}catch(r){return l()}}function d(t,e){var n=this,r=new this.constructor(y);void 0===r[ne]&&D(r);var o=n._state;if(o){var i=arguments[o-1];Q(function(){return L(o,r,i,n._result)})}else O(n,r,t,e);return r}function v(t){var e=this;if(t&&"object"==typeof t&&t.constructor===e)return t;var n=new e(y);return E(n,t),n}function y(){}function m(){return new TypeError("You cannot resolve a promise with itself")}function _(){return new TypeError("A promises callback cannot return that same promise.")}function w(t){try{return t.then}catch(e){return ue.error=e,ue}}function g(t,e,n,r){try{t.call(e,n,r)}catch(o){return o}}function b(t,e,n){Q(function(t){var r=!1,o=g(n,e,function(n){r||(r=!0,e!==n?E(t,n):j(t,n))},function(e){r||(r=!0,x(t,e))},"Settle: "+(t._label||" unknown promise"));!r&&o&&(r=!0,x(t,o))},t)}function T(t,e){e._state===oe?j(t,e._result):e._state===ie?x(t,e._result):O(e,void 0,function(e){return E(t,e)},function(e){return x(t,e)})}function A(t,e,r){e.constructor===t.constructor&&r===d&&e.constructor.resolve===v?T(t,e):r===ue?(x(t,ue.error),ue.error=null):void 0===r?j(t,e):n(r)?b(t,e,r):j(t,e)}function E(t,n){t===n?x(t,m()):e(n)?A(t,n,w(n)):j(t,n)}function S(t){t._onerror&&t._onerror(t._result),M(t)}function j(t,e){t._state===re&&(t._result=e,t._state=oe,0!==t._subscribers.length&&Q(M,t))}function x(t,e){t._state===re&&(t._state=ie,t._result=e,Q(S,t))}function O(t,e,n,r){var o=t._subscribers,i=o.length;t._onerror=null,o[i]=e,o[i+oe]=n,o[i+ie]=r,0===i&&t._state&&Q(M,t)}function M(t){var e=t._subscribers,n=t._state;if(0!==e.length){for(var r=void 0,o=void 0,i=t._result,u=0;ui;i++)e.resolve(t[i]).then(n,r)}):new e(function(t,e){return e(new TypeError("You must pass an array to race."))})}function Y(t){var e=this,n=new e(y);return x(n,t),n}function K(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function W(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function z(){var t=void 0;if("undefined"!=typeof o)t=o;else if("undefined"!=typeof self)t=self;else try{t=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}var n=t.Promise;if(n){var r=null;try{r=Object.prototype.toString.call(n.resolve())}catch(e){}if("[object Promise]"===r&&!n.cast)return}t.Promise=ae}var B=void 0;B=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)};var G=B,H=0,I=void 0,J=void 0,Q=function(t,e){te[H]=t,te[H+1]=e,H+=2,2===H&&(J?J(h):ee())},R="undefined"!=typeof window?window:void 0,V=R||{},X=V.MutationObserver||V.WebKitMutationObserver,Z="undefined"==typeof self&&"undefined"!=typeof r&&"[object process]"==={}.toString.call(r),$="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,te=new Array(1e3),ee=void 0;ee=Z?s():X?f():$?a():void 0===R&&"function"==typeof t?p():l();var ne=Math.random().toString(36).substring(16),re=void 0,oe=1,ie=2,ue=new P,se=new P,ce=0,fe=function(){function t(t,e){this._instanceConstructor=t,this.promise=new t(y),this.promise[ne]||D(this.promise),G(e)?(this.length=e.length,this._remaining=e.length,this._result=new Array(this.length),0===this.length?j(this.promise,this._result):(this.length=this.length||0,this._enumerate(e),0===this._remaining&&j(this.promise,this._result))):x(this.promise,F())}return t.prototype._enumerate=function(t){for(var e=0;this._state===re&&e1)for(var n=1;n