cordova-plugin-netcontroll-integration 1.0.166 → 1.0.167

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.166
1
+ Versao 1.0.167
2
2
 
3
3
  Funções internas de integração XMenu / NetControll
4
4
 
5
- - Homologacao Devices Tectoy K10, K10 MINI e P3 MIX.
5
+ - Homologacao Devices POSTech.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cordova-plugin-netcontroll-integration",
3
- "version": "1.0.166",
3
+ "version": "1.0.167",
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.166"
2
+ <plugin id="cordova-plugin-netcontroll-integration" version="1.0.167"
3
3
  xmlns="http://apache.org/cordova/ns/plugins/1.0"
4
4
  xmlns:android="http://schemas.android.com/apk/res/android">
5
5
 
@@ -28,6 +28,10 @@
28
28
  <clobbers target="cordova.plugins.NetControllCordovaPluginsIntegration.SafraPayIngenico" />
29
29
  </js-module>
30
30
 
31
+ <js-module name="POStech" src="www/POStech/POStech.js">
32
+ <clobbers target="cordova.plugins.NetControllCordovaPluginsIntegration.POStech" />
33
+ </js-module>
34
+
31
35
  <js-module name="TecToySuminD2Mini" src="www/TecToy/TecToySumniD2Mini.js">
32
36
  <clobbers target="cordova.plugins.NetControllCordovaPluginsIntegration.TecToySumniD2Mini" />
33
37
  </js-module>
@@ -141,7 +145,9 @@
141
145
  <resource-file src="src/libs/vero/positivo-printer-1.00.00.aar" target="libs/vero/positivo-printer-1.00.00.aar" />
142
146
  <resource-file src="src/libs/vero/posmpapi_1.01.01.aar" target="libs/vero/posmpapi_1.01.01.aar" />
143
147
 
144
-
148
+ <!--______________________________POStech______________________________-->
149
+ <source-file src="src/android/POStech/POStech.java" target-dir="src/cordova-plugin-netcontroll-integration/POStech" />
150
+ <resource-file src="src/libs/POStech/WT-SDK.jar" target="libs/POStech/WT-SDK.jar" />
145
151
 
146
152
 
147
153
  <framework src="src/build.gradle" custom="true" type="gradleReference" />
@@ -32,6 +32,10 @@ public class NetControllCordovaPluginsIntegration extends CordovaPlugin {
32
32
  //Vero
33
33
  public cordova.plugin.netcontroll.integration.VeroPOS veroPOS;
34
34
 
35
+ //POStech
36
+ public cordova.plugin.netcontroll.integration.POStech POStech;
37
+
38
+
35
39
  //Utils
36
40
  // public UtilsImageStore utilsImageStore;
37
41
 
@@ -107,6 +111,13 @@ public class NetControllCordovaPluginsIntegration extends CordovaPlugin {
107
111
  }
108
112
  }
109
113
 
114
+ private void initializePOStech(){
115
+ if (this.POStech == null) {
116
+ this.POStech = new cordova.plugin.netcontroll.integration.POStech();
117
+ this.POStech.initialize(this.cordova, this.webView);
118
+ }
119
+ }
120
+
110
121
  // private void initializeUtilsImageStore() {
111
122
  // if (this.utilsImageStore == null) {
112
123
  // this.utilsImageStore = new UtilsImageStore();
@@ -198,6 +209,17 @@ public class NetControllCordovaPluginsIntegration extends CordovaPlugin {
198
209
  default:
199
210
  break;
200
211
  }
212
+ case "postech":
213
+ String postechProduct = actionProviderList[1];
214
+ switch (postechProduct.toLowerCase()) {
215
+ case "postech":
216
+ this.initializePOStech();
217
+ String postechAction = actionProviderList[2];
218
+ boolean resultPOStechExecute = this.POStech.execute(postechAction, args, callbackContext);
219
+ return resultPOStechExecute;
220
+ default:
221
+ break;
222
+ }
201
223
  // case "utils":
