Skip to content

TagSpaces is an offline, open source, document manager with tagging support

TSN412 share functionality (#1161)

Stanimir8f82aca0fb3e
diff --git a/app/components/EntryContainer.tsx b/app/components/EntryContainer.tsx
index 601a7c3b6..06436d157 100644
--- a/app/components/EntryContainer.tsx
+++ b/app/components/EntryContainer.tsx
@@ -37,6 +37,7 @@ import ExpandIcon from '@material-ui/icons/SettingsEthernet';
import FolderIcon from '@material-ui/icons/FolderOpen';
import SplitPane from 'react-split-pane';
import DeleteIcon from '@material-ui/icons/Delete';
+import ShareIcon from '@material-ui/icons/Share';
import { withStyles } from '@material-ui/core/styles';
import RefreshIcon from '@material-ui/icons/Refresh';
import EntryProperties from '-/components/EntryProperties';
@@ -126,7 +127,9 @@ const styles: any = (theme: any) => ({
flexLeft: {
flexDirection: 'row',
flex: '1 1',
- display: 'flex'
+ display: 'flex',
+ overflowX: 'auto',
+ marginRight: 100
},
fileBadge: {
color: 'white',
@@ -574,6 +577,10 @@ class EntryContainer extends React.Component<Props, State> {
});
};
+ shareFile = (filePath: string) => {
+ PlatformIO.shareFiles([filePath]);
+ };
+
toggleFullScreen = () => {
// this.fileViewerContainer.addEventListener('onfullscreenchange', () => {
// alert('Fullscreen change');
@@ -721,13 +728,18 @@ class EntryContainer extends React.Component<Props, State> {
>
<FullScreenIcon />
</IconButton>
- <IconButton
- title={i18n.t('core:openInFullWidth')}
- aria-label={i18n.t('core:openInFullWidth')}
- onClick={this.props.toggleEntryFullWidth}
- >
- <ExpandIcon />
- </IconButton>
+ {AppConfig.isCordova && (
+ <IconButton
+ title={i18n.t('core:shareFile')}
+ aria-label={i18n.t('core:shareFile')}
+ data-tid="shareFile"
+ onClick={() =>
+ this.shareFile(`file:///${this.state.currentEntry.path}`)
+ }
+ >
+ <ShareIcon />
+ </IconButton>
+ )}
{!(PlatformIO.haveObjectStoreSupport() || AppConfig.isWeb) && (
<IconButton
title={i18n.t('core:openFileExternally')}
@@ -805,6 +817,13 @@ class EntryContainer extends React.Component<Props, State> {
>
<RefreshIcon />
</IconButton>
+ <IconButton
+ title={i18n.t('core:openInFullWidth')}
+ aria-label={i18n.t('core:openInFullWidth')}
+ onClick={this.props.toggleEntryFullWidth}
+ >
+ <ExpandIcon />
+ </IconButton>
</div>
<div className={classes.entryNavigationSection}>
<IconButton
diff --git a/app/services/cordova-io.ts b/app/services/cordova-io.ts
index eb0d6f8a6..114a95a71 100644
--- a/app/services/cordova-io.ts
+++ b/app/services/cordova-io.ts
@@ -1182,9 +1182,9 @@ export default class CordovaIO {
) {
window.open(filePath, '_system');
} else if (filePath.indexOf('file://') === 0) {
- window.plugins.fileOpener.open(filePath);
+ cordova.plugins.fileOpener2.open(filePath);
} else {
- window.plugins.fileOpener.open('file://' + filePath);
+ cordova.plugins.fileOpener2.open('file://' + filePath);
}
};
@@ -1198,4 +1198,28 @@ export default class CordovaIO {
focusWindow = () => {
console.log('Focusing window is not implemented in cordova.');
};
+
+ shareFiles = (files: Array<string>) => {
+ // this is the complete list of currently supported params you can pass to the plugin (all optional)
+ const options = {
+ // message: 'share file', // not supported on some apps (Facebook, Instagram)
+ subject: 'File sharing', // fi. for email
+ files, //: ['', ''], // an array of filenames either locally or remotely
+ // url: 'https://www.website.com/foo/#bar?a=b',
+ chooserTitle: 'Pick an app' // Android only, you can override the default share sheet title
+ //appPackageName: 'com.apple.social.facebook', // Android only, you can provide id of the App you want to share with
+ //iPadCoordinates: '0,0,0,0' //IOS only iPadCoordinates for where the popover should be point. Format with x,y,width,height
+ };
+
+ const onSuccess = function(result) {
+ console.log('Share completed? ' + result.completed); // On Android apps mostly return false even while it's true
+ console.log('Shared to app: ' + result.app); // On Android result.app since plugin version 5.4.0 this is no longer empty. On iOS it's empty when sharing is cancelled (result.completed=false)
+ };
+
+ const onError = function(msg) {
+ console.log('Sharing failed with message: ' + msg);
+ };
+
+ window.plugins.socialsharing.shareWithOptions(options, onSuccess, onError);
+ };
}
diff --git a/app/services/electron-io.ts b/app/services/electron-io.ts
index a646cc6a1..692f1edf6 100644
--- a/app/services/electron-io.ts
+++ b/app/services/electron-io.ts
@@ -887,4 +887,8 @@ export default class ElectronIO {
});
});
};
+
+ shareFiles = (files: Array<string>) => {
+ console.log('shareFiles is not implemented in electron.');
+ };
}
diff --git a/app/services/platform-io.ts b/app/services/platform-io.ts
index 155cff368..bd8af2f60 100644
--- a/app/services/platform-io.ts
+++ b/app/services/platform-io.ts
@@ -292,4 +292,12 @@ export default class PlatformIO {
static selectDirectoryDialog = (): Promise<any> =>
nativeAPI.selectDirectoryDialog();
+
+ static shareFiles = (files: Array<string>): void => {
+ if (AppConfig.isCordova) {
+ nativeAPI.shareFiles(files);
+ } else {
+ console.log('shareFiles is implemented in Cordova only.');
+ }
+ };
}
diff --git a/cordova/config.xml b/cordova/config.xml
index 5a0c145a8..c26f2678f 100644
--- a/cordova/config.xml
+++ b/cordova/config.xml
@@ -17,12 +17,12 @@
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
- <preference name="android-minSdkVersion" value="23" />
- <icon src="res/icon/android/mipmap-mdpi/ic_launcher.png" density="mdpi" />
- <icon src="res/icon/android/mipmap-hdpi/ic_launcher.png" density="hdpi" />
- <icon src="res/icon/android/mipmap-xhdpi/ic_launcher.png" density="xhdpi" />
- <icon src="res/icon/android/mipmap-xxhdpi/ic_launcher.png" density="xxhdpi" />
- <icon src="res/icon/android/mipmap-xxxhdpi/ic_launcher.png" density="xxxhdpi" />
+ <preference name="android-minSdkVersion" value="23" />
+ <icon density="mdpi" src="res/icon/android/mipmap-mdpi/ic_launcher.png" />
+ <icon density="hdpi" src="res/icon/android/mipmap-hdpi/ic_launcher.png" />
+ <icon density="xhdpi" src="res/icon/android/mipmap-xhdpi/ic_launcher.png" />
+ <icon density="xxhdpi" src="res/icon/android/mipmap-xxhdpi/ic_launcher.png" />
+ <icon density="xxxhdpi" src="res/icon/android/mipmap-xxxhdpi/ic_launcher.png" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
@@ -38,5 +38,4 @@
<variable name="ANDROID_SUPPORT_V4_VERSION" value="27.+" />
</plugin>
<plugin name="cordova-plugin-file" spec="6.0.2" />
- <engine name="android" spec="^7.1.4" />
</widget>
diff --git a/cordova/package.json b/cordova/package.json
index 9f8d5b2e4..2c45fa4ae 100644
--- a/cordova/package.json
+++ b/cordova/package.json
@@ -15,7 +15,10 @@
"cordova-plugin-camera": "4.1.0",
"cordova-plugin-device": "^2.0.3",
"cordova-plugin-file": "6.0.2",
- "cordova-plugin-whitelist": "^1.3.4"
+ "cordova-plugin-file-opener2": "^3.0.3",
+ "cordova-plugin-whitelist": "^1.3.4",
+ "cordova-plugin-x-socialsharing": "^5.6.8",
+ "es6-promise-plugin": "^4.2.2"
},
"cordova": {
"plugins": {
@@ -25,7 +28,10 @@
"cordova-plugin-camera": {
"ANDROID_SUPPORT_V4_VERSION": "27.+"
},
- "cordova-plugin-file": {}
+ "cordova-plugin-file": {},
+ "cordova-plugin-file-opener2": {
+ "ANDROID_SUPPORT_V4_VERSION": "27.+"
+ }
},
"platforms": [
"android"
diff --git a/cordova/platforms/android/android.json b/cordova/platforms/android/android.json
index a6647da27..d069f91cb 100644
--- a/cordova/platforms/android/android.json
+++ b/cordova/platforms/android/android.json
@@ -39,6 +39,14 @@
{
"xml": "<feature name=\"Whitelist\"><param name=\"android-package\" value=\"org.apache.cordova.whitelist.WhitelistPlugin\" /><param name=\"onload\" value=\"true\" /></feature>",
"count": 1
+ },
+ {
+ "xml": "<feature name=\"SocialSharing\"><param name=\"android-package\" value=\"nl.xservices.plugins.SocialSharing\" /></feature>",
+ "count": 1
+ },
+ {
+ "xml": "<feature name=\"FileOpener2\"><param name=\"android-package\" value=\"io.github.pwlin.cordova.plugins.fileopener2.FileOpener2\" /></feature>",
+ "count": 1
}
]
}
@@ -49,6 +57,10 @@
{
"xml": "<service android:name=\"de.appplant.cordova.plugin.background.ForegroundService\" />",
"count": 1
+ },
+ {
+ "xml": "<provider android:authorities=\"${applicationId}.sharing.provider\" android:exported=\"false\" android:grantUriPermissions=\"true\" android:name=\"nl.xservices.plugins.FileProvider\"><meta-data android:name=\"android.support.FILE_PROVIDER_PATHS\" android:resource=\"@xml/sharing_paths\" /></provider>",
+ "count": 1
}
],
"/manifest": [
@@ -60,13 +72,31 @@
"/*": [
{
"xml": "<uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\" />",
- "count": 2
+ "count": 3
+ },
+ {
+ "xml": "<uses-permission android:name=\"android.permission.READ_EXTERNAL_STORAGE\" />",
+ "count": 1
+ },
+ {
+ "xml": "<uses-permission android:name=\"android.permission.REQUEST_INSTALL_PACKAGES\" />",
+ "count": 1
}
],
"application": [
{
"xml": "<provider android:authorities=\"${applicationId}.provider\" android:exported=\"false\" android:grantUriPermissions=\"true\" android:name=\"org.apache.cordova.camera.FileProvider\"><meta-data android:name=\"android.support.FILE_PROVIDER_PATHS\" android:resource=\"@xml/camera_provider_paths\" /></provider>",
"count": 1
+ },
+ {
+ "xml": "<provider android:authorities=\"${applicationId}.fileOpener2.provider\" android:exported=\"false\" android:grantUriPermissions=\"true\" android:name=\"io.github.pwlin.cordova.plugins.fileopener2.FileProvider\"><meta-data android:name=\"android.support.FILE_PROVIDER_PATHS\" android:resource=\"@xml/opener_paths\" /></provider>",
+ "count": 1
+ }
+ ],
+ "/*/application": [
+ {
+ "xml": "<receiver android:enabled=\"true\" android:name=\"nl.xservices.plugins.ShareChooserPendingIntent\"><intent-filter><action android:name=\"android.intent.action.SEND\" /></intent-filter></receiver>",
+ "count": 1
}
]
}
@@ -89,6 +119,17 @@
},
"cordova-plugin-whitelist": {
"PACKAGE_NAME": "org.tagspaces.mobile"
+ },
+ "es6-promise-plugin": {
+ "PACKAGE_NAME": "org.tagspaces.mobile"
+ },
+ "cordova-plugin-x-socialsharing": {
+ "ANDROID_SUPPORT_V4_VERSION": "24.1.1+",
+ "PACKAGE_NAME": "org.tagspaces.mobile"
+ },
+ "cordova-plugin-file-opener2": {
+ "ANDROID_SUPPORT_V4_VERSION": "27.+",
+ "PACKAGE_NAME": "org.tagspaces.mobile"
}
},
"dependent_plugins": {},
@@ -314,13 +355,38 @@
"cordova"
],
"runs": true
+ },
+ {
+ "id": "es6-promise-plugin.Promise",
+ "file": "plugins/es6-promise-plugin/www/promise.js",
+ "pluginId": "es6-promise-plugin",
+ "runs": true
+ },
+ {
+ "id": "cordova-plugin-x-socialsharing.SocialSharing",
+ "file": "plugins/cordova-plugin-x-socialsharing/www/SocialSharing.js",
+ "pluginId": "cordova-plugin-x-socialsharing",
+ "clobbers": [
+ "window.plugins.socialsharing"
+ ]
+ },
+ {
+ "id": "cordova-plugin-file-opener2.FileOpener2",
+ "file": "plugins/cordova-plugin-file-opener2/www/plugins.FileOpener2.js",
+ "pluginId": "cordova-plugin-file-opener2",
+ "clobbers": [
+ "cordova.plugins.fileOpener2"
+ ]
}
],
"plugin_metadata": {
- "cordova-plugin-device": "2.0.2",
+ "cordova-plugin-device": "2.0.3",
"cordova-plugin-background-mode": "0.7.3",
"cordova-plugin-camera": "4.1.0",
"cordova-plugin-file": "6.0.2",
- "cordova-plugin-whitelist": "1.3.3"
+ "cordova-plugin-whitelist": "1.3.4",
+ "es6-promise-plugin": "4.2.2",
+ "cordova-plugin-x-socialsharing": "5.6.8",
+ "cordova-plugin-file-opener2": "3.0.3"
}
}
diff --git a/cordova/platforms/android/app/src/main/AndroidManifest.xml b/cordova/platforms/android/app/src/main/AndroidManifest.xml
index 5e49e2d5c..fbf688356 100644
--- a/cordova/platforms/android/app/src/main/AndroidManifest.xml
+++ b/cordova/platforms/android/app/src/main/AndroidManifest.xml
@@ -13,8 +13,21 @@
<provider android:authorities="${applicationId}.provider" android:exported="false" android:grantUriPermissions="true" android:name="org.apache.cordova.camera.FileProvider">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/camera_provider_paths" />
</provider>
+ <receiver android:enabled="true" android:name="nl.xservices.plugins.ShareChooserPendingIntent">
+ <intent-filter>
+ <action android:name="android.intent.action.SEND" />
+ </intent-filter>
+ </receiver>
+ <provider android:authorities="${applicationId}.sharing.provider" android:exported="false" android:grantUriPermissions="true" android:name="nl.xservices.plugins.FileProvider">
+ <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/sharing_paths" />
+ </provider>
+ <provider android:authorities="${applicationId}.fileOpener2.provider" android:exported="false" android:grantUriPermissions="true" android:name="io.github.pwlin.cordova.plugins.fileopener2.FileProvider">
+ <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/opener_paths" />
+ </provider>
</application>
<uses-sdk android:minSdkVersion="23" android:targetSdkVersion="27" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+ <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
+ <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
</manifest>
diff --git a/cordova/platforms/android/app/src/main/java/io/github/pwlin/cordova/plugins/fileopener2/FileOpener2.java b/cordova/platforms/android/app/src/main/java/io/github/pwlin/cordova/plugins/fileopener2/FileOpener2.java
new file mode 100644
index 000000000..399eb191b
--- /dev/null
+++ b/cordova/platforms/android/app/src/main/java/io/github/pwlin/cordova/plugins/fileopener2/FileOpener2.java
@@ -0,0 +1,199 @@
+/*
+The MIT License (MIT)
+
+Copyright (c) 2013 pwlin - [email protected]
+
+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.
+*/
+package io.github.pwlin.cordova.plugins.fileopener2;
+
+import java.io.File;
+import java.util.List;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.net.Uri;
+import android.os.Build;
+import android.webkit.MimeTypeMap;
+
+import io.github.pwlin.cordova.plugins.fileopener2.FileProvider;
+
+import org.apache.cordova.CordovaPlugin;
+import org.apache.cordova.CallbackContext;
+import org.apache.cordova.PluginResult;
+import org.apache.cordova.CordovaResourceApi;
+
+public class FileOpener2 extends CordovaPlugin {
+
+ /**
+ * Executes the request and returns a boolean.
+ *
+ * @param action
+ * The action to execute.
+ * @param args
+ * JSONArry of arguments for the plugin.
+ * @param callbackContext
+ * The callback context used when calling back into JavaScript.
+ * @return boolean.
+ */
+ public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
+ if (action.equals("open")) {
+ String fileUrl = args.getString(0);
+ String contentType = args.getString(1);
+ Boolean openWithDefault = true;
+ if(args.length() > 2){
+ openWithDefault = args.getBoolean(2);
+ }
+ this._open(fileUrl, contentType, openWithDefault, callbackContext);
+ }
+ else if (action.equals("uninstall")) {
+ this._uninstall(args.getString(0), callbackContext);
+ }
+ else if (action.equals("appIsInstalled")) {
+ JSONObject successObj = new JSONObject();
+ if (this._appIsInstalled(args.getString(0))) {
+ successObj.put("status", PluginResult.Status.OK.ordinal());
+ successObj.put("message", "Installed");
+ }
+ else {
+ successObj.put("status", PluginResult.Status.NO_RESULT.ordinal());
+ successObj.put("message", "Not installed");
+ }
+ callbackContext.success(successObj);
+ }
+ else {
+ JSONObject errorObj = new JSONObject();
+ errorObj.put("status", PluginResult.Status.INVALID_ACTION.ordinal());
+ errorObj.put("message", "Invalid action");
+ callbackContext.error(errorObj);
+ }
+ return true;
+ }
+
+ private void _open(String fileArg, String contentType, Boolean openWithDefault, CallbackContext callbackContext) throws JSONException {
+ String fileName = "";
+ try {
+ CordovaResourceApi resourceApi = webView.getResourceApi();
+ Uri fileUri = resourceApi.remapUri(Uri.parse(fileArg));
+ fileName = fileUri.getPath();
+ } catch (Exception e) {
+ fileName = fileArg;
+ }
+ File file = new File(fileName);
+ if (file.exists()) {
+ try {
+ if (contentType == null || contentType.trim().equals("")) {
+ contentType = _getMimeType(fileName);
+ }
+
+ Intent intent;
+ if (contentType.equals("application/vnd.android.package-archive")) {
+ // https://stackoverflow.com/questions/9637629/can-we-install-an-apk-from-a-contentprovider/9672282#9672282
+ intent = new Intent(Intent.ACTION_INSTALL_PACKAGE);
+ Uri path;
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
+ path = Uri.fromFile(file);
+ } else {
+ Context context = cordova.getActivity().getApplicationContext();
+ path = FileProvider.getUriForFile(context, cordova.getActivity().getPackageName() + ".fileOpener2.provider", file);
+ }
+ intent.setDataAndType(path, contentType);
+ intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_ACTIVITY_NEW_TASK);
+
+ } else {
+ intent = new Intent(Intent.ACTION_VIEW);
+ Context context = cordova.getActivity().getApplicationContext();
+ Uri path = FileProvider.getUriForFile(context, cordova.getActivity().getPackageName() + ".fileOpener2.provider", file);
+ intent.setDataAndType(path, contentType);
+ intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
+
+ }
+
+ /*
+ * @see
+ * http://stackoverflow.com/questions/14321376/open-an-activity-from-a-cordovaplugin
+ */
+ if(openWithDefault){
+ cordova.getActivity().startActivity(intent);
+ }
+ else{
+ cordova.getActivity().startActivity(Intent.createChooser(intent, "Open File in..."));
+ }
+
+ callbackContext.success();
+ } catch (android.content.ActivityNotFoundException e) {
+ JSONObject errorObj = new JSONObject();
+ errorObj.put("status", PluginResult.Status.ERROR.ordinal());
+ errorObj.put("message", "Activity not found: " + e.getMessage());
+ callbackContext.error(errorObj);
+ }
+ } else {
+ JSONObject errorObj = new JSONObject();
+ errorObj.put("status", PluginResult.Status.ERROR.ordinal());
+ errorObj.put("message", "File not found");
+ callbackContext.error(errorObj);
+ }
+ }
+
+ private String _getMimeType(String url) {
+ String mimeType = "*/*";
+ int extensionIndex = url.lastIndexOf('.');
+ if (extensionIndex > 0) {
+ String extMimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(url.substring(extensionIndex+1));
+ if (extMimeType != null) {
+ mimeType = extMimeType;
+ }
+ }
+ return mimeType;
+ }
+
+ private void _uninstall(String packageId, CallbackContext callbackContext) throws JSONException {
+ if (this._appIsInstalled(packageId)) {
+ Intent intent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE);
+ intent.setData(Uri.parse("package:" + packageId));
+ cordova.getActivity().startActivity(intent);
+ callbackContext.success();
+ }
+ else {
+ JSONObject errorObj = new JSONObject();
+ errorObj.put("status", PluginResult.Status.ERROR.ordinal());
+ errorObj.put("message", "This package is not installed");
+ callbackContext.error(errorObj);
+ }
+ }
+
+ private boolean _appIsInstalled(String packageId) {
+ PackageManager pm = cordova.getActivity().getPackageManager();
+ boolean appInstalled = false;
+ try {
+ pm.getPackageInfo(packageId, PackageManager.GET_ACTIVITIES);
+ appInstalled = true;
+ } catch (PackageManager.NameNotFoundException e) {
+ appInstalled = false;
+ }
+ return appInstalled;
+ }
+
+}
+
diff --git a/cordova/platforms/android/app/src/main/java/io/github/pwlin/cordova/plugins/fileopener2/FileProvider.java b/cordova/platforms/android/app/src/main/java/io/github/pwlin/cordova/plugins/fileopener2/FileProvider.java
new file mode 100644
index 000000000..c9d49844c
--- /dev/null
+++ b/cordova/platforms/android/app/src/main/java/io/github/pwlin/cordova/plugins/fileopener2/FileProvider.java
@@ -0,0 +1,29 @@
+/*
+The MIT License (MIT)
+
+Copyright (c) 2013 pwlin - [email protected]
+
+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.
+*/
+package io.github.pwlin.cordova.plugins.fileopener2;
+
+/*
+ * http://stackoverflow.com/questions/40746144/error-with-duplicated-fileprovider-in-manifest-xml-with-cordova/41550634#41550634
+ */
+public class FileProvider extends android.support.v4.content.FileProvider {
+}
diff --git a/cordova/platforms/android/app/src/main/java/nl/xservices/plugins/FileProvider.java b/cordova/platforms/android/app/src/main/java/nl/xservices/plugins/FileProvider.java
new file mode 100644
index 000000000..cf05180cb
--- /dev/null
+++ b/cordova/platforms/android/app/src/main/java/nl/xservices/plugins/FileProvider.java
@@ -0,0 +1,4 @@
+package nl.xservices.plugins;
+
+public class FileProvider extends android.support.v4.content.FileProvider {
+}
\ No newline at end of file
diff --git a/cordova/platforms/android/app/src/main/java/nl/xservices/plugins/ShareChooserPendingIntent.java b/cordova/platforms/android/app/src/main/java/nl/xservices/plugins/ShareChooserPendingIntent.java
new file mode 100644
index 000000000..6ca4315b6
--- /dev/null
+++ b/cordova/platforms/android/app/src/main/java/nl/xservices/plugins/ShareChooserPendingIntent.java
@@ -0,0 +1,16 @@
+package nl.xservices.plugins;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.util.Log;
+
+public class ShareChooserPendingIntent extends BroadcastReceiver {
+ public static String chosenComponent = null;
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (intent.getExtras() != null) {
+ ShareChooserPendingIntent.chosenComponent = intent.getExtras().get(Intent.EXTRA_CHOSEN_COMPONENT).toString();
+ }
+ }
+}
diff --git a/cordova/platforms/android/app/src/main/java/nl/xservices/plugins/SocialSharing.java b/cordova/platforms/android/app/src/main/java/nl/xservices/plugins/SocialSharing.java
new file mode 100644
index 000000000..e72446f42
--- /dev/null
+++ b/cordova/platforms/android/app/src/main/java/nl/xservices/plugins/SocialSharing.java
@@ -0,0 +1,799 @@
+package nl.xservices.plugins;
+
+import nl.xservices.plugins.*;
+
+import android.annotation.SuppressLint;
+import android.app.PendingIntent;
+import android.app.Activity;
+import android.content.*;
+import android.content.pm.ActivityInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.content.pm.LabeledIntent;
+import android.net.Uri;
+import android.os.Build;
+import android.os.Environment;
+import android.text.Html;
+import android.util.Base64;
+import android.view.Gravity;
+import android.widget.Toast;
+import android.util.Log;
+
+import org.apache.cordova.CallbackContext;
+import org.apache.cordova.CordovaInterface;
+import org.apache.cordova.CordovaPlugin;
+import org.apache.cordova.PluginResult;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.io.*;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLEncoder;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class SocialSharing extends CordovaPlugin {
+
+ private static final String ACTION_AVAILABLE_EVENT = "available";
+ private static final String ACTION_SHARE_EVENT = "share";
+ private static final String ACTION_SHARE_WITH_OPTIONS_EVENT = "shareWithOptions";
+ private static final String ACTION_CAN_SHARE_VIA = "canShareVia";
+ private static final String ACTION_CAN_SHARE_VIA_EMAIL = "canShareViaEmail";
+ private static final String ACTION_SHARE_VIA = "shareVia";
+ private static final String ACTION_SHARE_VIA_TWITTER_EVENT = "shareViaTwitter";
+ private static final String ACTION_SHARE_VIA_FACEBOOK_EVENT = "shareViaFacebook";
+ private static final String ACTION_SHARE_VIA_FACEBOOK_WITH_PASTEMESSAGEHINT = "shareViaFacebookWithPasteMessageHint";
+ private static final String ACTION_SHARE_VIA_WHATSAPP_EVENT = "shareViaWhatsApp";
+ private static final String ACTION_SHARE_VIA_INSTAGRAM_EVENT = "shareViaInstagram";
+ private static final String ACTION_SHARE_VIA_SMS_EVENT = "shareViaSMS";
+ private static final String ACTION_SHARE_VIA_EMAIL_EVENT = "shareViaEmail";
+
+ private static final int ACTIVITY_CODE_SEND__BOOLRESULT = 1;
+ private static final int ACTIVITY_CODE_SEND__OBJECT = 2;
+ private static final int ACTIVITY_CODE_SENDVIAEMAIL = 3;
+ private static final int ACTIVITY_CODE_SENDVIAWHATSAPP = 4;
+
+ private CallbackContext _callbackContext;
+
+ private String pasteMessage;
+
+ private abstract class SocialSharingRunnable implements Runnable {
+ public CallbackContext callbackContext;
+
+ SocialSharingRunnable(CallbackContext cb) {
+ this.callbackContext = cb;
+ }
+ }
+
+ @Override
+ public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
+ this._callbackContext = callbackContext; // only used for onActivityResult
+ this.pasteMessage = null;
+ if (ACTION_AVAILABLE_EVENT.equals(action)) {
+ callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK));
+ return true;
+ } else if (ACTION_SHARE_EVENT.equals(action)) {
+ return doSendIntent(callbackContext, args.getString(0), args.getString(1), args.getJSONArray(2), args.getString(3), null, null, false, true);
+ } else if (ACTION_SHARE_WITH_OPTIONS_EVENT.equals(action)) {
+ return shareWithOptions(callbackContext, args.getJSONObject(0));
+ } 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.isNull(3) ? args.getJSONArray(2) : null, 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.isNull(3) ? args.getJSONArray(2) : null, 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))) { // abid
+ return shareViaWhatsAppDirectly(callbackContext, args.getString(0), args.getString(1), args.getJSONArray(2), args.getString(3), args.getString(4));
+ } else if (notEmpty(args.getString(5))) { // phone
+ return shareViaWhatsAppDirectly(callbackContext, args.getString(0), args.getString(1), args.getJSONArray(2), args.getString(3), args.getString(5));
+ } else {
+ return doSendIntent(callbackContext, args.getString(0), args.getString(1), args.getJSONArray(2), args.getString(3), "whatsapp", null, false, true);
+ }
+ } else if (ACTION_SHARE_VIA_INSTAGRAM_EVENT.equals(action)) {
+ if (notEmpty(args.getString(0))) {
+ copyHintToClipboard(args.getString(0), "Instagram paste message");
+ }
+ return doSendIntent(callbackContext, args.getString(0), args.getString(1), args.getJSONArray(2), args.getString(3), "instagram", null, false, true);
+ } else if (ACTION_CAN_SHARE_VIA.equals(action)) {
+ return doSendIntent(callbackContext, args.getString(0), args.getString(1), args.getJSONArray(2), args.getString(3), args.getString(4), null, true, true);
+ } else if (ACTION_CAN_SHARE_VIA_EMAIL.equals(action)) {
+ if (isEmailAvailable()) {
+ callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK));
+ return true;
+ } else {
+ callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, "not available"));
+ return false;
+ }
+ } else if (ACTION_SHARE_VIA.equals(action)) {
+ return doSendIntent(callbackContext, args.getString(0), args.getString(1), args.getJSONArray(2), args.getString(3), args.getString(4), null, false, true);
+ } else if (ACTION_SHARE_VIA_SMS_EVENT.equals(action)) {
+ return invokeSMSIntent(callbackContext, args.getJSONObject(0), args.getString(1));
+ } else if (ACTION_SHARE_VIA_EMAIL_EVENT.equals(action)) {
+ return invokeEmailIntent(callbackContext, args.getString(0), args.getString(1), args.getJSONArray(2), args.isNull(3) ? null : args.getJSONArray(3), args.isNull(4) ? null : args.getJSONArray(4), args.isNull(5) ? null : args.getJSONArray(5));
+ } else {
+ callbackContext.error("socialSharing." + action + " is not a supported function. Did you mean '" + ACTION_SHARE_EVENT + "'?");
+ return false;
+ }
+ }
+
+ private boolean isEmailAvailable() {
+ final Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "[email protected]", null));
+ return cordova.getActivity().getPackageManager().queryIntentActivities(intent, 0).size() > 0;
+ }
+
+ private boolean invokeEmailIntent(final CallbackContext callbackContext, final String message, final String subject, final JSONArray to, final JSONArray cc, final JSONArray bcc, final JSONArray files) throws JSONException {
+
+ final SocialSharing plugin = this;
+ cordova.getThreadPool().execute(new SocialSharingRunnable(callbackContext) {
+ public void run() {
+ Intent draft = new Intent(Intent.ACTION_SENDTO);
+ if (notEmpty(message)) {
+ Pattern htmlPattern = Pattern.compile(".*\\<[^>]+>.*", Pattern.DOTALL);
+ if (htmlPattern.matcher(message).matches()) {
+ draft.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(message));
+ draft.setType("text/html");
+ } else {
+ draft.putExtra(android.content.Intent.EXTRA_TEXT, message);
+ draft.setType("text/plain");
+ }
+ }
+ if (notEmpty(subject)) {
+ draft.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
+ }
+ try {
+ if (to != null && to.length() > 0) {
+ draft.putExtra(android.content.Intent.EXTRA_EMAIL, toStringArray(to));
+ }
+ if (cc != null && cc.length() > 0) {
+ draft.putExtra(android.content.Intent.EXTRA_CC, toStringArray(cc));
+ }
+ if (bcc != null && bcc.length() > 0) {
+ draft.putExtra(android.content.Intent.EXTRA_BCC, toStringArray(bcc));
+ }
+ if (files.length() > 0) {
+ final String dir = getDownloadDir();
+ if (dir != null) {
+ ArrayList<Uri> fileUris = new ArrayList<Uri>();
+ for (int i = 0; i < files.length(); i++) {
+ Uri fileUri = getFileUriAndSetType(draft, 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);
+ }
+ }
+ if (!fileUris.isEmpty()) {
+ draft.putExtra(Intent.EXTRA_STREAM, fileUris);
+ }
+ }
+ }
+ } 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
+ draft.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+
+ draft.setData(Uri.parse("mailto:"));
+
+ List<ResolveInfo> emailAppList = cordova.getActivity().getPackageManager().queryIntentActivities(draft, 0);
+
+ List<LabeledIntent> labeledIntentList = new ArrayList();
+ for (ResolveInfo info : emailAppList) {
+ draft.setAction(Intent.ACTION_SEND_MULTIPLE);
+ draft.setType("application/octet-stream");
+
+ draft.setComponent(new ComponentName(info.activityInfo.packageName, info.activityInfo.name));
+ labeledIntentList.add(new LabeledIntent(draft, info.activityInfo.packageName, info.loadLabel(cordova.getActivity().getPackageManager()), info.icon));
+ }
+ final Intent emailAppLists = Intent.createChooser(labeledIntentList.remove(labeledIntentList.size() - 1), "Choose Email App");
+ emailAppLists.putExtra(Intent.EXTRA_INITIAL_INTENTS, labeledIntentList.toArray(new LabeledIntent[labeledIntentList.size()]));
+
+ // as an experiment for #300 we're explicitly running it on the ui thread here
+ cordova.getActivity().runOnUiThread(new Runnable() {
+ public void run() {
+ cordova.startActivityForResult(plugin, emailAppLists, ACTIVITY_CODE_SENDVIAEMAIL);
+ }
+ });
+ }
+ });
+
+ return true;
+ }
+
+ private String getDownloadDir() throws IOException {
+ // better check, otherwise it may crash the app
+ if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
+ // we need to use external storage since we need to share to another app
+ final String dir = webView.getContext().getExternalFilesDir(null) + "/socialsharing-downloads";
+ createOrCleanDir(dir);
+ return dir;
+ } else {
+ return null;
+ }
+ }
+
+ private boolean shareWithOptions(CallbackContext callbackContext, JSONObject jsonObject) {
+ return doSendIntent(
+ callbackContext,
+ jsonObject.optString("message", null),
+ jsonObject.optString("subject", null),
+ jsonObject.optJSONArray("files") == null ? new JSONArray() : jsonObject.optJSONArray("files"),
+ jsonObject.optString("url", null),
+ jsonObject.optString("appPackageName", null),
+ jsonObject.optString("chooserTitle", null),
+ false,
+ false
+ );
+ }
+
+ 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,
+ final String subject,
+ final JSONArray files,
+ final String url,
+ final String appPackageName,
+ final String chooserTitle,
+ final boolean peek,
+ final boolean boolResult,
+ final String appName) {
+
+ final CordovaInterface mycordova = cordova;
+ final CordovaPlugin plugin = this;
+
+ cordova.getThreadPool().execute(new SocialSharingRunnable(callbackContext) {
+ public void run() {
+ String message = msg;
+ final boolean hasMultipleAttachments = files.length() > 1;
+ final Intent sendIntent = new Intent(hasMultipleAttachments ? Intent.ACTION_SEND_MULTIPLE : Intent.ACTION_SEND);
+ final Intent receiverIntent = new Intent(cordova.getActivity().getApplicationContext(), ShareChooserPendingIntent.class);
+ final PendingIntent pendingIntent = PendingIntent.getBroadcast(cordova.getActivity().getApplicationContext(), 0, receiverIntent, PendingIntent.FLAG_UPDATE_CURRENT);
+ sendIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
+
+ try {
+ if (files.length() > 0 && !"".equals(files.getString(0))) {
+ final String dir = getDownloadDir();
+ if (dir != null) {
+ ArrayList<Uri> fileUris = new ArrayList<Uri>();
+ 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()));
+ fileUris.add(fileUri);
+ }
+ if (!fileUris.isEmpty()) {
+ if (hasMultipleAttachments) {
+ sendIntent.putExtra(Intent.EXTRA_STREAM, fileUris);
+ } else {
+ sendIntent.putExtra(Intent.EXTRA_STREAM, fileUri);
+ }
+ }
+ } else {
+ sendIntent.setType("text/plain");
+ }
+ } else {
+ sendIntent.setType("text/plain");
+ }
+ } catch (Exception e) {
+ callbackContext.error(e.getMessage());
+ }
+
+ if (notEmpty(subject)) {
+ sendIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
+ }
+
+ // add the URL to the message, as there seems to be no separate field
+ if (notEmpty(url)) {
+ if (notEmpty(message)) {
+ message += " " + url;
+ } else {
+ message = url;
+ }
+ }
+ if (notEmpty(message)) {
+ sendIntent.putExtra(android.content.Intent.EXTRA_TEXT, message);
+ // sometimes required when the user picks share via sms
+ if (Build.VERSION.SDK_INT < 21) { // LOLLIPOP
+ sendIntent.putExtra("sms_body", message);
+ }
+ }
+
+ // this was added to start the intent in a new window as suggested in #300 to prevent crashes upon return
+ sendIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+
+ if (appPackageName != null) {
+ String packageName = appPackageName;
+ String passedActivityName = null;
+ if (packageName.contains("/")) {
+ String[] items = appPackageName.split("/");
+ packageName = items[0];
+ passedActivityName = items[1];
+ }
+ final ActivityInfo activity = getActivity(callbackContext, sendIntent, packageName, appName);
+ if (activity != null) {
+ if (peek) {
+ callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK));
+ } else {
+ sendIntent.addCategory(Intent.CATEGORY_LAUNCHER);
+ sendIntent.setComponent(new ComponentName(activity.applicationInfo.packageName,
+ passedActivityName != null ? passedActivityName : activity.name));
+
+ // as an experiment for #300 we're explicitly running it on the ui thread here
+ cordova.getActivity().runOnUiThread(new Runnable() {
+ public void run() {
+ mycordova.startActivityForResult(plugin, sendIntent, 0);
+ }
+ });
+
+ if (pasteMessage != null) {
+ // add a little delay because target app (facebook only atm) needs to be started first
+ new Timer().schedule(new TimerTask() {
+ public void run() {
+ cordova.getActivity().runOnUiThread(new Runnable() {
+ public void run() {
+ copyHintToClipboard(msg, pasteMessage);
+ showPasteMessage(pasteMessage);
+ }
+ });
+ }
+ }, 2000);
+ }
+ }
+ }
+ } else {
+ if (peek) {
+ callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK));
+ } else {
+ // experimenting a bit
+ // as an experiment for #300 we're explicitly running it on the ui thread here
+ cordova.getActivity().runOnUiThread(new Runnable() {
+ public void run() {
+ Intent chooseIntent;
+ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP_MR1) {
+ // Intent.createChooser's third param was only added in SDK version 22.
+ chooseIntent = Intent.createChooser(sendIntent, chooserTitle, pendingIntent.getIntentSender());
+ } else {
+ chooseIntent = Intent.createChooser(sendIntent, chooserTitle);
+ }
+ mycordova.startActivityForResult(plugin, chooseIntent, boolResult ? ACTIVITY_CODE_SEND__BOOLRESULT : ACTIVITY_CODE_SEND__OBJECT);
+ }
+ });
+ }
+ }
+ }
+ });
+ return true;
+ }
+
+ @SuppressLint("NewApi")
+ private void copyHintToClipboard(String msg, String label) {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
+ return;
+ }
+ final ClipboardManager clipboard = (android.content.ClipboardManager) cordova.getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
+ final ClipData clip = android.content.ClipData.newPlainText(label, msg);
+ clipboard.setPrimaryClip(clip);
+ }
+
+ @SuppressLint("NewApi")
+ private void showPasteMessage(String label) {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
+ return;
+ }
+ final Toast toast = Toast.makeText(webView.getContext(), label, Toast.LENGTH_LONG);
+ toast.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL, 0, 0);
+ toast.show();
+ }
+
+ private Uri getFileUriAndSetType(Intent sendIntent, String dir, String image, String subject, int nthFile) throws IOException {
+ // we're assuming an image, but this can be any filetype you like
+ 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/*");
+ }
+
+ if (image.startsWith("http") || image.startsWith("www/")) {
+ String filename = getFileName(image);
+ localImage = "file://" + dir + "/" + filename.replaceAll("[^a-zA-Z0-9._-]", "");
+ if (image.startsWith("http")) {
+ // filename optimisation taken from https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin/pull/56
+ URLConnection connection = new URL(image).openConnection();
+ String disposition = connection.getHeaderField("Content-Disposition");
+ if (disposition != null) {
+ final Pattern dispositionPattern = Pattern.compile("filename=([^;]+)");
+ Matcher matcher = dispositionPattern.matcher(disposition);
+ if (matcher.find()) {
+ filename = matcher.group(1).replaceAll("[^a-zA-Z0-9._-]", "");
+ if (filename.length() == 0) {
+ // in this case we can't determine a filetype so some targets (gmail) may not render it correctly
+ filename = "file";
+ }
+ localImage = "file://" + dir + "/" + filename;
+ }
+ }
+ saveFile(getBytes(connection.getInputStream()), dir, filename);
+ } else {
+ saveFile(getBytes(webView.getContext().getAssets().open(image)), dir, filename);
+ }
+ } else if (image.startsWith("data:")) {
+ // safeguard for https://code.google.com/p/android/issues/detail?id=7901#c43
+ if (!image.contains(";base64,")) {
+ sendIntent.setType("text/plain");
+ return null;
+ }
+ // image looks like this: data:image/png;base64,R0lGODlhDAA...
+ final String encodedImg = image.substring(image.indexOf(";base64,") + 8);
+ // correct the intent type if anything else was passed, like a pdf: data:application/pdf;base64,..
+ if (!image.contains("data:image/")) {
+ sendIntent.setType(image.substring(image.indexOf("data:") + 5, image.indexOf(";base64")));
+ }
+ // the filename needs a valid extension, so it renders correctly in target apps
+ final String imgExtension = image.substring(image.indexOf("/") + 1, image.indexOf(";base64"));
+ String fileName;
+ // if a subject was passed, use it as the filename
+ // filenames must be unique when passing in multiple files [#158]
+ if (notEmpty(subject)) {
+ fileName = sanitizeFilename(subject) + (nthFile == 0 ? "" : "_" + nthFile) + "." + imgExtension;
+ } else {
+ fileName = "file" + (nthFile == 0 ? "" : "_" + nthFile) + "." + imgExtension;
+ }
+ saveFile(Base64.decode(encodedImg, Base64.DEFAULT), dir, fileName);
+ localImage = "file://" + dir + "/" + fileName;
+ } else if (image.startsWith("df:")) {
+ // safeguard for https://code.google.com/p/android/issues/detail?id=7901#c43
+ if (!image.contains(";base64,")) {
+ sendIntent.setType("text/plain");
+ return null;
+ }
+ // format looks like this : df:filename.txt;data:image/png;base64,R0lGODlhDAA...
+ final String fileName = image.substring(image.indexOf("df:") + 3, image.indexOf(";data:"));
+ final String fileType = image.substring(image.indexOf(";data:") + 6, image.indexOf(";base64,"));
+ final String encodedImg = image.substring(image.indexOf(";base64,") + 8);
+ sendIntent.setType(fileType);
+ saveFile(Base64.decode(encodedImg, Base64.DEFAULT), dir, sanitizeFilename(fileName));
+ localImage = "file://" + dir + "/" + sanitizeFilename(fileName);
+ } else if (!image.startsWith("file://")) {
+ throw new IllegalArgumentException("URL_NOT_SUPPORTED");
+ } else {
+ //get file MIME type
+ String type = getMIMEType(image);
+ //set intent data and Type
+ sendIntent.setType(type);
+ }
+ return Uri.parse(localImage);
+ }
+
+ private String getMIMEType(String fileName) {
+ String type = "*/*";
+ int dotIndex = fileName.lastIndexOf(".");
+ if (dotIndex == -1) {
+ return type;
+ }
+ final String end = fileName.substring(dotIndex+1, fileName.length()).toLowerCase();
+ String fromMap = MIME_Map.get(end);
+ return fromMap == null ? type : fromMap;
+ }
+
+ private static final Map<String, String> MIME_Map = new HashMap<String, String>();
+ static {
+ MIME_Map.put("3gp", "video/3gpp");
+ MIME_Map.put("apk", "application/vnd.android.package-archive");
+ MIME_Map.put("asf", "video/x-ms-asf");
+ MIME_Map.put("avi", "video/x-msvideo");
+ MIME_Map.put("bin", "application/octet-stream");
+ MIME_Map.put("bmp", "image/bmp");
+ MIME_Map.put("c", "text/plain");
+ MIME_Map.put("class", "application/octet-stream");
+ MIME_Map.put("conf", "text/plain");
+ MIME_Map.put("cpp", "text/plain");
+ MIME_Map.put("doc", "application/msword");
+ MIME_Map.put("docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
+ MIME_Map.put("xls", "application/vnd.ms-excel");
+ MIME_Map.put("xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+ MIME_Map.put("exe", "application/octet-stream");
+ MIME_Map.put("gif", "image/gif");
+ MIME_Map.put("gtar", "application/x-gtar");
+ MIME_Map.put("gz", "application/x-gzip");
+ MIME_Map.put("h", "text/plain");
+ MIME_Map.put("htm", "text/html");
+ MIME_Map.put("html", "text/html");
+ MIME_Map.put("jar", "application/java-archive");
+ MIME_Map.put("java", "text/plain");
+ MIME_Map.put("jpeg", "image/jpeg");
+ MIME_Map.put("jpg", "image/*");
+ MIME_Map.put("js", "application/x-javascript");
+ MIME_Map.put("log", "text/plain");
+ MIME_Map.put("m3u", "audio/x-mpegurl");
+ MIME_Map.put("m4a", "audio/mp4a-latm");
+ MIME_Map.put("m4b", "audio/mp4a-latm");
+ MIME_Map.put("m4p", "audio/mp4a-latm");
+ MIME_Map.put("m4u", "video/vnd.mpegurl");
+ MIME_Map.put("m4v", "video/x-m4v");
+ MIME_Map.put("mov", "video/quicktime");
+ MIME_Map.put("mp2", "audio/x-mpeg");
+ MIME_Map.put("mp3", "audio/x-mpeg");
+ MIME_Map.put("mp4", "video/mp4");
+ MIME_Map.put("mpc", "application/vnd.mpohun.certificate");
+ MIME_Map.put("mpe", "video/mpeg");
+ MIME_Map.put("mpeg", "video/mpeg");
+ MIME_Map.put("mpg", "video/mpeg");
+ MIME_Map.put("mpg4", "video/mp4");
+ MIME_Map.put("mpga", "audio/mpeg");
+ MIME_Map.put("msg", "application/vnd.ms-outlook");
+ MIME_Map.put("ogg", "audio/ogg");
+ MIME_Map.put("pdf", "application/pdf");
+ MIME_Map.put("png", "image/png");
+ MIME_Map.put("pps", "application/vnd.ms-powerpoint");
+ MIME_Map.put("ppt", "application/vnd.ms-powerpoint");
+ MIME_Map.put("pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation");
+ MIME_Map.put("prop", "text/plain");
+ MIME_Map.put("rc", "text/plain");
+ MIME_Map.put("rmvb", "audio/x-pn-realaudio");
+ MIME_Map.put("rtf", "application/rtf");
+ MIME_Map.put("sh", "text/plain");
+ MIME_Map.put("tar", "application/x-tar");
+ MIME_Map.put("tgz", "application/x-compressed");
+ MIME_Map.put("txt", "text/plain");
+ MIME_Map.put("wav", "audio/x-wav");
+ MIME_Map.put("wma", "audio/x-ms-wma");
+ MIME_Map.put("wmv", "audio/x-ms-wmv");
+ MIME_Map.put("wps", "application/vnd.ms-works");
+ MIME_Map.put("xml", "text/plain");
+ MIME_Map.put("z", "application/x-compress");
+ MIME_Map.put("zip", "application/x-zip-compressed");
+ MIME_Map.put("", "*/*");
+ }
+
+ // sending files is not supported with ACTION_VIEW, and with ACTION_SEND the message doesn't get prefilled :(
+ private boolean shareViaWhatsAppDirectly(final CallbackContext callbackContext, String message, final String subject, final JSONArray files, final String url, final String number) {
+ // add the URL to the message, as there seems to be no separate field
+ if (notEmpty(url)) {
+ if (notEmpty(message)) {
+ message += " " + url;
+ } else {
+ message = url;
+ }
+ }
+ final String shareMessage = message;
+ final SocialSharing plugin = this;
+ cordova.getThreadPool().execute(new SocialSharingRunnable(callbackContext) {
+ public void run() {
+ final Intent intent = new Intent(Intent.ACTION_VIEW);
+ try {
+ intent.setData(Uri.parse("https://api.whatsapp.com/send?phone=" + number + "&text=" + URLEncoder.encode(shareMessage, "UTF-8")));
+ // this was added to start the intent in a new window as suggested in #300 to prevent crashes upon return
+ // update: didn't help (doesn't seem to hurt either though)
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+
+ // as an experiment for #300 we're explicitly running it on the ui thread here
+ cordova.getActivity().runOnUiThread(new Runnable() {
+ public void run() {
+ try {
+ cordova.startActivityForResult(plugin, intent, ACTIVITY_CODE_SENDVIAWHATSAPP);
+ } catch (Exception e) {
+ callbackContext.error(e.getMessage());
+ }
+ }
+ });
+ } catch (Exception e) {
+ callbackContext.error(e.getMessage());
+ }
+ }
+ });
+ return true;
+ }
+
+ private boolean invokeSMSIntent(final CallbackContext callbackContext, JSONObject options, String p_phonenumbers) {
+ final String message = options.optString("message");
+ // TODO test this on a real SMS enabled device before releasing it
+// final String subject = options.optString("subject");
+// final String image = options.optString("image");
+ final String subject = null; //options.optString("subject");
+ final String image = null; // options.optString("image");
+ final String phonenumbers = getPhoneNumbersWithManufacturerSpecificSeparators(p_phonenumbers);
+ final SocialSharing plugin = this;
+ cordova.getThreadPool().execute(new SocialSharingRunnable(callbackContext) {
+ public void run() {
+ Intent intent;
+
+ if (Build.VERSION.SDK_INT >= 19) { // Build.VERSION_CODES.KITKAT) {
+ // passing in no phonenumbers for kitkat may result in an error,
+ // but it may also work for some devices, so documentation will need to cover this case
+ intent = new Intent(Intent.ACTION_SENDTO);
+ intent.setData(Uri.parse("smsto:" + (notEmpty(phonenumbers) ? phonenumbers : "")));
+ } else {
+ intent = new Intent(Intent.ACTION_VIEW);
+ intent.setType("vnd.android-dir/mms-sms");
+ if (phonenumbers != null) {
+ intent.putExtra("address", phonenumbers);
+ }
+ }
+ intent.putExtra("sms_body", message);
+ intent.putExtra("sms_subject", subject);
+
+ try {
+ if (image != null && !"".equals(image)) {
+ final Uri fileUri = getFileUriAndSetType(intent, getDownloadDir(), image, subject, 0);
+ if (fileUri != null) {
+ intent.putExtra(Intent.EXTRA_STREAM, fileUri);
+ }
+ }
+ // this was added to start the intent in a new window as suggested in #300 to prevent crashes upon return
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+
+ cordova.startActivityForResult(plugin, intent, 0);
+ } catch (Exception e) {
+ callbackContext.error(e.getMessage());
+ }
+ }
+ });
+ return true;
+ }
+
+ private static String getPhoneNumbersWithManufacturerSpecificSeparators(String phonenumbers) {
+ if (notEmpty(phonenumbers)) {
+ char separator;
+ if (android.os.Build.MANUFACTURER.equalsIgnoreCase("samsung")) {
+ separator = ',';
+ } else {
+ separator = ';';
+ }
+ return phonenumbers.replace(';', separator).replace(',', separator);
+ }
+ return null;
+ }
+
+ private ActivityInfo getActivity(final CallbackContext callbackContext, final Intent shareIntent, final String appPackageName, final String appName) {
+ final PackageManager pm = webView.getContext().getPackageManager();
+ List<ResolveInfo> activityList = pm.queryIntentActivities(shareIntent, 0);
+ for (final ResolveInfo app : activityList) {
+ if ((app.activityInfo.packageName).contains(appPackageName)) {
+ if (appName == null || (app.activityInfo.name).contains(appName)) {
+ return app.activityInfo;
+ }
+ }
+ }
+ // no matching app found
+ callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, getShareActivities(activityList)));
+ return null;
+ }
+
+ private JSONArray getShareActivities(List<ResolveInfo> activityList) {
+ List<String> packages = new ArrayList<String>();
+ for (final ResolveInfo app : activityList) {
+ packages.add(app.activityInfo.packageName);
+ }
+ return new JSONArray(packages);
+ }
+
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, Intent intent) {
+ super.onActivityResult(requestCode, resultCode, intent);
+ if (_callbackContext != null) {
+ switch (requestCode) {
+ case ACTIVITY_CODE_SEND__BOOLRESULT:
+ _callbackContext.sendPluginResult(new PluginResult(
+ PluginResult.Status.OK,
+ resultCode == Activity.RESULT_OK));
+ break;
+ case ACTIVITY_CODE_SEND__OBJECT:
+ JSONObject json = new JSONObject();
+ try {
+ json.put("completed", resultCode == Activity.RESULT_OK);
+ json.put("app", (ShareChooserPendingIntent.chosenComponent != null ? ShareChooserPendingIntent.chosenComponent : "")); // we need a completely different approach if we want to support this on Android. Idea: https://clickclickclack.wordpress.com/2012/01/03/intercepting-androids-action_send-intents/
+ _callbackContext.sendPluginResult(new PluginResult(
+ PluginResult.Status.OK,
+ json));
+ } catch (JSONException e) {
+ _callbackContext.error(e.getMessage());
+ }
+ break;
+ default:
+ _callbackContext.success();
+ }
+ }
+ }
+
+ private void createOrCleanDir(final String downloadDir) throws IOException {
+ final File dir = new File(downloadDir);
+ if (!dir.exists()) {
+ if (!dir.mkdirs()) {
+ throw new IOException("CREATE_DIRS_FAILED");
+ }
+ } else {
+ cleanupOldFiles(dir);
+ }
+ }
+
+ private static String getFileName(String url) {
+ if (url.endsWith("/")) {
+ url = url.substring(0, url.length()-1);
+ }
+ final String pattern = ".*/([^?#]+)?";
+ Pattern r = Pattern.compile(pattern);
+ Matcher m = r.matcher(url);
+ if (m.find()) {
+ return m.group(1);
+ } else {
+ return "file";
+ }
+ }
+
+ private byte[] getBytes(InputStream is) throws IOException {
+ ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+ int nRead;
+ byte[] data = new byte[16384];
+ while ((nRead = is.read(data, 0, data.length)) != -1) {
+ buffer.write(data, 0, nRead);
+ }
+ buffer.flush();
+ return buffer.toByteArray();
+ }
+
+ private void saveFile(byte[] bytes, String dirName, String fileName) throws IOException {
+ final File dir = new File(dirName);
+ final FileOutputStream fos = new FileOutputStream(new File(dir, fileName));
+ fos.write(bytes);
+ fos.flush();
+ fos.close();
+ }
+
+ /**
+ * As file.deleteOnExit does not work on Android, we need to delete files manually.
+ * Deleting them in onActivityResult is not a good idea, because for example a base64 encoded file
+ * will not be available for upload to Facebook (it's deleted before it's uploaded).
+ * So the best approach is deleting old files when saving (sharing) a new one.
+ */
+ private void cleanupOldFiles(File dir) {
+ for (File f : dir.listFiles()) {
+ //noinspection ResultOfMethodCallIgnored
+ f.delete();
+ }
+ }
+
+ private static boolean notEmpty(String what) {
+ return what != null &&
+ !"".equals(what) &&
+ !"null".equalsIgnoreCase(what);
+ }
+
+ private static String[] toStringArray(JSONArray jsonArray) throws JSONException {
+ String[] result = new String[jsonArray.length()];
+ for (int i = 0; i < jsonArray.length(); i++) {
+ result[i] = jsonArray.getString(i);
+ }
+ return result;
+ }
+
+ public static String sanitizeFilename(String name) {
+ return name.replaceAll("[:\\\\/*?|<> ]", "_");
+ }
+}
diff --git a/cordova/platforms/android/app/src/main/res/xml/config.xml b/cordova/platforms/android/app/src/main/res/xml/config.xml
index 5822528fe..81def37b1 100644
--- a/cordova/platforms/android/app/src/main/res/xml/config.xml
+++ b/cordova/platforms/android/app/src/main/res/xml/config.xml
@@ -21,6 +21,12 @@
<param name="android-package" value="org.apache.cordova.whitelist.WhitelistPlugin" />
<param name="onload" value="true" />
</feature>
+ <feature name="SocialSharing">
+ <param name="android-package" value="nl.xservices.plugins.SocialSharing" />
+ </feature>
+ <feature name="FileOpener2">
+ <param name="android-package" value="io.github.pwlin.cordova.plugins.fileopener2.FileOpener2" />
+ </feature>
<name>TagSpaces Beta</name>
<description>
Offline file organizer and browser with tagging support.
diff --git a/cordova/platforms/android/app/src/main/res/xml/opener_paths.xml b/cordova/platforms/android/app/src/main/res/xml/opener_paths.xml
new file mode 100644
index 000000000..0ffc88ec9
--- /dev/null
+++ b/cordova/platforms/android/app/src/main/res/xml/opener_paths.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- https://developer.android.com/reference/android/support/v4/content/FileProvider.html#SpecifyFiles -->
+<paths xmlns:android="http://schemas.android.com/apk/res/android">
+ <!-- cordova.file.dataDirectory -->
+ <files-path name="files" path="." />
+ <!-- cordova.file.cacheDirectory -->
+ <cache-path name="cache" path="." />
+ <!-- cordova.file.externalDataDirectory -->
+ <external-files-path name="external-files" path="." />
+ <!-- cordova.file.externalCacheDirectory -->
+ <external-cache-path name="external-cache" path="." />
+ <!-- cordova.file.externalRootDirectory -->
+ <external-path name="external" path="." />
+</paths>
diff --git a/cordova/platforms/android/app/src/main/res/xml/sharing_paths.xml b/cordova/platforms/android/app/src/main/res/xml/sharing_paths.xml
new file mode 100644
index 000000000..278084a21
--- /dev/null
+++ b/cordova/platforms/android/app/src/main/res/xml/sharing_paths.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<paths>
+ <external-path
+ name="Android/data/${applicationId}/socialsharing_downloads"
+ path="./socialsharing-downloads"/>
+
+ <root-path
+ name="root"
+ path="/"/>
+
+</paths>
\ No newline at end of file
diff --git a/cordova/platforms/android/gradle/wrapper/gradle-wrapper.jar b/cordova/platforms/android/gradle/wrapper/gradle-wrapper.jar
index 94336fcae..62d4c0535 100644
Binary files a/cordova/platforms/android/gradle/wrapper/gradle-wrapper.jar and b/cordova/platforms/android/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/cordova/platforms/android/gradlew b/cordova/platforms/android/gradlew
index cccdd3d51..fbd7c5158 100755
--- a/cordova/platforms/android/gradlew
+++ b/cordova/platforms/android/gradlew
@@ -1,5 +1,21 @@
#!/usr/bin/env sh
+#
+# Copyright 2015 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
##############################################################################
##
## Gradle start up script for UN*X
@@ -28,7 +44,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
@@ -66,6 +82,7 @@ esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
@@ -109,10 +126,11 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
@@ -138,19 +156,19 @@ if $cygwin ; then
else
eval `echo args$i`="\"$arg\""
fi
- i=$((i+1))
+ i=`expr $i + 1`
done
case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ 0) set -- ;;
+ 1) set -- "$args0" ;;
+ 2) set -- "$args0" "$args1" ;;
+ 3) set -- "$args0" "$args1" "$args2" ;;
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
@@ -159,14 +177,9 @@ save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
-APP_ARGS=$(save "$@")
+APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
-# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
-if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
- cd "$(dirname "$0")"
-fi
-
exec "$JAVACMD" "$@"
diff --git a/cordova/platforms/android/gradlew.bat b/cordova/platforms/android/gradlew.bat
index f9553162f..5093609d5 100644
--- a/cordova/platforms/android/gradlew.bat
+++ b/cordova/platforms/android/gradlew.bat
@@ -1,3 +1,19 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@@ -13,8 +29,11 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
@@ -65,6 +84,7 @@ set CMD_LINE_ARGS=%*
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
diff --git a/cordova/platforms/android/platform_www/cordova_plugins.js b/cordova/platforms/android/platform_www/cordova_plugins.js
index c6aa2a641..825eaebf2 100644
--- a/cordova/platforms/android/platform_www/cordova_plugins.js
+++ b/cordova/platforms/android/platform_www/cordova_plugins.js
@@ -221,16 +221,41 @@ module.exports = [
"cordova"
],
"runs": true
+ },
+ {
+ "id": "es6-promise-plugin.Promise",
+ "file": "plugins/es6-promise-plugin/www/promise.js",
+ "pluginId": "es6-promise-plugin",
+ "runs": true
+ },
+ {
+ "id": "cordova-plugin-x-socialsharing.SocialSharing",
+ "file": "plugins/cordova-plugin-x-socialsharing/www/SocialSharing.js",
+ "pluginId": "cordova-plugin-x-socialsharing",
+ "clobbers": [
+ "window.plugins.socialsharing"
+ ]
+ },
+ {
+ "id": "cordova-plugin-file-opener2.FileOpener2",
+ "file": "plugins/cordova-plugin-file-opener2/www/plugins.FileOpener2.js",
+ "pluginId": "cordova-plugin-file-opener2",
+ "clobbers": [
+ "cordova.plugins.fileOpener2"
+ ]
}
];
module.exports.metadata =
// TOP OF METADATA
{
- "cordova-plugin-device": "2.0.2",
+ "cordova-plugin-device": "2.0.3",
"cordova-plugin-background-mode": "0.7.3",
"cordova-plugin-camera": "4.1.0",
"cordova-plugin-file": "6.0.2",
- "cordova-plugin-whitelist": "1.3.3"
+ "cordova-plugin-whitelist": "1.3.4",
+ "es6-promise-plugin": "4.2.2",
+ "cordova-plugin-x-socialsharing": "5.6.8",
+ "cordova-plugin-file-opener2": "3.0.3"
};
// BOTTOM OF METADATA
});
\ No newline at end of file
diff --git a/cordova/platforms/android/platform_www/plugins/cordova-plugin-file-opener2/www/plugins.FileOpener2.js b/cordova/platforms/android/platform_www/plugins/cordova-plugin-file-opener2/www/plugins.FileOpener2.js
new file mode 100644
index 000000000..395c4d973
--- /dev/null
+++ b/cordova/platforms/android/platform_www/plugins/cordova-plugin-file-opener2/www/plugins.FileOpener2.js
@@ -0,0 +1,54 @@
+cordova.define("cordova-plugin-file-opener2.FileOpener2", function(require, exports, module) {
+/*jslint browser: true, devel: true, node: true, sloppy: true, plusplus: true*/
+/*global require, cordova */
+/*
+The MIT License (MIT)
+
+Copyright (c) 2013 pwlin - [email protected]
+
+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.
+*/
+var exec = require('cordova/exec');
+
+function FileOpener2() {}
+
+FileOpener2.prototype.open = function (fileName, contentType, callbackContext) {
+ contentType = contentType || '';
+ callbackContext = callbackContext || {};
+ exec(callbackContext.success || null, callbackContext.error || null, 'FileOpener2', 'open', [fileName, contentType]);
+};
+
+FileOpener2.prototype.showOpenWithDialog = function (fileName, contentType, callbackContext) {
+ contentType = contentType || '';
+ callbackContext = callbackContext || {};
+ exec(callbackContext.success || null, callbackContext.error || null, 'FileOpener2', 'open', [fileName, contentType, false, callbackContext.position || [0, 0]]);
+};
+
+FileOpener2.prototype.uninstall = function (packageId, callbackContext) {
+ callbackContext = callbackContext || {};
+ exec(callbackContext.success || null, callbackContext.error || null, 'FileOpener2', 'uninstall', [packageId]);
+};
+
+FileOpener2.prototype.appIsInstalled = function (packageId, callbackContext) {
+ callbackContext = callbackContext || {};
+ exec(callbackContext.success || null, callbackContext.error || null, 'FileOpener2', 'appIsInstalled', [packageId]);
+};
+
+module.exports = new FileOpener2();
+
+});
diff --git a/cordova/platforms/android/platform_www/plugins/cordova-plugin-x-socialsharing/www/SocialSharing.js b/cordova/platforms/android/platform_www/plugins/cordova-plugin-x-socialsharing/www/SocialSharing.js
new file mode 100644
index 000000000..d16bfdc1c
--- /dev/null
+++ b/cordova/platforms/android/platform_www/plugins/cordova-plugin-x-socialsharing/www/SocialSharing.js
@@ -0,0 +1,160 @@
+cordova.define("cordova-plugin-x-socialsharing.SocialSharing", function(require, exports, module) {
+function SocialSharing() {
+}
+
+// Override this method (after deviceready) to set the location where you want the iPad popup arrow to appear.
+// If not overridden with different values, the popup is not used. Example:
+//
+// window.plugins.socialsharing.iPadPopupCoordinates = function() {
+// return "100,100,200,300";
+// };
+SocialSharing.prototype.iPadPopupCoordinates = function () {
+ // left,top,width,height
+ return "-1,-1,-1,-1";
+};
+
+SocialSharing.prototype.setIPadPopupCoordinates = function (coords) {
+ console.log("Deprecated - setIPadPopupCoordinates no longer works since plugin version 5.5.0. See https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin/issues/1052");
+ // left,top,width,height
+ cordova.exec(function() {}, this._getErrorCallback(function() {}, "setIPadPopupCoordinates"), "SocialSharing", "setIPadPopupCoordinates", [coords]);
+};
+
+SocialSharing.prototype.available = function (callback) {
+ cordova.exec(function (avail) {
+ callback(avail ? true : false);
+ }, null, "SocialSharing", "available", []);
+};
+
+// this is the recommended way to share as it is the most feature-rich with respect to what you pass in and get back
+SocialSharing.prototype.shareWithOptions = function (options, successCallback, errorCallback) {
+ 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,
+ iPadCoordinates: sharedata.iPadCoordinates || undefined
+ };
+ 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, iPadCoordinates, successCallback, errorCallback) {
+ if (typeof iPadCoordinates === 'function') {
+ errorCallback = successCallback;
+ successCallback = iPadCoordinates;
+ iPadCoordinates = "";
+ }
+ cordova.exec(successCallback, this._getErrorCallback(errorCallback, "share"), "SocialSharing", "share", [message, subject, this._asArray(fileOrFileArray), url, iPadCoordinates]);
+};
+
+SocialSharing.prototype.shareViaTwitter = function (message, file /* multiple not allowed by twitter */, url, successCallback, errorCallback) {
+ var fileArray = this._asArray(file);
+ var ecb = this._getErrorCallback(errorCallback, "shareViaTwitter");
+ if (fileArray.length > 1) {
+ ecb("shareViaTwitter supports max one file");
+ } else {
+ cordova.exec(successCallback, ecb, "SocialSharing", "shareViaTwitter", [message, null, fileArray, url]);
+ }
+};
+
+SocialSharing.prototype.shareViaFacebook = function (message, fileOrFileArray, url, successCallback, errorCallback) {
+ cordova.exec(successCallback, this._getErrorCallback(errorCallback, "shareViaFacebook"), "SocialSharing", "shareViaFacebook", [message, null, this._asArray(fileOrFileArray), url]);
+};
+
+SocialSharing.prototype.shareViaFacebookWithPasteMessageHint = function (message, fileOrFileArray, url, pasteMessageHint, successCallback, errorCallback) {
+ pasteMessageHint = pasteMessageHint || "If you like you can paste a message from your clipboard";
+ cordova.exec(successCallback, this._getErrorCallback(errorCallback, "shareViaFacebookWithPasteMessageHint"), "SocialSharing", "shareViaFacebookWithPasteMessageHint", [message, null, this._asArray(fileOrFileArray), url, pasteMessageHint]);
+};
+
+SocialSharing.prototype.shareViaWhatsApp = function (message, fileOrFileArray, url, successCallback, errorCallback) {
+ cordova.exec(successCallback, this._getErrorCallback(errorCallback, "shareViaWhatsApp"), "SocialSharing", "shareViaWhatsApp", [message, null, this._asArray(fileOrFileArray), url, null, null]);
+};
+
+SocialSharing.prototype.shareViaWhatsAppToReceiver = function (receiver, message, fileOrFileArray, url, successCallback, errorCallback) {
+ cordova.exec(successCallback, this._getErrorCallback(errorCallback, "shareViaWhatsAppToReceiver"), "SocialSharing", "shareViaWhatsApp", [message, null, this._asArray(fileOrFileArray), url, receiver, null]);
+};
+
+SocialSharing.prototype.shareViaWhatsAppToPhone = function (phone, message, fileOrFileArray, url, successCallback, errorCallback) {
+ cordova.exec(successCallback, this._getErrorCallback(errorCallback, "shareViaWhatsAppToPhone"), "SocialSharing", "shareViaWhatsApp", [message, null, this._asArray(fileOrFileArray), url, null, phone]);
+};
+
+SocialSharing.prototype.shareViaSMS = function (options, phonenumbers, successCallback, errorCallback) {
+ var opts = options;
+ if (typeof options === "string") {
+ opts = {"message":options}; // for backward compatibility as the options param used to be the message
+ }
+ cordova.exec(successCallback, this._getErrorCallback(errorCallback, "shareViaSMS"), "SocialSharing", "shareViaSMS", [opts, phonenumbers]);
+};
+
+SocialSharing.prototype.shareViaEmail = function (message, subject, toArray, ccArray, bccArray, fileOrFileArray, successCallback, errorCallback) {
+ cordova.exec(successCallback, this._getErrorCallback(errorCallback, "shareViaEmail"), "SocialSharing", "shareViaEmail", [message, subject, this._asArray(toArray), this._asArray(ccArray), this._asArray(bccArray), this._asArray(fileOrFileArray)]);
+};
+
+SocialSharing.prototype.canShareVia = function (via, message, subject, fileOrFileArray, url, successCallback, errorCallback) {
+ cordova.exec(successCallback, this._getErrorCallback(errorCallback, "canShareVia"), "SocialSharing", "canShareVia", [message, subject, this._asArray(fileOrFileArray), url, via]);
+};
+
+SocialSharing.prototype.canShareViaEmail = function (successCallback, errorCallback) {
+ cordova.exec(successCallback, this._getErrorCallback(errorCallback, "canShareViaEmail"), "SocialSharing", "canShareViaEmail", []);
+};
+
+SocialSharing.prototype.shareViaInstagram = function (message, fileOrFileArray, successCallback, errorCallback) {
+ cordova.exec(successCallback, this._getErrorCallback(errorCallback, "shareViaInstagram"), "SocialSharing", "shareViaInstagram", [message, null, this._asArray(fileOrFileArray), null]);
+};
+
+SocialSharing.prototype.shareVia = function (via, message, subject, fileOrFileArray, url, successCallback, errorCallback) {
+ cordova.exec(successCallback, this._getErrorCallback(errorCallback, "shareVia"), "SocialSharing", "shareVia", [message, subject, this._asArray(fileOrFileArray), url, via]);
+};
+
+SocialSharing.prototype.saveToPhotoAlbum = function (fileOrFileArray, successCallback, errorCallback) {
+ cordova.exec(successCallback, this._getErrorCallback(errorCallback, "saveToPhotoAlbum"), "SocialSharing", "saveToPhotoAlbum", [this._asArray(fileOrFileArray)]);
+};
+
+SocialSharing.prototype._asArray = function (param) {
+ if (param == null) {
+ param = [];
+ } else if (typeof param === 'string') {
+ param = new Array(param);
+ }
+ return param;
+};
+
+SocialSharing.prototype._getErrorCallback = function (ecb, functionName) {
+ if (typeof ecb === 'function') {
+ return ecb;
+ } else {
+ return function (result) {
+ console.log("The injected error callback of '" + functionName + "' received: " + JSON.stringify(result));
+ }
+ }
+};
+
+SocialSharing.install = function () {
+ if (!window.plugins) {
+ window.plugins = {};
+ }
+
+ window.plugins.socialsharing = new SocialSharing();
+
+ // Note only polyfill navigator.share if it is not defined, since shareW3C implements L1 of the spec,
+ // and an existing navigator.share method could implement L2.
+ if (!navigator.share) {
+ navigator.share = window.plugins.socialsharing.shareW3C;
+ }
+
+ return window.plugins.socialsharing;
+};
+
+cordova.addConstructor(SocialSharing.install);
+
+});
diff --git a/cordova/platforms/android/platform_www/plugins/es6-promise-plugin/www/promise.js b/cordova/platforms/android/platform_www/plugins/es6-promise-plugin/www/promise.js
new file mode 100644
index 000000000..6cce47ae8
--- /dev/null
+++ b/cordova/platforms/android/platform_www/plugins/es6-promise-plugin/www/promise.js
@@ -0,0 +1,13 @@
+cordova.define("es6-promise-plugin.Promise", function(require, exports, module) {
+/*!
+ * @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;u<r.length;u++)o(r[u]);return o}({1:[function(t){void 0===window.Promise&&t("es6-promise").polyfill()},{"es6-promise":2}],2:[function(t,e,n){(function(r,o){!function(t,r){"object"==typeof n&&"undefined"!=typeof e?e.exports=r():"function"==typeof define&&define.amd?define(r):t.ES6Promise=r()}(this,function(){"use strict";function e(t){var e=typeof t;return null!==t&&("object"===e||"function"===e)}function n(t){return"function"==typeof t}function i(t){J=t}function u(t){Q=t}function s(){return function(){return r.nextTick(h)}}function c(){return"undefined"!=typeof I?function(){I(h)}:l()}function f(){var t=0,e=new X(h),n=document.createTextNode("");return e.observe(n,{characterData:!0}),function(){n.data=t=++t%2}}function a(){var t=new MessageChannel;return t.port1.onmessage=h,function(){return t.port2.postMessage(0)}}function l(){var t=setTimeout;return function(){return t(h,1)}}function h(){for(var t=0;H>t;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;u<e.length;u+=3)r=e[u],o=e[u+n],r?L(n,r,o,i):o(i);t._subscribers.length=0}}function P(){this.error=null}function C(t,e){try{return t(e)}catch(n){return se.error=n,se}}function L(t,e,r,o){var i=n(r),u=void 0,s=void 0,c=void 0,f=void 0;if(i){if(u=C(r,o),u===se?(f=!0,s=u.error,u.error=null):c=!0,e===u)return x(e,_()),void 0}else u=o,c=!0;e._state!==re||(i&&c?E(e,u):f?x(e,s):t===oe?j(e,u):t===ie&&x(e,u))}function k(t,e){try{e(function(e){E(t,e)},function(e){x(t,e)})}catch(n){x(t,n)}}function q(){return ce++}function D(t){t[ne]=ce++,t._state=void 0,t._result=void 0,t._subscribers=[]}function F(){return new Error("Array Methods must be provided an Array")}function F(){return new Error("Array Methods must be provided an Array")}function N(t){return new fe(this,t).promise}function U(t){var e=this;return G(t)?new e(function(n,r){for(var o=t.length,i=0;o>i;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&&e<t.length;e++)this._eachEntry(t[e],e)},t.prototype._eachEntry=function(t,e){var n=this._instanceConstructor,r=n.resolve;if(r===v){var o=w(t);if(o===d&&t._state!==re)this._settledAt(t._state,e,t._result);else if("function"!=typeof o)this._remaining--,this._result[e]=t;else if(n===ae){var i=new n(y);A(i,t,o),this._willSettleAt(i,e)}else this._willSettleAt(new n(function(e){return e(t)}),e)}else this._willSettleAt(r(t),e)},t.prototype._settledAt=function(t,e,n){var r=this.promise;r._state===re&&(this._remaining--,t===ie?x(r,n):this._result[e]=n),0===this._remaining&&j(r,this._result)},t.prototype._willSettleAt=function(t,e){var n=this;O(t,void 0,function(t){return n._settledAt(oe,e,t)},function(t){return n._settledAt(ie,e,t)})},t}(),ae=function(){function t(e){this[ne]=q(),this._result=this._state=void 0,this._subscribers=[],y!==e&&("function"!=typeof e&&K(),this instanceof t?k(this,e):W())}return t.prototype.catch=function(t){return this.then(null,t)},t.prototype.finally=function(t){var e=this,n=e.constructor;return e.then(function(e){return n.resolve(t()).then(function(){return e})},function(e){return n.resolve(t()).then(function(){throw e})})},t}();return ae.prototype.then=d,ae.all=N,ae.race=U,ae.resolve=v,ae.reject=Y,ae._setScheduler=i,ae._setAsap=u,ae._asap=Q,ae.polyfill=z,ae.Promise=ae,ae})}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:3}],3:[function(t,e){function n(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}function o(t){if(a===setTimeout)return setTimeout(t,0);if((a===n||!a)&&setTimeout)return a=setTimeout,setTimeout(t,0);try{return a(t,0)}catch(e){try{return a.call(null,t,0)}catch(e){return a.call(this,t,0)}}}function i(t){if(l===clearTimeout)return clearTimeout(t);if((l===r||!l)&&clearTimeout)return l=clearTimeout,clearTimeout(t);try{return l(t)}catch(e){try{return l.call(null,t)}catch(e){return l.call(this,t)}}}function u(){v&&p&&(v=!1,p.length?d=p.concat(d):y=-1,d.length&&s())}function s(){if(!v){var t=o(u);v=!0;for(var e=d.length;e;){for(p=d,d=[];++y<e;)p&&p[y].run();y=-1,e=d.length}p=null,v=!1,i(t)}}function c(t,e){this.fun=t,this.array=e}function f(){}var a,l,h=e.exports={};!function(){try{a="function"==typeof setTimeout?setTimeout:n}catch(t){a=n}try{l="function"==typeof clearTimeout?clearTimeout:r}catch(t){l=r}}();var p,d=[],v=!1,y=-1;h.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];d.push(new c(t,e)),1!==d.length||v||o(s)},c.prototype.run=function(){this.fun.apply(null,this.array)},h.title="browser",h.browser=!0,h.env={},h.argv=[],h.version="",h.versions={},h.on=f,h.addListener=f,h.once=f,h.off=f,h.removeListener=f,h.removeAllListeners=f,h.emit=f,h.prependListener=f,h.prependOnceListener=f,h.listeners=function(){return[]},h.binding=function(){throw new Error("process.binding is not supported")},h.cwd=function(){return"/"},h.chdir=function(){throw new Error("process.chdir is not supported")},h.umask=function(){return 0}},{}]},{},[1]);
+
+
+});
diff --git a/cordova/platforms/android/project.properties b/cordova/platforms/android/project.properties
index 93943886f..e8b2fb139 100644
--- a/cordova/platforms/android/project.properties
+++ b/cordova/platforms/android/project.properties
@@ -11,4 +11,5 @@
target=android-27
android.library.reference.1=CordovaLib
android.library.reference.2=app
-cordova.system.library.1=com.android.support:support-v4:27.+
\ No newline at end of file
+cordova.system.library.1=com.android.support:support-v4:27.+
+cordova.system.library.2=com.android.support:support-v4:27.+
\ No newline at end of file
diff --git a/cordova/yarn.lock b/cordova/yarn.lock
index dacfa5a0b..92d5365d1 100644
--- a/cordova/yarn.lock
+++ b/cordova/yarn.lock
@@ -112,6 +112,11 @@ cordova-plugin-device@^2.0.3:
resolved "https://registry.yarnpkg.com/cordova-plugin-device/-/cordova-plugin-device-2.0.3.tgz#c2b41b7efd0455dd097f89356d85bfdd5dadeb0f"
integrity sha512-Jb3V72btxf3XHpkPQsGdyc8N6tVBYn1vsxSFj43fIz9vonJDUThYPCJJHqk6PX6N4dJw6I4FjxkpfCR4LDYMlw==
+cordova-plugin-file-opener2@^3.0.3:
+ version "3.0.3"
+ resolved "https://registry.yarnpkg.com/cordova-plugin-file-opener2/-/cordova-plugin-file-opener2-3.0.3.tgz#921d49f319934abfd6156390f6d0e034e1ac97a6"
+ integrity sha512-hIEwntib8fTGlLyVFhRUsrk2SueVJtLPSfqvMrbgaRUCKY2AFNYPtsGiu5oCBKXSe+9Xxh6nIdLKdqGzaOnGAQ==
+
version "6.0.2"
resolved "https://registry.yarnpkg.com/cordova-plugin-file/-/cordova-plugin-file-6.0.2.tgz#f3911479f8357e9aacb5576674f8d95b31a1fb20"
@@ -122,6 +127,11 @@ cordova-plugin-whitelist@^1.3.4:
resolved "https://registry.yarnpkg.com/cordova-plugin-whitelist/-/cordova-plugin-whitelist-1.3.4.tgz#31938545c7c3e7de35c20ab08c2c3afa06e8a3f9"
integrity sha512-EYC5eQFVkoYXq39l7tYKE6lEjHJ04mvTmKXxGL7quHLdFPfJMNzru/UYpn92AOfpl3PQaZmou78C7EgmFOwFQQ==
+cordova-plugin-x-socialsharing@^5.6.8:
+ version "5.6.8"
+ resolved "https://registry.yarnpkg.com/cordova-plugin-x-socialsharing/-/cordova-plugin-x-socialsharing-5.6.8.tgz#81993336fa4260eb76a23ed1680cd63e1c72b040"
+ integrity sha512-R31ZQq00YNzLBwUM4VTE/uKhh/T0GEMuz/MZOw/Pu5AYIAAQkd7EMqFVhMtKs7wfHl1koiRz8+6nLDb19r2tBQ==
+
cordova-registry-mapper@^1.1.8:
version "1.1.15"
resolved "https://registry.yarnpkg.com/cordova-registry-mapper/-/cordova-registry-mapper-1.1.15.tgz#e244b9185b8175473bff6079324905115f83dc7c"
@@ -134,6 +144,11 @@ [email protected]:
dependencies:
sax "0.3.5"
+es6-promise-plugin@^4.2.2:
+ version "4.2.2"
+ resolved "https://registry.yarnpkg.com/es6-promise-plugin/-/es6-promise-plugin-4.2.2.tgz#cfa0cc1383d91f999a62a2bbf4bd97bec305e0ac"
+ integrity sha512-uoA4aVplXI9oqUYJFBAVRwAqIN9/n9JgrTAUGX3qPbnSZVE5yY1+6/MsoN5f4xsaPO62WjPHOdtts6okMN6tNA==
+
[email protected], glob@^5.0.13:
version "5.0.15"
resolved "https://registry.yarnpkg.com/glob/-/glob-5.0.15.tgz#1bc936b9e02f4a603fcc222ecf7633d30b8b93b1"