cordova-plugin-netcontroll-integration 1.0.1

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/README.md ADDED
@@ -0,0 +1,9 @@
1
+ Version 0.0.2 - Adição de Keywords, ajustes na configuração do plugin (plugin.xml e package.json) e adição de conteúdo ao README.
2
+ Version 0.0.3 - Versão da bibloteca E1 atualizada para 1.0.16 (corte extra no imprimeXMLNFCE removido), atualização de imports e adição de comentários.
3
+
4
+ É necessário instalar o plugin que permite a compilação de projetos/plugins que referenciem tanto as librarys do Android Support e AndroidX, que é o caso da versão mais atual da lib "E1":
5
+ #cordova-plugin-androidx-adapter
6
+
7
+ clobbers:
8
+ cordova.plugins.elgin.minipdv
9
+
@@ -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" />
7
+ </content>
8
+ <orderEntry type="inheritedJdk" />
9
+ <orderEntry type="sourceFolder" forTests="false" />
10
+ </component>
11
+ </module>
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "cordova-plugin-netcontroll-integration",
3
+ "version": "1.0.1",
4
+ "description": "Plugin cordova de integracao para uso interno (NetControll/ XMenu)",
5
+ "cordova": {
6
+ "id": "cordova-plugin-netcontroll-integration",
7
+ "platforms": [
8
+ "android"
9
+ ]
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/developernetcontroll/cordova-plugin-netcontroll-integration"
14
+ },
15
+ "keywords": [
16
+ "ecosystem:cordova",
17
+ "cordova-android",
18
+ "netcontroll",
19
+ "xmenu",
20
+ "elgin",
21
+ "minipdv",
22
+ "M8",
23
+ "M10"
24
+ ],
25
+ "author": "Luccas Quintino",
26
+ "license": "ISC",
27
+ "bugs": {
28
+ "url": "https://github.com/developernetcontroll/cordova-plugin-netcontroll-integration"
29
+ },
30
+ "homepage": "https://github.com/developernetcontroll/cordova-plugin-netcontroll-integration#readme"
31
+ }
package/plugin.xml ADDED
@@ -0,0 +1,36 @@
1
+ <?xml version='1.0' encoding='utf-8'?>
2
+ <plugin id="cordova-plugin-netcontroll-integration" version="1.0.13"
3
+ xmlns="http://apache.org/cordova/ns/plugins/1.0"
4
+ xmlns:android="http://schemas.android.com/apk/res/android">
5
+
6
+ <name>NetControllCordovaPluginsIntegration</name>
7
+ <js-module name="NetControllCordovaPluginsIntegration" src="www/NetControllCordovaPluginsIntegration.js">
8
+ <clobbers target="cordova.plugins.NetControllCordovaPluginsIntegration" />
9
+ </js-module>
10
+ <dependency id="cordova-plugin-androidx-adapter" version="1.1.3" />
11
+ <platform name="android">
12
+ <config-file parent="/*" target="res/xml/config.xml">
13
+ <feature name="NetControllCordovaPluginsIntegration">
14
+ <param name="android-package" value="cordova.plugin.netcontroll.integration.NetControllCordovaPluginsIntegration" />
15
+ <param name="onload" value="true"/>
16
+ </feature>
17
+
18
+ <preference name="AndroidXEnabled" value="true" />
19
+ </config-file>
20
+
21
+ <config-file parent="/*" target="AndroidManifest.xml">
22
+ </config-file>
23
+
24
+ <!-- executable source code > -->
25
+ <source-file src="src/android/NetControllCordovaPluginsIntegration.java" target-dir="src/cordova-plugin-m8/cordova-plugin-m8" />
26
+
27
+ <framework src="src/build.gradle" custom="true" type="gradleReference" />
28
+
29
+ <!-- Lib Files -->
30
+ <resource-file src="src/libs/minipdvm8.aar" target="libs/minipdvm8.aar" />
31
+ <resource-file src="src/libs/e1-v1.0.16-release.aar" target="libs/e1-v1.0.16-release.aar" />
32
+
33
+ <!--
34
+ <source-file src="src/android/NetControllCordovaPluginsIntegration.java" target-dir="src/cordova/plugin/netcontroll/integration/NetControllCordovaPluginsIntegration" /> -->
35
+ </platform>
36
+ </plugin>
@@ -0,0 +1,295 @@
1
+ package cordova.plugin.netcontroll.integration;
2
+
3
+ import org.apache.cordova.CordovaPlugin;
4
+ import org.apache.cordova.CallbackContext;
5
+ import org.apache.cordova.CordovaInterface;
6
+ import org.apache.cordova.CordovaWebView;
7
+
8
+ import org.json.JSONArray;
9
+ import org.json.JSONException;
10
+ import org.json.JSONObject;
11
+
12
+ import android.app.Activity;
13
+ import android.graphics.Bitmap;
14
+ import android.content.Context;
15
+ import android.util.Log;
16
+ import android.widget.Toast;
17
+ import android.net.Uri;
18
+ import android.content.Intent;
19
+ import android.provider.MediaStore;
20
+
21
+ import static android.app.Activity.RESULT_OK;
22
+
23
+ import java.util.HashMap;
24
+ import java.util.Map;
25
+
26
+ //Elgin Plugins
27
+ import com.elgin.e1.Impressora.Termica;
28
+
29
+ import javax.security.auth.callback.Callback;
30
+
31
+ /**
32
+ * This class echoes a string called from JavaScript.
33
+ */
34
+ public class NetControllCordovaPluginsIntegration extends CordovaPlugin {
35
+ //Cordova/Java Params
36
+ private Activity mActivity;
37
+ private Context mContext;
38
+ private CordovaWebView webView;
39
+
40
+ //Intents CODES
41
+ private static int REQ_CODE_SELECAOIMAGEM = 1234;
42
+
43
+ //CallbacksOnActivityResult
44
+ private CallbackContext selecionarImagemCallbackContext;
45
+
46
+ //cutPaper boolean for resultActivity
47
+ private boolean cutPaper = false;
48
+
49
+ @Override
50
+ public void initialize(CordovaInterface cordova, CordovaWebView webView) {
51
+ super.initialize(cordova, webView);
52
+ this.webView = webView;
53
+ mActivity = cordova.getActivity();
54
+ mContext = cordova.getActivity().getApplicationContext();
55
+
56
+ //Initialize printer
57
+ Termica.setContext(mActivity);
58
+ }
59
+
60
+ @Override
61
+ public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
62
+ if (action.equals("coolMethod")) {
63
+ // String message = args.getString(0);
64
+ // this.coolMethod(message, callbackContext);
65
+
66
+ int arg1 = args.getInt(0);
67
+ int arg2 = args.getInt(1);
68
+
69
+ int result = arg1 + arg2;
70
+
71
+ // if (Termica != null) {
72
+ // result = result * 2;
73
+ // }
74
+
75
+ callbackContext.success("Result: " + result );
76
+ return true;
77
+ }
78
+
79
+ else if(action.equals("AbreConexaoImpressora")){
80
+ try{
81
+ JSONObject params = args.getJSONObject(0);
82
+
83
+ int tipo = params.getInt("tipo");
84
+ String modelo = params.getString("modelo");
85
+ String conexao = params.getString("conexao");
86
+ int parametro = params.getInt("parametro");
87
+
88
+ int result = Termica.AbreConexaoImpressora(tipo, modelo, conexao, parametro);
89
+
90
+ callbackContext.success(result);
91
+ }catch (Exception e){
92
+ callbackContext.error("AbreConexaoImpressora error: " + e.toString());
93
+ }
94
+ }
95
+
96
+ else if(action.equals("FechaConexaoImpressora")){
97
+ try{
98
+ int result = Termica.FechaConexaoImpressora();
99
+
100
+ callbackContext.success(result);
101
+ } catch (Exception e){
102
+ callbackContext.error("FechaConexaoImpressora error: " + e.toString());
103
+ }
104
+ }
105
+
106
+ else if(action.equals("AvancaPapel")){
107
+ try{
108
+ JSONObject params = args.getJSONObject(0);
109
+
110
+ int linhas = params.getInt("linhas");
111
+
112
+ int result = Termica.AvancaPapel(linhas);
113
+
114
+ callbackContext.success(result);
115
+ }catch (Exception e){
116
+ callbackContext.error("AvancaPapel error: " + e.toString());
117
+ }
118
+ }
119
+
120
+ else if(action.equals("Corte")){
121
+ try{
122
+ JSONObject params = args.getJSONObject(0);
123
+
124
+ int avanco = params.getInt("avanco");
125
+
126
+ int result = Termica.Corte(avanco);
127
+
128
+ callbackContext.success(result);
129
+ }catch (Exception e){
130
+ callbackContext.error("Corte error: " + e.toString());
131
+ }
132
+ }
133
+
134
+ else if(action.equals("ImpressaoTexto")){
135
+ try{
136
+ JSONObject params = args.getJSONObject(0);
137
+
138
+ String dados = params.getString("dados");
139
+ int posicao = params.getInt("posicao");
140
+ int stilo = params.getInt("stilo");
141
+ int tamanho = params.getInt("tamanho");
142
+
143
+ int result = Termica.ImpressaoTexto(dados, posicao, stilo, tamanho);
144
+
145
+ callbackContext.success(result);
146
+ }catch (Exception e){
147
+ callbackContext.error("ImpressaoTexto error: " + e.toString());
148
+ }
149
+ return true;
150
+ }
151
+
152
+ else if(action.equals("ImpressaoCodigoBarras")){
153
+ try{
154
+ JSONObject params = args.getJSONObject(0);
155
+
156
+ int tipo = params.getInt("tipo");
157
+ String dados = params.getString("dados");
158
+ int altura = params.getInt("altura");
159
+ int largura = params.getInt("largura");
160
+ int HRI = params.getInt("HRI");
161
+
162
+ int result = Termica.ImpressaoCodigoBarras(tipo, dados, altura, largura, HRI);
163
+
164
+ callbackContext.success(result);
165
+ }catch (Exception e){
166
+ callbackContext.error("ImpressaoCodigoBarras error: " + e.toString());
167
+ }
168
+ return true;
169
+ }
170
+
171
+ else if (action.equals("DefinePosicao")){
172
+ try{
173
+ JSONObject params = args.getJSONObject(0);
174
+
175
+ int posicao = params.getInt("posicao");
176
+
177
+ int result = Termica.DefinePosicao(posicao);
178
+
179
+ callbackContext.success(result);
180
+ }catch (Exception e){
181
+ callbackContext.error("DefinePosicao error: " + e.toString());
182
+ }
183
+ return true;
184
+ }
185
+
186
+ else if(action.equals("ImpressaoQRCode")){
187
+ try{
188
+ JSONObject params = args.getJSONObject(0);
189
+
190
+ String dados = params.getString("dados");
191
+ int tamanho = params.getInt("tamanho");
192
+ int nivelCorrecao = params.getInt("nivelCorrecao");
193
+
194
+ int result = Termica.ImpressaoQRCode(dados, tamanho, nivelCorrecao);
195
+
196
+ callbackContext.success(result) ;
197
+ }catch (Exception e){
198
+ callbackContext.error("ImpressaoQRCode error: " + e.toString());
199
+ }
200
+ return true;
201
+ }
202
+
203
+ else if(action.equals("ImprimeXMLNFCe")){
204
+ try{
205
+ JSONObject params = args.getJSONObject(0);
206
+
207
+ String dados = params.getString("dados");
208
+ int indexcsc = params.getInt("indexcsc");
209
+ String csc = params.getString("csc");
210
+ int param = params.getInt("param");
211
+
212
+ int result = Termica.ImprimeXMLNFCe(dados, indexcsc, csc, param);
213
+
214
+ callbackContext.success(result);
215
+ }catch (Exception e){
216
+ callbackContext.error("ImprimeXMLNFCe error: " + e.toString());
217
+ }
218
+ return true;
219
+ }
220
+
221
+ else if(action.equals("ImprimeXMLSAT")){
222
+ try{
223
+ JSONObject params = args.getJSONObject(0);
224
+
225
+ String dados = params.getString("dados");
226
+ int param = params.getInt("param");
227
+
228
+ int result = Termica.ImprimeXMLSAT(dados, param);
229
+
230
+ callbackContext.success(result);
231
+
232
+ }catch (Exception e){
233
+ callbackContext.error("ImprimeXMLSAT error: " + e.toString());
234
+ }
235
+ return true;
236
+ }
237
+
238
+ else if(action.equals("AbreGavetaElgin")){
239
+ try{
240
+ int result = Termica.AbreGavetaElgin();
241
+
242
+ callbackContext.success(result);
243
+ } catch (Exception e){
244
+ callbackContext.error("AbreGavetaElgin error: " + e.toString());
245
+ }
246
+ }
247
+
248
+ else if(action.equals("StatusImpressora")){
249
+ try{
250
+ JSONObject params = args.getJSONObject(0);
251
+
252
+ int param = params.getInt("param");
253
+
254
+ int result = Termica.StatusImpressora(param);
255
+
256
+ callbackContext.success(result);
257
+ }catch (Exception e){
258
+ callbackContext.error("StatusImpressora error: " + e.toString());
259
+ }
260
+ return true;
261
+ }
262
+
263
+
264
+
265
+ else if(action.equals("ImprimeImagem")){
266
+ try{
267
+ JSONObject params = args.getJSONObject(0);
268
+
269
+ if(params.getBoolean("cutPaper")) this.cutPaper = true;
270
+ else this.cutPaper = false;
271
+
272
+ Intent intent = new Intent((Intent.ACTION_PICK));
273
+ intent.setType("image/*");
274
+
275
+ this.selecionarImagemCallbackContext = callbackContext;
276
+
277
+ cordova.setActivityResultCallback(this);
278
+ cordova.getActivity().startActivityForResult(intent, REQ_CODE_SELECAOIMAGEM);
279
+
280
+ }catch (Exception e){
281
+ callbackContext.error("ImprimirImagem error: " + e.toString());
282
+ }
283
+ return true;
284
+ }
285
+ return false;
286
+ }
287
+
288
+ private void coolMethod(String message, CallbackContext callbackContext) {
289
+ if (message != null && message.length() > 0) {
290
+ callbackContext.success(message);
291
+ } else {
292
+ callbackContext.error("Expected one non-empty string argument.");
293
+ }
294
+ }
295
+ }
@@ -0,0 +1,24 @@
1
+ repositories {
2
+ google()
3
+ jcenter()
4
+ flatDir {
5
+ dirs 'src/main/libs'
6
+ }
7
+ }
8
+ dependencies {
9
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
10
+
11
+ //Bibliotecas Elgin para utilização das funcionalidades dos minipdv`s
12
+ implementation(name: 'e1-v1.0.16-release', ext: 'aar')
13
+ implementation(name: 'minipdvm8', ext: 'aar')
14
+
15
+ //Biblioteca de suporte dos códigos de barras utilizada para impressão dos mesmos
16
+ implementation 'com.google.zxing:core:3.3.2'
17
+
18
+ //A lib e1 na versão 1.0.16 depende do suporte do androidx na inicialização
19
+ implementation "androidx.startup:startup-runtime:1.0.0"
20
+
21
+ //Em alguns frameworks (como o Ionic), pode ser necessário a definição de alguns atributos de cor utilizado por algumas das libs já incluidas, para evitar qualquer inconsistência nesse sentido
22
+ //adicionamos a implementação desses atributos em específicos, assim não será necessário que o plugin depende de alguma dependência como app-compat ou similares.
23
+ implementation 'com.android.support:design:28.0.0'
24
+ }
Binary file
Binary file
@@ -0,0 +1,61 @@
1
+ var exec = require('cordova/exec');
2
+
3
+ exports.coolMethod = function (arg0, success, error) {
4
+ exec(success, error, 'NetControllCordovaPluginsIntegration', 'coolMethod', [arg0]);
5
+ };
6
+
7
+ //Printer Functions
8
+
9
+ exports.AbreConexaoImpressora = function (params, success, error){
10
+ exec(success, error, 'MainActivity', 'AbreConexaoImpressora', [params]);
11
+ }
12
+
13
+ exports.FechaConexaoImpressora = function (success, error){
14
+ exec(success, error, 'MainActivity', 'FechaConexaoImpressora');
15
+ }
16
+
17
+ exports.AvancaPapel = function (params, success, error){
18
+ exec(success, error, 'MainActivity', 'AvancaPapel', [params]);
19
+ }
20
+
21
+ exports.Corte = function (params, success, error){
22
+ exec(success, error, 'MainActivity', 'Corte', [params]);
23
+ }
24
+
25
+ exports.ImpressaoTexto = function (params, success, error){
26
+ exec(success, error, 'MainActivity', 'ImpressaoTexto', [params]);
27
+ }
28
+
29
+ exports.ImpressaoCodigoBarras = function (params, success, error){
30
+ exec(success, error, 'MainActivity', 'ImpressaoCodigoBarras', [params]);
31
+ }
32
+
33
+ exports.DefinePosicao = function (params, success, error){
34
+ exec(success, error, 'MainActivity', 'DefinePosicao', [params]);
35
+ }
36
+
37
+ exports.ImpressaoQRCode = function (params, success, error){
38
+ exec(success, error, 'MainActivity', 'ImpressaoQRCode', [params]);
39
+ }
40
+
41
+ exports.ImprimeXMLNFCe = function (params, success, error){
42
+ exec(success, error, 'MainActivity', 'ImprimeXMLNFCe', [params]);
43
+ }
44
+
45
+ exports.ImprimeXMLSAT = function (params, success, error){
46
+ exec(success, error, 'MainActivity', 'ImprimeXMLSAT', [params]);
47
+ }
48
+
49
+ exports.AbreGavetaElgin = function (success, error){
50
+ exec(success, error, 'MainActivity', 'AbreGavetaElgin');
51
+ }
52
+
53
+ exports.StatusImpressora = function (params, success, error){
54
+ exec(success, error, 'MainActivity', 'StatusImpressora', [params]);
55
+ }
56
+
57
+
58
+ //CUSTOM METHOD
59
+ exports.imprimeImagem = function (params, success, error){
60
+ exec(success, error, 'MainActivity', 'ImprimeImagem', [params]);
61
+ }