Skip to content

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

Tsn579 registrer android app for opening certain files types (#1332)

Stanimir84eea3ebce70
diff --git a/app/services/cordova-io.ts b/app/services/cordova-io.ts
index 85f57cfb9..0ef799524 100644
--- a/app/services/cordova-io.ts
+++ b/app/services/cordova-io.ts
@@ -45,7 +45,7 @@ export default class CordovaIO {
fsRoot;
urlFromIntent;
- widgetAction;
+ // widgetAction;
loadedSettings: any;
loadedSettingsTags: any;
@@ -85,7 +85,37 @@ export default class CordovaIO {
window.plugins.fileOpener = cordova.plugins.fileOpener2;
}
- if (window.plugins.webintent) {
+ window.plugins.intentShim.onIntent(function(intent) {
+ /**
+ * intent:
+ action: "android.intent.action.VIEW"
+ component: "ComponentInfo{org.tagspaces.mobile/org.tagspaces.mobile.MainActivity}"
+ data: "file:///storage/emulated/0/Download/%D0%B4%D0%B5%D0%BA%D0%BB%D0%B0%D1%80%D0%B0%D1%86%D0%B8%D1%8F%20%D0%B7%D0%B0%20%D1%86%D0%BB%D1%80.pdf"
+ flags: 306184195
+ type: "application/pdf"
+ */
+ console.debug('Received Intent: ' + JSON.stringify(intent));
+ const protocol = window.location.protocol,
+ host = '//' + window.location.host,
+ path = window.location.pathname;
+ // query = window.location.search;
+
+ const newUrl =
+ protocol +
+ host +
+ path +
+ // query +
+ // (query ? '&' : '?') +
+ '?cmdopen=' +
+ intent.data.replace('file:///storage/emulated/0', 'file:///sdcard');
+ // encodeURIComponent(intent.data);
+
+ // window.history.pushState({ path: newUrl }, '', newUrl);
+ // TODO use event
+ window.location.replace(newUrl);
+ });
+
+ /* if (window.plugins.webintent) {
window.plugins.webintent.getUri(
url => {
if (url) {
@@ -96,15 +126,12 @@ export default class CordovaIO {
}
}
}
- // , function(error) {
- // showAlertDialog("WebIntent Error: " + error);
- // }
);
window.plugins.webintent.onNewIntent(url => {
this.widgetAction = url;
this.widgetActionHandler();
});
- }
+ } */
if (AppConfig.isCordovaiOS) {
setTimeout(() => {
@@ -151,8 +178,8 @@ export default class CordovaIO {
// TODO: reload curtent dir after background operation
};
- widgetActionHandler = () => {
- /* if (currentPath === null) {
+ // widgetActionHandler = () => {
+ /* if (currentPath === null) {
showAlertDialog('Please set location folder to use widget');
return;
}
@@ -168,12 +195,12 @@ export default class CordovaIO {
}
widgetAction = undefined; */
- };
+ // };
onApplicationLoad = () => {
- if (this.widgetAction) {
+ /* if (this.widgetAction) {
this.widgetActionHandler();
- }
+ } */
};
getFileSystemPromise = (localPath: string): Promise<any> => {
diff --git a/app/utils/misc.ts b/app/utils/misc.ts
index c26724998..2cbbc2eec 100644
--- a/app/utils/misc.ts
+++ b/app/utils/misc.ts
@@ -159,37 +159,39 @@ export function updateHistory(
currentDirectory: string,
entryPath?: string
) {
- // const isCloudLocation = currentLocation.type === locationType.TYPE_CLOUD;
- let urlParams = '?';
- let currentLocationPath = '';
- const isCloudLocation = currentLocation.type === locationType.TYPE_CLOUD;
+ if (currentLocation) {
+ // const isCloudLocation = currentLocation.type === locationType.TYPE_CLOUD;
+ let urlParams = '?';
+ let currentLocationPath = '';
+ const isCloudLocation = currentLocation.type === locationType.TYPE_CLOUD;
+
+ if (currentLocation && currentLocation.uuid) {
+ urlParams += 'tslid=' + encodeURIComponent(currentLocation.uuid);
+ currentLocationPath = getLocationPath(currentLocation);
+ }
- if (currentLocation && currentLocation.uuid) {
- urlParams += 'tslid=' + encodeURIComponent(currentLocation.uuid);
- currentLocationPath = getLocationPath(currentLocation);
- }
+ if (currentDirectory && currentDirectory.length > 0) {
+ const currentDir = isCloudLocation
+ ? currentDirectory
+ : currentDirectory.replace(currentLocationPath, '');
+ urlParams += '&tsdpath=' + encodeURIComponent(currentDir);
+ }
- if (currentDirectory && currentDirectory.length > 0) {
- const currentDir = isCloudLocation
- ? currentDirectory
- : currentDirectory.replace(currentLocationPath, '');
- urlParams += '&tsdpath=' + encodeURIComponent(currentDir);
- }
+ if (entryPath && entryPath.length > 0) {
+ const ePath = isCloudLocation
+ ? entryPath
+ : entryPath.replace(currentLocationPath, '');
+ urlParams += '&tsepath=' + encodeURIComponent(ePath);
+ }
- if (entryPath && entryPath.length > 0) {
- const ePath = isCloudLocation
- ? entryPath
- : entryPath.replace(currentLocationPath, '');
- urlParams += '&tsepath=' + encodeURIComponent(ePath);
- }
+ const localePar = getURLParameter('locale');
+ if (localePar && localePar.length > 1) {
+ urlParams += '&locale=' + localePar;
+ }
- const localePar = getURLParameter('locale');
- if (localePar && localePar.length > 1) {
- urlParams += '&locale=' + localePar;
+ window.history.pushState('', document.title, urlParams);
+ // console.log(window.location.href);
}
-
- window.history.pushState('', document.title, urlParams);
- // console.log(window.location.href);
}
export function dataURLtoBlob(dataURI) {
diff --git a/cordova/config.xml b/cordova/config.xml
index bce79887f..5ee7e2b02 100644
--- a/cordova/config.xml
+++ b/cordova/config.xml
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
-<widget id="org.tagspaces.mobile" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
+<widget id="org.tagspaces.mobile" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<name>TagSpaces</name>
<description>
Offline file organizer and browser with tagging support.
@@ -25,6 +25,36 @@
<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" />
+ <config-file platform="android" parent="/manifest/application/activity" target="AndroidManifest.xml" mode="merge">
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+ <data android:mimeType="application/pdf" android:scheme="file" />
+ <data android:mimeType="text/plain" android:scheme="file" />
+ <data android:mimeType="image/x-windows-bmp" android:scheme="file" />
+ <data android:mimeType="image/gif" android:scheme="file" />
+ <data android:mimeType="image/png" android:scheme="file" />
+ <data android:mimeType="image/jpeg" android:scheme="file" />
+ <data android:mimeType="image/webp" android:scheme="file" />
+ <data android:mimeType="video/webm" android:scheme="file" />
+ <data android:mimeType="video/ogg" android:scheme="file" />
+ <data android:mimeType="text/html" android:scheme="file" />
+ <data android:mimeType="application/json" android:scheme="file" />
+ </intent-filter>
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+ <data android:host="*" android:mimeType="*/*" android:pathPattern="..json" android:scheme="file" />
+ <data android:host="*" android:mimeType="*/*" android:pathPattern="..mht" android:scheme="file" />
+ <data android:host="*" android:mimeType="*/*" android:pathPattern="..mhtml" android:scheme="file" />
+ <data android:host="*" android:mimeType="*/*" android:pathPattern="..md" android:scheme="file" />
+ <data android:host="*" android:mimeType="*/*" android:pathPattern="..md.txt" android:scheme="file" />
+ <data android:host="*" android:mimeType="*/*" android:pathPattern="..markdown" android:scheme="file" />
+ <data android:host="*" android:mimeType="*/*" android:pathPattern="..ogv" android:scheme="file" />
+ </intent-filter>
+ </config-file>
</platform>
<platform name="ios">
<!--<preference name="NativeXHRLogging" value="full" />
diff --git a/cordova/package-lock.json b/cordova/package-lock.json
index 3a9c20991..9f7db1fc6 100644
--- a/cordova/package-lock.json
+++ b/cordova/package-lock.json
@@ -16,9 +16,9 @@
"integrity": "sha512-b+MGNyP9/LXkapreJzNUzcvuzZslj/RGgdVVJ16P2wSlYatfLycPObImqVJSmNAdyeShvNeM/pl3sVZsObFueg==",
"dev": true,
"requires": {
- "assert-plus": "1.0.0",
- "extsprintf": "1.4.0",
- "lodash": "4.17.20"
+ "assert-plus": "^1.0.0",
+ "extsprintf": "^1.4.0",
+ "lodash": "^4.17.15"
}
},
"@nodelib/fs.scandir": {
@@ -28,7 +28,7 @@
"dev": true,
"requires": {
"@nodelib/fs.stat": "2.0.3",
- "run-parallel": "1.1.10"
+ "run-parallel": "^1.1.9"
}
},
"@nodelib/fs.stat": {
@@ -44,7 +44,7 @@
"dev": true,
"requires": {
"@nodelib/fs.scandir": "2.1.3",
- "fastq": "1.9.0"
+ "fastq": "^1.6.0"
}
},
"abbrev": {
@@ -59,7 +59,7 @@
"integrity": "sha512-ojC2Ig7b/KJ6iNtR8e4bacmOsJyEkoERk3CKMIsnH7kJz5z6551NMbrVaRb7KXYavu1d74Uhml/bfcmqT3nAcg==",
"dev": true,
"requires": {
- "semver": "5.7.1"
+ "semver": "^5.7.1"
}
},
"ansi": {
@@ -85,10 +85,6 @@
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c="
},
- "bamboo.cordova.plugin.downloader": {
- "version": "git+https://github.com/sytolk/cordova-plugin-downloader.git#9ab2c3ad6c0faf9aefcc32a7870593daab5c69db",
- "dev": true
- },
"base64-js": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
@@ -104,7 +100,7 @@
"resolved": "https://registry.npmjs.org/bplist-creator/-/bplist-creator-0.0.8.tgz",
"integrity": "sha512-Za9JKzD6fjLC16oX2wsXfc+qBEhJBJB1YPInoAQpMLhDuj5aVOv1baGeIQSq1Fr3OCqzvsoQcSBSwGId/Ja2PA==",
"requires": {
- "stream-buffers": "2.2.0"
+ "stream-buffers": "~2.2.0"
}
},
"bplist-parser": {
@@ -112,7 +108,7 @@
"resolved": "https://registry.npmjs.org/bplist-parser/-/bplist-parser-0.2.0.tgz",
"integrity": "sha512-z0M+byMThzQmD9NILRniCUXYsYpjwnlO8N5uCFaCqIOpqRsJCrQL9NK3JsD67CN5a08nF5oIL2bD6loTdHOuKw==",
"requires": {
- "big-integer": "1.6.48"
+ "big-integer": "^1.6.44"
}
},
"brace-expansion": {
@@ -120,7 +116,7 @@
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"requires": {
- "balanced-match": "1.0.0",
+ "balanced-match": "^1.0.0",
"concat-map": "0.0.1"
}
},
@@ -130,9 +126,15 @@
"integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==",
"dev": true,
"requires": {
- "fill-range": "7.0.1"
+ "fill-range": "^7.0.1"
}
},
+ "com-darryncampbell-cordova-plugin-intent": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/com-darryncampbell-cordova-plugin-intent/-/com-darryncampbell-cordova-plugin-intent-2.0.0.tgz",
+ "integrity": "sha512-4f5BAyhpiGVsuouj2cokZCb99RA8V4O5YZnwGMliceFCu35BQcQvC0VLW55jl+xVDLhVymomnaBiHSktKKnK4w==",
+ "dev": true
+ },
"concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
@@ -144,13 +146,13 @@
"integrity": "sha512-2ZEgApK4LPMYW0zh/mLAH3CabzCaKE0yxQTzA2wTf0Eo2HHTJnRtDCf9spGf3nPOkubyXS6+pvzz5QzNHpVTqQ==",
"dev": true,
"requires": {
- "android-versions": "1.6.0",
- "cordova-common": "4.0.2",
- "execa": "4.1.0",
- "fs-extra": "9.0.1",
- "nopt": "4.0.3",
- "properties-parser": "0.3.1",
- "which": "2.0.2"
+ "android-versions": "^1.5.0",
+ "cordova-common": "^4.0.1",
+ "execa": "^4.0.2",
+ "fs-extra": "^9.0.1",
+ "nopt": "^4.0.3",
+ "properties-parser": "^0.3.1",
+ "which": "^2.0.2"
}
},
"cordova-common": {
@@ -159,20 +161,20 @@
"integrity": "sha512-od7aNShyuBajzPY83mUEO8tERwwWdFklXETHiXP5Ft87CWeo/tSuwNPFztyTy8XYc74yXdogXKPTJeUHuVzB8Q==",
"dev": true,
"requires": {
- "@netflix/nerror": "1.1.3",
- "ansi": "0.3.1",
- "bplist-parser": "0.2.0",
- "cross-spawn": "7.0.3",
- "elementtree": "0.1.7",
- "endent": "1.4.1",
- "fast-glob": "3.2.4",
- "fs-extra": "9.0.1",
- "glob": "7.1.6",
- "plist": "3.0.1",
- "q": "1.5.1",
- "read-chunk": "3.2.0",
- "strip-bom": "4.0.0",
- "underscore": "1.12.0"
+ "@netflix/nerror": "^1.1.3",
+ "ansi": "^0.3.1",
+ "bplist-parser": "^0.2.0",
+ "cross-spawn": "^7.0.1",
+ "elementtree": "^0.1.7",
+ "endent": "^1.4.1",
+ "fast-glob": "^3.2.2",
+ "fs-extra": "^9.0.0",
+ "glob": "^7.1.6",
+ "plist": "^3.0.1",
+ "q": "^1.5.1",
+ "read-chunk": "^3.2.0",
+ "strip-bom": "^4.0.0",
+ "underscore": "^1.9.2"
}
},
"cordova-ios": {
@@ -181,16 +183,16 @@
"integrity": "sha512-WHNvjVhkuwRpq95rISVXtcRyd6UGZapbmU+hO/CAn1c0AIT5WnO8mg2mOjv0WDNa0mt/V5P+N2Vig1UWwfxa5Q==",
"dev": true,
"requires": {
- "cordova-common": "4.0.2",
- "fs-extra": "9.0.1",
- "ios-sim": "8.0.2",
- "nopt": "4.0.3",
- "plist": "3.0.1",
- "semver": "7.3.4",
- "unorm": "1.6.0",
- "which": "2.0.2",
- "xcode": "3.0.1",
- "xml-escape": "1.1.0"
+ "cordova-common": "^4.0.2",
+ "fs-extra": "^9.0.0",
+ "ios-sim": "^8.0.2",
+ "nopt": "^4.0.3",
+ "plist": "^3.0.1",
+ "semver": "^7.3.2",
+ "unorm": "^1.6.0",
+ "which": "^2.0.2",
+ "xcode": "^3.0.1",
+ "xml-escape": "^1.1.0"
},
"dependencies": {
"semver": {
@@ -199,23 +201,19 @@
"integrity": "sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==",
"dev": true,
"requires": {
- "lru-cache": "6.0.0"
+ "lru-cache": "^6.0.0"
}
}
}
},
- "cordova-ourcodeworld-filebrowser": {
- "version": "git+https://github.com/ourcodeworld/cordova-ourcodeworld-filebrowser.git#b4824ea23d9e359708207158420b43cd5e816790",
- "dev": true
- },
"cordova-plugin-add-swift-support": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/cordova-plugin-add-swift-support/-/cordova-plugin-add-swift-support-2.0.2.tgz",
"integrity": "sha512-K03WDnsD3GT+n7Od3BnS17D8rYnAFZbZjjQJa2r7qW8QLq8+h7hGbFaiF+w5+nUtyAqUNq+HT/d/MdqBGLNzxA==",
"requires": {
- "glob": "7.1.6",
- "semver": "6.3.0",
- "xcode": "2.1.0"
+ "glob": "^7.1.3",
+ "semver": "^6.0.0",
+ "xcode": "^2.0.0"
},
"dependencies": {
"semver": {
@@ -233,8 +231,8 @@
"resolved": "https://registry.npmjs.org/xcode/-/xcode-2.1.0.tgz",
"integrity": "sha512-uCrmPITrqTEzhn0TtT57fJaNaw8YJs1aCzs+P/QqxsDbvPZSv7XMPPwXrKvHtD6pLjBM/NaVwraWJm8q83Y4iQ==",
"requires": {
- "simple-plist": "1.1.1",
- "uuid": "3.4.0"
+ "simple-plist": "^1.0.0",
+ "uuid": "^3.3.2"
}
}
}
@@ -245,8 +243,8 @@
"integrity": "sha512-W1SImn0cCCvOSTSfWWp5TnanIQrSuh2Bch+dcZXIzEn0km3Qb7VryeAqHhgBQYwwzC5Ollk1DtUAk/AJSojuZA==",
"dev": true,
"requires": {
- "q": "1.5.1",
- "recursive-readdir": "2.2.2"
+ "q": "^1.5.1",
+ "recursive-readdir": "^2.2.2"
}
},
"cordova-plugin-background-mode": {
@@ -280,9 +278,9 @@
"integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==",
"dev": true,
"requires": {
- "path-key": "3.1.1",
- "shebang-command": "2.0.0",
- "which": "2.0.2"
+ "path-key": "^3.1.0",
+ "shebang-command": "^2.0.0",
+ "which": "^2.0.1"
}
},
"dedent": {
@@ -306,7 +304,7 @@
"integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==",
"dev": true,
"requires": {
- "once": "1.4.0"
+ "once": "^1.4.0"
}
},
"endent": {
@@ -315,9 +313,9 @@
"integrity": "sha512-buHTb5c8AC9NshtP6dgmNLYkiT+olskbq1z6cEGvfGCF3Qphbu/1zz5Xu+yjTDln8RbxNhPoUyJ5H8MSrp1olQ==",
"dev": true,
"requires": {
- "dedent": "0.7.0",
- "fast-json-parse": "1.0.3",
- "objectorarray": "1.0.4"
+ "dedent": "^0.7.0",
+ "fast-json-parse": "^1.0.3",
+ "objectorarray": "^1.0.4"
}
},
"es6-promise-plugin": {
@@ -331,15 +329,15 @@
"integrity": "sha512-j5W0//W7f8UxAn8hXVnwG8tLwdiUy4FJLcSupCg6maBYZDpyBvTApK7KyuI4bKj8KOh1r2YH+6ucuYtJv1bTZA==",
"dev": true,
"requires": {
- "cross-spawn": "7.0.3",
- "get-stream": "5.2.0",
- "human-signals": "1.1.1",
- "is-stream": "2.0.0",
- "merge-stream": "2.0.0",
- "npm-run-path": "4.0.1",
- "onetime": "5.1.2",
- "signal-exit": "3.0.3",
- "strip-final-newline": "2.0.0"
+ "cross-spawn": "^7.0.0",
+ "get-stream": "^5.0.0",
+ "human-signals": "^1.1.1",
+ "is-stream": "^2.0.0",
+ "merge-stream": "^2.0.0",
+ "npm-run-path": "^4.0.0",
+ "onetime": "^5.1.0",
+ "signal-exit": "^3.0.2",
+ "strip-final-newline": "^2.0.0"
}
},
"extsprintf": {
@@ -354,12 +352,12 @@
"integrity": "sha512-kr/Oo6PX51265qeuCYsyGypiO5uJFgBS0jksyG7FUeCyQzNwYnzrNIMR1NXfkZXsMYXYLRAHgISHBz8gQcxKHQ==",
"dev": true,
"requires": {
- "@nodelib/fs.stat": "2.0.3",
- "@nodelib/fs.walk": "1.2.4",
- "glob-parent": "5.1.1",
- "merge2": "1.4.1",
- "micromatch": "4.0.2",
- "picomatch": "2.2.2"
+ "@nodelib/fs.stat": "^2.0.2",
+ "@nodelib/fs.walk": "^1.2.3",
+ "glob-parent": "^5.1.0",
+ "merge2": "^1.3.0",
+ "micromatch": "^4.0.2",
+ "picomatch": "^2.2.1"
}
},
"fast-json-parse": {
@@ -374,7 +372,7 @@
"integrity": "sha512-i7FVWL8HhVY+CTkwFxkN2mk3h+787ixS5S63eb78diVRc1MCssarHq3W5cj0av7YDSwmaV928RNag+U1etRQ7w==",
"dev": true,
"requires": {
- "reusify": "1.0.4"
+ "reusify": "^1.0.4"
}
},
"fill-range": {
@@ -383,7 +381,7 @@
"integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==",
"dev": true,
"requires": {
- "to-regex-range": "5.0.1"
+ "to-regex-range": "^5.0.1"
}
},
"fs-extra": {
@@ -392,10 +390,10 @@
"integrity": "sha512-h2iAoN838FqAFJY2/qVpzFXy+EBxfVE220PalAqQLDVsFOHLJrZvut5puAbCdNv6WJk+B8ihI+k0c7JK5erwqQ==",
"dev": true,
"requires": {
- "at-least-node": "1.0.0",
- "graceful-fs": "4.2.4",
- "jsonfile": "6.1.0",
- "universalify": "1.0.0"
+ "at-least-node": "^1.0.0",
+ "graceful-fs": "^4.2.0",
+ "jsonfile": "^6.0.1",
+ "universalify": "^1.0.0"
}
},
"fs.realpath": {
@@ -409,7 +407,7 @@
"integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==",
"dev": true,
"requires": {
- "pump": "3.0.0"
+ "pump": "^3.0.0"
}
},
"glob": {
@@ -417,12 +415,12 @@
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz",
"integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==",
"requires": {
- "fs.realpath": "1.0.0",
- "inflight": "1.0.6",
- "inherits": "2.0.4",
- "minimatch": "3.0.4",
- "once": "1.4.0",
- "path-is-absolute": "1.0.1"
+ "fs.realpath": "^1.0.0",
+ "inflight": "^1.0.4",
+ "inherits": "2",
+ "minimatch": "^3.0.4",
+ "once": "^1.3.0",
+ "path-is-absolute": "^1.0.0"
}
},
"glob-parent": {
@@ -431,7 +429,7 @@
"integrity": "sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ==",
"dev": true,
"requires": {
- "is-glob": "4.0.1"
+ "is-glob": "^4.0.1"
}
},
"graceful-fs": {
@@ -451,8 +449,8 @@
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
"requires": {
- "once": "1.4.0",
- "wrappy": "1.0.2"
+ "once": "^1.3.0",
+ "wrappy": "1"
}
},
"inherits": {
@@ -466,10 +464,10 @@
"integrity": "sha512-P7nEG771bfd+JoMRjnis1gpZOkjTUUxu+4Ek1Z+eoaEEoT9byllU9pxfQ8Df7hL3gSkIQxNwTSLhos2I8tWUQA==",
"dev": true,
"requires": {
- "bplist-parser": "0.0.6",
+ "bplist-parser": "^0.0.6",
"nopt": "1.0.9",
- "plist": "3.0.1",
- "simctl": "2.0.0"
+ "plist": "^3.0.1",
+ "simctl": "^2"
},
"dependencies": {
"bplist-parser": {
@@ -484,7 +482,7 @@
"integrity": "sha1-O8DXy6e/sNWmdtvtfA6+SKT9RU4=",
"dev": true,
"requires": {
- "abbrev": "1.1.1"
+ "abbrev": "1"
}
}
}
@@ -501,7 +499,7 @@
"integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==",
"dev": true,
"requires": {
- "is-extglob": "2.1.1"
+ "is-extglob": "^2.1.1"
}
},
"is-number": {
@@ -528,8 +526,8 @@
"integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==",
"dev": true,
"requires": {
- "graceful-fs": "4.2.4",
- "universalify": "2.0.0"
+ "graceful-fs": "^4.1.6",
+ "universalify": "^2.0.0"
},
"dependencies": {
"universalify": {
@@ -552,7 +550,7 @@
"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
"dev": true,
"requires": {
- "yallist": "4.0.0"
+ "yallist": "^4.0.0"
}
},
"merge-stream": {
@@ -573,8 +571,8 @@
"integrity": "sha512-y7FpHSbMUMoyPbYUSzO6PaZ6FyRnQOpHuKwbo1G+Knck95XVU4QAiKdGEnj5wwoS7PlOgthX/09u5iFJ+aYf5Q==",
"dev": true,
"requires": {
- "braces": "3.0.2",
- "picomatch": "2.2.2"
+ "braces": "^3.0.1",
+ "picomatch": "^2.0.5"
}
},
"mimic-fn": {
@@ -588,7 +586,7 @@
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"requires": {
- "brace-expansion": "1.1.11"
+ "brace-expansion": "^1.1.7"
}
},
"nopt": {
@@ -597,8 +595,8 @@
"integrity": "sha512-CvaGwVMztSMJLOeXPrez7fyfObdZqNUK1cPAEzLHrTybIua9pMdmmPR5YwtfNftIOMv3DPUhFaxsZMNTQO20Kg==",
"dev": true,
"requires": {
- "abbrev": "1.1.1",
- "osenv": "0.1.5"
+ "abbrev": "1",
+ "osenv": "^0.1.4"
}
},
"npm-run-path": {
@@ -607,7 +605,7 @@
"integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==",
"dev": true,
"requires": {
- "path-key": "3.1.1"
+ "path-key": "^3.0.0"
}
},
"objectorarray": {
@@ -621,7 +619,7 @@
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
"requires": {
- "wrappy": "1.0.2"
+ "wrappy": "1"
}
},
"onetime": {
@@ -630,7 +628,7 @@
"integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==",
"dev": true,
"requires": {
- "mimic-fn": "2.1.0"
+ "mimic-fn": "^2.1.0"
}
},
"os-homedir": {
@@ -651,8 +649,8 @@
"integrity": "sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==",
"dev": true,
"requires": {
- "os-homedir": "1.0.2",
- "os-tmpdir": "1.0.2"
+ "os-homedir": "^1.0.0",
+ "os-tmpdir": "^1.0.0"
}
},
"p-finally": {
@@ -695,9 +693,9 @@
"resolved": "https://registry.npmjs.org/plist/-/plist-3.0.1.tgz",
"integrity": "sha512-GpgvHHocGRyQm74b6FWEZZVRroHKE1I0/BTjAmySaohK+cUn+hZpbqXkc3KWgW3gQYkqcQej35FohcT0FRlkRQ==",
"requires": {
- "base64-js": "1.5.1",
- "xmlbuilder": "9.0.7",
- "xmldom": "0.1.31"
+ "base64-js": "^1.2.3",
+ "xmlbuilder": "^9.0.7",
+ "xmldom": "0.1.x"
}
},
"properties-parser": {
@@ -706,7 +704,7 @@
"integrity": "sha1-ExbpU5/7/ZOEXjabIRAiq9R4dxo=",
"dev": true,
"requires": {
- "string.prototype.codepointat": "0.2.1"
+ "string.prototype.codepointat": "^0.2.0"
}
},
"pump": {
@@ -715,8 +713,8 @@
"integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==",
"dev": true,
"requires": {
- "end-of-stream": "1.4.4",
- "once": "1.4.0"
+ "end-of-stream": "^1.1.0",
+ "once": "^1.3.1"
}
},
"q": {
@@ -731,8 +729,8 @@
"integrity": "sha512-CEjy9LCzhmD7nUpJ1oVOE6s/hBkejlcJEgLQHVnQznOSilOPb+kpKktlLfFDK3/WP43+F80xkUTM2VOkYoSYvQ==",
"dev": true,
"requires": {
- "pify": "4.0.1",
- "with-open-file": "0.1.7"
+ "pify": "^4.0.1",
+ "with-open-file": "^0.1.6"
}
},
"recursive-readdir": {
@@ -774,7 +772,7 @@
"integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==",
"dev": true,
"requires": {
- "shebang-regex": "3.0.0"
+ "shebang-regex": "^3.0.0"
}
},
"shebang-regex": {
@@ -801,8 +799,8 @@
"integrity": "sha512-5rB7rN4N3b0z0nFdy9eczVssXqrv2aAgdVRksPVqVoiDtvXmfzNvebp3EMdId2sAUzXIflarQlx4P0hjVQEzKQ==",
"dev": true,
"requires": {
- "shelljs": "0.2.6",
- "tail": "0.4.0"
+ "shelljs": "^0.2.6",
+ "tail": "^0.4.0"
}
},
"simple-plist": {
@@ -812,7 +810,7 @@
"requires": {
"bplist-creator": "0.0.8",
"bplist-parser": "0.2.0",
- "plist": "3.0.1"
+ "plist": "^3.0.1"
}
},
"stream-buffers": {
@@ -850,7 +848,7 @@
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
"dev": true,
"requires": {
- "is-number": "7.0.0"
+ "is-number": "^7.0.0"
}
},
"underscore": {
@@ -883,7 +881,7 @@
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
"dev": true,
"requires": {
- "isexe": "2.0.0"
+ "isexe": "^2.0.0"
}
},
"with-open-file": {
@@ -892,9 +890,9 @@
"integrity": "sha512-ecJS2/oHtESJ1t3ZfMI3B7KIDKyfN0O16miWxdn30zdh66Yd3LsRFebXZXq6GU4xfxLf6nVxp9kIqElb5fqczA==",
"dev": true,
"requires": {
- "p-finally": "1.0.0",
- "p-try": "2.2.0",
- "pify": "4.0.1"
+ "p-finally": "^1.0.0",
+ "p-try": "^2.1.0",
+ "pify": "^4.0.1"
}
},
"wrappy": {
@@ -908,8 +906,8 @@
"integrity": "sha512-kCz5k7J7XbJtjABOvkc5lJmkiDh8VhjVCGNiqdKCscmVpdVUpEAyXv1xmCLkQJ5dsHqx3IPO4XW+NTDhU/fatA==",
"dev": true,
"requires": {
- "simple-plist": "1.1.1",
- "uuid": "7.0.3"
+ "simple-plist": "^1.1.0",
+ "uuid": "^7.0.3"
}
},
"xml-escape": {
diff --git a/cordova/package.json b/cordova/package.json
index 1cf173057..3146d5f83 100644
--- a/cordova/package.json
+++ b/cordova/package.json
@@ -38,7 +38,8 @@
},
"cordova-plugin-androidx-adapter": {},
"com.ourcodeworld.plugins.Filebrowser": {},
- "cordova-plugin-add-swift-support": {}
+ "cordova-plugin-add-swift-support": {},
+ "com-darryncampbell-cordova-plugin-intent": {}
},
"platforms": [
"android",
@@ -48,9 +49,10 @@
"devDependencies": {
"@globules-io/cordova-plugin-ios-xhr": "^1.0.4",
"bamboo.cordova.plugin.downloader": "git+https://github.com/sytolk/cordova-plugin-downloader.git",
+ "com-darryncampbell-cordova-plugin-intent": "^2.0.0",
"cordova-android": "^9.0.0",
"cordova-ios": "^6.1.1",
"cordova-ourcodeworld-filebrowser": "git+https://github.com/ourcodeworld/cordova-ourcodeworld-filebrowser.git",
"cordova-plugin-androidx-adapter": "^1.1.3"
}
-}
+}
\ No newline at end of file
diff --git a/cordova/platforms/android/android.json b/cordova/platforms/android/android.json
index df8f0f504..88e437950 100644
--- a/cordova/platforms/android/android.json
+++ b/cordova/platforms/android/android.json
@@ -55,6 +55,10 @@
{
"xml": "<feature name=\"Filebrowser\"><param name=\"android-package\" value=\"com.ourcodeworld.plugins.filebrowser.Filebrowser\" /></feature>",
"count": 1
+ },
+ {
+ "xml": "<feature name=\"IntentShim\"><param name=\"android-package\" value=\"com.darryncampbell.cordova.plugin.intent.IntentShim\" /><param name=\"onload\" value=\"true\" /></feature>",
+ "count": 1
}
]
}
@@ -77,6 +81,10 @@
{
"xml": "<activity android:label=\"Filepicker\" android:name=\"com.nononsenseapps.filepicker.FilePickerActivity\" android:theme=\"@style/FilePickerTheme\"><intent-filter><action android:name=\"android.intent.action.GET_CONTENT\" /><category android:name=\"android.intent.category.DEFAULT\" /></intent-filter></activity>",
"count": 1
+ },
+ {
+ "xml": "<provider android:authorities=\"${applicationId}.darryncampbell.cordova.plugin.intent.fileprovider\" android:exported=\"false\" android:grantUriPermissions=\"true\" android:name=\"com.darryncampbell.cordova.plugin.intent.CordovaPluginIntentFileProvider\"><meta-data android:name=\"android.support.FILE_PROVIDER_PATHS\" android:resource=\"@xml/provider_paths\" /></provider>",
+ "count": 1
}
],
"/manifest": [
@@ -86,11 +94,15 @@
},
{
"xml": "<uses-permission android:name=\"android.permission.READ_EXTERNAL_STORAGE\" />",
- "count": 2
+ "count": 3
},
{
"xml": "<uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\" />",
"count": 2
+ },
+ {
+ "xml": "<uses-permission android:name=\"android.permission.REQUEST_INSTALL_PACKAGES\" />",
+ "count": 1
}
],
"/*": [
@@ -122,6 +134,20 @@
"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
}
+ ],
+ "/manifest/application/activity": [
+ {
+ "xml": "<intent-filter><action android:name=\"com.darryncampbell.cordova.plugin.intent.ACTION\" /><category android:name=\"android.intent.category.DEFAULT\" /></intent-filter>",
+ "count": 1
+ },
+ {
+ "xml": "<intent-filter><action android:name=\"android.intent.action.VIEW\" /><category android:name=\"android.intent.category.DEFAULT\" /><category android:name=\"android.intent.category.BROWSABLE\" /><data android:mimeType=\"application/pdf\" android:scheme=\"file\" /><data android:mimeType=\"text/plain\" android:scheme=\"file\" /><data android:mimeType=\"image/x-windows-bmp\" android:scheme=\"file\" /><data android:mimeType=\"image/gif\" android:scheme=\"file\" /><data android:mimeType=\"image/png\" android:scheme=\"file\" /><data android:mimeType=\"image/jpeg\" android:scheme=\"file\" /><data android:mimeType=\"image/webp\" android:scheme=\"file\" /><data android:mimeType=\"video/webm\" android:scheme=\"file\" /><data android:mimeType=\"video/ogg\" android:scheme=\"file\" /><data android:mimeType=\"text/html\" android:scheme=\"file\" /><data android:mimeType=\"application/json\" android:scheme=\"file\" /></intent-filter>",
+ "count": 3
+ },
+ {
+ "xml": "<intent-filter><action android:name=\"android.intent.action.VIEW\" /><category android:name=\"android.intent.category.DEFAULT\" /><category android:name=\"android.intent.category.BROWSABLE\" /><data android:host=\"*\" android:mimeType=\"*/*\" android:pathPattern=\"..json\" android:scheme=\"file\" /><data android:host=\"*\" android:mimeType=\"*/*\" android:pathPattern=\"..mht\" android:scheme=\"file\" /><data android:host=\"*\" android:mimeType=\"*/*\" android:pathPattern=\"..mhtml\" android:scheme=\"file\" /><data android:host=\"*\" android:mimeType=\"*/*\" android:pathPattern=\"..md\" android:scheme=\"file\" /><data android:host=\"*\" android:mimeType=\"*/*\" android:pathPattern=\"..md.txt\" android:scheme=\"file\" /><data android:host=\"*\" android:mimeType=\"*/*\" android:pathPattern=\"..markdown\" android:scheme=\"file\" /><data android:host=\"*\" android:mimeType=\"*/*\" android:pathPattern=\"..ogv\" android:scheme=\"file\" /></intent-filter>",
+ "count": 3
+ }
]
}
}
@@ -165,6 +191,9 @@
},
"cordova-plugin-add-swift-support": {
"PACKAGE_NAME": "org.tagspaces.mobile"
+ },
+ "com-darryncampbell-cordova-plugin-intent": {
+ "PACKAGE_NAME": "org.tagspaces.mobile"
}
},
"dependent_plugins": {},
@@ -428,6 +457,14 @@
"clobbers": [
"window.OurCodeWorld.Filebrowser"
]
+ },
+ {
+ "id": "com-darryncampbell-cordova-plugin-intent.IntentShim",
+ "file": "plugins/com-darryncampbell-cordova-plugin-intent/www/IntentShim.js",
+ "pluginId": "com-darryncampbell-cordova-plugin-intent",
+ "clobbers": [
+ "intentShim"
+ ]
}
],
"plugin_metadata": {
@@ -442,6 +479,7 @@
"cordova-plugin-androidx-adapter": "1.1.3",
"com.whebcraft.cordova.plugin.downloader": "0.1.0",
"com.ourcodeworld.plugins.Filebrowser": "1.0.0",
- "cordova-plugin-add-swift-support": "2.0.2"
+ "cordova-plugin-add-swift-support": "2.0.2",
+ "com-darryncampbell-cordova-plugin-intent": "2.0.0"
}
}
diff --git a/cordova/platforms/android/app/build.gradle b/cordova/platforms/android/app/build.gradle
index 19d62071d..c1a7c58b7 100644
--- a/cordova/platforms/android/app/build.gradle
+++ b/cordova/platforms/android/app/build.gradle
@@ -353,6 +353,7 @@ dependencies {
// SUB-PROJECT DEPENDENCIES START
implementation(project(path: ":CordovaLib"))
implementation "androidx.legacy:legacy-support-v4:1.0.0"
+ implementation "androidx.core:core:1.1.0"
// SUB-PROJECT DEPENDENCIES END
}
diff --git a/cordova/platforms/android/app/src/main/AndroidManifest.xml b/cordova/platforms/android/app/src/main/AndroidManifest.xml
index b91f45c9a..f7def5ce4 100644
--- a/cordova/platforms/android/app/src/main/AndroidManifest.xml
+++ b/cordova/platforms/android/app/src/main/AndroidManifest.xml
@@ -8,6 +8,38 @@
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
+ <intent-filter>
+ <action android:name="com.darryncampbell.cordova.plugin.intent.ACTION" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+ <data android:mimeType="application/pdf" android:scheme="file" />
+ <data android:mimeType="text/plain" android:scheme="file" />
+ <data android:mimeType="image/x-windows-bmp" android:scheme="file" />
+ <data android:mimeType="image/gif" android:scheme="file" />
+ <data android:mimeType="image/png" android:scheme="file" />
+ <data android:mimeType="image/jpeg" android:scheme="file" />
+ <data android:mimeType="image/webp" android:scheme="file" />
+ <data android:mimeType="video/webm" android:scheme="file" />
+ <data android:mimeType="video/ogg" android:scheme="file" />
+ <data android:mimeType="text/html" android:scheme="file" />
+ <data android:mimeType="application/json" android:scheme="file" />
+ </intent-filter>
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+ <data android:host="*" android:mimeType="*/*" android:pathPattern="..json" android:scheme="file" />
+ <data android:host="*" android:mimeType="*/*" android:pathPattern="..mht" android:scheme="file" />
+ <data android:host="*" android:mimeType="*/*" android:pathPattern="..mhtml" android:scheme="file" />
+ <data android:host="*" android:mimeType="*/*" android:pathPattern="..md" android:scheme="file" />
+ <data android:host="*" android:mimeType="*/*" android:pathPattern="..md.txt" android:scheme="file" />
+ <data android:host="*" android:mimeType="*/*" android:pathPattern="..markdown" android:scheme="file" />
+ <data android:host="*" android:mimeType="*/*" android:pathPattern="..ogv" android:scheme="file" />
+ </intent-filter>
</activity>
<service android:name="de.appplant.cordova.plugin.background.ForegroundService" />
<provider android:authorities="${applicationId}.cordova.plugin.camera.provider" android:exported="false" android:grantUriPermissions="true" android:name="org.apache.cordova.camera.FileProvider">
@@ -36,6 +68,9 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
+ <provider android:authorities="${applicationId}.darryncampbell.cordova.plugin.intent.fileprovider" android:exported="false" android:grantUriPermissions="true" android:name="com.darryncampbell.cordova.plugin.intent.CordovaPluginIntentFileProvider">
+ <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/provider_paths" />
+ </provider>
</application>
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
diff --git a/cordova/platforms/android/app/src/main/java/com/darryncampbell/plugin/intent/CordovaPluginIntentFileProvider.java b/cordova/platforms/android/app/src/main/java/com/darryncampbell/plugin/intent/CordovaPluginIntentFileProvider.java
new file mode 100644
index 000000000..a88663cf7
--- /dev/null
+++ b/cordova/platforms/android/app/src/main/java/com/darryncampbell/plugin/intent/CordovaPluginIntentFileProvider.java
@@ -0,0 +1,4 @@
+package com.darryncampbell.cordova.plugin.intent;
+
+public class CordovaPluginIntentFileProvider extends androidx.core.content.FileProvider {
+}
diff --git a/cordova/platforms/android/app/src/main/java/com/darryncampbell/plugin/intent/IntentShim.java b/cordova/platforms/android/app/src/main/java/com/darryncampbell/plugin/intent/IntentShim.java
new file mode 100644
index 000000000..4bc5ceca0
--- /dev/null
+++ b/cordova/platforms/android/app/src/main/java/com/darryncampbell/plugin/intent/IntentShim.java
@@ -0,0 +1,830 @@
+package com.darryncampbell.cordova.plugin.intent;
+
+import android.Manifest;
+import android.app.Activity;
+import android.content.BroadcastReceiver;
+import android.content.ClipData;
+import android.content.ComponentName;
+import android.content.ContentResolver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.pm.PackageManager;
+import android.database.Cursor;
+import android.net.Uri;
+import android.os.Build;
+import android.os.Bundle;
+import android.os.Environment;
+import android.provider.DocumentsContract;
+import android.provider.MediaStore;
+import androidx.core.app.ActivityCompat;
+import androidx.core.content.ContextCompat;
+import androidx.core.content.FileProvider;
+import android.text.Html;
+import android.util.Log;
+import android.view.KeyEvent;
+import android.webkit.MimeTypeMap;
+
+import org.apache.cordova.CallbackContext;
+import org.apache.cordova.CordovaActivity;
+import org.apache.cordova.CordovaPlugin;
+import org.apache.cordova.CordovaResourceApi;
+import org.apache.cordova.PluginResult;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.io.File;
+
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import static android.os.Environment.getExternalStorageDirectory;
+import static android.os.Environment.getExternalStorageState;
+
+public class IntentShim extends CordovaPlugin {
+
+ private static final String LOG_TAG = "Cordova Intents Shim";
+ private CallbackContext onNewIntentCallbackContext = null;
+ private CallbackContext onBroadcastCallbackContext = null;
+ private CallbackContext onActivityResultCallbackContext = null;
+
+ private Intent deferredIntent = null;
+
+ public IntentShim() {
+
+ }
+
+ public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException
+ {
+ Log.d(LOG_TAG, "Action: " + action);
+ if (action.equals("startActivity") || action.equals("startActivityForResult"))
+ {
+ // Credit: https://github.com/chrisekelley/cordova-webintent
+ if (args.length() != 1) {
+ callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.INVALID_ACTION));
+ return false;
+ }
+
+ JSONObject obj = args.getJSONObject(0);
+ Intent intent = populateIntent(obj, callbackContext);
+ int requestCode = obj.has("requestCode") ? obj.getInt("requestCode") : 1;
+
+ boolean bExpectResult = false;
+ if (action.equals("startActivityForResult"))
+ {
+ bExpectResult = true;
+ this.onActivityResultCallbackContext = callbackContext;
+ }
+ startActivity(intent, bExpectResult, requestCode, callbackContext);
+
+ return true;
+ }
+ else if (action.equals("sendBroadcast"))
+ {
+ // Credit: https://github.com/chrisekelley/cordova-webintent
+ if (args.length() != 1) {
+ callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.INVALID_ACTION));
+ return false;
+ }
+
+ // Parse the arguments
+ JSONObject obj = args.getJSONObject(0);
+ Intent intent = populateIntent(obj, callbackContext);
+
+ sendBroadcast(intent);
+ callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK));
+ return true;
+ }
+ else if (action.equals("startService"))
+ {
+ if (args.length() != 1) {
+ callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.INVALID_ACTION));
+ return false;
+ }
+ JSONObject obj = args.getJSONObject(0);
+ Intent intent = populateIntent(obj, callbackContext);
+ startService(intent);
+ callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK));
+ return true;
+ }
+ else if (action.equals("registerBroadcastReceiver")) {
+ try
+ {
+ // Ensure we only have a single registered broadcast receiver
+ this.cordova.getActivity().unregisterReceiver(myBroadcastReceiver);
+ }
+ catch (IllegalArgumentException e) {}
+
+ // No error callback
+ if(args.length() != 1) {
+ callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.INVALID_ACTION));
+ return false;
+ }
+
+ // Expect an array of filterActions
+ JSONObject obj = args.getJSONObject(0);
+ JSONArray filterActions = obj.has("filterActions") ? obj.getJSONArray("filterActions") : null;
+ if (filterActions == null || filterActions.length() == 0)
+ {
+ // The arguments are not correct
+ Log.w(LOG_TAG, "filterActions argument is not in the expected format");
+ callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.INVALID_ACTION));
+ return false;
+ }
+
+ this.onBroadcastCallbackContext = callbackContext;
+
+ PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT);
+ result.setKeepCallback(true);
+
+ IntentFilter filter = new IntentFilter();
+ for (int i = 0; i < filterActions.length(); i++) {
+ Log.d(LOG_TAG, "Registering broadcast receiver for filter: " + filterActions.getString(i));
+ filter.addAction(filterActions.getString(i));
+ }
+
+ // Allow an array of filterCategories
+ JSONArray filterCategories = obj.has("filterCategories") ? obj.getJSONArray("filterCategories") : null;
+ if (filterCategories != null) {
+ for (int i = 0; i < filterCategories.length(); i++) {
+ Log.d(LOG_TAG, "Registering broadcast receiver for category filter: " + filterCategories.getString(i));
+ filter.addCategory(filterCategories.getString(i));
+ }
+ }
+
+ // Add any specified Data Schemes
+ // https://github.com/darryncampbell/darryncampbell-cordova-plugin-intent/issues/24
+ JSONArray filterDataSchemes = obj.has("filterDataSchemes") ? obj.getJSONArray("filterDataSchemes") : null;
+ if (filterDataSchemes != null && filterDataSchemes.length() > 0)
+ {
+ for (int i = 0; i < filterDataSchemes.length(); i++)
+ {
+ Log.d(LOG_TAG, "Associating data scheme to filter: " + filterDataSchemes.getString(i));
+ filter.addDataScheme(filterDataSchemes.getString(i));
+ }
+ }
+
+ this.cordova.getActivity().registerReceiver(myBroadcastReceiver, filter);
+
+ callbackContext.sendPluginResult(result);
+ }
+ else if (action.equals("unregisterBroadcastReceiver"))
+ {
+ try
+ {
+ this.cordova.getActivity().unregisterReceiver(myBroadcastReceiver);
+ }
+ catch (IllegalArgumentException e) {}
+ }
+ else if (action.equals("onIntent"))
+ {
+ // Credit: https://github.com/napolitano/cordova-plugin-intent
+ if(args.length() != 1) {
+ callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.INVALID_ACTION));
+ return false;
+ }
+
+ this.onNewIntentCallbackContext = callbackContext;
+
+ if (this.deferredIntent != null) {
+ fireOnNewIntent(this.deferredIntent);
+ this.deferredIntent = null;
+ }
+
+ PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT);
+ result.setKeepCallback(true);
+ callbackContext.sendPluginResult(result);
+ return true;
+ }
+ else if (action.equals("onActivityResult"))
+ {
+ if(args.length() != 1) {
+ callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.INVALID_ACTION));
+ return false;
+ }
+
+ this.onActivityResultCallbackContext = callbackContext;
+
+ PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT);
+ result.setKeepCallback(true);
+ callbackContext.sendPluginResult(result);
+ return true;
+ }
+ else if (action.equals("getIntent"))
+ {
+ // Credit: https://github.com/napolitano/cordova-plugin-intent
+ if(args.length() != 0) {
+ callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.INVALID_ACTION));
+ return false;
+ }
+
+ Intent intent;
+
+ if (this.deferredIntent != null) {
+ intent = this.deferredIntent;
+ this.deferredIntent = null;
+ }
+ else {
+ intent = cordova.getActivity().getIntent();
+ }
+
+ callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, getIntentJson(intent)));
+ return true;
+ }
+ else if (action.equals("sendResult"))
+ {
+ // Assuming this application was started with startActivityForResult, send the result back
+ // https://github.com/darryncampbell/darryncampbell-cordova-plugin-intent/issues/3
+ Intent result = new Intent();
+ if (args.length() > 0)
+ {
+ JSONObject json = args.getJSONObject(0);
+ JSONObject extras = (json.has("extras"))?json.getJSONObject("extras"):null;
+
+ // Populate the extras if any exist
+ if (extras != null) {
+ JSONArray extraNames = extras.names();
+ for (int i = 0; i < extraNames.length(); i++) {
+ String key = extraNames.getString(i);
+ Object extrasObj = extras.get(key);
+ if (extrasObj instanceof JSONObject) {
+ // The extra is a bundle
+ Bundle bundle = toBundle((JSONObject) extras.get(key));
+ result.putExtra(key, bundle);
+ } else if (extrasObj instanceof Boolean) {
+ result.putExtra(key, extras.getBoolean(key));
+ } else if(extrasObj instanceof Integer) {
+ result.putExtra(key, extras.getInt(key));
+ } else if(extrasObj instanceof Long) {
+ result.putExtra(key, extras.getLong(key));
+ } else if(extrasObj instanceof Double) {
+ result.putExtra(key, extras.getDouble(key));
+ } else if (extrasObj instanceof Float) {
+ result.putExtra(key, extras.getDouble(key));
+ } else {
+ result.putExtra(key, extras.getString(key));
+ }
+ }
+ }
+ }
+
+ //set result
+ cordova.getActivity().setResult(Activity.RESULT_OK, result);
+ callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK));
+
+ //finish the activity
+ cordova.getActivity().finish();
+
+ }
+ else if (action.equals("realPathFromUri"))
+ {
+ if (args.length() != 1) {
+ callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.INVALID_ACTION));
+ return false;
+ }
+
+ JSONObject obj = args.getJSONObject(0);
+ String realPath = getRealPathFromURI_API19(obj, callbackContext);
+ callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, realPath));
+ return true;
+
+ }
+
+ return true;
+ }
+
+ private Uri remapUriWithFileProvider(String uriAsString, final CallbackContext callbackContext)
+ {
+ // Create the URI via FileProvider Special case for N and above when installing apks
+ int permissionCheck = ContextCompat.checkSelfPermission(this.cordova.getActivity(),
+ Manifest.permission.READ_EXTERNAL_STORAGE);
+ if (permissionCheck != PackageManager.PERMISSION_GRANTED)
+ {
+ // Could do better here - if the app does not already have permission should
+ // only continue when we get the success callback from this.
+ ActivityCompat.requestPermissions(this.cordova.getActivity(),
+ new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 1);
+ callbackContext.error("Please grant read external storage permission");
+ return null;
+ }
+
+ try
+ {
+ String externalStorageState = getExternalStorageState();
+ if (externalStorageState.equals(Environment.MEDIA_MOUNTED) || externalStorageState.equals(Environment.MEDIA_MOUNTED_READ_ONLY)) {
+ String fileName = uriAsString.substring(uriAsString.indexOf('/') + 2, uriAsString.length());
+ File uriAsFile = new File(fileName);
+ boolean fileExists = uriAsFile.exists();
+ if (!fileExists)
+ {
+ Log.e(LOG_TAG, "File at path " + uriAsFile.getPath() + " with name " + uriAsFile.getName() + "does not exist");
+ callbackContext.error("File not found: " + uriAsFile.toString());
+ return null;
+ }
+ String PACKAGE_NAME = this.cordova.getActivity().getPackageName() + ".darryncampbell.cordova.plugin.intent.fileprovider";
+ Uri uri = FileProvider.getUriForFile(this.cordova.getActivity().getApplicationContext(), PACKAGE_NAME, uriAsFile);
+ return uri;
+ }
+ else
+ {
+ Log.e(LOG_TAG, "Storage directory is not mounted. Please ensure the device is not connected via USB for file transfer");
+ callbackContext.error("Storage directory is returning not mounted");
+ return null;
+ }
+ }
+ catch(StringIndexOutOfBoundsException e)
+ {
+ Log.e(LOG_TAG, "URL is not well formed");
+ callbackContext.error("URL is not well formed");
+ return null;
+ }
+ }
+
+ private String getRealPathFromURI_API19(JSONObject obj, CallbackContext callbackContext) throws JSONException
+ {
+ // Credit: https://stackoverflow.com/questions/2789276/android-get-real-path-by-uri-getpath/2790688
+ Uri uri = obj.has("uri") ? Uri.parse(obj.getString("uri")) : null;
+ if (uri == null)
+ {
+ Log.w(LOG_TAG, "URI is not a specified parameter");
+ throw new JSONException("URI is not a specified parameter");
+ }
+ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
+ String filePath = "";
+ if (uri.getHost().contains("com.android.providers.media")) {
+ int permissionCheck = ContextCompat.checkSelfPermission(this.cordova.getActivity(),
+ Manifest.permission.READ_EXTERNAL_STORAGE);
+ if (permissionCheck != PackageManager.PERMISSION_GRANTED)
+ {
+ // Could do better here - if the app does not already have permission should
+ // only continue when we get the success callback from this.
+ ActivityCompat.requestPermissions(this.cordova.getActivity(),
+ new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 1);
+ callbackContext.error("Please grant read external storage permission");
+ return null;
+ }
+
+ // Image pick from recent
+ String wholeID = DocumentsContract.getDocumentId(uri);
+
+ // Split at colon, use second item in the array
+ String id = wholeID.split(":")[1];
+
+ String[] column = {MediaStore.Images.Media.DATA};
+
+ // where id is equal to
+ String sel = MediaStore.Images.Media._ID + "=?";
+
+ // This line requires read storage permission
+
+ Cursor cursor = this.cordova.getActivity().getApplicationContext().getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
+ column, sel, new String[]{id}, null);
+
+ int columnIndex = cursor.getColumnIndex(column[0]);
+
+ if (cursor.moveToFirst()) {
+ filePath = cursor.getString(columnIndex);
+ }
+ cursor.close();
+ return filePath;
+ } else {
+ // image pick from gallery
+ String[] proj = {MediaStore.Images.Media.DATA};
+ Cursor cursor = this.cordova.getActivity().getApplicationContext().getContentResolver().query(uri, proj, null, null, null);
+ int column_index
+ = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
+ cursor.moveToFirst();
+ return cursor.getString(column_index);
+ }
+ }
+
+ return "Requires KK or higher";
+ }
+
+ private void startActivity(Intent i, boolean bExpectResult, int requestCode, CallbackContext callbackContext) {
+
+ if (i.resolveActivityInfo(this.cordova.getActivity().getPackageManager(), 0) != null)
+ {
+ if (bExpectResult)
+ {
+ cordova.setActivityResultCallback(this);
+ this.cordova.getActivity().startActivityForResult(i, requestCode);
+ }
+ else
+ {
+ this.cordova.getActivity().startActivity(i);
+ callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK));
+ }
+ }
+ else
+ {
+ // Return an error as there is no app to handle this intent
+ callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR));
+ }
+ }
+
+ private void sendBroadcast(Intent intent) {
+ this.cordova.getActivity().sendBroadcast(intent);
+ }
+
+ private void startService(Intent intent)
+ {
+ this.cordova.getActivity().startService(intent);
+ }
+
+ private Intent populateIntent(JSONObject obj, CallbackContext callbackContext) throws JSONException
+ {
+ // Credit: https://github.com/chrisekelley/cordova-webintent
+ // Credit: https://github.com/chrisekelley/cordova-webintent
+ String type = obj.has("type") ? obj.getString("type") : null;
+ String packageAssociated = obj.has("package") ? obj.getString("package") : null;
+
+ //Uri uri = obj.has("url") ? resourceApi.remapUri(Uri.parse(obj.getString("url"))) : null;
+ Uri uri = null;
+ final CordovaResourceApi resourceApi = webView.getResourceApi();
+ if (obj.has("url"))
+ {
+ String uriAsString = obj.getString("url");
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && uriAsString.startsWith("file://"))
+ {
+ uri = remapUriWithFileProvider(uriAsString, callbackContext);
+ }
+ else
+ {
+ uri = resourceApi.remapUri(Uri.parse(obj.getString("url")));
+ }
+ }
+
+ JSONObject extras = obj.has("extras") ? obj.getJSONObject("extras") : null;
+ Map<String, Object> extrasMap = new HashMap<String, Object>();
+ Bundle bundle = null;
+ String bundleKey = "";
+ if (extras != null) {
+ JSONArray extraNames = extras.names();
+ for (int i = 0; i < extraNames.length(); i++) {
+ String key = extraNames.getString(i);
+ Object extrasObj = extras.get(key);
+ if (extrasObj instanceof JSONObject) {
+ // The extra is a bundle
+ bundleKey = key;
+ bundle = toBundle((JSONObject) extras.get(key));
+ } else {
+ extrasMap.put(key, extras.get(key));
+ }
+ }
+ }
+
+ String action = obj.has("action") ? obj.getString("action") : null;
+ Intent i = new Intent();
+ if (action != null)
+ i.setAction(action);
+
+ if (type != null && uri != null) {
+ i.setDataAndType(uri, type); //Fix the crash problem with android 2.3.6
+ } else {
+ if (type != null) {
+ i.setType(type);
+ }
+ if (uri != null)
+ {
+ i.setData(uri);
+ }
+ }
+
+ JSONObject component = obj.has("component") ? obj.getJSONObject("component") : null;
+ if (component != null)
+ {
+ // User has specified an explicit intent
+ String componentPackage = component.has("package") ? component.getString("package") : null;
+ String componentClass = component.has("class") ? component.getString("class") : null;
+ if (componentPackage == null || componentClass == null)
+ {
+ Log.w(LOG_TAG, "Component specified but missing corresponding package or class");
+ throw new JSONException("Component specified but missing corresponding package or class");
+ }
+
+ else
+ {
+ ComponentName componentName = new ComponentName(componentPackage, componentClass);
+ i.setComponent(componentName);
+ }
+ }
+
+ if (packageAssociated != null)
+ i.setPackage(packageAssociated);
+
+ JSONArray flags = obj.has("flags") ? obj.getJSONArray("flags") : null;
+ if (flags != null)
+ {
+ int length = flags.length();
+ for (int k = 0; k < length; k++)
+ {
+ i.addFlags(flags.getInt(k));
+ }
+ }
+
+ if (bundle != null)
+ i.putExtra(bundleKey, bundle);
+
+ for (String key : extrasMap.keySet()) {
+ Object value = extrasMap.get(key);
+ String valueStr = String.valueOf(value);
+ // If type is text html, the extra text must sent as HTML
+ if (key.equals(Intent.EXTRA_TEXT) && type.equals("text/html")) {
+ i.putExtra(key, Html.fromHtml(valueStr));
+ } else if (key.equals(Intent.EXTRA_STREAM)) {
+ // allows sharing of images as attachments.
+ // value in this case should be a URI of a file
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && valueStr.startsWith("file://"))
+ {
+ Uri uriOfStream = remapUriWithFileProvider(valueStr, callbackContext);
+ if (uriOfStream != null)
+ i.putExtra(key, uriOfStream);
+ }
+ else
+ {
+ //final CordovaResourceApi resourceApi = webView.getResourceApi();
+ i.putExtra(key, resourceApi.remapUri(Uri.parse(valueStr)));
+ }
+ } else if (key.equals(Intent.EXTRA_EMAIL)) {
+ // allows to add the email address of the receiver
+ i.putExtra(Intent.EXTRA_EMAIL, new String[] { valueStr });
+ } else if (key.equals(Intent.EXTRA_KEY_EVENT)) {
+ // allows to add a key event object
+ JSONObject keyEventJson = new JSONObject(valueStr);
+ int keyAction = keyEventJson.getInt("action");
+ int keyCode = keyEventJson.getInt("code");
+ KeyEvent keyEvent = new KeyEvent(keyAction, keyCode);
+ i.putExtra(Intent.EXTRA_KEY_EVENT, keyEvent);
+ } else {
+ if (value instanceof Boolean) {
+ i.putExtra(key, Boolean.valueOf(valueStr));
+ } else if(value instanceof Integer) {
+ i.putExtra(key, Integer.valueOf(valueStr));
+ } else if(value instanceof Long) {
+ i.putExtra(key, Long.valueOf(valueStr));
+ } else if(value instanceof Double) {
+ i.putExtra(key, Double.valueOf(valueStr));
+ } else {
+ i.putExtra(key, valueStr);
+ }
+ }
+ }
+
+ i.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
+
+ if (obj.has("chooser")) {
+ i = Intent.createChooser(i, obj.getString("chooser"));
+ }
+
+ return i;
+ }
+
+ @Override
+ public void onNewIntent(Intent intent) {
+ if (this.onNewIntentCallbackContext != null) {
+ fireOnNewIntent(intent);
+ }
+ else {
+ // save the intent for use when onIntent action is called in the execute method
+ this.deferredIntent = intent;
+ }
+ }
+
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, Intent intent)
+ {
+ super.onActivityResult(requestCode, resultCode, intent);
+ if (onActivityResultCallbackContext != null && intent != null)
+ {
+ intent.putExtra("requestCode", requestCode);
+ intent.putExtra("resultCode", resultCode);
+ PluginResult result = new PluginResult(PluginResult.Status.OK, getIntentJson(intent));
+ result.setKeepCallback(true);
+ onActivityResultCallbackContext.sendPluginResult(result);
+ }
+ else if (onActivityResultCallbackContext != null)
+ {
+ Intent canceledIntent = new Intent();
+ canceledIntent.putExtra("requestCode", requestCode);
+ canceledIntent.putExtra("resultCode", resultCode);
+ PluginResult canceledResult = new PluginResult(PluginResult.Status.OK, getIntentJson(canceledIntent));
+ canceledResult.setKeepCallback(true);
+ onActivityResultCallbackContext.sendPluginResult(canceledResult);
+ }
+
+ }
+
+ private BroadcastReceiver myBroadcastReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ String action = intent.getAction();
+ if (onBroadcastCallbackContext != null)
+ {
+ PluginResult result = new PluginResult(PluginResult.Status.OK, getIntentJson(intent));
+ result.setKeepCallback(true);
+ onBroadcastCallbackContext.sendPluginResult(result);
+ }
+ }
+ };
+
+ /**
+ * Sends the provided Intent to the onNewIntentCallbackContext.
+ *
+ * @param intent This is the intent to send to the JS layer.
+ */
+ private void fireOnNewIntent(Intent intent) {
+ PluginResult result = new PluginResult(PluginResult.Status.OK, getIntentJson(intent));
+ result.setKeepCallback(true);
+ this.onNewIntentCallbackContext.sendPluginResult(result);
+ }
+
+ /**
+ * Return JSON representation of intent attributes
+ *
+ * @param intent
+ * Credit: https://github.com/napolitano/cordova-plugin-intent
+ */
+ private JSONObject getIntentJson(Intent intent) {
+ JSONObject intentJSON = null;
+ ClipData clipData = null;
+ JSONObject[] items = null;
+ ContentResolver cR = this.cordova.getActivity().getApplicationContext().getContentResolver();
+ MimeTypeMap mime = MimeTypeMap.getSingleton();
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
+ clipData = intent.getClipData();
+ if(clipData != null) {
+ int clipItemCount = clipData.getItemCount();
+ items = new JSONObject[clipItemCount];
+
+ for (int i = 0; i < clipItemCount; i++) {
+
+ ClipData.Item item = clipData.getItemAt(i);
+
+ try {
+ items[i] = new JSONObject();
+ items[i].put("htmlText", item.getHtmlText());
+ items[i].put("intent", item.getIntent());
+ items[i].put("text", item.getText());
+ items[i].put("uri", item.getUri());
+
+ if (item.getUri() != null) {
+ String type = cR.getType(item.getUri());
+ String extension = mime.getExtensionFromMimeType(cR.getType(item.getUri()));
+
+ items[i].put("type", type);
+ items[i].put("extension", extension);
+ }
+
+ } catch (JSONException e) {
+ Log.d(LOG_TAG, " Error thrown during intent > JSON conversion");
+ Log.d(LOG_TAG, e.getMessage());
+ Log.d(LOG_TAG, Arrays.toString(e.getStackTrace()));
+ }
+
+ }
+ }
+ }
+
+ try {
+ intentJSON = new JSONObject();
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
+ if(items != null) {
+ intentJSON.put("clipItems", new JSONArray(items));
+ }
+ }
+
+ intentJSON.put("type", intent.getType());
+ intentJSON.put("extras", toJsonObject(intent.getExtras()));
+ intentJSON.put("action", intent.getAction());
+ intentJSON.put("categories", intent.getCategories());
+ intentJSON.put("flags", intent.getFlags());
+ intentJSON.put("component", intent.getComponent());
+ intentJSON.put("data", intent.getData());
+ intentJSON.put("package", intent.getPackage());
+
+ return intentJSON;
+ } catch (JSONException e) {
+ Log.d(LOG_TAG, " Error thrown during intent > JSON conversion");
+ Log.d(LOG_TAG, e.getMessage());
+ Log.d(LOG_TAG, Arrays.toString(e.getStackTrace()));
+
+ return null;
+ }
+ }
+
+ private static JSONObject toJsonObject(Bundle bundle) {
+ // Credit: https://github.com/napolitano/cordova-plugin-intent
+ try {
+ return (JSONObject) toJsonValue(bundle);
+ } catch (JSONException e) {
+ throw new IllegalArgumentException("Cannot convert bundle to JSON: " + e.getMessage(), e);
+ }
+ }
+
+ private static Object toJsonValue(final Object value) throws JSONException {
+ // Credit: https://github.com/napolitano/cordova-plugin-intent
+ if (value == null) {
+ return null;
+ } else if (value instanceof Bundle) {
+ final Bundle bundle = (Bundle) value;
+ final JSONObject result = new JSONObject();
+ for (final String key : bundle.keySet()) {
+ result.put(key, toJsonValue(bundle.get(key)));
+ }
+ return result;
+ } else if ((value.getClass().isArray())) {
+ final JSONArray result = new JSONArray();
+ int length = Array.getLength(value);
+ for (int i = 0; i < length; ++i) {
+ result.put(i, toJsonValue(Array.get(value, i)));
+ }
+ return result;
+ }
+ else if (value instanceof ArrayList<?>) {
+ final ArrayList arrayList = (ArrayList<?>)value;
+ final JSONArray result = new JSONArray();
+ for (int i = 0; i < arrayList.size(); i++)
+ result.put(toJsonValue(arrayList.get(i)));
+ return result;
+ }
+ else if (
+ value instanceof String
+ || value instanceof Boolean
+ || value instanceof Integer
+ || value instanceof Long
+ || value instanceof Double) {
+ return value;
+ } else {
+ return String.valueOf(value);
+ }
+ }
+
+ private Bundle toBundle(final JSONObject obj) {
+ Bundle returnBundle = new Bundle();
+ if (obj == null) {
+ return null;
+ }
+ try {
+ Iterator<?> keys = obj.keys();
+ while(keys.hasNext())
+ {
+ String key = (String)keys.next();
+ Object compare = obj.get(key);
+ if (obj.get(key) instanceof String)
+ returnBundle.putString(key, obj.getString(key));
+ else if (obj.get(key) instanceof Boolean)
+ returnBundle.putBoolean(key, obj.getBoolean(key));
+ else if (obj.get(key) instanceof Integer)
+ returnBundle.putInt(key, obj.getInt(key));
+ else if (obj.get(key) instanceof Long)
+ returnBundle.putLong(key, obj.getLong(key));
+ else if (obj.get(key) instanceof Double)
+ returnBundle.putDouble(key, obj.getDouble(key));
+ else if (obj.get(key).getClass().isArray() || obj.get(key) instanceof JSONArray)
+ {
+ JSONArray jsonArray = obj.getJSONArray(key);
+ int length = jsonArray.length();
+ if (jsonArray.get(0) instanceof String)
+ {
+ String[] stringArray = new String[length];
+ for (int j = 0; j < length; j++)
+ stringArray[j] = jsonArray.getString(j);
+ returnBundle.putStringArray(key, stringArray);
+ //returnBundle.putParcelableArray(key, obj.get);
+ }
+ else
+ {
+ if (key.equals("PLUGIN_CONFIG")) {
+ ArrayList<Bundle> bundleArray = new ArrayList<Bundle>();
+ for (int k = 0; k < length; k++) {
+ bundleArray.add(toBundle(jsonArray.getJSONObject(k)));
+ }
+ returnBundle.putParcelableArrayList(key, bundleArray);
+ } else {
+ Bundle[] bundleArray = new Bundle[length];
+ for (int k = 0; k < length; k++)
+ bundleArray[k] = toBundle(jsonArray.getJSONObject(k));
+ returnBundle.putParcelableArray(key, bundleArray);
+ }
+ }
+ }
+ else if (obj.get(key) instanceof JSONObject)
+ returnBundle.putBundle(key, toBundle((JSONObject)obj.get(key)));
+ }
+ }
+ catch (JSONException e) {
+ e.printStackTrace();
+ }
+
+
+ return returnBundle;
+ }
+}
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 563d12b6a..f0b5f7b97 100644
--- a/cordova/platforms/android/app/src/main/res/xml/config.xml
+++ b/cordova/platforms/android/app/src/main/res/xml/config.xml
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
-<widget id="org.tagspaces.mobile" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
+<widget id="org.tagspaces.mobile" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<feature name="Device">
<param name="android-package" value="org.apache.cordova.device.Device" />
</feature>
@@ -33,6 +33,10 @@
<feature name="Filebrowser">
<param name="android-package" value="com.ourcodeworld.plugins.filebrowser.Filebrowser" />
</feature>
+ <feature name="IntentShim">
+ <param name="android-package" value="com.darryncampbell.cordova.plugin.intent.IntentShim" />
+ <param name="onload" value="true" />
+ </feature>
<name>TagSpaces</name>
<description>
Offline file organizer and browser with tagging support.
@@ -54,6 +58,31 @@
<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" />
+ <config-file mode="merge" parent="/manifest/application/activity" platform="android" target="AndroidManifest.xml">
+ <intent-filter>
+ <data android:mimeType="application/pdf" android:scheme="file" />
+ <data android:mimeType="text/plain" android:scheme="file" />
+ <data android:mimeType="image/x-windows-bmp" android:scheme="file" />
+ <data android:mimeType="image/gif" android:scheme="file" />
+ <data android:mimeType="image/png" android:scheme="file" />
+ <data android:mimeType="image/jpeg" android:scheme="file" />
+ <data android:mimeType="image/webp" android:scheme="file" />
+ <data android:mimeType="video/webm" android:scheme="file" />
+ <data android:mimeType="video/ogg" android:scheme="file" />
+ <data android:mimeType="text/html" android:scheme="file" />
+ <data android:mimeType="application/json" android:scheme="file" />
+ <action android:name="android.intent.action.VIEW" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+ <data android:host="*" android:mimeType="*/*" android:pathPattern="..json" android:scheme="file" />
+ <data android:host="*" android:mimeType="*/*" android:pathPattern="..mht" android:scheme="file" />
+ <data android:host="*" android:mimeType="*/*" android:pathPattern="..mhtml" android:scheme="file" />
+ <data android:host="*" android:mimeType="*/*" android:pathPattern="..md" android:scheme="file" />
+ <data android:host="*" android:mimeType="*/*" android:pathPattern="..md.txt" android:scheme="file" />
+ <data android:host="*" android:mimeType="*/*" android:pathPattern="..markdown" android:scheme="file" />
+ <data android:host="*" android:mimeType="*/*" android:pathPattern="..ogv" android:scheme="file" />
+ </intent-filter>
+ </config-file>
<preference name="loglevel" value="DEBUG" />
<preference name="KeepRunning" value="true" />
<preference name="AndroidPersistentFileLocation" value="Compatibility" />
diff --git a/cordova/platforms/android/app/src/main/res/xml/provider_paths.xml b/cordova/platforms/android/app/src/main/res/xml/provider_paths.xml
new file mode 100644
index 000000000..6077b3992
--- /dev/null
+++ b/cordova/platforms/android/app/src/main/res/xml/provider_paths.xml
@@ -0,0 +1,3 @@
+<paths xmlns:android='http://schemas.android.com/apk/res/android'>
+ <external-path name='external_files' path='.' />
+</paths>
\ No newline at end of file
diff --git a/cordova/platforms/android/platform_www/cordova_plugins.js b/cordova/platforms/android/platform_www/cordova_plugins.js
index 2b3a5ac6a..1f6aa0de1 100644
--- a/cordova/platforms/android/platform_www/cordova_plugins.js
+++ b/cordova/platforms/android/platform_www/cordova_plugins.js
@@ -259,6 +259,14 @@ cordova.define('cordova/plugin_list', function(require, exports, module) {
"clobbers": [
"window.OurCodeWorld.Filebrowser"
]
+ },
+ {
+ "id": "com-darryncampbell-cordova-plugin-intent.IntentShim",
+ "file": "plugins/com-darryncampbell-cordova-plugin-intent/www/IntentShim.js",
+ "pluginId": "com-darryncampbell-cordova-plugin-intent",
+ "clobbers": [
+ "intentShim"
+ ]
}
];
module.exports.metadata = {
@@ -273,6 +281,7 @@ cordova.define('cordova/plugin_list', function(require, exports, module) {
"cordova-plugin-androidx-adapter": "1.1.3",
"com.whebcraft.cordova.plugin.downloader": "0.1.0",
"com.ourcodeworld.plugins.Filebrowser": "1.0.0",
- "cordova-plugin-add-swift-support": "2.0.2"
+ "cordova-plugin-add-swift-support": "2.0.2",
+ "com-darryncampbell-cordova-plugin-intent": "2.0.0"
};
});
\ No newline at end of file
diff --git a/cordova/platforms/android/platform_www/plugins/com-darryncampbell-cordova-plugin-intent/www/IntentShim.js b/cordova/platforms/android/platform_www/plugins/com-darryncampbell-cordova-plugin-intent/www/IntentShim.js
new file mode 100644
index 000000000..67be5340c
--- /dev/null
+++ b/cordova/platforms/android/platform_www/plugins/com-darryncampbell-cordova-plugin-intent/www/IntentShim.js
@@ -0,0 +1,91 @@
+cordova.define("com-darryncampbell-cordova-plugin-intent.IntentShim", function(require, exports, module) {
+var argscheck = require('cordova/argscheck'),
+ channel = require('cordova/channel'),
+ utils = require('cordova/utils'),
+ exec = require('cordova/exec'),
+ cordova = require('cordova');
+
+
+/**
+ * This represents a thin shim layer over the Android Intent implementation
+ * @constructor
+ */
+function IntentShim() {
+ var me = this;
+}
+
+IntentShim.prototype.ACTION_SEND = "android.intent.action.SEND";
+IntentShim.prototype.ACTION_VIEW= "android.intent.action.VIEW";
+IntentShim.prototype.ACTION_INSTALL_PACKAGE="android.intent.action.INSTALL_PACKAGE";
+IntentShim.prototype.ACTION_UNINSTALL_PACKAGE= "android.intent.action.UNINSTALL_PACKAGE";
+IntentShim.prototype.EXTRA_TEXT = "android.intent.extra.TEXT";
+IntentShim.prototype.EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
+IntentShim.prototype.EXTRA_STREAM = "android.intent.extra.STREAM";
+IntentShim.prototype.EXTRA_EMAIL = "android.intent.extra.EMAIL";
+IntentShim.prototype.ACTION_CALL = "android.intent.action.CALL";
+IntentShim.prototype.ACTION_SENDTO = "android.intent.action.SENDTO";
+// StartActivityForResult
+IntentShim.prototype.ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
+IntentShim.prototype.ACTION_PICK = "android.intent.action.PICK";
+IntentShim.prototype.RESULT_CANCELED = 0; // Activity.RESULT_CANCELED
+IntentShim.prototype.RESULT_OK = -1; // Activity.RESULT_OK
+
+IntentShim.prototype.startActivity = function(params, successCallback, errorCallback) {
+ argscheck.checkArgs('off', 'IntentShim.startActivity', arguments);
+ exec(successCallback, errorCallback, "IntentShim", "startActivity", [params]);
+};
+
+IntentShim.prototype.startActivityForResult = function(params, successCallback, errorCallback) {
+ argscheck.checkArgs('off', 'IntentShim.startActivityForResult', arguments);
+ exec(successCallback, errorCallback, "IntentShim", "startActivityForResult", [params]);
+};
+
+IntentShim.prototype.sendBroadcast = function(params, successCallback, errorCallback) {
+ argscheck.checkArgs('off', 'IntentShim.sendBroadcast', arguments);
+ exec(successCallback, errorCallback, "IntentShim", "sendBroadcast", [params]);
+};
+
+IntentShim.prototype.startService = function(params, successCallback, errorCallback) {
+ argscheck.checkArgs('off', 'IntentShim.startService', arguments);
+ exec(successCallback, errorCallback, "IntentShim", "startService", [params]);
+};
+
+IntentShim.prototype.registerBroadcastReceiver = function(params, callback) {
+ argscheck.checkArgs('of', 'IntentShim.registerBroadcastReceiver', arguments);
+ exec(callback, null, "IntentShim", "registerBroadcastReceiver", [params]);
+};
+
+IntentShim.prototype.unregisterBroadcastReceiver = function() {
+ argscheck.checkArgs('', 'IntentShim.unregisterBroadcastReceiver', arguments);
+ exec(null, null, "IntentShim", "unregisterBroadcastReceiver", []);
+};
+
+IntentShim.prototype.onIntent = function(callback) {
+ argscheck.checkArgs('f', 'IntentShim.onIntent', arguments);
+ exec(callback, null, "IntentShim", "onIntent", [callback]);
+};
+
+IntentShim.prototype.onActivityResult = function(callback) {
+ argscheck.checkArgs('f', 'IntentShim.onActivityResult', arguments);
+ exec(callback, null, "IntentShim", "onActivityResult", [callback]);
+};
+
+IntentShim.prototype.getIntent = function(successCallback, failureCallback) {
+ argscheck.checkArgs('ff', 'IntentShim.getIntent', arguments);
+ exec(successCallback, failureCallback, "IntentShim", "getIntent", []);
+};
+
+IntentShim.prototype.sendResult = function(params, callback) {
+ argscheck.checkArgs('of', 'IntentShim.sendResult', arguments);
+ exec(callback, null, "IntentShim", "sendResult", [params]);
+}
+
+IntentShim.prototype.realPathFromUri = function(params, successCallback, errorCallback) {
+ argscheck.checkArgs('off', 'IntentShim.realPathFromUri', arguments);
+ exec(successCallback, errorCallback, "IntentShim", "realPathFromUri", [params]);
+};
+
+window.intentShim = new IntentShim();
+window.plugins = window.plugins || {};
+window.plugins.intentShim = window.intentShim;
+});
diff --git a/cordova/platforms/android/project.properties b/cordova/platforms/android/project.properties
index 26f09f2cd..442493b34 100644
--- a/cordova/platforms/android/project.properties
+++ b/cordova/platforms/android/project.properties
@@ -14,4 +14,5 @@ android.library.reference.2=app
cordova.system.library.1=androidx.legacy:legacy-support-v4:1.0.0
cordova.system.library.2=androidx.legacy:legacy-support-v4:1.0.0
cordova.system.library.3=androidx.legacy:legacy-support-v4:1.0.0
-cordova.gradle.include.1=com.ourcodeworld.plugins.Filebrowser/mobile-plugin.gradle
\ No newline at end of file
+cordova.gradle.include.1=com.ourcodeworld.plugins.Filebrowser/mobile-plugin.gradle
+cordova.system.library.4=androidx.core:core:1.1.0
\ No newline at end of file
diff --git a/cordova/platforms/ios/ios.json b/cordova/platforms/ios/ios.json
index 9a29c6e79..faf4fafe9 100644
--- a/cordova/platforms/ios/ios.json
+++ b/cordova/platforms/ios/ios.json
@@ -105,6 +105,9 @@
"PHOTO_LIBRARY_ADD_USAGE_DESCRIPTION": "This app requires photo library access to function properly.",
"PHOTO_LIBRARY_USAGE_DESCRIPTION": "This app requires photo library access to function properly.",
"PACKAGE_NAME": "org.tagspaces.mobile"
+ },
+ "com-darryncampbell-cordova-plugin-intent": {
+ "PACKAGE_NAME": "org.tagspaces.mobile"
}
},
"dependent_plugins": {},
@@ -368,6 +371,14 @@
"clobbers": [
"window.plugins.socialsharing"
]
+ },
+ {
+ "id": "com-darryncampbell-cordova-plugin-intent.IntentShim",
+ "file": "plugins/com-darryncampbell-cordova-plugin-intent/www/IntentShim.js",
+ "pluginId": "com-darryncampbell-cordova-plugin-intent",
+ "clobbers": [
+ "intentShim"
+ ]
}
],
"plugin_metadata": {
@@ -382,6 +393,7 @@
"cordova-plugin-file-opener2": "3.0.4",
"cordova-plugin-whitelist": "1.3.4",
"es6-promise-plugin": "4.2.2",
- "cordova-plugin-x-socialsharing": "5.6.8"
+ "cordova-plugin-x-socialsharing": "5.6.8",
+ "com-darryncampbell-cordova-plugin-intent": "2.0.0"
}
}
diff --git a/cordova/platforms/ios/platform_www/cordova_plugins.js b/cordova/platforms/ios/platform_www/cordova_plugins.js
index cba92f03e..87ca27141 100644
--- a/cordova/platforms/ios/platform_www/cordova_plugins.js
+++ b/cordova/platforms/ios/platform_www/cordova_plugins.js
@@ -259,6 +259,14 @@ cordova.define('cordova/plugin_list', function(require, exports, module) {
"clobbers": [
"window.plugins.socialsharing"
]
+ },
+ {
+ "id": "com-darryncampbell-cordova-plugin-intent.IntentShim",
+ "file": "plugins/com-darryncampbell-cordova-plugin-intent/www/IntentShim.js",
+ "pluginId": "com-darryncampbell-cordova-plugin-intent",
+ "clobbers": [
+ "intentShim"
+ ]
}
];
module.exports.metadata = {
@@ -273,6 +281,7 @@ cordova.define('cordova/plugin_list', function(require, exports, module) {
"cordova-plugin-file-opener2": "3.0.4",
"cordova-plugin-whitelist": "1.3.4",
"es6-promise-plugin": "4.2.2",
- "cordova-plugin-x-socialsharing": "5.6.8"
+ "cordova-plugin-x-socialsharing": "5.6.8",
+ "com-darryncampbell-cordova-plugin-intent": "2.0.0"
};
});
\ No newline at end of file
diff --git a/cordova/platforms/ios/platform_www/plugins/com-darryncampbell-cordova-plugin-intent/www/IntentShim.js b/cordova/platforms/ios/platform_www/plugins/com-darryncampbell-cordova-plugin-intent/www/IntentShim.js
new file mode 100644
index 000000000..67be5340c
--- /dev/null
+++ b/cordova/platforms/ios/platform_www/plugins/com-darryncampbell-cordova-plugin-intent/www/IntentShim.js
@@ -0,0 +1,91 @@
+cordova.define("com-darryncampbell-cordova-plugin-intent.IntentShim", function(require, exports, module) {
+var argscheck = require('cordova/argscheck'),
+ channel = require('cordova/channel'),
+ utils = require('cordova/utils'),
+ exec = require('cordova/exec'),
+ cordova = require('cordova');
+
+
+/**
+ * This represents a thin shim layer over the Android Intent implementation
+ * @constructor
+ */
+function IntentShim() {
+ var me = this;
+}
+
+IntentShim.prototype.ACTION_SEND = "android.intent.action.SEND";
+IntentShim.prototype.ACTION_VIEW= "android.intent.action.VIEW";
+IntentShim.prototype.ACTION_INSTALL_PACKAGE="android.intent.action.INSTALL_PACKAGE";
+IntentShim.prototype.ACTION_UNINSTALL_PACKAGE= "android.intent.action.UNINSTALL_PACKAGE";
+IntentShim.prototype.EXTRA_TEXT = "android.intent.extra.TEXT";
+IntentShim.prototype.EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
+IntentShim.prototype.EXTRA_STREAM = "android.intent.extra.STREAM";
+IntentShim.prototype.EXTRA_EMAIL = "android.intent.extra.EMAIL";
+IntentShim.prototype.ACTION_CALL = "android.intent.action.CALL";
+IntentShim.prototype.ACTION_SENDTO = "android.intent.action.SENDTO";
+// StartActivityForResult
+IntentShim.prototype.ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
+IntentShim.prototype.ACTION_PICK = "android.intent.action.PICK";
+IntentShim.prototype.RESULT_CANCELED = 0; // Activity.RESULT_CANCELED
+IntentShim.prototype.RESULT_OK = -1; // Activity.RESULT_OK
+
+IntentShim.prototype.startActivity = function(params, successCallback, errorCallback) {
+ argscheck.checkArgs('off', 'IntentShim.startActivity', arguments);
+ exec(successCallback, errorCallback, "IntentShim", "startActivity", [params]);
+};
+
+IntentShim.prototype.startActivityForResult = function(params, successCallback, errorCallback) {
+ argscheck.checkArgs('off', 'IntentShim.startActivityForResult', arguments);
+ exec(successCallback, errorCallback, "IntentShim", "startActivityForResult", [params]);
+};
+
+IntentShim.prototype.sendBroadcast = function(params, successCallback, errorCallback) {
+ argscheck.checkArgs('off', 'IntentShim.sendBroadcast', arguments);
+ exec(successCallback, errorCallback, "IntentShim", "sendBroadcast", [params]);
+};
+
+IntentShim.prototype.startService = function(params, successCallback, errorCallback) {
+ argscheck.checkArgs('off', 'IntentShim.startService', arguments);
+ exec(successCallback, errorCallback, "IntentShim", "startService", [params]);
+};
+
+IntentShim.prototype.registerBroadcastReceiver = function(params, callback) {
+ argscheck.checkArgs('of', 'IntentShim.registerBroadcastReceiver', arguments);
+ exec(callback, null, "IntentShim", "registerBroadcastReceiver", [params]);
+};
+
+IntentShim.prototype.unregisterBroadcastReceiver = function() {
+ argscheck.checkArgs('', 'IntentShim.unregisterBroadcastReceiver', arguments);
+ exec(null, null, "IntentShim", "unregisterBroadcastReceiver", []);
+};
+
+IntentShim.prototype.onIntent = function(callback) {
+ argscheck.checkArgs('f', 'IntentShim.onIntent', arguments);
+ exec(callback, null, "IntentShim", "onIntent", [callback]);
+};
+
+IntentShim.prototype.onActivityResult = function(callback) {
+ argscheck.checkArgs('f', 'IntentShim.onActivityResult', arguments);
+ exec(callback, null, "IntentShim", "onActivityResult", [callback]);
+};
+
+IntentShim.prototype.getIntent = function(successCallback, failureCallback) {
+ argscheck.checkArgs('ff', 'IntentShim.getIntent', arguments);
+ exec(successCallback, failureCallback, "IntentShim", "getIntent", []);
+};
+
+IntentShim.prototype.sendResult = function(params, callback) {
+ argscheck.checkArgs('of', 'IntentShim.sendResult', arguments);
+ exec(callback, null, "IntentShim", "sendResult", [params]);
+}
+
+IntentShim.prototype.realPathFromUri = function(params, successCallback, errorCallback) {
+ argscheck.checkArgs('off', 'IntentShim.realPathFromUri', arguments);
+ exec(successCallback, errorCallback, "IntentShim", "realPathFromUri", [params]);
+};
+
+window.intentShim = new IntentShim();
+window.plugins = window.plugins || {};
+window.plugins.intentShim = window.intentShim;
+});
diff --git a/cordova/platforms/ios/www/cordova_plugins.js b/cordova/platforms/ios/www/cordova_plugins.js
index cba92f03e..87ca27141 100644
--- a/cordova/platforms/ios/www/cordova_plugins.js
+++ b/cordova/platforms/ios/www/cordova_plugins.js
@@ -259,6 +259,14 @@ cordova.define('cordova/plugin_list', function(require, exports, module) {
"clobbers": [
"window.plugins.socialsharing"
]
+ },
+ {
+ "id": "com-darryncampbell-cordova-plugin-intent.IntentShim",
+ "file": "plugins/com-darryncampbell-cordova-plugin-intent/www/IntentShim.js",
+ "pluginId": "com-darryncampbell-cordova-plugin-intent",
+ "clobbers": [
+ "intentShim"
+ ]
}
];
module.exports.metadata = {
@@ -273,6 +281,7 @@ cordova.define('cordova/plugin_list', function(require, exports, module) {
"cordova-plugin-file-opener2": "3.0.4",
"cordova-plugin-whitelist": "1.3.4",
"es6-promise-plugin": "4.2.2",
- "cordova-plugin-x-socialsharing": "5.6.8"
+ "cordova-plugin-x-socialsharing": "5.6.8",
+ "com-darryncampbell-cordova-plugin-intent": "2.0.0"
};
});
\ No newline at end of file
diff --git a/cordova/platforms/ios/www/plugins/com-darryncampbell-cordova-plugin-intent/www/IntentShim.js b/cordova/platforms/ios/www/plugins/com-darryncampbell-cordova-plugin-intent/www/IntentShim.js
new file mode 100644
index 000000000..67be5340c
--- /dev/null
+++ b/cordova/platforms/ios/www/plugins/com-darryncampbell-cordova-plugin-intent/www/IntentShim.js
@@ -0,0 +1,91 @@
+cordova.define("com-darryncampbell-cordova-plugin-intent.IntentShim", function(require, exports, module) {
+var argscheck = require('cordova/argscheck'),
+ channel = require('cordova/channel'),
+ utils = require('cordova/utils'),
+ exec = require('cordova/exec'),
+ cordova = require('cordova');
+
+
+/**
+ * This represents a thin shim layer over the Android Intent implementation
+ * @constructor
+ */
+function IntentShim() {
+ var me = this;
+}
+
+IntentShim.prototype.ACTION_SEND = "android.intent.action.SEND";
+IntentShim.prototype.ACTION_VIEW= "android.intent.action.VIEW";
+IntentShim.prototype.ACTION_INSTALL_PACKAGE="android.intent.action.INSTALL_PACKAGE";
+IntentShim.prototype.ACTION_UNINSTALL_PACKAGE= "android.intent.action.UNINSTALL_PACKAGE";
+IntentShim.prototype.EXTRA_TEXT = "android.intent.extra.TEXT";
+IntentShim.prototype.EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
+IntentShim.prototype.EXTRA_STREAM = "android.intent.extra.STREAM";
+IntentShim.prototype.EXTRA_EMAIL = "android.intent.extra.EMAIL";
+IntentShim.prototype.ACTION_CALL = "android.intent.action.CALL";
+IntentShim.prototype.ACTION_SENDTO = "android.intent.action.SENDTO";
+// StartActivityForResult
+IntentShim.prototype.ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
+IntentShim.prototype.ACTION_PICK = "android.intent.action.PICK";
+IntentShim.prototype.RESULT_CANCELED = 0; // Activity.RESULT_CANCELED
+IntentShim.prototype.RESULT_OK = -1; // Activity.RESULT_OK
+
+IntentShim.prototype.startActivity = function(params, successCallback, errorCallback) {
+ argscheck.checkArgs('off', 'IntentShim.startActivity', arguments);
+ exec(successCallback, errorCallback, "IntentShim", "startActivity", [params]);
+};
+
+IntentShim.prototype.startActivityForResult = function(params, successCallback, errorCallback) {
+ argscheck.checkArgs('off', 'IntentShim.startActivityForResult', arguments);
+ exec(successCallback, errorCallback, "IntentShim", "startActivityForResult", [params]);
+};
+
+IntentShim.prototype.sendBroadcast = function(params, successCallback, errorCallback) {
+ argscheck.checkArgs('off', 'IntentShim.sendBroadcast', arguments);
+ exec(successCallback, errorCallback, "IntentShim", "sendBroadcast", [params]);
+};
+
+IntentShim.prototype.startService = function(params, successCallback, errorCallback) {
+ argscheck.checkArgs('off', 'IntentShim.startService', arguments);
+ exec(successCallback, errorCallback, "IntentShim", "startService", [params]);
+};
+
+IntentShim.prototype.registerBroadcastReceiver = function(params, callback) {
+ argscheck.checkArgs('of', 'IntentShim.registerBroadcastReceiver', arguments);
+ exec(callback, null, "IntentShim", "registerBroadcastReceiver", [params]);
+};
+
+IntentShim.prototype.unregisterBroadcastReceiver = function() {
+ argscheck.checkArgs('', 'IntentShim.unregisterBroadcastReceiver', arguments);
+ exec(null, null, "IntentShim", "unregisterBroadcastReceiver", []);
+};
+
+IntentShim.prototype.onIntent = function(callback) {
+ argscheck.checkArgs('f', 'IntentShim.onIntent', arguments);
+ exec(callback, null, "IntentShim", "onIntent", [callback]);
+};
+
+IntentShim.prototype.onActivityResult = function(callback) {
+ argscheck.checkArgs('f', 'IntentShim.onActivityResult', arguments);
+ exec(callback, null, "IntentShim", "onActivityResult", [callback]);
+};
+
+IntentShim.prototype.getIntent = function(successCallback, failureCallback) {
+ argscheck.checkArgs('ff', 'IntentShim.getIntent', arguments);
+ exec(successCallback, failureCallback, "IntentShim", "getIntent", []);
+};
+
+IntentShim.prototype.sendResult = function(params, callback) {
+ argscheck.checkArgs('of', 'IntentShim.sendResult', arguments);
+ exec(callback, null, "IntentShim", "sendResult", [params]);
+}
+
+IntentShim.prototype.realPathFromUri = function(params, successCallback, errorCallback) {
+ argscheck.checkArgs('off', 'IntentShim.realPathFromUri', arguments);
+ exec(successCallback, errorCallback, "IntentShim", "realPathFromUri", [params]);
+};
+
+window.intentShim = new IntentShim();
+window.plugins = window.plugins || {};
+window.plugins.intentShim = window.intentShim;
+});
diff --git a/cordova/yarn.lock b/cordova/yarn.lock
index 575d72b0a..16047825e 100644
--- a/cordova/yarn.lock
+++ b/cordova/yarn.lock
@@ -155,22 +155,35 @@ cordova-common@^4.0.1, cordova-common@^4.0.2:
strip-bom "^4.0.0"
underscore "^1.9.2"
-cordova-ios@^6.1.0:
- version "6.1.1"
- resolved "https://registry.yarnpkg.com/cordova-ios/-/cordova-ios-6.1.1.tgz#3347303ddbc3a98073fcb5e0d3af47db66ea2491"
- integrity sha512-WHNvjVhkuwRpq95rISVXtcRyd6UGZapbmU+hO/CAn1c0AIT5WnO8mg2mOjv0WDNa0mt/V5P+N2Vig1UWwfxa5Q==
+cordova-ios@^6.1.1:
+ version "6.2.0"
+ resolved "https://registry.yarnpkg.com/cordova-ios/-/cordova-ios-6.2.0.tgz#3aaec7376b9a202cdcaf28faab6a79823b04c519"
+ integrity sha512-sLjZg2QBI1SpQVwfe0MSn89YNVkBGLW9Q1vcFJBsqKBrhvoEOJ5Ytq0gwqdhgTOGzlwJUfxC6OHM3jcsRjtYrw==
dependencies:
cordova-common "^4.0.2"
- fs-extra "^9.0.0"
+ fs-extra "^9.1.0"
ios-sim "^8.0.2"
- nopt "^4.0.3"
+ nopt "^5.0.0"
plist "^3.0.1"
- semver "^7.3.2"
+ semver "^7.3.4"
unorm "^1.6.0"
which "^2.0.2"
xcode "^3.0.1"
xml-escape "^1.1.0"
+"cordova-ourcodeworld-filebrowser@git+https://github.com/ourcodeworld/cordova-ourcodeworld-filebrowser.git":
+ version "1.0.0"
+ resolved "git+https://github.com/ourcodeworld/cordova-ourcodeworld-filebrowser.git#b4824ea23d9e359708207158420b43cd5e816790"
+
+ version "2.0.2"
+ resolved "https://registry.yarnpkg.com/cordova-plugin-add-swift-support/-/cordova-plugin-add-swift-support-2.0.2.tgz#bfa848356f35edc0898403eb510fe407adb40e9f"
+ integrity sha512-K03WDnsD3GT+n7Od3BnS17D8rYnAFZbZjjQJa2r7qW8QLq8+h7hGbFaiF+w5+nUtyAqUNq+HT/d/MdqBGLNzxA==
+ dependencies:
+ glob "^7.1.3"
+ semver "^6.0.0"
+ xcode "^2.0.0"
+
cordova-plugin-androidx-adapter@^1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/cordova-plugin-androidx-adapter/-/cordova-plugin-androidx-adapter-1.1.3.tgz#aa7e673ee342de208a6a34a50986ee2ac4b5ba60"
@@ -307,6 +320,16 @@ fs-extra@^9.0.0, fs-extra@^9.0.1:
jsonfile "^6.0.1"
universalify "^1.0.0"
+fs-extra@^9.1.0:
+ version "9.1.0"
+ resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-9.1.0.tgz#5954460c764a8da2094ba3554bf839e6b9a7c86d"
+ integrity sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==
+ dependencies:
+ at-least-node "^1.0.0"
+ graceful-fs "^4.2.0"
+ jsonfile "^6.0.1"
+ universalify "^2.0.0"
+
fs.realpath@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
@@ -326,7 +349,7 @@ glob-parent@^5.1.0:
dependencies:
is-glob "^4.0.1"
-glob@^7.1.6:
+glob@^7.1.3, glob@^7.1.6:
version "7.1.6"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6"
integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==
@@ -464,6 +487,13 @@ nopt@^4.0.3:
abbrev "1"
osenv "^0.1.4"
+nopt@^5.0.0:
+ version "5.0.0"
+ resolved "https://registry.yarnpkg.com/nopt/-/nopt-5.0.0.tgz#530942bb58a512fccafe53fe210f13a25355dc88"
+ integrity sha512-Tbj67rffqceeLpcRXrT7vKAN8CwfPeIBgM7E6iBkmKLV7bEMwpGgYLGv0jACUsECaa/vuxP0IjEont6umdMgtQ==
+ dependencies:
+ abbrev "1"
+
npm-run-path@^4.0.0:
version "4.0.1"
resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-4.0.1.tgz#b7ecd1e5ed53da8e37a55e1c2269e0b97ed748ea"
@@ -602,7 +632,12 @@ semver@^5.7.1:
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7"
integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==
-semver@^7.3.2:
+semver@^6.0.0:
+ version "6.3.0"
+ resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
+ integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==
+
+semver@^7.3.4:
version "7.3.4"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.4.tgz#27aaa7d2e4ca76452f98d3add093a72c943edc97"
integrity sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==
@@ -639,7 +674,7 @@ simctl@^2:
shelljs "^0.2.6"
tail "^0.4.0"
-simple-plist@^1.1.0:
+simple-plist@^1.0.0, simple-plist@^1.1.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/simple-plist/-/simple-plist-1.1.1.tgz#54367ca28bc5996a982c325c1c4a4c1a05f4047c"
integrity sha512-pKMCVKvZbZTsqYR6RKgLfBHkh2cV89GXcA/0CVPje3sOiNOnXA8+rp/ciAMZ7JRaUdLzlEM6JFfUn+fS6Nt3hg==
@@ -700,6 +735,11 @@ unorm@^1.6.0:
resolved "https://registry.yarnpkg.com/unorm/-/unorm-1.6.0.tgz#029b289661fba714f1a9af439eb51d9b16c205af"
integrity sha512-b2/KCUlYZUeA7JFUuRJZPUtr4gZvBh7tavtv4fvk4+KV9pfGiR6CQAQAWl49ZpR3ts2dk4FYkP7EIgDJoiOLDA==
+uuid@^3.3.2:
+ version "3.4.0"
+ resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee"
+ integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==
+
uuid@^7.0.3:
version "7.0.3"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-7.0.3.tgz#c5c9f2c8cf25dc0a372c4df1441c41f5bd0c680b"
@@ -726,6 +766,14 @@ wrappy@1:
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=
+xcode@^2.0.0:
+ version "2.1.0"
+ resolved "https://registry.yarnpkg.com/xcode/-/xcode-2.1.0.tgz#bab64a7e954bb50ca8d19da7e09531c65a43ecfe"
+ integrity sha512-uCrmPITrqTEzhn0TtT57fJaNaw8YJs1aCzs+P/QqxsDbvPZSv7XMPPwXrKvHtD6pLjBM/NaVwraWJm8q83Y4iQ==
+ dependencies:
+ simple-plist "^1.0.0"
+ uuid "^3.3.2"
+
xcode@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/xcode/-/xcode-3.0.1.tgz#3efb62aac641ab2c702458f9a0302696146aa53c"