cordova-plugin-netcontroll-integration 1.0.2 → 1.0.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cordova-plugin-netcontroll-integration",
3
- "version": "1.0.2",
3
+ "version": "1.0.5",
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.13"
2
+ <plugin id="cordova-plugin-netcontroll-integration" version="1.0.4"
3
3
  xmlns="http://apache.org/cordova/ns/plugins/1.0"
4
4
  xmlns:android="http://schemas.android.com/apk/res/android">
5
5
 
@@ -7,6 +7,26 @@
7
7
  <js-module name="NetControllCordovaPluginsIntegration" src="www/NetControllCordovaPluginsIntegration.js">
8
8
  <clobbers target="cordova.plugins.NetControllCordovaPluginsIntegration" />
9
9
  </js-module>
10
+ <js-module name="ElginM10Terminal" src="www/Elgin/M10Terminal.js">
11
+ <!-- <clobbers target="window.ElginM10Terminal" /> -->
12
+ <clobbers target="cordova.plugins.NetControllCordovaPluginsIntegration.ElginM10Terminal" />
13
+ </js-module>
14
+
15
+ <js-module name="CieloLioLocal" src="www/Cielo/LioLocal.js">
16
+ <!-- <clobbers target="window.ElginM10Terminal" /> -->
17
+ <clobbers target="cordova.plugins.NetControllCordovaPluginsIntegration.CieloLioLocal" />
18
+ </js-module>
19
+
20
+ <js-module src="www/alice.js" name="alice">
21
+ <clobbers target="cordova.plugins.NetControllCordovaPluginsIntegration.alice" />
22
+ <!-- <runs/> -->
23
+ </js-module>
24
+ <js-module src="www/bob.js" name="bob">
25
+ <clobbers target="cordova.plugins.NetControllCordovaPluginsIntegration.bob" />
26
+ <!-- <runs/> -->
27
+ </js-module>
28
+
29
+
10
30
  <dependency id="cordova-plugin-androidx-adapter" version="1.1.3" />
11
31
  <platform name="android">
12
32
  <config-file parent="/*" target="res/xml/config.xml">
@@ -23,6 +43,10 @@
23
43
 
24
44
  <!-- executable source code > -->
25
45
  <source-file src="src/android/NetControllCordovaPluginsIntegration.java" target-dir="src/cordova-plugin-m8/cordova-plugin-m8" />
46
+ <source-file src="src/android/Elgin/ElginM10Terminal.java" target-dir="src/cordova-plugin-m8/cordova-plugin-m8" />
47
+ <source-file src="src/android/Cielo/CieloLioLocal.java" target-dir="src/cordova-plugin-m8/cordova-plugin-m8" />
48
+ <!-- <source-file src="src/android/NetControllCordovaPluginsIntegration.java" target-dir="src/cordova/plugin/netcontroll/integration/NetControllCordovaPluginsIntegration" />
49
+ <source-file src="src/android/Elgin/ElginM10Terminal.java" target-dir="src/cordova-plugin-m8/cordova-plugin-m8" /> -->
26
50
 
27
51
  <framework src="src/build.gradle" custom="true" type="gradleReference" />
28
52
 
@@ -31,6 +55,7 @@
31
55
  <resource-file src="src/libs/e1-v1.0.16-release.aar" target="libs/e1-v1.0.16-release.aar" />
32
56
 
33
57
  <!--
34
- <source-file src="src/android/NetControllCordovaPluginsIntegration.java" target-dir="src/cordova/plugin/netcontroll/integration/NetControllCordovaPluginsIntegration" /> -->
58
+ <source-file src="src/android/NetControllCordovaPluginsIntegration.java" target-dir="src/cordova/plugin/netcontroll/integration/NetControllCordovaPluginsIntegration" />
59
+ -->
35
60
  </platform>
36
61
  </plugin>
