com-easystep2-datawedge-plugin-intent-cordova 4.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Darryn
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,348 @@
1
+ *Please be aware that this application / sample is provided as-is for demonstration purposes without any guarantee of support*
2
+ =========================================================
3
+
4
+ # EasyStep2 DataWedge Plugin Intent
5
+
6
+ This is an updated and maintained version of the original [darryncampbell-cordova-plugin-intent](https://github.com/darryncampbell/darryncampbell-cordova-plugin-intent) plugin, now named `com.easystep2.datawedge.plugin.intent`.
7
+
8
+ [![npm version](http://img.shields.io/npm/v/com.easystep2.datawedge.plugin.intent.svg?style=flat-square)](https://npmjs.org/package/com.easystep2.datawedge.plugin.intent "View this project on npm")
9
+
10
+ ## Enhancements by EasyStep2
11
+ - Fixed compatibility issues with Angular 14+
12
+ - Maintained in two branches:
13
+ - **cordova**: For traditional Cordova applications
14
+ - **capacitor**: For Ionic Capacitor applications
15
+ - Regularly updated and maintained
16
+
17
+ The original plugin badges are preserved for reference:
18
+
19
+ [![Original npm version](http://img.shields.io/npm/v/com-darryncampbell-cordova-plugin-intent.svg?style=flat-square&label=original)](https://npmjs.org/package/com-darryncampbell-cordova-plugin-intent "View original project on npm")
20
+ [![Original npm downloads](http://img.shields.io/npm/dm/com-darryncampbell-cordova-plugin-intent.svg?style=flat-square&label=original%20downloads)](https://npmjs.org/package/com-darryncampbell-cordova-plugin-intent "View original project on npm")
21
+ [![Original npm total downloads](http://img.shields.io/npm/dt/com-darryncampbell-cordova-plugin-intent.svg?style=flat-square&label=original%20total)](https://npmjs.org/package/com-darryncampbell-cordova-plugin-intent "View original project on npm")
22
+ [![Original npm licence](http://img.shields.io/npm/l/com-darryncampbell-cordova-plugin-intent.svg?style=flat-square&label=license)](https://npmjs.org/package/com-darryncampbell-cordova-plugin-intent "View original project on npm")
23
+
24
+ Note: the original plugin was the underlying implementation for https://www.npmjs.com/package/@ionic-native/web-intent and https://ionicframework.com/docs/native/web-intent/
25
+
26
+ # Android X support
27
+ - For Android X Support please use version >= [2.x.x](https://www.npmjs.com/package/com.easystep2.datawedge.plugin.intent)
28
+ - For Android Support Library please refer to the original plugin version [1.3.x](https://www.npmjs.com/package/com-darryncampbell-cordova-plugin-intent/v/1.3.0)
29
+
30
+ # Interaction with Camera Plugin
31
+ If you are installing this plugin along with cordova-plugin-camera you **MUST install cordova-plugin-camera first.**
32
+
33
+ # Overview
34
+ This Cordova plugin provides a general purpose shim layer for the Android intent mechanism, exposing various ways to handle sending and receiving intents.
35
+
36
+ ## Credits
37
+ This project is based on code released under the following MIT projects:
38
+ - https://github.com/darryncampbell/darryncampbell-cordova-plugin-intent
39
+ - https://github.com/napolitano/cordova-plugin-intent (marked as no longer maintained)
40
+ - https://github.com/Initsogar/cordova-webintent.git (no longer available on github but the project is forked here: https://github.com/darryncampbell/cordova-webintent)
41
+
42
+ This project is also released under MIT. Credit is given in the code where appropriate.
43
+
44
+ ## IntentShim
45
+ This plugin defines a `window.plugins.intentShim` object which provides an API for interacting with the Android intent mechanism on any Android device.
46
+
47
+ ## Testing / Example
48
+ An example application is available at https://github.com/darryncampbell/plugin-intent-api-exerciser to demonstrate the API and can be used to test the functionality.
49
+
50
+ ## Installation
51
+
52
+ ### Cordova
53
+ ```bash
54
+ cordova plugin add com.easystep2.datawedge.plugin.intent
55
+ ```
56
+
57
+ ### Ionic Capacitor
58
+ ```bash
59
+ npm install com.easystep2.datawedge.plugin.intent
60
+ npx cap sync
61
+ ```
62
+
63
+ ## Supported Platforms
64
+ - Android
65
+
66
+ ## intentShim.registerBroadcastReceiver
67
+
68
+ Registers a broadcast receiver for the specified filters
69
+
70
+ window.plugins.intentShim.registerBroadcastReceiver(filters, callback);
71
+
72
+ ### Description
73
+
74
+ The `intentShim.registerBroadcastReceiver` function registers a dynamic broadcast receiver for the specified list of filters and invokes the specified callback when any of those filters are received
75
+
76
+ ### Example
77
+
78
+ Register a broadcast receiver for two filters:
79
+
80
+ window.plugins.intentShim.registerBroadcastReceiver({
81
+ filterActions: [
82
+ 'com.easystep2.datawedge.plugin.broadcastIntent.ACTION',
83
+ 'com.easystep2.datawedge.plugin.broadcastIntent.ACTION_2'
84
+ ]
85
+ },
86
+ function(intent) {
87
+ console.log('Received broadcast intent: ' + JSON.stringify(intent.extras));
88
+ }
89
+ );
90
+
91
+
92
+ ## intentShim.unregisterBroadcastReceiver
93
+
94
+ Unregisters any BroadcastRecivers
95
+
96
+ window.plugins.intentShim.unregisterBroadcastReceiver();
97
+
98
+ ### Description
99
+
100
+ The `intentShim.unregisterBroadcastReceiver` function unregisters all broadcast receivers registered with `intentShim.registerBroadcastReceiver(filters, callback);`. No further broadcasts will be received for any registered filter after this call.
101
+
102
+ ### Android Quirks
103
+
104
+ The developer is responsible for calling unregister / register when their application goes into the background or comes back to the foreground, if desired.
105
+
106
+ ### Example
107
+
108
+ Unregister the broadcast receiver when the application receives an onPause event:
109
+
110
+ bindEvents: function() {
111
+ document.addEventListener('pause', this.onPause, false);
112
+ },
113
+ onPause: function()
114
+ {
115
+ window.plugins.intentShim.unregisterBroadcastReceiver();
116
+ }
117
+
118
+ ## intentShim.sendBroadcast
119
+
120
+ Sends a broadcast intent
121
+
122
+ window.plugins.intentShim.sendBroadcast(action, extras, successCallback, failureCallback);
123
+
124
+ ### Description
125
+
126
+ The `intentShim.sendBroadcast` function sends an Android broadcast intent with a specified action
127
+
128
+ ### Example
129
+
130
+ Send a broadcast intent to a specified action that contains a random number in the extras
131
+
132
+ window.plugins.intentShim.startActivity(
133
+ {
134
+ action: "com.easystep2.datawedge.plugin.intent.ACTION",
135
+ extras: {
136
+ 'random.number': Math.floor((Math.random() * 1000) + 1)
137
+ }
138
+ },
139
+ function() {},
140
+ function() {alert('Failed to open URL via Android Intent')}
141
+ );
142
+
143
+
144
+ ## intentShim.onIntent
145
+
146
+ Returns the content of the intent used whenever the application activity is launched
147
+
148
+ window.plugins.intentShim.onIntent(callback);
149
+
150
+ ### Description
151
+
152
+ The `intentShim.onIntent` function returns the intent which launched the Activity and maps to the Android Activity's onNewIntent() method, https://developer.android.com/reference/android/app/Activity.html#onNewIntent(android.content.Intent). The registered callback is invoked whenever the activity is launched
153
+
154
+ ### Android Quirks
155
+
156
+ By default the android application will be created with launch mode set to 'SingleTop'. If you wish to change this to 'SingleTask' you can do so by modifying `config.xml` as follows:
157
+
158
+ <platform name="android">
159
+ ...
160
+ <preference name="AndroidLaunchMode" value="singleTask"/>
161
+ </platform>
162
+ See https://www.mobomo.com/2011/06/android-understanding-activity-launchmode/ for more information on the differences between the two.
163
+
164
+ ### Example
165
+
166
+ Registers a callback to be invoked
167
+
168
+ window.plugins.intentShim.onIntent(function (intent) {
169
+ console.log('Received Intent: ' + JSON.stringify(intent.extras));
170
+ });
171
+
172
+ ## intentShim.startActivity
173
+
174
+ Starts a new activity using an intent built from action, url, type, extras or some subset of those parameters
175
+
176
+ window.plugins.intentShim.startActivity(params, successCallback, failureCallback);
177
+
178
+ ### Description
179
+
180
+ The `intentShim.startActivity` function maps to Android's activity method startActivity, https://developer.android.com/reference/android/app/Activity.html#startActivity(android.content.Intent) to launch a new activity.
181
+
182
+ ### Android Quirks
183
+
184
+ Some common actions are defined as constants in the plugin, see below.
185
+
186
+ ### Examples
187
+
188
+ Launch the maps activity
189
+
190
+ window.plugins.intentShim.startActivity(
191
+ {
192
+ action: window.plugins.intentShim.ACTION_VIEW,
193
+ url: 'geo:0,0?q=London'
194
+ },
195
+ function() {},
196
+ function() {alert('Failed to open URL via Android Intent')}
197
+ );
198
+
199
+ Launch the web browser
200
+
201
+ window.plugins.intentShim.startActivity(
202
+ {
203
+ action: window.plugins.intentShim.ACTION_VIEW,
204
+ url: 'http://www.google.co.uk'
205
+ },
206
+ function() {},
207
+ function() {alert('Failed to open URL via Android Intent')}
208
+ );
209
+
210
+ ## intentShim.getIntent
211
+
212
+ Retrieves the intent that launched the activity
213
+
214
+ window.plugins.intentShim.getIntent(resultCallback, failureCallback);
215
+
216
+ ### Description
217
+
218
+ The `intentShim.getIntent` function maps to Android's activity method getIntent, https://developer.android.com/reference/android/app/Activity.html#getIntent() to return the intent that started this activity.
219
+
220
+ ### Example
221
+
222
+ window.plugins.intentShim.getIntent(
223
+ function(intent)
224
+ {
225
+ console.log('Action' + JSON.stringify(intent.action));
226
+ var intentExtras = intent.extras;
227
+ if (intentExtras == null)
228
+ intentExtras = "No extras in intent";
229
+ console.log('Launch Intent Extras: ' + JSON.stringify(intentExtras));
230
+ },
231
+ function()
232
+ {
233
+ console.log('Error getting launch intent');
234
+ });
235
+
236
+
237
+ ## intentShim.startActivityForResult
238
+
239
+ Starts a new activity and return the result to the application
240
+
241
+ window.plugins.intentShim.startActivityForResult(params, resultCallback, failureCallback);
242
+
243
+ ### Description
244
+
245
+ The `intentShim.startActivityForResult` function maps to Android's activity method startActivityForResult, https://developer.android.com/reference/android/app/Activity.html#startActivityForResult(android.content.Intent, int) to launch a new activity and the resulting data is returned via the resultCallback.
246
+
247
+ ### Android Quirks
248
+
249
+ Some common actions are defined as constants in the plugin, see below.
250
+
251
+ ### Example
252
+
253
+ Pick an Android contact
254
+
255
+ window.plugins.intentShim.startActivityForResult(
256
+ {
257
+ action: window.plugins.intentShim.ACTION_PICK,
258
+ url: "content://com.android.contacts/contacts",
259
+ requestCode: 1
260
+ },
261
+ function(intent)
262
+ {
263
+ if (intent.extras.requestCode == 1)
264
+ {
265
+ console.log('Picked contact: ' + intent.data);
266
+ }
267
+ },
268
+ function()
269
+ {
270
+ console.log("StartActivityForResult failure");
271
+ });
272
+
273
+ ## intentShim.sendResult
274
+
275
+ Assuming this application was started with `intentShim.startActivityForResult`, send a result back
276
+
277
+ window.plugins.intentShim.sendResult(args, callback);
278
+
279
+ ### Description
280
+
281
+ The `intentShim.sendResult` function returns an `Activity.RESULT_OK` Intent to the activity that started this application, along with any extras that you want to send along (as `args.extras` object), and a `callback` function. It then calls Android Activity's finish() method, https://developer.android.com/reference/android/app/Activity.html#finish().
282
+
283
+ ### Android Quirks
284
+
285
+ Both `args` and `callback` arguments have to be provided. If you do not need the functionality, send an empty object and an empty function
286
+
287
+ window.plugins.intentShim.sendResult({}, function() {});
288
+
289
+ ### Example
290
+
291
+ window.plugins.intentShim.sendResult(
292
+ {
293
+ extras: {
294
+ 'Test Intent': 'Successfully sent',
295
+ 'Test Intent int': 42,
296
+ 'Test Intent bool': true,
297
+ 'Test Intent double': parseFloat("142.12")
298
+ }
299
+ },
300
+ function() {
301
+
302
+ }
303
+ );
304
+
305
+ ## intentShim.packageExists
306
+ Returns a boolean indicating if a specific package is installed on the device.
307
+
308
+ ```js
309
+ window.plugins.intentShim.packageExists(packageName, callback);
310
+ ```
311
+
312
+ ### Description
313
+
314
+ The `intentShim.packageExists` function returns a boolean indicating if a specific [package](https://developer.android.com/studio/build/configure-app-module#set_the_application_id) is installed on the current device.
315
+
316
+ ### Example
317
+ ```js
318
+ const packageName = 'com.android.contacts';
319
+
320
+ window.plugins.intentShim.packageExists(packageName, (exists) => {
321
+ if (exists) {
322
+ console.log(`${packageName} exists!`);
323
+ } else {
324
+ console.log(`${packageName} does not exist...`);
325
+ }
326
+ });
327
+ ```
328
+
329
+ ## Predefined Constants
330
+
331
+ The following constants are defined in the plugin for use in JavaScript
332
+ - window.plugins.intentShim.ACTION_SEND
333
+ - window.plugins.intentShim.ACTION_VIEW
334
+ - window.plugins.intentShim.EXTRA_TEXT
335
+ - window.plugins.intentShim.EXTRA_SUBJECT
336
+ - window.plugins.intentShim.EXTRA_STREAM
337
+ - window.plugins.intentShim.EXTRA_EMAIL
338
+ - window.plugins.intentShim.ACTION_CALL
339
+ - window.plugins.intentShim.ACTION_SENDTO
340
+ - window.plugins.intentShim.ACTION_GET_CONTENT
341
+ - window.plugins.intentShim.ACTION_PICK
342
+
343
+ ## Tested Versions
344
+
345
+ Tested with Cordova version 6.5.0 and Cordova Android version 6.2.1
346
+
347
+
348
+
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "com-easystep2-datawedge-plugin-intent-cordova",
3
+ "version": "4.2.2",
4
+ "description": "Capacitor and Cordova plugins for Android Intents",
5
+ "scripts": {
6
+ "test": "echo \"Error: no test specified\" && exit 1"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/easystep2/easystep2-datawedge-plugin-intent.git"
11
+ },
12
+ "keywords": [
13
+ "capacitor",
14
+ "cordova",
15
+ "plugin",
16
+ "android",
17
+ "intent",
18
+ "datawedge",
19
+ "zebra",
20
+ "scanner",
21
+ "barcode"
22
+ ],
23
+ "author": "Easystep2",
24
+ "license": "MIT",
25
+ "cordova": {
26
+ "id": "com-easystep2-datawedge-plugin-intent-cordova",
27
+ "platforms": [
28
+ "android"
29
+ ]
30
+ }
31
+ }
package/plugin.xml ADDED
@@ -0,0 +1,84 @@
1
+ <?xml version='1.0' encoding='utf-8'?>
2
+ <plugin id="com-easystep2-datawedge-plugin-intent" version="4.1.1" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
3
+ <name>Intent Shim</name>
4
+ <js-module name="IntentShim" src="www/IntentShim.js">
5
+ <clobbers target="intentShim" />
6
+ </js-module>
7
+
8
+ <hook type="after_prepare" src="hooks/after_prepare.js" />
9
+
10
+ <!-- android -->
11
+ <platform name="android">
12
+ <config-file target="res/xml/config.xml" parent="/*">
13
+ <feature name="IntentShim" >
14
+ <param name="android-package" value="com.easystep2.datawedge.plugin.intent.IntentShim"/>
15
+ <param name="onload" value="true"/>
16
+ </feature>
17
+ </config-file>
18
+ <config-file target="AndroidManifest.xml" platform="android" parent="/manifest/application/activity" mode="merge">
19
+ <intent-filter>
20
+ <action android:name="com.easystep2.datawedge.plugin.intent.ACTION" />
21
+ <category android:name="android.intent.category.DEFAULT" />
22
+ </intent-filter>
23
+ </config-file>
24
+ <config-file target="AndroidManifest.xml" platform="android" parent="/manifest" mode="merge">
25
+ <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32" />
26
+ </config-file>
27
+ <config-file target="AndroidManifest.xml" platform="android" parent="/manifest/application" mode="merge">
28
+ <provider
29
+ android:name="com.easystep2.datawedge.plugin.intent.CordovaPluginIntentFileProvider"
30
+ android:authorities="${applicationId}.easystep2.datawedge.plugin.intent.fileprovider"
31
+ android:exported="false"
32
+ android:grantUriPermissions="true">
33
+ <meta-data
34
+ android:name="android.support.FILE_PROVIDER_PATHS"
35
+ android:resource="@xml/provider_paths"/>
36
+ </provider>
37
+ </config-file>
38
+
39
+ <!-- Add explicit FileProvider configuration for Android 7+ (API 24+) -->
40
+ <config-file target="AndroidManifest.xml" parent="application">
41
+ <provider
42
+ android:name="androidx.core.content.FileProvider"
43
+ android:authorities="${applicationId}.easystep2.datawedge.plugin.intent.fileprovider"
44
+ android:exported="false"
45
+ android:grantUriPermissions="true">
46
+ <meta-data
47
+ android:name="android.support.FILE_PROVIDER_PATHS"
48
+ android:resource="@xml/provider_paths" />
49
+ </provider>
50
+ </config-file>
51
+
52
+ <!-- Ensure FileProvider is properly configured -->
53
+ <config-file target="AndroidManifest.xml" parent="application">
54
+ <!-- FileProvider might already be defined, just ensure it has these attributes -->
55
+ <provider
56
+ android:name="androidx.core.content.FileProvider"
57
+ android:authorities="${applicationId}.easystep2.datawedge.plugin.intent.fileprovider"
58
+ android:exported="false"
59
+ android:grantUriPermissions="true">
60
+ <meta-data
61
+ android:name="android.support.FILE_PROVIDER_PATHS"
62
+ android:resource="@xml/provider_paths" />
63
+ </provider>
64
+ </config-file>
65
+
66
+ <!-- Add necessary permissions with maxSdkVersion where appropriate -->
67
+ <config-file target="AndroidManifest.xml" parent="/*">
68
+ <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32" />
69
+ <!-- For Android 13+ (API 33+), add more specific media permissions -->
70
+ <uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
71
+ <uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
72
+ <uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
73
+ </config-file>
74
+
75
+ <source-file src="src/android/IntentShim.java" target-dir="src/com/easystep2/plugin/intent" />
76
+ <source-file src="src/android/CordovaPluginIntentFileProvider.java" target-dir="src/com/easystep2/plugin/intent" />
77
+ <resource-file src="src/android/res/xml/provider_paths.xml" target="res/xml/provider_paths.xml"/>
78
+ <framework src="androidx.core:core:1.1.0" />
79
+ </platform>
80
+
81
+ </plugin>
82
+ </platform>
83
+
84
+ </plugin>
@@ -0,0 +1,4 @@
1
+ package com.easystep2.datawedge.plugin.intent;
2
+
3
+ public class CordovaPluginIntentFileProvider extends androidx.core.content.FileProvider {
4
+ }