senset-walkie-plugin 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
package/.idea/misc.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectRootManager" version="2" project-jdk-name="Android API 33, extension level 3 Platform" project-jdk-type="Android SDK">
4
+ <output url="file://$PROJECT_DIR$/out" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/senset-walkie.iml" filepath="$PROJECT_DIR$/senset-walkie.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
package/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$/../../../.." vcs="Git" />
5
+ </component>
6
+ </project>
package/README.md ADDED
@@ -0,0 +1,2 @@
1
+ # Printer plugin
2
+
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "senset-walkie-plugin",
3
+ "version": "0.0.1",
4
+ "description": "Ivo popis package.json.",
5
+ "cordova": {
6
+ "id": "senset-walkie-plugin",
7
+ "platforms": [
8
+ "android"
9
+ ]
10
+ },
11
+ "keywords": [
12
+ "cordova",
13
+ "android",
14
+ "senset",
15
+ "walkie",
16
+ "ecosystem:cordova",
17
+ "cordova-android"
18
+ ],
19
+ "engines": [
20
+ {
21
+ "name": "cordova",
22
+ "version": ">=3.0.0"
23
+ }
24
+ ],
25
+ "author": "Ivan Ivanco <info@senset.sk>",
26
+ "license": "MIT",
27
+ "bugs": {
28
+ "url": "https://github.com/stanidesis/toastyplugin/issues"
29
+ },
30
+ "homepage": "https://bitbucket.org/orderocks/printer-plugin.git"
31
+ }
package/plugin.xml ADDED
@@ -0,0 +1,39 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
3
+ xmlns:android="http://schemas.android.com/apk/res/android"
4
+ id="senset-walkie" version="0.0.1">
5
+ <name>Senset Walkie Talkie plugin</name>
6
+
7
+ <description>Ivo plugin popis.</description>
8
+ <license>MIT</license>
9
+
10
+ <keywords>cordova,android,bluetooth,printer</keywords>
11
+ <repo>https://bitbucket.org/orderocks/printer-plugin.git</repo>
12
+ <!-- <issue>https://github.com/stanidesis/toastyplugin/issues</issue> -->
13
+
14
+ <engines>
15
+ <engine name="cordova" version=">=3.0.0"/>
16
+ </engines>
17
+
18
+ <js-module src="www/senset-walkie.js" name="sensetWalkie">
19
+ <clobbers target="window.plugins.sensetWalkie" />
20
+ </js-module>
21
+ <platform name="android">
22
+ <config-file target="res/xml/config.xml" parent="/*">
23
+ <feature name="sensetWalkie">
24
+ <param name="android-package" value="sk.senset.cordova.plugin.sensetWalkie"/>
25
+ </feature>
26
+ </config-file>
27
+
28
+ <config-file target="AndroidManifest.xml" parent="/*">
29
+ <uses-permission android:name="android.permission.BLUETOOTH" />
30
+ <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
31
+ <service android:name="sk.senset.cordova.plugin.SendService" >
32
+ <intent-filter>
33
+ <action android:name="sk.senset.cordova.plugin.SendService" />
34
+ </intent-filter>
35
+ </service>
36
+ </config-file>
37
+ <source-file src="src/android/SensetWalkie.java" target-dir="src/sk/senset/cordova/plugin" />
38
+ </platform>
39
+ </plugin>
@@ -0,0 +1,11 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="JAVA_MODULE" version="4">
3
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
4
+ <exclude-output />
5
+ <content url="file://$MODULE_DIR$">
6
+ <sourceFolder url="file://$MODULE_DIR$/src/android" isTestSource="false" packagePrefix="sk.senset.cordova.plugin" />
7
+ </content>
8
+ <orderEntry type="inheritedJdk" />
9
+ <orderEntry type="sourceFolder" forTests="false" />
10
+ </component>
11
+ </module>
@@ -0,0 +1,69 @@
1
+ package sk.senset.cordova.plugin;
2
+ // Cordova-required packages
3
+
4
+ import org.apache.cordova.CallbackContext;
5
+ import org.apache.cordova.CordovaPlugin;
6
+ import org.apache.cordova.PluginResult;
7
+ import org.json.JSONArray;
8
+ import org.json.JSONException;
9
+ import org.json.JSONObject;
10
+
11
+ import android.util.Log;
12
+
13
+ import java.text.SimpleDateFormat;
14
+ import java.util.Calendar;
15
+
16
+ public class SensetWalkie extends CordovaPlugin {
17
+
18
+ public static String logs = "";
19
+ public static String logGroup = "";
20
+
21
+ public static void debug(String text) {
22
+ String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(Calendar.getInstance().getTime());
23
+ if (SensetWalkie.logGroup.equals("")) {
24
+ SensetWalkie.logGroup = new SimpleDateFormat("yyyyMMdd_HHmmssSSS").format(Calendar.getInstance().getTime());
25
+ }
26
+ String debugtext = "G:" + SensetWalkie.logGroup + "|D:" + timeStamp + "|T:" + text + "|||";
27
+ Log.i("WALKIEPRINT", debugtext);
28
+ SensetWalkie.logs += debugtext;
29
+ }
30
+
31
+ @Override
32
+ public boolean execute(String action, JSONArray args,
33
+ final CallbackContext callbackContext) {
34
+ String userId;
35
+ String companyId;
36
+ String userName;
37
+ SensetWalkie.debug("SensetWalkie execute " + action);
38
+ try {
39
+ JSONObject options = args.getJSONObject(0);
40
+ userId = options.getString("userId");
41
+ companyId = options.getString("companyId");
42
+ userName = options.getString("userName");
43
+ SensetWalkie.debug("SensetWalkie userId " + userId + ", userName: " + userName + ", companyId: " + companyId);
44
+ } catch (JSONException e) {
45
+ callbackContext.error("Error encountered: " + e.getMessage());
46
+ SensetWalkie.logs = "";
47
+ return false;
48
+ }
49
+ // if (printerName.equals("")) {
50
+ // callbackContext.error("o1-Empty printer name");
51
+ // SensetWalkie.logs = "";
52
+ // return false;
53
+ // }
54
+ // BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
55
+ // if (!bluetoothAdapter.isEnabled()) {
56
+ // callbackContext.error("o4-Bluetooth not enabled");
57
+ // SensetWalkie.logs = "";
58
+ // return false;
59
+ // }
60
+ if (action.equals("start")) {
61
+ callbackContext.success(SensetWalkie.logs);
62
+ return true;
63
+ }
64
+ callbackContext.error("Unknown method: " + action);
65
+ SensetWalkie.logs = "";
66
+ return false;
67
+ }
68
+
69
+ }
@@ -0,0 +1,21 @@
1
+ function SensetWalkie() {}
2
+
3
+ // The function that passes work along to native shells
4
+ // Message is a string, duration may be 'long' or 'short'
5
+ SensetWalkie.prototype.start = function(companyId, userId, userName, successCallback, errorCallback) {
6
+ var options = {};
7
+ options.companyId = companyId+'';
8
+ options.userId = userId+'';
9
+ options.userName = userName+'';
10
+ cordova.exec(successCallback, errorCallback, 'SensetWalkie', 'start', [options]);
11
+ }
12
+
13
+ // Installation constructor that binds SensetWalkie to window
14
+ SensetWalkie.install = function() {
15
+ if (!window.plugins) {
16
+ window.plugins = {};
17
+ }
18
+ window.plugins.SensetWalkie = new SensetWalkie();
19
+ return window.plugins.SensetWalkie;
20
+ };
21
+ cordova.addConstructor(SensetWalkie.install)