@@ -0,0 +1,196 @@
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
+ import javax.security.auth.callback.Callback;
27
+
28
+ import java.util.List;
29
+
30
+ //Cielo Package
31
+ import cielo.orders.domain.Credentials;
32
+
33
+ import cielo.orders.domain.Item;
34
+ import cielo.orders.domain.CheckoutRequest;
35
+ import cielo.orders.domain.Order;
36
+ import cielo.orders.domain.product.PrimaryProduct;
37
+ import cielo.orders.domain.product.SecondaryProduct;
38
+ import cielo.orders.domain.ResultOrders;
39
+
40
+ import cielo.sdk.order.OrderManager;
41
+ import cielo.sdk.order.ServiceBindListener;
42
+ import cielo.sdk.order.payment.PaymentCode;
43
+ import cielo.sdk.order.payment.PaymentListener;
44
+ import cielo.sdk.order.payment.PaymentError;
45
+
46
+
47
+
48
+
49
+
50
+ /**
51
+ * This class echoes a string called from JavaScript.
52
+ */
53
+ public class CieloLioLocal {
54
+ //Cielo
55
+ public OrderManager orderManager;
56
+ public boolean orderManagerServiceBinded = false;
57
+
58
+
59
+ //Cordova/Java Params
60
+ private Activity mActivity;
61
+ private Context mContext;
62
+ private CordovaWebView webView;
63
+
64
+ //Intents CODES
65
+ private static int REQ_CODE_SELECAOIMAGEM = 1234;
66
+
67
+ //CallbacksOnActivityResult
68
+ private CallbackContext selecionarImagemCallbackContext;
69
+
70
+
71
+ public void initialize(CordovaInterface cordova, CordovaWebView webView) {
72
+ this.webView = webView;
73
+ mActivity = cordova.getActivity();
74
+ mContext = cordova.getActivity().getApplicationContext();
75
+ }
76
+
77
+ public String Teste() {
78
+ return "Result - CieloLioLocalClass: ok";
79
+ }
80
+
81
+ public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
82
+
83
+ if (action.equals("Teste")) {
84
+ int arg1 = args.getInt(0);
85
+ if (arg1 == 0) {
86
+ Credentials credentials = new Credentials("M2vcq2fr0oWKbKd5bvpDoGZvHXQ8IneDLBJEulDjxNA59MOA2D/ EMOfYfErX7Y537JZgJvlgG0r805v5jYTxCgNiPtxm500bBUSxh", "NMgpwK4N5dcLCWnOr2kYbDIFcQdLPEn5M2ObKUTULEOdhxzFZu");
87
+ orderManager = new OrderManager(credentials, mContext);
88
+ if (credentials == null) {
89
+ callbackContext.success("Result - CieloLioLocalClass: Erro Credencial " + action);
90
+ return false;
91
+ } else {
92
+ callbackContext.success("Result - CieloLioLocalClass: Tem Credencial " + action + " Token: " + credentials.getAccessToken().toString());
93
+ return true;
94
+
95
+ }
96
+
97
+
98
+ // callbackContext.success("Result - CieloLioLocalClass: ok " + action);
99
+ // return false;
100
+ }
101
+ else {
102
+ callbackContext.success("Result - CieloLioLocalClass: noOk " + action);
103
+ return false;
104
+ }
105
+ }
106
+ else if (action.equals("ListarPagamentos")) {
107
+ try {
108
+ Credentials credentials = new Credentials("M2vcq2fr0oWKbKd5bvpDoGZvHXQ8IneDLBJEulDjxNA59MOA2D/ EMOfYfErX7Y537JZgJvlgG0r805v5jYTxCgNiPtxm500bBUSxh", "NMgpwK4N5dcLCWnOr2kYbDIFcQdLPEn5M2ObKUTULEOdhxzFZu");
109
+ orderManager = new OrderManager(credentials, mContext);
110
+
111
+ orderManager.bind(mContext, new ServiceBindListener() {
112
+
113
+ @Override
114
+ public void onServiceBoundError(Throwable throwable) {
115
+ orderManagerServiceBinded = false;
116
+
117
+ callbackContext.success("Result - ListarPagamentos: " + "Error Detail: " + throwable.getMessage());
118
+ // Toast.makeText(getApplicationContext(),
119
+ // String.format("Erro fazendo bind do serviço de ordem -> %s",
120
+ // throwable.getMessage()), Toast.LENGTH_LONG).show();
121
+ // return false;
122
+ }
123
+
124
+ @Override
125
+ public void onServiceBound() {
126
+ orderManagerServiceBinded = true;
127
+ orderManager.createDraftOrder("REFERENCIA DA ORDEM");
128
+ // callbackContext.success("Result - ListarPagamentos: " + "REFERENCIA DA ORDEM => listOrders");
129
+
130
+ ResultOrders resultOrders = orderManager.retrieveOrders(200, 0);
131
+ final List<Order> orderList = resultOrders.getResults();
132
+ String ordersList = "";
133
+ for (Order or : orderList) {
134
+ if (!or.getItems().isEmpty()) {
135
+ ordersList += or.getReference() + " - Price: " + or.getPrice() + "\n";
136
+ }
137
+ // Log.i("Order: ", or.getNumber() + " - " + or.getPrice());
138
+ }
139
+ if (ordersList != "") {
140
+ // txtEmptyValue.setText(ordersList);
141
+ callbackContext.success("Result - ListarPagamentos: " + "REFERENCIA DA ORDEM => listOrders \n" + ordersList);
142
+ }
143
+ // callbackContext.success("Service Bound");
144
+ // listOrders();
145
+ // return true;
146
+ }
147
+
148
+ @Override
149
+ public void onServiceUnbound() {
150
+ orderManagerServiceBinded = false;
151
+ }
152
+ });
153
+ return true;
154
+ } catch (Exception error1) {
155
+ // alertarMensagem(resutText, error1);
156
+ callbackContext.success("Result - ListarPagamentos: " + "Error Detail: " + error1);
157
+ }
158
+ // callbackContext.success("Result - ListarPagamentos: Ok " + action);
159
+ // return true;
160
+ }
161
+ return false;
162
+ }
163
+
164
+
165
+
166
+
167
+ // Cielo Functions
168
+ protected void configSDKListarPagamentos() {
169
+ Credentials credentials = new Credentials("M2vcq2fr0oWKbKd5bvpDoGZvHXQ8IneDLBJEulDjxNA59MOA2D/ EMOfYfErX7Y537JZgJvlgG0r805v5jYTxCgNiPtxm500bBUSxh", "NMgpwK4N5dcLCWnOr2kYbDIFcQdLPEn5M2ObKUTULEOdhxzFZu");
170
+ // orderManager = new OrderManager(credentials, this);
171
+ // orderManager.bind(this, new ServiceBindListener() {
172
+
173
+ // @Override
174
+ // public void onServiceBoundError(Throwable throwable) {
175
+ // orderManagerServiceBinded = false;
176
+
177
+ // Toast.makeText(getApplicationContext(),
178
+ // String.format("Erro fazendo bind do serviço de ordem -> %s",
179
+ // throwable.getMessage()), Toast.LENGTH_LONG).show();
180
+ // }
181
+
182
+ // @Override
183
+ // public void onServiceBound() {
184
+ // orderManagerServiceBinded = true;
185
+ // orderManager.createDraftOrder("REFERENCIA DA ORDEM");
186
+ // listOrders();
187
+ // }
188
+
189
+ // @Override
190
+ // public void onServiceUnbound() {
191
+ // orderManagerServiceBinded = false;
192
+ // }
193
+ // });
194
+ }
195
+
196
+ }
@@ -0,0 +1,282 @@
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 ElginM10Terminal {
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
+ public void initialize(CordovaInterface cordova, CordovaWebView webView) {
50
+ this.webView = webView;
51
+ mActivity = cordova.getActivity();
52
+ mContext = cordova.getActivity().getApplicationContext();
53
+
54
+ //Initialize printer
55
+ Termica.setContext(mActivity);
56
+ }
57
+
58
+ public String Teste() {
59
+ return "Result - ElginClass: ok";
60
+ }
61
+
62
+ public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
63
+
64
+ if (action.equals("Teste")) {
65
+ int arg1 = args.getInt(0);
66
+ if (arg1 == 0) {
67
+ callbackContext.success("Result - ElginClass: ok " + action);
68
+ return false;
69
+ }
70
+ else {
71
+ callbackContext.success("Result - ElginClass: noOk " + action);
72
+ return false;
73
+ }
74
+ }
75
+
76
+ else if(action.equals("AbreConexaoImpressora")){
77
+ try{
78
+ JSONObject params = args.getJSONObject(0);
79
+
80
+ int tipo = params.getInt("tipo");
81
+ String modelo = params.getString("modelo");
82
+ String conexao = params.getString("conexao");
83
+ int parametro = params.getInt("parametro");
84
+
85
+ int result = Termica.AbreConexaoImpressora(tipo, modelo, conexao, parametro);
86
+
87
+ callbackContext.success(result);
88
+ }catch (Exception e){
89
+ callbackContext.error("AbreConexaoImpressora error: " + e.toString());
90
+ }
91
+ }
92
+
93
+ // else if(action.equals("FechaConexaoImpressora")){
94
+ // try{
95
+ // int result = Termica.FechaConexaoImpressora();
96
+
97
+ // callbackContext.success(result);
98
+ // } catch (Exception e){
99
+ // callbackContext.error("FechaConexaoImpressora error: " + e.toString());
100
+ // }
101
+ // }
102
+
103
+ // else if(action.equals("AvancaPapel")){
104
+ // try{
105
+ // JSONObject params = args.getJSONObject(0);
106
+
107
+ // int linhas = params.getInt("linhas");
108
+
109
+ // int result = Termica.AvancaPapel(linhas);
110
+
111
+ // callbackContext.success(result);
112
+ // }catch (Exception e){
113
+ // callbackContext.error("AvancaPapel error: " + e.toString());
114
+ // }
115
+ // }
116
+
117
+ // else if(action.equals("Corte")){
118
+ // try{
119
+ // JSONObject params = args.getJSONObject(0);
120
+
121
+ // int avanco = params.getInt("avanco");
122
+
123
+ // int result = Termica.Corte(avanco);
124
+
125
+ // callbackContext.success(result);
126
+ // }catch (Exception e){
127
+ // callbackContext.error("Corte error: " + e.toString());
128
+ // }
129
+ // }
130
+
131
+ else if(action.equals("ImpressaoTexto")){
132
+ try{
133
+ JSONObject params = args.getJSONObject(0);
134
+
135
+ String dados = params.getString("dados");
136
+ int posicao = params.getInt("posicao");
137
+ int stilo = params.getInt("stilo");
138
+ int tamanho = params.getInt("tamanho");
139
+
140
+ int result = Termica.ImpressaoTexto(dados, posicao, stilo, tamanho);
141
+
142
+ callbackContext.success(result);
143
+ }catch (Exception e){
144
+ callbackContext.error("ImpressaoTexto error: " + e.toString());
145
+ }
146
+ return true;
147
+ }
148
+
149
+ // else if(action.equals("ImpressaoCodigoBarras")){
150
+ // try{
151
+ // JSONObject params = args.getJSONObject(0);
152
+
153
+ // int tipo = params.getInt("tipo");
154
+ // String dados = params.getString("dados");
155
+ // int altura = params.getInt("altura");
156
+ // int largura = params.getInt("largura");
157
+ // int HRI = params.getInt("HRI");
158
+
159
+ // int result = Termica.ImpressaoCodigoBarras(tipo, dados, altura, largura, HRI);
160
+
161
+ // callbackContext.success(result);
162
+ // }catch (Exception e){
163
+ // callbackContext.error("ImpressaoCodigoBarras error: " + e.toString());
164
+ // }
165
+ // return true;
166
+ // }
167
+
168
+ // else if (action.equals("DefinePosicao")){
169
+ // try{
170
+ // JSONObject params = args.getJSONObject(0);
171
+
172
+ // int posicao = params.getInt("posicao");
173
+
174
+ // int result = Termica.DefinePosicao(posicao);
175
+
176
+ // callbackContext.success(result);
177
+ // }catch (Exception e){
178
+ // callbackContext.error("DefinePosicao error: " + e.toString());
179
+ // }
180
+ // return true;
181
+ // }
182
+
183
+ // else if(action.equals("ImpressaoQRCode")){
184
+ // try{
185
+ // JSONObject params = args.getJSONObject(0);
186
+
187
+ // String dados = params.getString("dados");
188
+ // int tamanho = params.getInt("tamanho");
189
+ // int nivelCorrecao = params.getInt("nivelCorrecao");
190
+
191
+ // int result = Termica.ImpressaoQRCode(dados, tamanho, nivelCorrecao);
192
+
193
+ // callbackContext.success(result) ;
194
+ // }catch (Exception e){
195
+ // callbackContext.error("ImpressaoQRCode error: " + e.toString());
196
+ // }
197
+ // return true;
198
+ // }
199
+
200
+ // else if(action.equals("ImprimeXMLNFCe")){
201
+ // try{
202
+ // JSONObject params = args.getJSONObject(0);
203
+
204
+ // String dados = params.getString("dados");
205
+ // int indexcsc = params.getInt("indexcsc");
206
+ // String csc = params.getString("csc");
207
+ // int param = params.getInt("param");
208
+
209
+ // int result = Termica.ImprimeXMLNFCe(dados, indexcsc, csc, param);
210
+
211
+ // callbackContext.success(result);
212
+ // }catch (Exception e){
213
+ // callbackContext.error("ImprimeXMLNFCe error: " + e.toString());
214
+ // }
215
+ // return true;
216
+ // }
217
+
218
+ // else if(action.equals("ImprimeXMLSAT")){
219
+ // try{
220
+ // JSONObject params = args.getJSONObject(0);
221
+
222
+ // String dados = params.getString("dados");
223
+ // int param = params.getInt("param");
224
+
225
+ // int result = Termica.ImprimeXMLSAT(dados, param);
226
+
227
+ // callbackContext.success(result);
228
+
229
+ // }catch (Exception e){
230
+ // callbackContext.error("ImprimeXMLSAT error: " + e.toString());
231
+ // }
232
+ // return true;
233
+ // }
234
+
235
+ // else if(action.equals("AbreGavetaElgin")){
236
+ // try{
237
+ // int result = Termica.AbreGavetaElgin();
238
+
239
+ // callbackContext.success(result);
240
+ // } catch (Exception e){
241
+ // callbackContext.error("AbreGavetaElgin error: " + e.toString());
242
+ // }
243
+ // }
244
+
245
+ // else if(action.equals("StatusImpressora")){
246
+ // try{
247
+ // JSONObject params = args.getJSONObject(0);
248
+
249
+ // int param = params.getInt("param");
250
+
251
+ // int result = Termica.StatusImpressora(param);
252
+
253
+ // callbackContext.success(result);
254
+ // }catch (Exception e){
255
+ // callbackContext.error("StatusImpressora error: " + e.toString());
256
+ // }
257
+ // return true;
258
+ // }
259
+
260
+ // else if(action.equals("ImprimeImagem")){
261
+ // try{
262
+ // JSONObject params = args.getJSONObject(0);
263
+
264
+ // if(params.getBoolean("cutPaper")) this.cutPaper = true;
265
+ // else this.cutPaper = false;
266
+
267
+ // Intent intent = new Intent((Intent.ACTION_PICK));
268
+ // intent.setType("image/*");
269
+
270
+ // this.selecionarImagemCallbackContext = callbackContext;
271
+
272
+ // this.cordova.setActivityResultCallback(this);
273
+ // this.cordova.getActivity().startActivityForResult(intent, REQ_CODE_SELECAOIMAGEM);
274
+
275
+ // }catch (Exception e){
276
+ // callbackContext.error("ImprimirImagem error: " + e.toString());
277
+ // }
278
+ // return true;
279
+ // }
280
+ return false;
281
+ }
282
+ }
@@ -23,273 +23,75 @@ import static android.app.Activity.RESULT_OK;
23
23
  import java.util.HashMap;
