forked from j3k0/cordova-plugin-openwith
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
1,107 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"extends": "standard", | ||
"plugins": [ | ||
"standard", | ||
"mocha", | ||
"promise" | ||
], | ||
"rules": { | ||
"mocha/no-exclusive-tests": "error" | ||
}, | ||
"env": { | ||
"browser": true, | ||
"node": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/sh | ||
|
||
# Version of PMD to install | ||
VERSION=5.8.1 | ||
|
||
set -e | ||
COPYWD="$PWD" | ||
cd "`dirname $0`" | ||
INSTALL_DIR=$PWD/node_modules/pmd-bin-$VERSION | ||
BIN_DIR=$PWD/node_modules/.bin | ||
|
||
if test -e $INSTALL_DIR; then | ||
# echo "PMD version $VERSION is already installed" | ||
exit 0 | ||
fi | ||
|
||
echo "Intalling PMD version $VERSION into node_modules" | ||
|
||
curl -OL https://github.com/pmd/pmd/releases/download/pmd_releases%2F$VERSION/pmd-bin-$VERSION.zip | ||
unzip pmd-bin-$VERSION.zip | ||
rm -f pmd-bin-$VERSION.zip | ||
|
||
mkdir -p node_modules | ||
mv pmd-bin-$VERSION > $INSTALL_DIR | ||
|
||
cat << EOF > $BIN_DIR/pmd | ||
#!/bin/sh | ||
echo | ||
$INSTALL_DIR/bin/run.sh pmd "\$@" | ||
EOF | ||
chmod +x $BIN_DIR/pmd | ||
|
||
cat << EOF > $INSTALL_DIR/package.json | ||
{ | ||
"name": "pdm", | ||
"version": "$VERSION" | ||
} | ||
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{ | ||
"name": "cc.fovea.cordova.openwith", | ||
"version": "1.0.0", | ||
"description": "Cordova \"Open With\" plugin for iOS and Android", | ||
"cordova": { | ||
"id": "cc.fovea.cordova.openwith", | ||
"platforms": [ | ||
"android", | ||
"ios" | ||
] | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/j3k0/cordova-plugin-openwith.git" | ||
}, | ||
"keywords": [ | ||
"ecosystem:cordova", | ||
"cordova-android", | ||
"cordova-ios", | ||
"cordova", | ||
"phonegap", | ||
"openwith", | ||
"ios", | ||
"android" | ||
], | ||
"scripts": { | ||
"test": "npm run js-lint && npm run js-test && npm run java-lint", | ||
"install-dev": "./install-pmd", | ||
"java-lint": "pmd -minimumpriority 3 -d src/android -R java-basic,java-android,java-braces,java-codesize,java-empty,java-finalizers,java-imports,java-naming,java-optimizations,java-strictexception,java-strings,java-sunsecure,java-typeresolution,java-unnecessary,java-unusedcode -f textcolor", | ||
"js-lint": "eslint www", | ||
"js-test": "mocha www", | ||
"js-lint-watch": "esw --watch www", | ||
"js-test-watch": "mocha --watch www" | ||
}, | ||
"author": "Jean-Christophe Hoelt <[email protected]>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/j3k0/cordova-plugin-openwith/issues" | ||
}, | ||
"homepage": "https://github.com/j3k0/cordova-plugin-openwith", | ||
"devDependencies": { | ||
"eslint": "^4.7.2", | ||
"eslint-config-standard": "^10.2.1", | ||
"eslint-plugin-import": "^2.7.0", | ||
"eslint-plugin-mocha": "^4.11.0", | ||
"eslint-plugin-node": "^5.1.1", | ||
"eslint-plugin-promise": "^3.5.0", | ||
"eslint-plugin-standard": "^3.0.1", | ||
"eslint-watch": "^3.1.2", | ||
"expect.js": "^0.3.1", | ||
"mocha": "^3.5.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
The MIT License (MIT) | ||
Copyright (c) 2013-2015 Jean-Christophe Hoelt | ||
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. | ||
--> | ||
|
||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
id="cc.fovea.cordova.openwith" | ||
version="1.0.0"> | ||
|
||
<name>Open With</name> | ||
<description>Cordova "Open With" plugin for iOS and Android</description> | ||
<engines> | ||
<engine name="cordova" version=">=2.4.0" /> | ||
</engines> | ||
<repo>https://github.com/j3k0/cordova-plugin-openwith.git</repo> | ||
<issue>https://github.com/j3k0/cordova-plugin-openwith/issues</issue> | ||
|
||
<license>MIT</license> | ||
<keywords>cordova,phonegap,openwith,ios,android</keywords> | ||
|
||
<!-- ios --> | ||
<platform name="ios"> | ||
<js-module src="www/openwith.js" name="openwith"> | ||
<clobbers target="cordova.openwith" /> | ||
</js-module> | ||
|
||
<!-- Cordova 2.2 --> | ||
<plugins-plist key="OpenWith" string="OpenWith" /> | ||
|
||
<!-- Cordova 2.5+ --> | ||
<config-file target="config.xml" parent="/*"> | ||
<feature name="OpenWith"> | ||
<param name="ios-package" value="OpenWith"/> | ||
</feature> | ||
</config-file> | ||
|
||
<header-file src="src/ios/OpenWith.h" /> | ||
<source-file src="src/ios/OpenWith.m" /> | ||
</platform> | ||
|
||
<!-- android --> | ||
<platform name="android"> | ||
<preference name="MIME_TYPE" /> | ||
|
||
<js-module src="www/openwith.js" name="openwith"> | ||
<clobbers target="cordova.openwith" /> | ||
</js-module> | ||
|
||
<config-file target="AndroidManifest.xml" parent="/manifest/application/activity"> | ||
<!-- Open With --> | ||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> | ||
<!-- See https://developer.android.com/guide/topics/manifest/data-element.html --> | ||
<intent-filter> | ||
<!-- action android:name="android.intent.action.VIEW" / --> | ||
<!-- category android:name="android.intent.category.BROWSABLE" / --> | ||
<!-- action android:name="android.intent.action.SEND_MULTIPLE" / --> | ||
<action android:name="android.intent.action.SEND" /> | ||
<category android:name="android.intent.category.DEFAULT" /> | ||
<data android:mimeType="$MIME_TYPE" /> | ||
</intent-filter> | ||
</config-file> | ||
|
||
<!-- Cordova >= 3.0.0 --> | ||
<config-file target="res/xml/config.xml" parent="/*"> | ||
<feature name="OpenWithPlugin"> | ||
<param name="android-package" value="cc.fovea.openwith.OpenWithPlugin"/> | ||
</feature> | ||
<preference name="AndroidLaunchMode" value="singleTask"/> | ||
</config-file> | ||
|
||
<!-- cordova plugin src files --> | ||
<source-file src="src/android/cc/fovea/openwith/OpenWithPlugin.java" target-dir="src/cc/fovea/openwith" /> | ||
<source-file src="src/android/cc/fovea/openwith/PluginResultSender.java" target-dir="src/cc/fovea/openwith" /> | ||
<source-file src="src/android/cc/fovea/openwith/Serializer.java" target-dir="src/cc/fovea/openwith" /> | ||
<source-file src="src/android/cc/fovea/openwith/ByteStreams.java" target-dir="src/cc/fovea/openwith" /> | ||
</platform> | ||
|
||
<!-- | ||
vim: ts=4:sw=4:et | ||
--> | ||
</plugin> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
NODE_VERSION=v6 | ||
|
||
nvm ls $NODE_VERSION || nvm install $NODE_VERSION | ||
nvm use $NODE_VERSION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
package cc.fovea.openwith; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.OutputStream; | ||
import java.nio.ByteBuffer; | ||
|
||
/** | ||
* Convert an InputStream to a byte array. | ||
* | ||
* Sourced from Google guava classes. | ||
*/ | ||
@SuppressWarnings("PMD.ShortVariable") | ||
@SuppressWarnings("PMD.AvoidThrowingNullPointerException") | ||
public final class ByteStreams { | ||
|
||
/** Throws if the argument is null. */ | ||
public static <T> T checkNotNull(final T reference) { | ||
if (reference == null) { | ||
throw new NullPointerException(); | ||
} | ||
return reference; | ||
} | ||
|
||
/** Throws if the argument is false. */ | ||
public static void checkArgument(final boolean expression) { | ||
if (!expression) { | ||
throw new IllegalArgumentException(); | ||
} | ||
} | ||
|
||
/** Throws if the index isn't in [0..size]. */ | ||
public static int checkPositionIndex(final int index, final int size) { | ||
// Carefully optimized for execution by hotspot (explanatory comment above) | ||
if (index < 0 || index > size) { | ||
throw new IndexOutOfBoundsException("invalid index"); | ||
} | ||
return index; | ||
} | ||
|
||
/** | ||
* Creates a new byte array for buffering reads or writes. | ||
*/ | ||
static byte[] createBuffer() { | ||
return new byte[8192]; | ||
} | ||
|
||
private ByteStreams() {} | ||
|
||
/** | ||
* Copies all bytes from the input stream to the output stream. Does not close or flush either | ||
* stream. | ||
* | ||
* @param from the input stream to read from | ||
* @param to the output stream to write to | ||
* @return the number of bytes copied | ||
* @throws IOException if an I/O error occurs | ||
*/ | ||
public static long copy( | ||
final InputStream from, | ||
final OutputStream to) | ||
throws IOException { | ||
checkNotNull(from); | ||
checkNotNull(to); | ||
final byte[] buf = createBuffer(); | ||
final long total = 0; | ||
while (true) { | ||
final int r = from.read(buf); | ||
if (r == -1) { | ||
break; | ||
} | ||
to.write(buf, 0, r); | ||
total += r; | ||
} | ||
return total; | ||
} | ||
|
||
/** | ||
* Reads all bytes from an input stream into a byte array. Does not close the stream. | ||
* | ||
* @param in the input stream to read from | ||
* @return a byte array containing all the bytes from the stream | ||
* @throws IOException if an I/O error occurs | ||
*/ | ||
public static byte[] toByteArray(final InputStream in) throws IOException { | ||
// Presize the ByteArrayOutputStream since we know how large it will need | ||
// to be, unless that value is less than the default ByteArrayOutputStream | ||
// size (32). | ||
final ByteArrayOutputStream out = new ByteArrayOutputStream( | ||
Math.max(32, in.available())); | ||
copy(in, out); | ||
return out.toByteArray(); | ||
} | ||
} | ||
// vim: ts=4:sw=4:et |
Oops, something went wrong.