202
224
  // String utilsProduct = actionProviderList[1];
203
225
  // switch (utilsProduct.toLowerCase()) {
@@ -0,0 +1,140 @@
1
+ package cordova.plugin.netcontroll.integration;
2
+
3
+ import android.app.Activity;
4
+ import android.app.Service;
5
+ import android.content.ComponentName;
6
+ import android.content.Context;
7
+ import android.content.Intent;
8
+ import android.content.ServiceConnection;
9
+ import android.graphics.Bitmap;
10
+ import android.os.Environment;
11
+ import android.os.IBinder;
12
+ import android.os.RemoteException;
13
+ import android.util.Log;
14
+ import android.view.View;
15
+
16
+ import org.apache.cordova.CallbackContext;
17
+ import org.apache.cordova.CordovaInterface;
18
+ import org.apache.cordova.CordovaWebView;
19
+ import org.json.JSONArray;
20
+ import org.json.JSONException;
21
+ import org.json.JSONObject;
22
+
23
+ import java.io.IOException;
24
+
25
+ import cn.wintec.aidl.CashboxService;
26
+ import cn.wintec.aidl.DispC035Service;
27
+ import cn.wintec.aidl.LEDService;
28
+ import cn.wintec.aidl.LabelPrinterService;
29
+ import cn.wintec.aidl.PrinterService;
30
+ import cn.wintec.aidl.ScaleListener;
31
+ import cn.wintec.aidl.ScaleService;
32
+ import cn.wintec.aidl.WintecManagerService;
33
+
34
+ public class POStech {
35
+
36
+ //Cordova/Java Params
37
+ private Activity mActivity;
38
+ private Context mContext;
39
+ private CordovaInterface mCordova;
40
+ private CordovaWebView mWebView;
41
+
42
+ private int TamanhoBobina;
43
+ private int RotacionarImpresso;
44
+
45
+ private WintecManagerService WINTEC;
46
+ private PrinterService printer;
47
+ private LabelPrinterService labelprinter;
48
+ public static ScaleService scaleService;
49
+ public static DispC035Service dispC035Service;
50
+ public static LEDService ledService;
51
+ public static CashboxService cashboxService;
52
+
53
+
54
+ public void initialize(CordovaInterface cordova, CordovaWebView webView) {
55
+ mActivity = cordova.getActivity();
56
+ mContext = cordova.getActivity().getApplicationContext();
57
+ mCordova = cordova;
58
+ mWebView = webView;
59
+ }
60
+
61
+ public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
62
+ String callbackContextMessageBase = "Result POSTech - " + action + ": ";
63
+ if (action.equals("Initialize")) {
64
+ JSONObject params = args.getJSONObject(0);
65
+ try {
66
+ Intent intent = new Intent();
67
+ intent.setAction("cn.wintec.SERVICE");
68
+ intent.setPackage("cn.wintec.sdk");
69
+ mActivity.bindService(intent, conn, Service.BIND_AUTO_CREATE);
70
+ callbackContext.success(callbackContextMessageBase + "Success");
71
+ return true;
72
+ } catch (Exception error) {
73
+ callbackContext.error(callbackContextMessageBase + "Error Detail: " + error);
74
+ }
75
+ } else if (action.equals("ImpressaoTextoNetPrint")) {
76
+ JSONObject params = args.getJSONObject(0);
77
+ try {
78
+ String dados = params.getString("dados");
79
+ Boolean negrito = false;
80
+ try {
81
+ negrito = params.getBoolean("negrito");
82
+ }catch (Exception ex){
83
+ }
84
+
85
+ String html = cordova.plugin.netcontroll.integration.util.NetControllPrinter.ConverterTextoImpressoToHtml(dados, negrito);
86
+ cordova.plugin.netcontroll.integration.util.NetControllPrinter.ConverterHtmlToBitmap(html, mContext, bitmapResult -> {
87
+ Bitmap dadosImg = bitmapResult;
88
+
89
+ try {
90
+ dadosImg = cordova.plugin.netcontroll.integration.util.NetControllPrinter.ResizeBitmap(dadosImg, 550);
91
+ dadosImg = cordova.plugin.netcontroll.integration.util.NetControllPrinter.RotacionarBitmap(dadosImg, 180);
92
+ } catch (Exception err) {
93
+ }
94
+
95
+ try {
96
+ printer.PRN_OpenUSB(0, 0);
97
+ printer.PRN_Init();
98
+ printer.PRN_SetDensity(0);
99
+ printer.PRN_PrintDotBitmap(dadosImg, 0);
100
+ printer.PRN_PrintAndFeedLine(5);
101
+ printer.PRN_CutPaper();
102
+ printer.PRN_Close();
103
+ } catch (RemoteException e) {
104
+ }
105
+
106
+ callbackContext.success(callbackContextMessageBase + "Success");
107
+ });
108
+ } catch (Exception e) {
109
+ callbackContext.error("ImpressaoTextoNetPrintImg error: " + e.toString());
110
+ }
111
+ return true;
112
+ }
113
+ return false;
114
+ }
115
+
116
+ //region Methods
117
+
118
+ private ServiceConnection conn = new ServiceConnection() {
119
+ @Override
120
+ public void onServiceConnected(ComponentName name, IBinder service) {
121
+ WINTEC = WintecManagerService.Stub.asInterface(service);
122
+ try {
123
+ printer = PrinterService.Stub.asInterface(WINTEC.getPrinterService());
124
+ labelprinter = LabelPrinterService.Stub.asInterface(WINTEC.getLabelPrinterService());
125
+ scaleService = ScaleService.Stub.asInterface(WINTEC.getScaleService());
126
+ dispC035Service = DispC035Service.Stub.asInterface(WINTEC.getDispC035Service());
127
+ ledService = LEDService.Stub.asInterface(WINTEC.getLEDService());
128
+ cashboxService = CashboxService.Stub.asInterface(WINTEC.getCashboxService());
129
+
130
+ } catch (Exception e) {
131
+ e.printStackTrace();
132
+ }
133
+ }
134
+
135
+ @Override
136
+ public void onServiceDisconnected(ComponentName name) {
137
+ WINTEC = null;
138
+ }
139
+ };
140
+ }
package/src/build.gradle CHANGED
@@ -1,6 +1,6 @@
1
1
  repositories {
2
2
  google()
3
- jcenter()
3
+ //jcenter()
4
4
  flatDir {
5
5
  dirs 'src/main/libs'
6
6
  }
@@ -69,6 +69,9 @@ dependencies {
69
69
  // implementation(name: 'vero/positivo-printer-1.00.00', ext: 'aar')
70
70
  implementation('com.sunmi:printerlibrary:1.0.22')
71
71
 
72
+ //_____________________ POStech _________________________
73
+ implementation(name:'POStech/WT-SDK', ext:'jar')
74
+
72
75
 
73
76
  //A lib e1 na versão 1.0.16 depende do suporte do androidx na inicialização
74
77
  implementation "androidx.startup:startup-runtime:1.0.0"
Binary file
@@ -0,0 +1,15 @@
1
+ var exec = require('cordova/exec');
2
+
3
+ //Printer Functions
4
+
5
+ exports.Initialize = function (params, success, error) {
6
+ exec(success, error, 'NetControllCordovaPluginsIntegration', 'POStech.POStech.Initialize', [params]);
7
+ }
8
+
9
+ exports.ImpressaoTextoNetPrint = function (params, success, error) {
10
+ exec(success, error, 'NetControllCordovaPluginsIntegration', 'POStech.POStech.ImpressaoTextoNetPrint', [params]);
11
+ }
12
+
13
+ exports.ImpressaoBase64NetPrint = function (params, success, error) {
14
+ exec(success, error, 'NetControllCordovaPluginsIntegration', 'POStech.POStech.ImpressaoBase64NetPrint', [params]);
15
+ }