24
24
  import java.util.Map;
25
25
 
26
- //Elgin Plugins
27
- import com.elgin.e1.Impressora.Termica;
28
-
29
26
  import javax.security.auth.callback.Callback;
30
27
 
31
28
  /**
32
29
  * This class echoes a string called from JavaScript.
33
30
  */
34
31
  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;
32
+ //Elgin
33
+ public ElginM10Terminal elginM10Terminal;
45
34
 
46
- //cutPaper boolean for resultActivity
47
- private boolean cutPaper = false;
35
+ //Cielo
36
+ public CieloLioLocal cieloLioLocal;
48
37
 
49
38
  @Override
50
39
  public void initialize(CordovaInterface cordova, CordovaWebView webView) {
51
40
  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
41
  }
59
42
 
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
- }
43
+ private void initializeElginM10Terminal() {
44
+ if (this.elginM10Terminal == null) {
45
+ this.elginM10Terminal = new ElginM10Terminal();
46
+ this.elginM10Terminal.initialize(this.cordova, this.webView);
104
47
  }
48
+ }
105
49
 
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;
50
+ private void initializeCieloLioLocal() {
51
+ if (this.cieloLioLocal == null) {
52
+ this.cieloLioLocal = new CieloLioLocal();
53
+ this.cieloLioLocal.initialize(this.cordova, this.webView);
261
54
  }
55
+ }
262
56
 
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());
57
+ @Override
58
+ public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
59
+ try {
60
+ String result = "Sem resultado";
61
+ String[] actionProviderList = action.split("\\.");
62
+ String provider = actionProviderList[0];
63
+
64
+ switch (provider.toLowerCase()) {
65
+ case "elgin":
66
+ String elginProduct = actionProviderList[1];
67
+ switch (elginProduct.toLowerCase()) {
68
+ case "m10terminal":
69
+ this.initializeElginM10Terminal();
70
+ String elginAction = actionProviderList[2];
71
+ boolean resultElginExecute = this.elginM10Terminal.execute(elginAction, args, callbackContext);
72
+ return resultElginExecute;
73
+ default:
74
+ break;
75
+ }
76
+ case "cielo":
77
+ String cieloProduct = actionProviderList[1];
78
+ switch (cieloProduct.toLowerCase()) {
79
+ case "liolocal":
80
+ this.initializeCieloLioLocal();
81
+ String cieloAction = actionProviderList[2];
82
+ boolean resultCieloExecute = this.cieloLioLocal.execute(cieloAction, args, callbackContext);
83
+ return resultCieloExecute;
84
+ default:
85
+ break;
86
+ }
87
+ default:
88
+ break;
282
89
  }
90
+ callbackContext.success(result);
283
91
  return true;
92
+ } catch (Exception e) {
93
+ callbackContext.error("NetControllCordovaPluginsIntegration excute error: " + e.toString());
284
94
  }
