capacitor-hugin-gmp3 0.2.2 → 0.3.0

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
@@ -9,14 +9,6 @@ npm install capacitor-hugin-gmp3
9
9
  npx cap sync
10
10
  ```
11
11
 
12
- ## Version Compatibility
13
-
14
- | Capacitor Version |Plugin Version|
15
- | ------------- | ----------------------------------------------------------- |
16
- | Capacitor v5 | 0.3.x|
17
- | Capacitor v6 | 0.2.x|
18
- | Capacitor v7 | 0.1.x|
19
-
20
12
  ## API
21
13
 
22
14
  <docgen-index>
@@ -45,14 +45,6 @@ android {
45
45
  dirs 'libs'
46
46
  }
47
47
  }
48
- buildFeatures {
49
- aidl true
50
- }
51
- sourceSets {
52
- main {
53
- aidl.srcDirs = ['src/main/aidl']
54
- }
55
- }
56
48
  }
57
49
 
58
50
  repositories {
@@ -1,9 +1,2 @@
1
1
  <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
- <application>
3
- <service
4
- android:name=".PrinterCoverService"
5
- android:process=":printer_process"
6
- android:exported="false"
7
- android:permission="android.permission.BIND_JOB_SERVICE"/>
8
- </application>
9
2
  </manifest>
@@ -0,0 +1,122 @@
1
+ package com.kerzz.hugin.gmp3;
2
+
3
+ import android.util.Log;
4
+
5
+ import com.getcapacitor.JSObject;
6
+
7
+ import gmp3.droid.printer.DeviceInfo;
8
+ import gmp3.droid.printer.HuginPrinter;
9
+ import gmp3.droid.printer.Utility;
10
+
11
+ public class CapacitorHuginGMP3 {
12
+ protected final HuginPrinter huginPrinter = new HuginPrinter();
13
+ private final String TAG = "CapacitorHuginGMP3Plugin";
14
+ protected boolean tcpConnected = false;
15
+ private int tcpRetry = 0;
16
+ private boolean tcpConnect(String ip, Integer port) {
17
+ try {
18
+ if(tcpConnected) return true;
19
+ if (port == null) {
20
+ Log.w(TAG,"Port parametresi eksik.");
21
+ return false;
22
+ }
23
+
24
+ return huginPrinter.TCPConnect(ip, port);
25
+ } catch (RuntimeException e) {
26
+ return false;
27
+ }
28
+ }
29
+
30
+ protected boolean connect(String ip, int port, String terminalNo) {
31
+ try {
32
+ tcpConnected = tcpConnect(ip,port);
33
+ if(!tcpConnected) {
34
+ tcpRetry += 1;
35
+ Log.w(TAG,"TCP Bağlantısı sağlanamadı. Tekrar deneniyor: " + tcpRetry);
36
+ return false;
37
+ }
38
+ DeviceInfo serverInfo = new DeviceInfo();
39
+ serverInfo.Brand = "HUGIN";
40
+ serverInfo.IP = ip;
41
+ serverInfo.Model = "HUGIN COMPACT";
42
+ serverInfo.Port = port;
43
+ serverInfo.TerminalNo = terminalNo;// "FP11004397";
44
+ serverInfo.Version = "";
45
+ serverInfo.SerialNum = "";
46
+ Log.i(TAG, serverInfo.IP);
47
+ return huginPrinter.Connect(serverInfo, serverInfo.TerminalNo, "");
48
+ } catch (Exception e) {
49
+ return false;
50
+ }
51
+ }
52
+
53
+ protected String libraryVersion() {
54
+ return huginPrinter.LibraryVersion();
55
+ }
56
+
57
+ protected boolean printZReport() {
58
+ try {
59
+ String[] response = printResponse(huginPrinter.PrintZReport());
60
+ int errorCode = Integer.parseInt(response[0]);
61
+ if(errorCode != 0) {
62
+ System.out.println("Error Code : " + Utility.GetErrorMessage(errorCode));
63
+ return false;
64
+ }
65
+
66
+ return true;
67
+ } catch (Exception e) {
68
+ return false;
69
+ }
70
+ }
71
+
72
+ protected boolean printXReport(int type) {
73
+ try {
74
+ String[] response = printResponse(huginPrinter.PrintXReport(type));
75
+ int errorCode = Integer.parseInt(response[0]);
76
+ if(errorCode != 0) {
77
+ System.out.println("Error Code : " + Utility.GetErrorMessage(errorCode));
78
+ return false;
79
+ }
80
+ return true;
81
+ } catch (Exception e) {
82
+ return false;
83
+ }
84
+ }
85
+
86
+
87
+ protected static String[] printResponse(String response) {
88
+ int res = 6;
89
+ String[] splitted = response.split("\\|", 0);
90
+ if (splitted.length >= 2) {
91
+ res = Integer.parseInt(splitted[0]);
92
+ System.out.println("Error Code : " + Utility.GetErrorMessage(res));
93
+ System.out.println("State : " + Utility.GetStateMessage(Integer.parseInt(splitted[1])));
94
+ }
95
+
96
+ System.out.println("Full Response : " + response);
97
+ return splitted;
98
+ }
99
+
100
+ protected String sale(JSObject saleItem) {
101
+ String res = huginPrinter.CheckPrinterStatus();
102
+ Log.i(TAG, res);
103
+ String result = huginPrinter.PrintDocumentHeader();
104
+ Log.i(TAG, result);
105
+ String str = huginPrinter.PrintJSONDocumentDeptOnly(saleItem.toString());
106
+ Log.i(TAG, str);
107
+ String[] response = printResponse(str);
108
+ if(response.length > 2) {
109
+ return printResponse(str)[2];
110
+ }
111
+ return "-1";
112
+ // String result = huginPrinter.PrintDocumentHeader();
113
+ // String item1 = huginPrinter.PrintItem(1, 15, 3.00, "Capacitor Ürün", "", 1, 1);
114
+ // String item2 = huginPrinter.PrintItem(1, 30, 3.00, "Capacitor Ürün 2", "", 1, 1);
115
+ // String payment = huginPrinter.PrintPayment(0 , -1 , 300);
116
+ //
117
+ // huginPrinter.CloseReceipt(false);
118
+
119
+ }
120
+
121
+
122
+ }
@@ -1,14 +1,8 @@
1
1
  package com.kerzz.hugin.gmp3;
2
2
 
3
+ import static com.kerzz.hugin.gmp3.CapacitorHuginGMP3.printResponse;
3
4
 
4
- import android.content.ComponentName;
5
- import android.content.Context;
6
- import android.content.Intent;
7
- import android.content.ServiceConnection;
8
5
  import android.os.Build;
9
- import android.os.DeadObjectException;
10
- import android.os.IBinder;
11
- import android.os.RemoteException;
12
6
  import android.util.Log;
13
7
 
14
8
  import com.getcapacitor.JSArray;
@@ -17,8 +11,6 @@ import com.getcapacitor.Plugin;
17
11
  import com.getcapacitor.PluginCall;
18
12
  import com.getcapacitor.PluginMethod;
19
13
  import com.getcapacitor.annotation.CapacitorPlugin;
20
- import com.kerzz.hugin.gmp3.IPrinterService;
21
-
22
14
 
23
15
  import java.time.LocalDateTime;
24
16
 
@@ -27,42 +19,30 @@ import gmp3.droid.printer.Utility;
27
19
 
28
20
  @CapacitorPlugin(name = "CapacitorHuginGMP3")
29
21
  public class CapacitorHuginGMP3Plugin extends Plugin {
22
+ private final CapacitorHuginGMP3 implementation = new CapacitorHuginGMP3();
30
23
  private final String TAG = "CapacitorHuginGMP3";
31
- private IPrinterService printerService;
32
- private boolean bound = false;
33
-
34
- private final ServiceConnection serviceConnection = new ServiceConnection() {
35
- @Override
36
- public void onServiceConnected(ComponentName name, IBinder service) {
37
- printerService = IPrinterService.Stub.asInterface(service);
38
- bound = true;
39
- Log.d(TAG, "Printer servise bağlandı.");
40
- }
41
-
42
- @Override
43
- public void onServiceDisconnected(ComponentName name) {
44
- printerService = null;
45
- bound = false;
46
- Log.d(TAG, "Printer servis bağlantısı koptu.");
47
- Intent intent = new Intent(getContext(), PrinterCoverService.class);
48
- getContext().bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE);
49
- }
50
- };
51
24
  @Override
52
25
  public void load() {
53
26
  super.load();
54
- Intent intent = new Intent(getContext(), PrinterCoverService.class);
55
- getContext().bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE);
27
+ }
28
+
29
+ public CapacitorHuginGMP3Plugin() {
30
+ Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
31
+ @Override
32
+ public void uncaughtException(Thread t, Throwable e) {
33
+ Log.e(TAG, "Yakalanmayan hata: " + e.getMessage());
34
+ // Burada kullanıcıya hata gösterebilirsin veya loglayabilirsin
35
+ // Uygulama çökmeye devam eder ama en azından bilgi alırsın
36
+ }
37
+ });
38
+ Log.d(TAG, "HuginPrinter constructor çalıştı ve exception handler kuruldu.");
39
+
56
40
  }
57
41
 
58
42
  @PluginMethod
59
43
  public void GetLibraryVersion(PluginCall call) {
60
- try {
61
- String version = printerService.libraryVersion();
62
- call.resolve(new JSObject().put("version", version));
63
- } catch (Exception e) {
64
- call.resolve(new JSObject().put("version", -1));
65
- }
44
+ String version = implementation.libraryVersion();
45
+ call.resolve(new JSObject().put("version", version));
66
46
  }
67
47
 
68
48
  @PluginMethod
@@ -81,15 +61,12 @@ public class CapacitorHuginGMP3Plugin extends Plugin {
81
61
  return;
82
62
  }
83
63
 
84
- boolean connected = printerService.connect(ip, port, terminalNo);
64
+ boolean connected = implementation.connect(ip, port, terminalNo);
85
65
  JSObject result = new JSObject();
86
66
  result.put("connected", connected);
87
67
  call.resolve(result);
88
- } catch (RemoteException e) {
89
- JSObject result = new JSObject();
90
- result.put("connected", false);
91
- call.resolve(result);
92
- Log.i(TAG,"Hata Bizde" + e.toString());
68
+ } catch (Exception e) {
69
+ Log.i(TAG,e.toString());
93
70
  }
94
71
  }
95
72
 
@@ -106,7 +83,7 @@ public class CapacitorHuginGMP3Plugin extends Plugin {
106
83
 
107
84
  Log.i(TAG, "Sale Request: " + saleItem);
108
85
 
109
- String response = printerService.Sale(saleItem.toString());
86
+ String response = implementation.sale(saleItem);
110
87
  Log.i(TAG, "Sale Response: " + response);
111
88
  JSObject res = new JSObject();
112
89
  if(!response.equals("-1")) {
@@ -120,52 +97,38 @@ public class CapacitorHuginGMP3Plugin extends Plugin {
120
97
  call.resolve(res);
121
98
  }
122
99
 
123
- } catch (RemoteException e) {
124
- Log.e(TAG, "Sale Error", e);
125
- call.reject("Must Reconnect", e);
126
100
  } catch (Exception e) {
101
+ Log.e(TAG, "Sale Error", e);
127
102
  call.reject("Sale failed", e);
128
103
  }
129
104
  }
130
105
 
131
106
  @PluginMethod
132
107
  public void PrintZReport(PluginCall call) {
133
- if (printerService != null) {
134
- try {
135
- call.resolve(JSObjectHelper.result(printerService.printZReport()));
136
- } catch (RemoteException e) {
137
- Log.e(TAG, e.toString());
138
- call.resolve(JSObjectHelper.result(false));
139
- }
140
- }
108
+ call.resolve(JSObjectHelper.result(implementation.printZReport()));
141
109
  }
142
110
 
143
111
  @PluginMethod
144
- public void PrintXReport(PluginCall call) throws DeadObjectException {
145
- if (printerService != null) {
146
- int type = 1;
147
- try {
148
- Integer typeValue = call.getInt("type");
149
- if (typeValue != null) {
150
- type = typeValue;
151
- }
152
- call.resolve(JSObjectHelper.result(printerService.printXReport(type)));
153
- } catch (RemoteException e) {
154
- Log.e(TAG, e.toString());
155
- call.resolve(JSObjectHelper.result(false));
112
+ public void PrintXReport(PluginCall call) {
113
+ int type = 1;
114
+ try {
115
+ Integer typeValue = call.getInt("type");
116
+ if (typeValue != null) {
117
+ type = typeValue;
156
118
  }
119
+ } catch (Exception e) {
120
+ Log.e(TAG, e.toString());
157
121
  }
158
-
122
+ call.resolve(JSObjectHelper.result(implementation.printXReport(type)));
159
123
  }
160
124
 
161
125
  @PluginMethod
162
126
  public void GetDepartments(PluginCall call) {
163
127
  JSArray depts = new JSArray();
164
128
  try {
165
- printerService.VoidReceipt();
166
129
  for (int i = 1; i < 9; i++) { // 1-8
167
- String deptResponse = printerService.GetDepartment(i);
168
- String[] parts = PrinterCoverService.printResponse(deptResponse);
130
+ String deptResponse = implementation.huginPrinter.GetDepartment(i);
131
+ String[] parts = printResponse(deptResponse);
169
132
 
170
133
  if (parts.length >= 6) {
171
134
  JSObject dept = new JSObject();
@@ -189,12 +152,11 @@ public class CapacitorHuginGMP3Plugin extends Plugin {
189
152
 
190
153
  @PluginMethod
191
154
  public void GetVatRates(PluginCall call) {
155
+ JSArray vatRates = new JSArray();
192
156
  try {
193
- printerService.VoidReceipt();
194
- JSArray vatRates = new JSArray();
195
- for (int i = 0; i < 8; i++) { // 0'dan 7'e
196
- String vatResponse = printerService.GetVatRate(i);
197
- String[] responseParts = PrinterCoverService.printResponse(vatResponse);
157
+ for (int i = 0; i < 9; i++) { // 0'dan 8'e
158
+ String vatResponse = implementation.huginPrinter.GetVATRate(i);
159
+ String[] responseParts = CapacitorHuginGMP3.printResponse(vatResponse);
198
160
  if (responseParts.length >= 3) {
199
161
  vatRates.put(responseParts[2]); // 3. parça: KDV oranı
200
162
  }
@@ -254,19 +216,17 @@ public class CapacitorHuginGMP3Plugin extends Plugin {
254
216
  return;
255
217
  }
256
218
 
219
+ String vatResponse = implementation.huginPrinter.GetVATRate(vatId - 1);
220
+ String[] vatParts = printResponse(vatResponse);
257
221
 
222
+ if (vatParts.length < 3 || vatParts[2] == null || vatParts[2].trim().isEmpty()) {
223
+ call.reject("Belirtilen vatId (" + vatId + ") için geçerli bir KDV oranı bulunamadı. Lütfen önce geçerli bir KDV oranı tanımlayın.");
224
+ return;
225
+ }
258
226
 
259
227
  try {
260
- printerService.VoidReceipt();
261
- String vatResponse = printerService.GetVatRate(vatId - 1);
262
- String[] vatParts = PrinterCoverService.printResponse(vatResponse);
263
-
264
- if (vatParts.length < 3 || vatParts[2] == null || vatParts[2].trim().isEmpty()) {
265
- call.reject("Belirtilen vatId (" + vatId + ") için geçerli bir KDV oranı bulunamadı. Lütfen önce geçerli bir KDV oranı tanımlayın.");
266
- return;
267
- }
268
- String response = printerService.SetDepartment(id, name, vatId, price, weighable);
269
- String[] parts = PrinterCoverService.printResponse(response);
228
+ String response = implementation.huginPrinter.SetDepartment(id, name, vatId, price, weighable);
229
+ String[] parts = printResponse(response);
270
230
  int errorCode = Integer.parseInt(parts[0]);
271
231
 
272
232
  if (errorCode != 0) {
@@ -310,16 +270,15 @@ public class CapacitorHuginGMP3Plugin extends Plugin {
310
270
  return;
311
271
  }
312
272
 
313
- if (vatRate < -1 || vatRate > 100) {
273
+ if (vatRate < 0 || vatRate > 100) {
314
274
  call.reject("KDV oranı (vatRate) 0 ile 100 arasında olmalıdır.");
315
275
  return;
316
276
  }
317
277
 
318
278
  // --- KDV Ayarlama ---
319
279
  try {
320
- printerService.VoidReceipt();
321
- String response = printerService.SetVATRate(index, vatRate);
322
- String[] parts = PrinterCoverService.printResponse(response);
280
+ String response = implementation.huginPrinter.SetVATRate(index, vatRate);
281
+ String[] parts = printResponse(response);
323
282
  int errorCode = Integer.parseInt(parts[0]);
324
283
 
325
284
  if (errorCode != 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capacitor-hugin-gmp3",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "description": "Hugin plugin for TCP/IP",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -9,8 +9,6 @@
9
9
  "files": [
10
10
  "android/src/main/",
11
11
  "android/build.gradle",
12
- "android/libs/",
13
- "android/libs/gmp3android.aar",
14
12
  "dist/",
15
13
  "ios/Sources",
16
14
  "ios/Tests",
@@ -48,10 +46,10 @@
48
46
  "prepublishOnly": "npm run build"
49
47
  },
50
48
  "devDependencies": {
51
- "@capacitor/android": "^6.0.0",
52
- "@capacitor/core": "^6.0.0",
49
+ "@capacitor/android": "^5.0.0",
50
+ "@capacitor/core": "^5.0.0",
53
51
  "@capacitor/docgen": "^0.3.0",
54
- "@capacitor/ios": "^6.0.0",
52
+ "@capacitor/ios": "^5.0.0",
55
53
  "@ionic/eslint-config": "^0.4.0",
56
54
  "@ionic/prettier-config": "^4.0.0",
57
55
  "@ionic/swiftlint-config": "^2.0.0",
@@ -64,7 +62,7 @@
64
62
  "typescript": "~4.1.5"
65
63
  },
66
64
  "peerDependencies": {
67
- "@capacitor/core": ">=6.0.0"
65
+ "@capacitor/core": ">=5.0.0"
68
66
  },
69
67
  "prettier": "@ionic/prettier-config",
70
68
  "swiftlint": "@ionic/swiftlint-config",
Binary file
@@ -1,19 +0,0 @@
1
- // IPrinterService.aidl
2
- package com.kerzz.hugin.gmp3;
3
-
4
-
5
- // Declare any non-default types here with import statements
6
-
7
- interface IPrinterService {
8
- boolean printXReport(int type);
9
- boolean printZReport();
10
- boolean connect(String ip, int port, String terminalNo);
11
- boolean tcpConnect(String ip, int port);
12
- String Sale(String saleItem);
13
- String GetDepartment(int depId);
14
- String GetVatRate(int index);
15
- String libraryVersion();
16
- String SetDepartment(int id, String name, int vatId, double price, int weighable);
17
- String SetVATRate(int index, double vatRate);
18
- String VoidReceipt();
19
- }
@@ -1,207 +0,0 @@
1
- package com.kerzz.hugin.gmp3;
2
-
3
- import android.app.Service;
4
- import android.content.Intent;
5
- import android.os.DeadObjectException;
6
- import android.os.IBinder;
7
- import android.os.RemoteException;
8
- import android.util.Log;
9
-
10
- import gmp3.droid.printer.DeviceInfo;
11
- import gmp3.droid.printer.HuginPrinter;
12
- import gmp3.droid.printer.Utility;
13
-
14
- public class PrinterCoverService extends Service {
15
- private final String TAG = "PrinterCoverService";
16
- protected HuginPrinter printer = new HuginPrinter();
17
- protected boolean tcpConnected = false;
18
-
19
- private final IPrinterService.Stub binder = new IPrinterService.Stub() {
20
- @Override
21
- public boolean printXReport(int type) throws DeadObjectException {
22
- try {
23
- if (type < 0 || type > 10) {
24
- Log.e("PrinterCoverService", "Geçersiz parametre.");
25
- return false;
26
- }
27
- return _printXReport(printer,type);
28
- } catch (DeadObjectException e) {
29
- Log.e("PrinterCoverService", "Java hatası: " + e.getMessage(), e);
30
- return false;
31
- }
32
- }
33
-
34
- @Override
35
- public boolean printZReport() throws DeadObjectException {
36
- try {
37
- return _printZReport(printer);
38
- } catch (DeadObjectException e) {
39
- Log.e("PrinterCoverService", "Java hatası: " + e.getMessage(), e);
40
- return false;
41
- }
42
- }
43
-
44
- @Override
45
- public boolean connect(String ip, int port, String terminalNo) throws RemoteException {
46
- try {
47
- tcpConnected = tcpConnect(ip,port);
48
- if(!tcpConnected) {
49
- Log.w(TAG,"TCP Bağlantısı sağlanamadı.");
50
- return false;
51
- }
52
- DeviceInfo serverInfo = new DeviceInfo();
53
- serverInfo.Brand = "HUGIN";
54
- serverInfo.IP = ip;
55
- serverInfo.Model = "HUGIN COMPACT";
56
- serverInfo.Port = port;
57
- serverInfo.TerminalNo = terminalNo;// "FP11004397";
58
- serverInfo.Version = "";
59
- serverInfo.SerialNum = "";
60
- Log.i(TAG, serverInfo.IP);
61
- return printer.Connect(serverInfo, serverInfo.TerminalNo, "");
62
- } catch (Exception e) {
63
- return false;
64
- }
65
- }
66
-
67
- @Override
68
- public boolean tcpConnect(String ip, int port) throws RemoteException {
69
- try {
70
- Log.i(TAG, "Binder TCP Connect");
71
- if (ip == null || ip.isEmpty() || port <= 0) {
72
- Log.e(TAG, "Geçersiz IP veya port.");
73
- return false;
74
- }
75
- return printer.TCPConnect(ip, port);
76
- } catch (Exception e) {
77
- Log.e(TAG, "tcpConnect hata: " + e.getMessage(), e);
78
- return false;
79
- } finally {
80
- Log.i(TAG, "Finally ");
81
- }
82
- }
83
-
84
-
85
- @Override
86
- public String Sale(String saleItem) throws RemoteException {
87
- try {
88
- printer.VoidReceipt();
89
- String res = printer.CheckPrinterStatus();
90
- Log.i(TAG, res);
91
- String result = printer.PrintDocumentHeader();
92
- Log.i(TAG, result);
93
- String str = printer.PrintJSONDocumentDeptOnly(saleItem);
94
- Log.i(TAG, str);
95
- String[] response = printResponse(str);
96
- if(response.length > 2) {
97
- return printResponse(str)[2];
98
- }
99
- return "-1";
100
- } catch (Exception e) {
101
- return "-1";
102
- }
103
- }
104
-
105
-
106
- @Override
107
- public String GetDepartment(int index) throws RemoteException {
108
- try {
109
- return printer.GetDepartment(index);
110
- } catch (Exception e) {
111
- return "";
112
- }
113
- }
114
-
115
- @Override
116
- public String GetVatRate(int index) throws RemoteException {
117
- try {
118
- return printer.GetVATRate(index);
119
- } catch (Exception e) {
120
- return "";
121
- }
122
- }
123
-
124
- @Override
125
- public String libraryVersion() throws RemoteException {
126
- return printer.LibraryVersion();
127
- }
128
-
129
- @Override
130
- public String SetDepartment(int var1, String var2, int var3, double var4, int var6) throws RemoteException {
131
- return printer.SetDepartment(var1,var2,var3,var4,var6);
132
- }
133
-
134
- @Override
135
- public String SetVATRate(int index, double vatRate) throws RemoteException {
136
- return printer.SetVATRate(index, vatRate);
137
- }
138
-
139
- @Override
140
- public String VoidReceipt() throws RemoteException {
141
- printer.VoidReceipt();
142
- return "";
143
- }
144
- };
145
-
146
- @Override
147
- public IBinder onBind(Intent intent) {
148
- return binder;
149
- }
150
-
151
- @Override
152
- public void onCreate() {
153
- super.onCreate();
154
- printer = new HuginPrinter();
155
- Thread.setDefaultUncaughtExceptionHandler((t, e) -> {
156
- Log.e("GlobalCrash", "Yakalanamayan hata: " + e.getMessage(), e);
157
- android.os.Process.killProcess(android.os.Process.myPid());
158
- System.exit(1); // ❗ Android alert göstermez
159
- });
160
- }
161
-
162
-
163
- private boolean _printXReport(HuginPrinter printer,int type) throws DeadObjectException {
164
- try {
165
- printer.VoidReceipt();
166
- String[] response = printResponse(printer.PrintXReport(type));
167
- int errorCode = Integer.parseInt(response[0]);
168
- if(errorCode != 0) {
169
- System.out.println("Error Code : " + Utility.GetErrorMessage(errorCode));
170
- return false;
171
- }
172
- return true;
173
- } catch (Exception e) {
174
- return false;
175
- }
176
- }
177
-
178
- private boolean _printZReport(HuginPrinter printer) throws DeadObjectException {
179
- try {
180
- printer.VoidReceipt();
181
- String[] response = printResponse(printer.PrintZReport());
182
- int errorCode = Integer.parseInt(response[0]);
183
- if(errorCode != 0) {
184
- System.out.println("Error Code : " + Utility.GetErrorMessage(errorCode));
185
- return false;
186
- }
187
-
188
- return true;
189
- } catch (Exception e) {
190
- return false;
191
- }
192
- }
193
-
194
- public static String[] printResponse(String response) {
195
- int res = 6;
196
- String[] splitted = response.split("\\|", 0);
197
- if (splitted.length >= 2) {
198
- res = Integer.parseInt(splitted[0]);
199
- System.out.println("Error Code : " + Utility.GetErrorMessage(res));
200
- System.out.println("State : " + Utility.GetStateMessage(Integer.parseInt(splitted[1])));
201
- }
202
-
203
- System.out.println("Full Response : " + response);
204
- return splitted;
205
- }
206
-
207
- }