cordova-plugin-netcontroll-integration 1.0.152 → 1.0.154

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 CHANGED
@@ -1,5 +1,5 @@
1
- Versao 1.0.152
1
+ Versao 1.0.154
2
2
 
3
3
  Funções internas de integração XMenu / NetControll
4
4
 
5
- - Ajuste Rede GPOS700
5
+ - Comunicação segunda tela TPRO Elgin
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cordova-plugin-netcontroll-integration",
3
- "version": "1.0.152",
3
+ "version": "1.0.154",
4
4
  "description": "Plugin cordova de integracao para uso interno (NetControll/ XMenu)",
5
5
  "cordova": {
6
6
  "id": "cordova-plugin-netcontroll-integration",
package/plugin.xml CHANGED
@@ -1,5 +1,5 @@
1
1
  <?xml version='1.0' encoding='utf-8'?>
2
- <plugin id="cordova-plugin-netcontroll-integration" version="1.0.152"
2
+ <plugin id="cordova-plugin-netcontroll-integration" version="1.0.154"
3
3
  xmlns="http://apache.org/cordova/ns/plugins/1.0"
4
4
  xmlns:android="http://schemas.android.com/apk/res/android">
5
5
 
@@ -116,6 +116,7 @@
116
116
  <resource-file src="src/libs/elgin/minipdvm8-v01.00.00-release.aar" target="libs/elgin/minipdvm8-v01.00.00-release.aar" />
117
117
  <resource-file src="src/libs/elgin/satelgin-8.1.1-release.aar" target="libs/elgin/satelgin-8.1.1-release.aar" />
118
118
  <resource-file src="src/libs/elgin/scanner-v1.1-release.aar" target="libs/elgin/scanner-v1.1-release.aar" />
119
+ <resource-file src="src/libs/elgin/display-v02.00.00-release.aar" target="libs/elgin/display-v02.00.00-release.aar" />
119
120
 
120
121
 
121
122
 
@@ -10,10 +10,14 @@ import org.json.JSONException;
10
10
  import org.json.JSONObject;
11
11
 
12
12
 
13
+ import android.Manifest;
14
+ import android.content.pm.PackageManager;
13
15
  import android.graphics.Bitmap;
16
+ import android.os.Bundle;
14
17
  import android.os.AsyncTask;
15
18
 
16
19
  import com.elgin.e1.Balanca.BalancaE1;
20
+ import com.elgin.e1.display.E1_Display;
17
21
  import com.google.zxing.EncodeHintType;
18
22
  import com.google.zxing.MultiFormatWriter;
19
23
  import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
@@ -22,9 +26,16 @@ import com.izettle.html2bitmap.content.WebViewContent;
22
26
 
23
27
 
24
28
  import androidx.annotation.NonNull;
29
+ import androidx.core.app.ActivityCompat;
30
+ import androidx.appcompat.app.AppCompatActivity;
31
+
32
+ import androidx.core.content.ContextCompat;
33
+
25
34
  import android.app.Activity;
26
35
  // import android.graphics.Bitmap;
27
36
  import android.content.Context;
37
+ import android.graphics.Bitmap;
38
+ import android.graphics.BitmapFactory;
28
39
  // import android.util.Log;
29
40
  // import android.widget.Toast;
30
41
  // import android.net.Uri;
@@ -59,6 +70,7 @@ import com.google.zxing.common.BitMatrix;
59
70
  import android.graphics.BitmapFactory;
60
71
  // import android.graphics.Matrix;
61
72
 
73
+ import android.os.Environment;
62
74
  import android.util.Base64;
63
75
  import java.io.ByteArrayOutputStream;
64
76
  // import java.util.Objects;
@@ -77,7 +89,9 @@ import com.elgin.e1.Impressora.Termica;
77
89
 
78
90
  import javax.security.auth.callback.Callback;
79
91
 
80
- public class ElginM10Terminal {
92
+ import io.cordova.hellocordova.MainActivity;
93
+
94
+ public class ElginM10Terminal extends AppCompatActivity {
81
95
  //Cordova/Java Params
82
96
  private Activity mActivity;
83
97
  private Context mContext;
@@ -99,6 +113,11 @@ public class ElginM10Terminal {
99
113
  private int SerialLength;
100
114
  private char SerialParity;
101
115
  private int SerialStopbits;
116
+ private E1_Display imin;
117
+
118
+ String[] permissions = new String[]{
119
+ Manifest.permission.WRITE_EXTERNAL_STORAGE,
120
+ };
102
121
 
103
122
  public void initialize(CordovaInterface cordova, CordovaWebView webView) {
104
123
  this.webView = webView;
@@ -115,8 +134,8 @@ public class ElginM10Terminal {
115
134
  }
116
135
 
117
136
  public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
118
- if(action.equals("AbreConexaoImpressora")){
119
- try{
137
+ if (action.equals("AbreConexaoImpressora")) {
138
+ try {
120
139
  JSONObject params = args.getJSONObject(0);
121
140
 
122
141
  int tipo = params.getInt("tipo");
@@ -125,26 +144,24 @@ public class ElginM10Terminal {
125
144
  int parametro = params.getInt("parametro");
126
145
 
127
146
  int result = Termica.AbreConexaoImpressora(tipo, modelo, conexao, parametro);
128
-
147
+ //cordova.plugin.netcontroll.integration.util.NetControllPrinter.RequestPermissions(this.mActivity, this.mContext);
148
+ if(ContextCompat.checkSelfPermission(this.mActivity, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED)
149
+ ActivityCompat.requestPermissions(this.mActivity, permissions, 0);
129
150
  callbackContext.success(result);
130
- }catch (Exception e){
151
+ } catch (Exception e) {
131
152
  callbackContext.error("AbreConexaoImpressora error: " + e.toString());
132
153
  }
133
154
  return true;
134
- }
135
-
136
- else if(action.equals("FechaConexaoImpressora")){
137
- try{
155
+ } else if (action.equals("FechaConexaoImpressora")) {
156
+ try {
138
157
  int result = Termica.FechaConexaoImpressora();
139
158
  callbackContext.success(result);
140
- } catch (Exception e){
159
+ } catch (Exception e) {
141
160
  callbackContext.error("FechaConexaoImpressora error: " + e.toString());
142
161
  }
143
162
  return true;
144
- }
145
-
146
- else if(action.equals("AvancaPapel")){
147
- try{
163
+ } else if (action.equals("AvancaPapel")) {
164
+ try {
148
165
  JSONObject params = args.getJSONObject(0);
149
166
 
150
167
  int linhas = params.getInt("linhas");
@@ -152,14 +169,12 @@ public class ElginM10Terminal {
152
169
  int result = Termica.AvancaPapel(linhas);
153
170
 
154
171
  callbackContext.success(result);
155
- }catch (Exception e){
172
+ } catch (Exception e) {
156
173
  callbackContext.error("AvancaPapel error: " + e.toString());
157
174
  }
158
175
  return true;
159
- }
160
-
161
- else if(action.equals("Corte")){
162
- try{
176
+ } else if (action.equals("Corte")) {
177
+ try {
163
178
  JSONObject params = args.getJSONObject(0);
164
179
 
165
180
  int avanco = params.getInt("avanco");
@@ -167,14 +182,12 @@ public class ElginM10Terminal {
167
182
  int result = Termica.Corte(avanco);
168
183
 
169
184
  callbackContext.success(result);
170
- }catch (Exception e){
185
+ } catch (Exception e) {
171
186
  callbackContext.error("Corte error: " + e.toString());
172
187
  }
173
188
  return true;
174
- }
175
-
176
- else if(action.equals("ImpressaoTexto")){
177
- try{
189
+ } else if (action.equals("ImpressaoTexto")) {
190
+ try {
178
191
  JSONObject params = args.getJSONObject(0);
179
192
 
180
193
  String dados = params.getString("dados");
@@ -185,14 +198,12 @@ public class ElginM10Terminal {
185
198
  int result = Termica.ImpressaoTexto(dados, posicao, stilo, tamanho);
186
199
 
187
200
  callbackContext.success(result);
188
- }catch (Exception e){
201
+ } catch (Exception e) {
189
202
  callbackContext.error("ImpressaoTexto error: " + e.toString());
190
203
  }
191
204
  return true;
192
- }
193
-
194
- else if(action.equals("ImpressaoCodigoBarras")){
195
- try{
205
+ } else if (action.equals("ImpressaoCodigoBarras")) {
206
+ try {
196
207
  JSONObject params = args.getJSONObject(0);
197
208
 
198
209
  int tipo = params.getInt("tipo");
@@ -204,14 +215,12 @@ public class ElginM10Terminal {
204
215
  int result = Termica.ImpressaoCodigoBarras(tipo, dados, altura, largura, HRI);
205
216
 
206
217
  callbackContext.success(result);
207
- }catch (Exception e){
218
+ } catch (Exception e) {
208
219
  callbackContext.error("ImpressaoCodigoBarras error: " + e.toString());
209
220
  }
210
221
  return true;
211
- }
212
-
213
- else if (action.equals("DefinePosicao")){
214
- try{
222
+ } else if (action.equals("DefinePosicao")) {
223
+ try {
215
224
  JSONObject params = args.getJSONObject(0);
216
225
 
217
226
  int posicao = params.getInt("posicao");
@@ -219,14 +228,12 @@ public class ElginM10Terminal {
219
228
  int result = Termica.DefinePosicao(posicao);
220
229
 
221
230
  callbackContext.success(result);
222
- }catch (Exception e){
231
+ } catch (Exception e) {
223
232
  callbackContext.error("DefinePosicao error: " + e.toString());
224
233
  }
225
234
  return true;
226
- }
227
-
228
- else if(action.equals("ImpressaoQRCode")){
229
- try{
235
+ } else if (action.equals("ImpressaoQRCode")) {
236
+ try {
230
237
  JSONObject params = args.getJSONObject(0);
231
238
 
232
239
  String dados = params.getString("dados");
@@ -235,15 +242,13 @@ public class ElginM10Terminal {
235
242
 
236
243
  int result = Termica.ImpressaoQRCode(dados, tamanho, nivelCorrecao);
237
244
 
238
- callbackContext.success(result) ;
239
- }catch (Exception e){
245
+ callbackContext.success(result);
246
+ } catch (Exception e) {
240
247
  callbackContext.error("ImpressaoQRCode error: " + e.toString());
241
248
  }
242
249
  return true;
243
- }
244
-
245
- else if(action.equals("ImprimeXMLNFCe")){
246
- try{
250
+ } else if (action.equals("ImprimeXMLNFCe")) {
251
+ try {
247
252
  JSONObject params = args.getJSONObject(0);
248
253
 
249
254
  String dados = params.getString("dados");
@@ -254,14 +259,12 @@ public class ElginM10Terminal {
254
259
  int result = Termica.ImprimeXMLNFCe(dados, indexcsc, csc, param);
255
260
 
256
261
  callbackContext.success(result);
257
- }catch (Exception e){
262
+ } catch (Exception e) {
258
263
  callbackContext.error("ImprimeXMLNFCe error: " + e.toString());
259
264
  }
260
265
  return true;
261
- }
262
-
263
- else if(action.equals("ImprimeXMLSAT")){
264
- try{
266
+ } else if (action.equals("ImprimeXMLSAT")) {
267
+ try {
265
268
  JSONObject params = args.getJSONObject(0);
266
269
 
267
270
  String dados = params.getString("dados");
@@ -271,25 +274,21 @@ public class ElginM10Terminal {
271
274
 
272
275
  callbackContext.success(result);
273
276
 
274
- }catch (Exception e){
277
+ } catch (Exception e) {
275
278
  callbackContext.error("ImprimeXMLSAT error: " + e.toString());
276
279
  }
277
280
  return true;
278
- }
279
-
280
- else if(action.equals("AbreGavetaElgin")){
281
- try{
281
+ } else if (action.equals("AbreGavetaElgin")) {
282
+ try {
282
283
  int result = Termica.AbreGavetaElgin();
283
284
 
284
285
  callbackContext.success(result);
285
- } catch (Exception e){
286
+ } catch (Exception e) {
286
287
  callbackContext.error("AbreGavetaElgin error: " + e.toString());
287
288
  }
288
289
  return true;
289
- }
290
-
291
- else if(action.equals("ConfigurarBalanca")){
292
- try{
290
+ } else if (action.equals("ConfigurarBalanca")) {
291
+ try {
293
292
  JSONObject params = args.getJSONObject(0);
294
293
 
295
294
  this.ModelBalanca = params.getString("modelBalanca");
@@ -318,35 +317,31 @@ public class ElginM10Terminal {
318
317
  int retorno2 = BalancaE1.ConfigurarProtocoloComunicacao(this.Protocol);
319
318
 
320
319
  callbackContext.success(String.format("\nConfigurarModeloBalanca: %d\nConfigurarProtocoloComunicacao: %d", retorno1, retorno2));
321
- }catch (Exception e){
320
+ } catch (Exception e) {
322
321
  callbackContext.error("ConfigurarBalanca error: " + e.toString());
323
322
  }
324
323
  return true;
325
- }
326
-
327
- else if(action.equals("LerPesoBalanca")){
328
- try{
329
- if (this.ModelBalanca == null || this.ModelBalanca == "" ) {
324
+ } else if (action.equals("LerPesoBalanca")) {
325
+ try {
326
+ if (this.ModelBalanca == null || this.ModelBalanca == "") {
330
327
  callbackContext.error("LerPesoBalanca error: Balança não configurada");
331
328
  return false;
332
329
  }
333
330
  int retorno1 = BalancaE1.AbrirSerial(this.SerialBaudrate, this.SerialLength, this.SerialParity, this.SerialStopbits); // Configuracao serial da balanca...
334
331
  String retorno2 = BalancaE1.LerPeso(1);
335
332
  int retorno3 = BalancaE1.Fechar();
336
- if (retorno1 == 0 ) {
333
+ if (retorno1 == 0) {
337
334
  callbackContext.success(retorno2);
338
335
  } else {
339
336
  callbackContext.error(String.format("\nAbrirSerial: %d\nLerPeso: %s\nFechar: %d", retorno1, retorno2, retorno3));
340
337
  return false;
341
338
  }
342
- }catch (Exception e){
339
+ } catch (Exception e) {
343
340
  callbackContext.error("StatusImpressora error: " + e.toString());
344
341
  }
345
342
  return true;
346
- }
347
-
348
- else if(action.equals("StatusImpressora")){
349
- try{
343
+ } else if (action.equals("StatusImpressora")) {
344
+ try {
350
345
  JSONObject params = args.getJSONObject(0);
351
346
 
352
347
  int param = params.getInt("param");
@@ -354,14 +349,12 @@ public class ElginM10Terminal {
354
349
  int result = Termica.StatusImpressora(param);
355
350
 
356
351
  callbackContext.success(result);
357
- }catch (Exception e){
352
+ } catch (Exception e) {
358
353
  callbackContext.error("StatusImpressora error: " + e.toString());
359
354
  }
360
355
  return true;
361
- }
362
-
363
- else if(action.equals("ImprimeImagemBase64")){
364
- try{
356
+ } else if (action.equals("ImprimeImagemBase64")) {
357
+ try {
365
358
  JSONObject params = args.getJSONObject(0);
366
359
  String base64String = params.getString("base64String");
367
360
  int result = 0;
@@ -376,7 +369,7 @@ public class ElginM10Terminal {
376
369
  }
377
370
  // // // // callbackContext.success(decodedString);
378
371
  callbackContext.success(result);
379
- } catch (Exception e){
372
+ } catch (Exception e) {
380
373
  callbackContext.error("AbreGavetaElgin error: " + e.toString());
381
374
  }
382
375
  return true;
@@ -409,17 +402,14 @@ public class ElginM10Terminal {
409
402
  // callbackContext.error("ImprimirImagem error: " + e.toString());
410
403
  // }
411
404
  // return true;
412
- }
413
-
414
-
415
- else if (action.equals("ImpressaoTextoNetPrint")) {
405
+ } else if (action.equals("ImpressaoTextoNetPrint")) {
416
406
  JSONObject params = args.getJSONObject(0);
417
407
  try {
418
408
  String dados = params.getString("dados");
419
409
  Boolean negrito = false;
420
410
  try {
421
411
  negrito = params.getBoolean("negrito");
422
- }catch (Exception ex){
412
+ } catch (Exception ex) {
423
413
  }
424
414
  boolean abrirGaveta = cordova.plugin.netcontroll.integration.util.NetControllPrinter.EnviarAberturaGaveta(dados);
425
415
  String html = cordova.plugin.netcontroll.integration.util.NetControllPrinter.ConverterTextoImpressoToHtml(dados, negrito);
@@ -442,7 +432,7 @@ public class ElginM10Terminal {
442
432
  callbackContext.error("Result - ConverterHtmlToBitmap: " + "Error Detail: " + errorPost);
443
433
  }
444
434
  if (abrirGaveta) {
445
- Termica.AbreGavetaElgin();
435
+ Termica.AbreGavetaElgin();
446
436
  }
447
437
  }
448
438
  });
@@ -450,10 +440,8 @@ public class ElginM10Terminal {
450
440
  callbackContext.error("ImpressaoTextoNetPrint error: " + e.toString());
451
441
  }
452
442
  return true;
453
- }
454
-
455
- else if (action.equals("ImpressaoBase64NetPrint")) {
456
- try{
443
+ } else if (action.equals("ImpressaoBase64NetPrint")) {
444
+ try {
457
445
  JSONObject params = args.getJSONObject(0);
458
446
  String base64String = params.getString("base64String");
459
447
  Bitmap dadosBmp = cordova.plugin.netcontroll.integration.util.NetControllPrinter.ConverterBase64ToBitmap(base64String);
@@ -464,12 +452,55 @@ public class ElginM10Terminal {
464
452
  } else {
465
453
  callbackContext.success("Impresso Base64 Ok");
466
454
  }
467
- } catch (Exception e){
455
+ } catch (Exception e) {
468
456
  callbackContext.error("PrintTesteBase64 error: " + e.toString());
469
457
  }
470
458
  return true;
459
+
460
+ } else if (action.equals("InicializaDisplay")) {
461
+ try {
462
+ imin.init(this.mActivity, E1_Display.DisplayDevices.TPRO);
463
+
464
+ if(ContextCompat.checkSelfPermission(this.mActivity, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED){
465
+ ActivityCompat.requestPermissions(this.mActivity, permissions, 0);
466
+ }
467
+ int result = -1;
468
+ result = imin.InicializaDisplay();
469
+ if (result != 0) {
470
+ callbackContext.error("Erro ao iniciar o display");
471
+ } else {
472
+ callbackContext.success("InicializaDisplay Ok");
473
+ }
474
+ } catch (Exception e) {
475
+ callbackContext.error("InicializaDisplay error: " + e.toString());
476
+ }
477
+ return true;
478
+
479
+ } else if (action.equals("ApresentaImagemDisplayBitmap")) {
480
+ JSONObject params = args.getJSONObject(0);
481
+ try {
482
+ String dados = params.getString("dados");
483
+ cordova.plugin.netcontroll.integration.util.NetControllPrinter.ConverterHtmlToBitmap(dados, mContext, bitmap -> {
484
+ if (bitmap != null) {
485
+ try {
486
+ int retorno = -1;
487
+ if (bitmap != null) {
488
+ retorno = imin.ApresentaImagemDisplay(bitmap);
489
+ }
490
+ if (retorno != 0) {
491
+ callbackContext.error("Erro ao Exibir img bitmap: " + retorno);
492
+ } else {
493
+ callbackContext.success("ApresentaImagemDisplayBitmap Ok");
494
+ }
495
+ } catch (Exception errorPost) {
496
+ callbackContext.error("Result - ApresentaImagemDisplayBitmap: " + "Error Detail: " + errorPost);
497
+ }
498
+ }
499
+ });
500
+ } catch (Exception e) {
501
+ callbackContext.error("ApresentaImagemDisplayBitmap error: " + e.toString());
502
+ }
471
503
  }
472
- return false;
504
+ return true;
473
505
  }
474
- }
475
-
506
+ }
package/src/build.gradle CHANGED
@@ -40,6 +40,7 @@ dependencies {
40
40
  implementation(name: 'elgin/InterfaceAutomacao-v2.0.0.12', ext: 'aar')
41
41
  implementation(name: 'elgin/cloudpossdk-s-1.0.2', ext: 'aar')
42
42
  implementation(name: 'elgin/minipdvm8-v01.00.00-release', ext: 'aar')
43
+ implementation(name: 'elgin/display-v02.00.00-release', ext: 'aar')
43
44
 
44
45
 
45
46
  //______________________________ UseRede ______________________________
@@ -84,6 +84,13 @@ exports.ImpressaoTextoNetPrintOld = function (params, success, error) {
84
84
  ImpressaoTextoNetPrintHelper(params.dados, success, error);
85
85
  }
86
86
 
87
+ exports.InicializaDisplay = function (success, error) {
88
+ exec(success, error, 'NetControllCordovaPluginsIntegration', 'Elgin.M10Terminal.InicializaDisplay');
89
+ }
90
+
91
+ exports.ApresentaImagemDisplayBitmap = function (params, success, error) {
92
+ exec(success, error, 'NetControllCordovaPluginsIntegration', 'Elgin.M10Terminal.ApresentaImagemDisplayBitmap', [params]);
93
+ }
87
94
 
88
95
  function ImpressaoTextoNetPrintHelper(textoImpresso, success, onError) {
89
96
  console.log('ImpressaoTextoNetPrintHelper');
@@ -7,7 +7,6 @@ exports.Testar = function (params, success, error) {
7
7
  }
8
8
 
9
9
  exports.InicializaImpressao = function (params, success, error) {
10
- debugger;
11
10
  exec(success, error, 'NetControllCordovaPluginsIntegration', 'Rede.Gpos700.InicializaImpressao', [params]);
12
11
  }
13
12