285
95
  return false;
286
96
  }
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
97
  }
package/src/build.gradle CHANGED
@@ -8,6 +8,10 @@ repositories {
8
8
  dependencies {
9
9
  implementation fileTree(dir: 'libs', include: ['*.jar'])
10
10
 
11
+ //Bibliotecas Cielo para utilização das funcionalidades dos lio`
12
+ implementation 'com.cielo.lio:order-manager:1.4.0'
13
+ // --------------------------------------------------------------------------- //
14
+
11
15
  //Bibliotecas Elgin para utilização das funcionalidades dos minipdv`s
12
16
  implementation(name: 'e1-v1.0.16-release', ext: 'aar')
13
17
  implementation(name: 'minipdvm8', ext: 'aar')
@@ -0,0 +1,13 @@
1
+ var exec = require('cordova/exec');
2
+
3
+ //Cielo Lio Local Functions
4
+
5
+ exports.Teste = function (params, success, error) {
6
+ exec(success, error, 'NetControllCordovaPluginsIntegration', 'Cielo.LioLocal.Teste', [params]);
7
+ }
8
+
9
+ exports.ListarPagamentos = function (params, success, error) {
10
+ exec(success, error, 'NetControllCordovaPluginsIntegration', 'Cielo.LioLocal.ListarPagamentos', [params]);
11
+ }
12
+
13
+
@@ -0,0 +1,64 @@
1
+ var exec = require('cordova/exec');
2
+
3
+ //Printer Functions
4
+
5
+ exports.Teste = function (params, success, error) {
6
+ exec(success, error, 'NetControllCordovaPluginsIntegration', 'Elgin.M10Terminal.Teste', [params]);
7
+ }
8
+
9
+ exports.AbreConexaoImpressora = function (params, success, error) {
10
+ exec(success, error, 'NetControllCordovaPluginsIntegration', 'Elgin.M10Terminal.AbreConexaoImpressora', [params]);
11
+ }
12
+
13
+ exports.FechaConexaoImpressora = function (success, error) {
14
+ exec(success, error, 'NetControllCordovaPluginsIntegration', 'Elgin.M10Terminal.FechaConexaoImpressora');
15
+ }
16
+
17
+ exports.AvancaPapel = function (params, success, error) {
18
+ exec(success, error, 'NetControllCordovaPluginsIntegration', 'Elgin.M10Terminal.AvancaPapel', [params]);
19
+ }
20
+
21
+ exports.Corte = function (params, success, error) {
22
+ exec(success, error, 'NetControllCordovaPluginsIntegration', 'Elgin.M10Terminal.Corte', [params]);
23
+ }
24
+
25
+ exports.ImpressaoTexto = function (params, success, error) {
26
+ exec(success, error, 'NetControllCordovaPluginsIntegration', 'Elgin.M10Terminal.ImpressaoTexto', [params]);
27
+ }
28
+
29
+ exports.ImpressaoCodigoBarras = function (params, success, error) {
30
+ exec(success, error, 'NetControllCordovaPluginsIntegration', 'Elgin.M10Terminal.ImpressaoCodigoBarras', [params]);
31
+ }
32
+
33
+ exports.DefinePosicao = function (params, success, error) {
34
+ exec(success, error, 'NetControllCordovaPluginsIntegration', 'Elgin.M10Terminal.DefinePosicao', [params]);
35
+ }
36
+
37
+ exports.ImpressaoQRCode = function (params, success, error) {
38
+ exec(success, error, 'NetControllCordovaPluginsIntegration', 'Elgin.M10Terminal.ImpressaoQRCode', [params]);
39
+ }
40
+
41
+ exports.ImprimeXMLNFCe = function (params, success, error) {
42
+ exec(success, error, 'NetControllCordovaPluginsIntegration', 'Elgin.M10Terminal.ImprimeXMLNFCe', [params]);
43
+ }
44
+
45
+ exports.ImprimeXMLSAT = function (params, success, error) {
46
+ exec(success, error, 'NetControllCordovaPluginsIntegration', 'Elgin.M10Terminal.ImprimeXMLSAT', [params]);
47
+ }
48
+
49
+ exports.AbreGavetaElgin = function (success, error) {
50
+ exec(success, error, 'NetControllCordovaPluginsIntegration', 'Elgin.M10Terminal.AbreGavetaElgin');
51
+ }
52
+
53
+ exports.StatusImpressora = function (params, success, error) {
54
+ exec(success, error, 'NetControllCordovaPluginsIntegration', 'Elgin.M10Terminal.StatusImpressora', [params]);
55
+ }
56
+
57
+
58
+ //CUSTOM METHOD
59
+ exports.imprimeImagem = function (params, success, error) {
60
+ exec(success, error, 'NetControllCordovaPluginsIntegration', 'Elgin.M10Terminal.ImprimeImagem', [params]);
61
+ }
62
+
63
+
64
+
@@ -1,61 +1,10 @@
1
1
  var exec = require('cordova/exec');
2
2
 
3
- exports.coolMethod = function (arg0, success, error) {
4
- exec(success, error, 'NetControllCordovaPluginsIntegration', 'coolMethod', [arg0]);
3
+ exports.TesteRoot = function (arg0, success, error) {
4
+ exec(success, error, 'NetControllCordovaPluginsIntegration', 'Teste', [arg0]);
5
5
  };
6
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
-
7
+ exports.coolMethod2 = function (arg0, success, error) {
8
+ exec(success, error, 'NetControllCordovaPluginsIntegration', 'coolMethod2', [arg0]);
9
+ };
57
10
 
58
- //CUSTOM METHOD
59
- exports.imprimeImagem = function (params, success, error){
60
- exec(success, error, 'MainActivity', 'ImprimeImagem', [params]);
61
- }
package/www/alice.js ADDED
@@ -0,0 +1,4 @@
1
+ function alice() {
2
+ console.log("Hello World From Alice!");
3
+ }
4
+ module.exports = alice;
package/www/bob.js ADDED
@@ -0,0 +1,10 @@
1
+ var alice = require('cordova-plugin-netcontroll-integration.alice');
2
+
3
+ function bob(){
4
+ console.log("Hello World From Bob! Are you there Alice?");
5
+ alice();
6
+ }
7
+
8
+ // bob();
9
+
10
+ module.exports = bob;