react-native-printer-imin 0.9.0 → 0.10.2
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/LICENSE +20 -20
- package/README.md +43 -36
- package/android/build.gradle +112 -112
- package/android/gradle.properties +5 -5
- package/android/src/main/AndroidManifest.xml +3 -3
- package/android/src/main/AndroidManifestNew.xml +2 -2
- package/android/src/main/java/com/printerimin/PrinterIminModule.java +2052 -1664
- package/android/src/main/java/com/printerimin/PrinterIminPackage.java +28 -28
- package/android/src/main/java/com/printerimin/Utils.java +300 -300
- package/lib/commonjs/index.js +57 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/typing.js +125 -1
- package/lib/commonjs/typing.js.map +1 -1
- package/lib/module/index.js +17 -4
- package/lib/module/index.js.map +1 -1
- package/lib/module/typing.js +124 -0
- package/lib/module/typing.js.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/typing.d.ts +140 -0
- package/lib/typescript/src/typing.d.ts.map +1 -1
- package/package.json +163 -162
- package/react-native-printer-imin.podspec +41 -41
- package/src/index.tsx +423 -395
- package/src/typing.ts +465 -245
|
@@ -1,1664 +1,2052 @@
|
|
|
1
|
-
package com.printerimin;
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import com.bumptech.glide.Glide;
|
|
5
|
-
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
|
6
|
-
|
|
7
|
-
import android.
|
|
8
|
-
import android.graphics.
|
|
9
|
-
import android.
|
|
10
|
-
import android.
|
|
11
|
-
import android.os.
|
|
12
|
-
import android.
|
|
13
|
-
|
|
14
|
-
import
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
import
|
|
18
|
-
|
|
19
|
-
import com.facebook.react.bridge.
|
|
20
|
-
import com.facebook.react.bridge.
|
|
21
|
-
import com.facebook.react.bridge.
|
|
22
|
-
import com.facebook.react.bridge.
|
|
23
|
-
import com.facebook.react.bridge.
|
|
24
|
-
import com.facebook.react.bridge.
|
|
25
|
-
import com.facebook.react.bridge.
|
|
26
|
-
|
|
27
|
-
import com.facebook.react.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
import com.imin.
|
|
34
|
-
import com.imin.
|
|
35
|
-
|
|
36
|
-
import
|
|
37
|
-
import
|
|
38
|
-
import
|
|
39
|
-
import
|
|
40
|
-
import
|
|
41
|
-
|
|
42
|
-
import
|
|
43
|
-
import
|
|
44
|
-
|
|
45
|
-
import
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
import
|
|
49
|
-
|
|
50
|
-
import
|
|
51
|
-
|
|
52
|
-
import
|
|
53
|
-
import
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
promise.
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
promise.
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
promise.
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
if (
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
if (
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
promise.
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
@ReactMethod
|
|
916
|
-
public void
|
|
917
|
-
try {
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
int
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
promise.resolve(
|
|
1093
|
-
}
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
}
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
@Override
|
|
1189
|
-
public void
|
|
1190
|
-
}
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
@Override
|
|
1219
|
-
public void
|
|
1220
|
-
}
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
@Override
|
|
1249
|
-
public void
|
|
1250
|
-
}
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
@Override
|
|
1279
|
-
public void
|
|
1280
|
-
}
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
@Override
|
|
1309
|
-
public void
|
|
1310
|
-
}
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
@Override
|
|
1339
|
-
public void
|
|
1340
|
-
}
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
promise.resolve(PrinterHelper.getInstance().
|
|
1421
|
-
} else {
|
|
1422
|
-
promise.resolve(null);
|
|
1423
|
-
}
|
|
1424
|
-
} catch (Exception e) {
|
|
1425
|
-
promise.reject("
|
|
1426
|
-
}
|
|
1427
|
-
}
|
|
1428
|
-
|
|
1429
|
-
@ReactMethod
|
|
1430
|
-
public void
|
|
1431
|
-
try {
|
|
1432
|
-
if (iminPrintUtils == null) {
|
|
1433
|
-
promise.resolve(PrinterHelper.getInstance().
|
|
1434
|
-
} else {
|
|
1435
|
-
promise.resolve(null);
|
|
1436
|
-
}
|
|
1437
|
-
} catch (Exception e) {
|
|
1438
|
-
promise.reject("
|
|
1439
|
-
}
|
|
1440
|
-
}
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
} catch (Exception e) {
|
|
1451
|
-
promise.reject("
|
|
1452
|
-
}
|
|
1453
|
-
}
|
|
1454
|
-
|
|
1455
|
-
@ReactMethod
|
|
1456
|
-
public void
|
|
1457
|
-
try {
|
|
1458
|
-
if (iminPrintUtils == null) {
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
promise.
|
|
1478
|
-
}
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
}
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
@ReactMethod
|
|
1496
|
-
public void
|
|
1497
|
-
try {
|
|
1498
|
-
if (iminPrintUtils == null) {
|
|
1499
|
-
PrinterHelper.getInstance().
|
|
1500
|
-
}
|
|
1501
|
-
promise.resolve(null);
|
|
1502
|
-
} catch (Exception e) {
|
|
1503
|
-
promise.reject("
|
|
1504
|
-
}
|
|
1505
|
-
}
|
|
1506
|
-
|
|
1507
|
-
@ReactMethod
|
|
1508
|
-
public void
|
|
1509
|
-
try {
|
|
1510
|
-
if (iminPrintUtils == null) {
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
promise.
|
|
1580
|
-
}
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
promise.
|
|
1592
|
-
}
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
promise.
|
|
1604
|
-
}
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
promise.
|
|
1616
|
-
}
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
}
|
|
1648
|
-
|
|
1649
|
-
@ReactMethod
|
|
1650
|
-
public void
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1
|
+
package com.printerimin;
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import com.bumptech.glide.Glide;
|
|
5
|
+
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
|
6
|
+
|
|
7
|
+
import android.annotation.SuppressLint;
|
|
8
|
+
import android.graphics.Bitmap;
|
|
9
|
+
import android.graphics.Typeface;
|
|
10
|
+
import android.os.IBinder;
|
|
11
|
+
import android.os.RemoteException;
|
|
12
|
+
import android.graphics.BitmapFactory;
|
|
13
|
+
import android.os.Build;
|
|
14
|
+
import android.util.Log;
|
|
15
|
+
|
|
16
|
+
import androidx.annotation.NonNull;
|
|
17
|
+
import androidx.annotation.Nullable;
|
|
18
|
+
|
|
19
|
+
import com.facebook.react.bridge.Arguments;
|
|
20
|
+
import com.facebook.react.bridge.Promise;
|
|
21
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
22
|
+
import com.facebook.react.bridge.ReactContext;
|
|
23
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
24
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
25
|
+
import com.facebook.react.bridge.ReadableArray;
|
|
26
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
27
|
+
import com.facebook.react.bridge.WritableMap;
|
|
28
|
+
|
|
29
|
+
import com.facebook.react.module.annotations.ReactModule;
|
|
30
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
import com.imin.printer.ILabelPrintResult;
|
|
34
|
+
import com.imin.printer.INeoPrinterCallback;
|
|
35
|
+
import com.imin.printer.PrinterHelper;
|
|
36
|
+
import com.imin.printer.enums.Align;
|
|
37
|
+
import com.imin.printer.enums.ErrorLevel;
|
|
38
|
+
import com.imin.printer.enums.HumanReadable;
|
|
39
|
+
import com.imin.printer.enums.ImageAlgorithm;
|
|
40
|
+
import com.imin.printer.enums.Rotate;
|
|
41
|
+
import com.imin.printer.enums.Shape;
|
|
42
|
+
import com.imin.printer.enums.Symbology;
|
|
43
|
+
import com.imin.printer.label.LabelAreaStyle;
|
|
44
|
+
import com.imin.printer.label.LabelBarCodeStyle;
|
|
45
|
+
import com.imin.printer.label.LabelBitmapStyle;
|
|
46
|
+
import com.imin.printer.label.LabelCanvasStyle;
|
|
47
|
+
import com.imin.printer.label.LabelQrCodeStyle;
|
|
48
|
+
import com.imin.printer.label.LabelTextStyle;
|
|
49
|
+
import com.imin.printerlib.Callback;
|
|
50
|
+
import com.imin.printerlib.IminPrintUtils;
|
|
51
|
+
|
|
52
|
+
import java.util.ArrayList;
|
|
53
|
+
import java.util.Arrays;
|
|
54
|
+
import java.util.HashMap;
|
|
55
|
+
import java.util.List;
|
|
56
|
+
import java.util.Map;
|
|
57
|
+
|
|
58
|
+
import org.json.JSONArray;
|
|
59
|
+
import org.json.JSONObject;
|
|
60
|
+
|
|
61
|
+
import org.json.JSONException;
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
import java.lang.RuntimeException;
|
|
65
|
+
|
|
66
|
+
import android.content.Context;
|
|
67
|
+
import android.content.Intent;
|
|
68
|
+
import android.content.IntentFilter;
|
|
69
|
+
import android.content.BroadcastReceiver;
|
|
70
|
+
|
|
71
|
+
@ReactModule(name = PrinterIminModule.NAME)
|
|
72
|
+
public class PrinterIminModule extends ReactContextBaseJavaModule {
|
|
73
|
+
private final ReactApplicationContext reactContext;
|
|
74
|
+
public static final String NAME = "PrinterImin";
|
|
75
|
+
private IminPrintUtils iminPrintUtils;
|
|
76
|
+
// private String[] modelArry = {"W27_Pro", "I23M01", "I23M02", "I23D01", "D4-503 Pro", "D4-504 Pro", "D4-505 Pro", "MS2-11", "MS2-12", "MS1-15"};
|
|
77
|
+
private static final String ACTION_PRITER_STATUS_CHANGE = "com.imin.printerservice.PRITER_STATUS_CHANGE";
|
|
78
|
+
private static final String ACTION_POGOPIN_STATUS_CHANGE = "com.imin.printerservice.PRITER_CONNECT_STATUS_CHANGE";
|
|
79
|
+
private String sdkVersion = "1.0.0";
|
|
80
|
+
private static final String ACTION_PRITER_STATUS = "status";
|
|
81
|
+
private IminPrintUtils.PrintConnectType connectType = IminPrintUtils.PrintConnectType.USB;
|
|
82
|
+
public static final String TAG = "IminPrinterReactNativePlugin";
|
|
83
|
+
private BroadcastReceiver mBroadcastReceiver;
|
|
84
|
+
|
|
85
|
+
public PrinterIminModule(ReactApplicationContext reactContext) {
|
|
86
|
+
super(reactContext);
|
|
87
|
+
this.reactContext = reactContext;
|
|
88
|
+
// List<String> modelList = Arrays.asList(modelArry);
|
|
89
|
+
if (Build.MODEL.contains("W27_Pro") || Build.MODEL.contains("I23D") || Build.MODEL.contains("I23M") || Build.MODEL.contains("I24D") || Build.MODEL.contains("I24T") || Build.MODEL.contains("I24M")) {
|
|
90
|
+
//初始化 2.0 的 SDK。
|
|
91
|
+
PrinterHelper.getInstance().initPrinterService(reactContext);
|
|
92
|
+
sdkVersion = "2.0.0";
|
|
93
|
+
}
|
|
94
|
+
// if (modelList.contains(Build.MODEL)) {
|
|
95
|
+
// //初始化 2.0 的 SDK。
|
|
96
|
+
// PrinterHelper.getInstance().initPrinterService(reactContext);
|
|
97
|
+
// sdkVersion = "2.0.0";
|
|
98
|
+
// }
|
|
99
|
+
else {
|
|
100
|
+
//初始化 1.0 SDK
|
|
101
|
+
|
|
102
|
+
iminPrintUtils = IminPrintUtils.getInstance(reactContext);
|
|
103
|
+
String deviceModel = Utils.getInstance().getModel();
|
|
104
|
+
if (deviceModel.contains("M2-203") || deviceModel.contains("M2-202") || deviceModel.contains("M2-Pro")) {
|
|
105
|
+
connectType = IminPrintUtils.PrintConnectType.SPI;
|
|
106
|
+
} else {
|
|
107
|
+
connectType = IminPrintUtils.PrintConnectType.USB;
|
|
108
|
+
}
|
|
109
|
+
iminPrintUtils.setIsOpenLog(IminPrintUtils.isOpenLog == 1 ? 0 : 1);
|
|
110
|
+
iminPrintUtils.resetDevice();
|
|
111
|
+
sdkVersion = "1.0.0";
|
|
112
|
+
}
|
|
113
|
+
initializeBroadcastReceiver();
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
@Override
|
|
117
|
+
@NonNull
|
|
118
|
+
public String getName() {
|
|
119
|
+
return NAME;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
private void sendEvent(ReactContext reactContext, String eventName, @Nullable WritableMap params) {
|
|
123
|
+
|
|
124
|
+
try {
|
|
125
|
+
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(eventName, params);
|
|
126
|
+
} catch (RuntimeException e) {
|
|
127
|
+
Log.e(TAG, "java.lang.RuntimeException: Trying to invoke JS before CatalystInstance has been set!", e);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
@ReactMethod
|
|
132
|
+
public void initPrinter(final Promise promise) {
|
|
133
|
+
try {
|
|
134
|
+
if (iminPrintUtils != null) {
|
|
135
|
+
iminPrintUtils.initPrinter(connectType);
|
|
136
|
+
} else {
|
|
137
|
+
PrinterHelper.getInstance().initPrinter(reactContext.getPackageName(), null);
|
|
138
|
+
}
|
|
139
|
+
promise.resolve(true);
|
|
140
|
+
} catch (Exception e) {
|
|
141
|
+
promise.reject("ININTPRINTER_FAILED", e.getMessage());
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
@ReactMethod
|
|
146
|
+
public void getPrinterStatus(final Promise promise) {
|
|
147
|
+
try {
|
|
148
|
+
WritableMap payload = Arguments.createMap();
|
|
149
|
+
if (iminPrintUtils != null) {
|
|
150
|
+
if (connectType.equals(IminPrintUtils.PrintConnectType.SPI)) {
|
|
151
|
+
iminPrintUtils.getPrinterStatus(connectType, new Callback() {
|
|
152
|
+
@Override
|
|
153
|
+
public void callback(int status) {
|
|
154
|
+
payload.putString("message", Utils.getInstance().getPrinterStatusText(status));
|
|
155
|
+
payload.putString("code", String.format("%d", status));
|
|
156
|
+
promise.resolve(payload);
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
} else {
|
|
160
|
+
int status = iminPrintUtils.getPrinterStatus(connectType);
|
|
161
|
+
payload.putString("message", Utils.getInstance().getPrinterStatusText(status));
|
|
162
|
+
payload.putString("code", String.format("%d", status));
|
|
163
|
+
promise.resolve(payload);
|
|
164
|
+
}
|
|
165
|
+
} else {
|
|
166
|
+
int status = PrinterHelper.getInstance().getPrinterStatus();
|
|
167
|
+
payload.putString("message", Utils.getInstance().getPrinterStatusText(status));
|
|
168
|
+
payload.putString("code", String.format("%d", status));
|
|
169
|
+
promise.resolve(payload);
|
|
170
|
+
}
|
|
171
|
+
payload.putString("message", "sdsd");
|
|
172
|
+
payload.putString("code", "1");
|
|
173
|
+
promise.resolve(payload);
|
|
174
|
+
} catch (Exception e) {
|
|
175
|
+
promise.reject("getPrinterStatus_failed", e.getMessage());
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
@ReactMethod
|
|
181
|
+
public void setTextSize(int size, final Promise promise) {
|
|
182
|
+
try {
|
|
183
|
+
if (iminPrintUtils != null) {
|
|
184
|
+
iminPrintUtils.setTextSize(size);
|
|
185
|
+
}
|
|
186
|
+
promise.resolve(null);
|
|
187
|
+
} catch (Exception e) {
|
|
188
|
+
promise.reject("setTextSize_failed", e.getMessage());
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
@ReactMethod
|
|
193
|
+
public void setTextTypeface(int font, final Promise promise) {
|
|
194
|
+
try {
|
|
195
|
+
if (iminPrintUtils != null) {
|
|
196
|
+
switch (font) {
|
|
197
|
+
case 1:
|
|
198
|
+
iminPrintUtils.setTextTypeface(Typeface.MONOSPACE);
|
|
199
|
+
break;
|
|
200
|
+
case 2:
|
|
201
|
+
iminPrintUtils.setTextTypeface(Typeface.DEFAULT_BOLD);
|
|
202
|
+
break;
|
|
203
|
+
case 3:
|
|
204
|
+
iminPrintUtils.setTextTypeface(Typeface.SANS_SERIF);
|
|
205
|
+
break;
|
|
206
|
+
case 4:
|
|
207
|
+
iminPrintUtils.setTextTypeface(Typeface.SERIF);
|
|
208
|
+
break;
|
|
209
|
+
default:
|
|
210
|
+
iminPrintUtils.setTextTypeface(Typeface.DEFAULT);
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
promise.resolve(null);
|
|
215
|
+
} catch (Exception e) {
|
|
216
|
+
promise.reject("setTextTypeface_failed", e.getMessage());
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
@ReactMethod
|
|
221
|
+
public void setTextStyle(int style, final Promise promise) {
|
|
222
|
+
try {
|
|
223
|
+
if (iminPrintUtils != null) {
|
|
224
|
+
iminPrintUtils.setTextStyle(style);
|
|
225
|
+
}
|
|
226
|
+
promise.resolve(null);
|
|
227
|
+
} catch (Exception e) {
|
|
228
|
+
promise.reject("setTextStyle_failed", e.getMessage());
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
@ReactMethod
|
|
233
|
+
public void setAlignment(int alignment, final Promise promise) {
|
|
234
|
+
try {
|
|
235
|
+
if (iminPrintUtils != null) {
|
|
236
|
+
iminPrintUtils.setAlignment(alignment);
|
|
237
|
+
}
|
|
238
|
+
promise.resolve(null);
|
|
239
|
+
} catch (Exception e) {
|
|
240
|
+
promise.reject("setAlignment_failed", e.getMessage());
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
@ReactMethod
|
|
245
|
+
public void setTextLineSpacing(float space, final Promise promise) {
|
|
246
|
+
try {
|
|
247
|
+
if (iminPrintUtils != null) {
|
|
248
|
+
iminPrintUtils.setTextLineSpacing(space);
|
|
249
|
+
}
|
|
250
|
+
promise.resolve(null);
|
|
251
|
+
} catch (Exception e) {
|
|
252
|
+
promise.reject("setTextLineSpacing_failed", e.getMessage());
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
@ReactMethod
|
|
257
|
+
public void printText(String text, final Promise promise) {
|
|
258
|
+
try {
|
|
259
|
+
if (iminPrintUtils != null) {
|
|
260
|
+
iminPrintUtils.printText(text + "\n");
|
|
261
|
+
} else {
|
|
262
|
+
PrinterHelper.getInstance().printText(text + "\n", null);
|
|
263
|
+
}
|
|
264
|
+
promise.resolve(null);
|
|
265
|
+
} catch (Exception e) {
|
|
266
|
+
promise.reject("printText_failed", e.getMessage());
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
@ReactMethod
|
|
271
|
+
public void printAntiWhiteText(String text, final Promise promise) {
|
|
272
|
+
try {
|
|
273
|
+
if (iminPrintUtils != null) {
|
|
274
|
+
iminPrintUtils.printAntiWhiteText(text);
|
|
275
|
+
}
|
|
276
|
+
promise.resolve(null);
|
|
277
|
+
} catch (Exception e) {
|
|
278
|
+
promise.reject("printAntiWhiteText_failed", e.getMessage());
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
@ReactMethod
|
|
283
|
+
public void setTextWidth(int width, final Promise promise) {
|
|
284
|
+
try {
|
|
285
|
+
if (iminPrintUtils != null) {
|
|
286
|
+
iminPrintUtils.setTextWidth(width);
|
|
287
|
+
}
|
|
288
|
+
promise.resolve(null);
|
|
289
|
+
} catch (Exception e) {
|
|
290
|
+
promise.reject("setTextWidth_failed", e.getMessage());
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
@ReactMethod
|
|
295
|
+
public void printAndLineFeed(final Promise promise) {
|
|
296
|
+
try {
|
|
297
|
+
if (iminPrintUtils != null) {
|
|
298
|
+
iminPrintUtils.printAndLineFeed();
|
|
299
|
+
} else {
|
|
300
|
+
PrinterHelper.getInstance().printAndLineFeed();
|
|
301
|
+
}
|
|
302
|
+
promise.resolve(null);
|
|
303
|
+
} catch (Exception e) {
|
|
304
|
+
promise.reject("printAndLineFeed_failed", e.getMessage());
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
@ReactMethod
|
|
309
|
+
public void printAndFeedPaper(int height, final Promise promise) {
|
|
310
|
+
try {
|
|
311
|
+
if (iminPrintUtils != null) {
|
|
312
|
+
iminPrintUtils.printAndFeedPaper(height);
|
|
313
|
+
} else {
|
|
314
|
+
PrinterHelper.getInstance().printAndFeedPaper(height);
|
|
315
|
+
}
|
|
316
|
+
promise.resolve(null);
|
|
317
|
+
} catch (Exception e) {
|
|
318
|
+
promise.reject("printAndLineFeed_failed", e.getMessage());
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
@SuppressLint("LongLogTag")
|
|
323
|
+
@ReactMethod
|
|
324
|
+
public void printColumnsText(ReadableArray cols, final Promise promise) {
|
|
325
|
+
try {
|
|
326
|
+
String[] colsText = new String[cols.size()];
|
|
327
|
+
int[] colsWidth = new int[cols.size()];
|
|
328
|
+
int[] colsAlign = new int[cols.size()];
|
|
329
|
+
int[] colsFontSize = new int[cols.size()];
|
|
330
|
+
for (int i = 0; i < cols.size(); i++) {
|
|
331
|
+
ReadableMap col = cols.getMap(i);
|
|
332
|
+
String textColumn = col.getString("text");
|
|
333
|
+
int widthColumn = col.getInt("width");
|
|
334
|
+
int alignColumn = col.getInt("align");
|
|
335
|
+
Log.d(TAG, "printColumnsText: colsText" + textColumn);
|
|
336
|
+
int fontSizeColumn = col.getInt("fontSize");
|
|
337
|
+
colsText[i] = textColumn;
|
|
338
|
+
colsWidth[i] = widthColumn;
|
|
339
|
+
colsAlign[i] = alignColumn;
|
|
340
|
+
colsFontSize[i] = fontSizeColumn;
|
|
341
|
+
}
|
|
342
|
+
Log.d(TAG, "printColumnsText: colsText" + colsText);
|
|
343
|
+
Log.d(TAG, "printColumnsText: colsWidth" + colsWidth);
|
|
344
|
+
Log.d(TAG, "printColumnsText: colsAlign" + colsAlign);
|
|
345
|
+
Log.d(TAG, "printColumnsText: colsFontSize" + colsFontSize);
|
|
346
|
+
if (iminPrintUtils != null) {
|
|
347
|
+
iminPrintUtils.printColumnsText(colsText, colsWidth, colsAlign, colsFontSize);
|
|
348
|
+
} else {
|
|
349
|
+
PrinterHelper.getInstance().printColumnsText(colsText, colsWidth, colsAlign, colsFontSize, null);
|
|
350
|
+
}
|
|
351
|
+
promise.resolve(null);
|
|
352
|
+
} catch (Exception e) {
|
|
353
|
+
promise.reject("printColumnsText_failed", e.getMessage());
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
@ReactMethod
|
|
358
|
+
public void setPageFormat(int style, final Promise promise) {
|
|
359
|
+
try {
|
|
360
|
+
if (iminPrintUtils != null) {
|
|
361
|
+
iminPrintUtils.setPageFormat(style);
|
|
362
|
+
} else {
|
|
363
|
+
PrinterHelper.getInstance().setPageFormat(style);
|
|
364
|
+
}
|
|
365
|
+
promise.resolve(null);
|
|
366
|
+
} catch (Exception e) {
|
|
367
|
+
promise.reject("setPageFormat_failed", e.getMessage());
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
@ReactMethod
|
|
372
|
+
public void partialCut(final Promise promise) {
|
|
373
|
+
try {
|
|
374
|
+
if (iminPrintUtils != null) {
|
|
375
|
+
iminPrintUtils.partialCut();
|
|
376
|
+
} else {
|
|
377
|
+
PrinterHelper.getInstance().partialCut();
|
|
378
|
+
}
|
|
379
|
+
promise.resolve(null);
|
|
380
|
+
} catch (Exception e) {
|
|
381
|
+
promise.reject("partialCut_failed", e.getMessage());
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
@ReactMethod
|
|
386
|
+
public void fullCut(final Promise promise) {
|
|
387
|
+
try {
|
|
388
|
+
if (iminPrintUtils == null) {
|
|
389
|
+
PrinterHelper.getInstance().fullCut();
|
|
390
|
+
}
|
|
391
|
+
promise.resolve(null);
|
|
392
|
+
} catch (Exception e) {
|
|
393
|
+
promise.reject("fullCut_failed", e.getMessage());
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
@ReactMethod
|
|
398
|
+
public void printSingleBitmap(ReadableMap config, final Promise promise) {
|
|
399
|
+
try {
|
|
400
|
+
String url = config.getString("url");
|
|
401
|
+
if (config.hasKey("width") && config.hasKey("height")) {
|
|
402
|
+
int width = config.getInt("width");
|
|
403
|
+
int height = config.getInt("height");
|
|
404
|
+
Bitmap image = Glide.with(reactContext).asBitmap().load(url).diskCacheStrategy(DiskCacheStrategy.NONE).skipMemoryCache(true).submit(width, height).get();
|
|
405
|
+
if (image.isRecycled()) {
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
if (iminPrintUtils != null) {
|
|
409
|
+
if (config.hasKey("align")) {
|
|
410
|
+
int align = config.getInt("align");
|
|
411
|
+
iminPrintUtils.printSingleBitmap(image, align);
|
|
412
|
+
} else {
|
|
413
|
+
iminPrintUtils.printSingleBitmap(image);
|
|
414
|
+
}
|
|
415
|
+
} else {
|
|
416
|
+
if (config.hasKey("align")) {
|
|
417
|
+
int align = config.getInt("align");
|
|
418
|
+
PrinterHelper.getInstance().printBitmapWithAlign(image, align, null);
|
|
419
|
+
} else {
|
|
420
|
+
PrinterHelper.getInstance().printBitmap(image, null);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
} else {
|
|
424
|
+
Bitmap image = Glide.with(reactContext).asBitmap().load(url).diskCacheStrategy(DiskCacheStrategy.NONE).skipMemoryCache(true).submit().get();
|
|
425
|
+
if (image.isRecycled()) {
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
if (iminPrintUtils != null) {
|
|
429
|
+
if (config.hasKey("align")) {
|
|
430
|
+
int align = config.getInt("align");
|
|
431
|
+
iminPrintUtils.printSingleBitmap(image, align);
|
|
432
|
+
} else {
|
|
433
|
+
iminPrintUtils.printSingleBitmap(image);
|
|
434
|
+
}
|
|
435
|
+
} else {
|
|
436
|
+
if (config.hasKey("align")) {
|
|
437
|
+
int align = config.getInt("align");
|
|
438
|
+
PrinterHelper.getInstance().printBitmapWithAlign(image, align, null);
|
|
439
|
+
} else {
|
|
440
|
+
PrinterHelper.getInstance().printBitmap(image, null);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
promise.resolve(null);
|
|
445
|
+
} catch (Exception e) {
|
|
446
|
+
promise.reject("printSingleBitmap_failed", e.getMessage());
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
@ReactMethod
|
|
451
|
+
public void printMultiBitmap(ReadableMap config, final Promise promise) {
|
|
452
|
+
try {
|
|
453
|
+
ReadableArray urls = config.getArray("urls");
|
|
454
|
+
ArrayList<Bitmap> bitmaps = new ArrayList<Bitmap>();
|
|
455
|
+
if (config.hasKey("width") && config.hasKey("height")) {
|
|
456
|
+
int width = config.getInt("width");
|
|
457
|
+
int height = config.getInt("height");
|
|
458
|
+
for (int i = 0; i < urls.size(); i++) {
|
|
459
|
+
Bitmap image = Glide.with(reactContext).asBitmap().load(urls.getString(i)).diskCacheStrategy(DiskCacheStrategy.NONE).skipMemoryCache(true).submit(width, height).get();
|
|
460
|
+
if (!image.isRecycled()) {
|
|
461
|
+
bitmaps.add(image);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
if (iminPrintUtils != null) {
|
|
465
|
+
if (config.hasKey("align")) {
|
|
466
|
+
int align = config.getInt("align");
|
|
467
|
+
iminPrintUtils.printMultiBitmap(bitmaps, align);
|
|
468
|
+
} else {
|
|
469
|
+
iminPrintUtils.printMultiBitmap(bitmaps, 0);
|
|
470
|
+
}
|
|
471
|
+
} else {
|
|
472
|
+
if (config.hasKey("align")) {
|
|
473
|
+
int align = config.getInt("align");
|
|
474
|
+
PrinterHelper.getInstance().printMultiBitmapWithAlign(bitmaps, align, null);
|
|
475
|
+
} else {
|
|
476
|
+
PrinterHelper.getInstance().printMultiBitmap(bitmaps, null);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
} else {
|
|
480
|
+
for (int i = 0; i < urls.size(); i++) {
|
|
481
|
+
Bitmap image = Glide.with(reactContext).asBitmap().load(urls.getString(i)).diskCacheStrategy(DiskCacheStrategy.NONE).skipMemoryCache(true).submit().get();
|
|
482
|
+
if (!image.isRecycled()) {
|
|
483
|
+
bitmaps.add(image);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
if (iminPrintUtils != null) {
|
|
487
|
+
if (config.hasKey("align")) {
|
|
488
|
+
int align = config.getInt("align");
|
|
489
|
+
iminPrintUtils.printMultiBitmap(bitmaps, align);
|
|
490
|
+
} else {
|
|
491
|
+
iminPrintUtils.printMultiBitmap(bitmaps, 0);
|
|
492
|
+
}
|
|
493
|
+
} else {
|
|
494
|
+
if (config.hasKey("align")) {
|
|
495
|
+
int align = config.getInt("align");
|
|
496
|
+
PrinterHelper.getInstance().printMultiBitmapWithAlign(bitmaps, align, null);
|
|
497
|
+
} else {
|
|
498
|
+
PrinterHelper.getInstance().printMultiBitmap(bitmaps, null);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
promise.resolve(null);
|
|
503
|
+
} catch (Exception e) {
|
|
504
|
+
promise.reject("printMultiBitmap_failed", e.getMessage());
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
@ReactMethod
|
|
509
|
+
public void printSingleBitmapBlackWhite(ReadableMap config, final Promise promise) {
|
|
510
|
+
try {
|
|
511
|
+
String url = config.getString("url");
|
|
512
|
+
if (config.hasKey("width") && config.hasKey("height")) {
|
|
513
|
+
int width = config.getInt("width");
|
|
514
|
+
int height = config.getInt("height");
|
|
515
|
+
Bitmap image = Glide.with(reactContext).asBitmap().load(url).diskCacheStrategy(DiskCacheStrategy.NONE).skipMemoryCache(true).submit(width, height).get();
|
|
516
|
+
if (image.isRecycled()) {
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
519
|
+
if (iminPrintUtils != null) {
|
|
520
|
+
iminPrintUtils.printSingleBitmapBlackWhite(image);
|
|
521
|
+
}
|
|
522
|
+
} else {
|
|
523
|
+
Bitmap image = Glide.with(reactContext).asBitmap().load(url).diskCacheStrategy(DiskCacheStrategy.NONE).skipMemoryCache(true).submit().get();
|
|
524
|
+
if (image.isRecycled()) {
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
if (iminPrintUtils != null) {
|
|
528
|
+
iminPrintUtils.printSingleBitmapBlackWhite(image);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
promise.resolve(null);
|
|
532
|
+
} catch (Exception e) {
|
|
533
|
+
promise.reject("printSingleBitmapBlackWhite_failed", e.getMessage());
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
@ReactMethod
|
|
538
|
+
public void setQrCodeSize(int qrSize, final Promise promise) {
|
|
539
|
+
try {
|
|
540
|
+
if (iminPrintUtils != null) {
|
|
541
|
+
iminPrintUtils.setQrCodeSize(qrSize);
|
|
542
|
+
} else {
|
|
543
|
+
PrinterHelper.getInstance().setQrCodeSize(qrSize);
|
|
544
|
+
}
|
|
545
|
+
promise.resolve(null);
|
|
546
|
+
} catch (Exception e) {
|
|
547
|
+
promise.reject("setQrCodeSize_failed", e.getMessage());
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
@ReactMethod
|
|
552
|
+
public void setLeftMargin(int margin, final Promise promise) {
|
|
553
|
+
try {
|
|
554
|
+
if (iminPrintUtils != null) {
|
|
555
|
+
iminPrintUtils.setLeftMargin(margin);
|
|
556
|
+
} else {
|
|
557
|
+
PrinterHelper.getInstance().setLeftMargin(margin);
|
|
558
|
+
}
|
|
559
|
+
promise.resolve(null);
|
|
560
|
+
} catch (Exception e) {
|
|
561
|
+
promise.reject("setLeftMargin_failed", e.getMessage());
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
@ReactMethod
|
|
566
|
+
public void setBarCodeWidth(int width, final Promise promise) {
|
|
567
|
+
try {
|
|
568
|
+
if (iminPrintUtils != null) {
|
|
569
|
+
iminPrintUtils.setBarCodeWidth(width);
|
|
570
|
+
} else {
|
|
571
|
+
PrinterHelper.getInstance().setBarCodeWidth(width);
|
|
572
|
+
}
|
|
573
|
+
promise.resolve(null);
|
|
574
|
+
} catch (Exception e) {
|
|
575
|
+
promise.reject("setBarCodeWidth_failed", e.getMessage());
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
@ReactMethod
|
|
580
|
+
public void setBarCodeHeight(int height, final Promise promise) {
|
|
581
|
+
try {
|
|
582
|
+
if (iminPrintUtils != null) {
|
|
583
|
+
iminPrintUtils.setBarCodeHeight(height);
|
|
584
|
+
} else {
|
|
585
|
+
PrinterHelper.getInstance().setBarCodeHeight(height);
|
|
586
|
+
}
|
|
587
|
+
promise.resolve(null);
|
|
588
|
+
} catch (Exception e) {
|
|
589
|
+
promise.reject("setBarCodeHeight_failed", e.getMessage());
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
@ReactMethod
|
|
594
|
+
public void setBarCodeContentPrintPos(int position, final Promise promise) {
|
|
595
|
+
try {
|
|
596
|
+
if (iminPrintUtils != null) {
|
|
597
|
+
iminPrintUtils.setBarCodeContentPrintPos(position);
|
|
598
|
+
} else {
|
|
599
|
+
PrinterHelper.getInstance().setBarCodeContentPrintPos(position);
|
|
600
|
+
}
|
|
601
|
+
promise.resolve(null);
|
|
602
|
+
} catch (Exception e) {
|
|
603
|
+
promise.reject("setBarCodeContentPrintPos_failed", e.getMessage());
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
@ReactMethod
|
|
608
|
+
public void printBarCode(ReadableMap config, final Promise promise) {
|
|
609
|
+
try {
|
|
610
|
+
String barCodeContent = config.getString("data");
|
|
611
|
+
int barCodeType = config.getInt("type");
|
|
612
|
+
if (iminPrintUtils != null) {
|
|
613
|
+
if (config.hasKey("align")) {
|
|
614
|
+
int barCodeAlign = config.getInt("align");
|
|
615
|
+
iminPrintUtils.printBarCode(barCodeType, barCodeContent, barCodeAlign);
|
|
616
|
+
} else {
|
|
617
|
+
iminPrintUtils.printBarCode(barCodeType, barCodeContent);
|
|
618
|
+
}
|
|
619
|
+
} else {
|
|
620
|
+
if (config.hasKey("align")) {
|
|
621
|
+
int barCodeAlign = config.getInt("align");
|
|
622
|
+
if (config.hasKey("position") && config.hasKey("height") && config.hasKey("width")) {
|
|
623
|
+
int position = config.getInt("position");
|
|
624
|
+
int height = config.getInt("height");
|
|
625
|
+
int width = config.getInt("width");
|
|
626
|
+
PrinterHelper.getInstance().printBarCodeWithFull(barCodeContent, barCodeType, width, height, barCodeAlign, position, null);
|
|
627
|
+
} else {
|
|
628
|
+
PrinterHelper.getInstance().printBarCodeWithAlign(barCodeContent, barCodeType, barCodeAlign, null);
|
|
629
|
+
}
|
|
630
|
+
} else {
|
|
631
|
+
PrinterHelper.getInstance().printBarCode(barCodeContent, barCodeType, null);
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
promise.resolve(null);
|
|
635
|
+
} catch (Exception e) {
|
|
636
|
+
promise.reject("printBarCode_failed", e.getMessage());
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
@ReactMethod
|
|
642
|
+
public void setDoubleQRSize(int size, final Promise promise) {
|
|
643
|
+
try {
|
|
644
|
+
if (iminPrintUtils != null) {
|
|
645
|
+
iminPrintUtils.setDoubleQRSize(size);
|
|
646
|
+
} else {
|
|
647
|
+
PrinterHelper.getInstance().setDoubleQRSize(size);
|
|
648
|
+
}
|
|
649
|
+
promise.resolve(null);
|
|
650
|
+
} catch (Exception e) {
|
|
651
|
+
promise.reject("setDoubleQRSize_failed", e.getMessage());
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
@ReactMethod
|
|
656
|
+
public void setDoubleQR1Level(int level, final Promise promise) {
|
|
657
|
+
try {
|
|
658
|
+
if (iminPrintUtils != null) {
|
|
659
|
+
iminPrintUtils.setDoubleQR1Level(level);
|
|
660
|
+
} else {
|
|
661
|
+
PrinterHelper.getInstance().setDoubleQR1Level(level);
|
|
662
|
+
}
|
|
663
|
+
promise.resolve(null);
|
|
664
|
+
} catch (Exception e) {
|
|
665
|
+
promise.reject("setDoubleQR1Level_failed", e.getMessage());
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
@ReactMethod
|
|
670
|
+
public void setDoubleQR2Level(int level, final Promise promise) {
|
|
671
|
+
try {
|
|
672
|
+
if (iminPrintUtils != null) {
|
|
673
|
+
iminPrintUtils.setDoubleQR2Level(level);
|
|
674
|
+
} else {
|
|
675
|
+
PrinterHelper.getInstance().setDoubleQR2Level(level);
|
|
676
|
+
}
|
|
677
|
+
promise.resolve(null);
|
|
678
|
+
} catch (Exception e) {
|
|
679
|
+
promise.reject("setDoubleQR2Level_failed", e.getMessage());
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
@ReactMethod
|
|
684
|
+
public void setDoubleQR1MarginLeft(int leftMargin, final Promise promise) {
|
|
685
|
+
try {
|
|
686
|
+
if (iminPrintUtils != null) {
|
|
687
|
+
iminPrintUtils.setDoubleQR1MarginLeft(leftMargin);
|
|
688
|
+
} else {
|
|
689
|
+
PrinterHelper.getInstance().setDoubleQR1MarginLeft(leftMargin);
|
|
690
|
+
}
|
|
691
|
+
promise.resolve(null);
|
|
692
|
+
} catch (Exception e) {
|
|
693
|
+
promise.reject("setDoubleQR1MarginLeft_failed", e.getMessage());
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
@ReactMethod
|
|
698
|
+
public void setDoubleQR2MarginLeft(int leftMargin, final Promise promise) {
|
|
699
|
+
try {
|
|
700
|
+
if (iminPrintUtils != null) {
|
|
701
|
+
iminPrintUtils.setDoubleQR2MarginLeft(leftMargin);
|
|
702
|
+
} else {
|
|
703
|
+
PrinterHelper.getInstance().setDoubleQR2MarginLeft(leftMargin);
|
|
704
|
+
}
|
|
705
|
+
promise.resolve(null);
|
|
706
|
+
} catch (Exception e) {
|
|
707
|
+
promise.reject("setDoubleQR2MarginLeft_failed", e.getMessage());
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
@ReactMethod
|
|
712
|
+
public void setQrCodeErrorCorrectionLev(int level, final Promise promise) {
|
|
713
|
+
try {
|
|
714
|
+
if (iminPrintUtils != null) {
|
|
715
|
+
iminPrintUtils.setQrCodeErrorCorrectionLev(level);
|
|
716
|
+
} else {
|
|
717
|
+
PrinterHelper.getInstance().setQrCodeErrorCorrectionLev(level);
|
|
718
|
+
}
|
|
719
|
+
promise.resolve(null);
|
|
720
|
+
} catch (Exception e) {
|
|
721
|
+
promise.reject("setQrCodeErrorCorrectionLev_failed", e.getMessage());
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
@ReactMethod
|
|
726
|
+
public void setDoubleQR1Version(int version, final Promise promise) {
|
|
727
|
+
try {
|
|
728
|
+
if (iminPrintUtils != null) {
|
|
729
|
+
iminPrintUtils.setDoubleQR1Version(version);
|
|
730
|
+
} else {
|
|
731
|
+
PrinterHelper.getInstance().setDoubleQR1Version(version);
|
|
732
|
+
}
|
|
733
|
+
promise.resolve(null);
|
|
734
|
+
} catch (Exception e) {
|
|
735
|
+
promise.reject("setDoubleQR1Version_failed", e.getMessage());
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
@ReactMethod
|
|
740
|
+
public void setDoubleQR2Version(int version, final Promise promise) {
|
|
741
|
+
try {
|
|
742
|
+
if (iminPrintUtils != null) {
|
|
743
|
+
iminPrintUtils.setDoubleQR2Version(version);
|
|
744
|
+
} else {
|
|
745
|
+
PrinterHelper.getInstance().setDoubleQR2Version(version);
|
|
746
|
+
}
|
|
747
|
+
promise.resolve(null);
|
|
748
|
+
} catch (Exception e) {
|
|
749
|
+
promise.reject("setDoubleQR2Version_failed", e.getMessage());
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
@ReactMethod
|
|
754
|
+
public void printQrCode(ReadableMap config, final Promise promise) {
|
|
755
|
+
try {
|
|
756
|
+
String qrStr = config.getString("data");
|
|
757
|
+
if (config.hasKey("align")) {
|
|
758
|
+
int align = config.getInt("align");
|
|
759
|
+
if (iminPrintUtils != null) {
|
|
760
|
+
iminPrintUtils.printQrCode(qrStr, align);
|
|
761
|
+
} else {
|
|
762
|
+
if (config.hasKey("qrSize") && config.hasKey("level")) {
|
|
763
|
+
int qrSize = config.getInt("qrSize");
|
|
764
|
+
int qrLevel = config.getInt("level");
|
|
765
|
+
PrinterHelper.getInstance().printQRCodeWithFull(qrStr, qrSize, qrLevel, align, null);
|
|
766
|
+
} else {
|
|
767
|
+
PrinterHelper.getInstance().printQrCodeWithAlign(qrStr, align, null);
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
} else {
|
|
771
|
+
if (iminPrintUtils != null) {
|
|
772
|
+
iminPrintUtils.printQrCode(qrStr);
|
|
773
|
+
} else {
|
|
774
|
+
PrinterHelper.getInstance().printQrCode(qrStr, null);
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
promise.resolve(null);
|
|
778
|
+
} catch (Exception e) {
|
|
779
|
+
promise.reject("printQrCode_failed", e.getMessage());
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
@ReactMethod
|
|
784
|
+
public void printDoubleQR(ReadableMap config, final Promise promise) {
|
|
785
|
+
try {
|
|
786
|
+
String qrCode1Text = config.getString("qrCode1Text");
|
|
787
|
+
String qrCode2Text = config.getString("qrCode2Text");
|
|
788
|
+
if (iminPrintUtils != null) {
|
|
789
|
+
iminPrintUtils.printDoubleQR(qrCode1Text, qrCode2Text);
|
|
790
|
+
} else {
|
|
791
|
+
PrinterHelper.getInstance().printDoubleQR(qrCode1Text, qrCode2Text, null);
|
|
792
|
+
}
|
|
793
|
+
promise.resolve(null);
|
|
794
|
+
} catch (Exception e) {
|
|
795
|
+
promise.reject("printDoubleQR_failed", e.getMessage());
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
@ReactMethod
|
|
800
|
+
public void openCashBox(final Promise promise) {
|
|
801
|
+
try {
|
|
802
|
+
if (iminPrintUtils != null) {
|
|
803
|
+
Utils.getInstance().opencashBox();
|
|
804
|
+
} else {
|
|
805
|
+
PrinterHelper.getInstance().openDrawer();
|
|
806
|
+
}
|
|
807
|
+
promise.resolve(null);
|
|
808
|
+
} catch (Exception e) {
|
|
809
|
+
promise.reject("openCashBox_failed", e.getMessage());
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
|
|
815
|
+
@ReactMethod
|
|
816
|
+
public void setInitIminPrinter(boolean isDefault, final Promise promise) {
|
|
817
|
+
try {
|
|
818
|
+
if (iminPrintUtils != null) {
|
|
819
|
+
iminPrintUtils.setInitIminPrinter(isDefault);
|
|
820
|
+
}
|
|
821
|
+
promise.resolve(null);
|
|
822
|
+
} catch (Exception e) {
|
|
823
|
+
promise.reject("setInitIminPrinter_failed", e.getMessage());
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
@ReactMethod
|
|
828
|
+
public void resetDevice(final Promise promise) {
|
|
829
|
+
try {
|
|
830
|
+
if (iminPrintUtils != null) {
|
|
831
|
+
iminPrintUtils.resetDevice();
|
|
832
|
+
}
|
|
833
|
+
promise.resolve(null);
|
|
834
|
+
} catch (Exception e) {
|
|
835
|
+
promise.reject("resetDevice_failed", e.getMessage());
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
@ReactMethod
|
|
840
|
+
public void printerSelfChecking(final Promise promise) {
|
|
841
|
+
try {
|
|
842
|
+
if (iminPrintUtils == null) {
|
|
843
|
+
PrinterHelper.getInstance().printerSelfChecking(null);
|
|
844
|
+
}
|
|
845
|
+
promise.resolve(null);
|
|
846
|
+
} catch (Exception e) {
|
|
847
|
+
promise.reject("printerSelfChecking_failed", e.getMessage());
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
@ReactMethod
|
|
852
|
+
public void openLogs(int open, final Promise promise) {
|
|
853
|
+
try {
|
|
854
|
+
if (iminPrintUtils != null) {
|
|
855
|
+
iminPrintUtils.setIsOpenLog(open);
|
|
856
|
+
}
|
|
857
|
+
promise.resolve(null);
|
|
858
|
+
} catch (Exception e) {
|
|
859
|
+
promise.reject("setIsOpenLog_failed", e.getMessage());
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
@ReactMethod
|
|
864
|
+
public void sendRAWDataHexStr(String byteStr, final Promise promise) {
|
|
865
|
+
try {
|
|
866
|
+
if (iminPrintUtils != null) {
|
|
867
|
+
iminPrintUtils.sendRAWData(byteStr);
|
|
868
|
+
}
|
|
869
|
+
promise.resolve(null);
|
|
870
|
+
} catch (Exception e) {
|
|
871
|
+
promise.reject("sendRAWDataHexStr_failed", e.getMessage());
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
@ReactMethod
|
|
876
|
+
public void printSingleBitmapColorChart(ReadableMap config, final Promise promise) {
|
|
877
|
+
try {
|
|
878
|
+
String url = config.getString("url");
|
|
879
|
+
if (config.hasKey("width") && config.hasKey("height")) {
|
|
880
|
+
int width = config.getInt("width");
|
|
881
|
+
int height = config.getInt("height");
|
|
882
|
+
Bitmap image = Glide.with(reactContext).asBitmap().load(url).diskCacheStrategy(DiskCacheStrategy.NONE).skipMemoryCache(true).submit(width, height).get();
|
|
883
|
+
if (image.isRecycled()) {
|
|
884
|
+
return;
|
|
885
|
+
}
|
|
886
|
+
if (iminPrintUtils == null) {
|
|
887
|
+
if (config.hasKey("align")) {
|
|
888
|
+
int align = config.getInt("align");
|
|
889
|
+
PrinterHelper.getInstance().printBitmapColorChartWithAlign(image, align, null);
|
|
890
|
+
} else {
|
|
891
|
+
PrinterHelper.getInstance().printBitmapColorChart(image, null);
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
} else {
|
|
895
|
+
Bitmap image = Glide.with(reactContext).asBitmap().load(url).diskCacheStrategy(DiskCacheStrategy.NONE).skipMemoryCache(true).submit().get();
|
|
896
|
+
if (image.isRecycled()) {
|
|
897
|
+
return;
|
|
898
|
+
}
|
|
899
|
+
if (iminPrintUtils == null) {
|
|
900
|
+
if (config.hasKey("align")) {
|
|
901
|
+
int align = config.getInt("align");
|
|
902
|
+
PrinterHelper.getInstance().printBitmapColorChartWithAlign(image, align, null);
|
|
903
|
+
} else {
|
|
904
|
+
PrinterHelper.getInstance().printBitmapColorChart(image, null);
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
promise.resolve(null);
|
|
909
|
+
} catch (Exception e) {
|
|
910
|
+
promise.reject("printSingleBitmap_failed", e.getMessage());
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
|
|
915
|
+
@ReactMethod
|
|
916
|
+
public void sendRAWData(ReadableArray bytes, final Promise promise) {
|
|
917
|
+
try {
|
|
918
|
+
// 处理接收到的 Uint8Array 数据
|
|
919
|
+
byte[] rawData = new byte[bytes.size()];
|
|
920
|
+
for (int i = 0; i < bytes.size(); i++) {
|
|
921
|
+
rawData[i] = (byte) bytes.getInt(i);
|
|
922
|
+
}
|
|
923
|
+
if (iminPrintUtils == null) {
|
|
924
|
+
PrinterHelper.getInstance().sendRAWData(rawData, null);
|
|
925
|
+
}
|
|
926
|
+
promise.resolve(null);
|
|
927
|
+
} catch (Exception e) {
|
|
928
|
+
promise.reject("sendRAWData_failed", e.getMessage());
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
@ReactMethod
|
|
933
|
+
public void printColumnsString(ReadableArray cols, final Promise promise) {
|
|
934
|
+
try {
|
|
935
|
+
String[] colsText = new String[cols.size()];
|
|
936
|
+
int[] colsWidth = new int[cols.size()];
|
|
937
|
+
int[] colsAlign = new int[cols.size()];
|
|
938
|
+
int[] colsFontSize = new int[cols.size()];
|
|
939
|
+
for (int i = 0; i < cols.size(); i++) {
|
|
940
|
+
ReadableMap col = cols.getMap(i);
|
|
941
|
+
String textColumn = col.getString("text");
|
|
942
|
+
int widthColumn = col.getInt("width");
|
|
943
|
+
int alignColumn = col.getInt("align");
|
|
944
|
+
int fontSizeColumn = col.getInt("fontSize");
|
|
945
|
+
colsText[i] = textColumn;
|
|
946
|
+
colsWidth[i] = widthColumn;
|
|
947
|
+
colsAlign[i] = alignColumn;
|
|
948
|
+
colsFontSize[i] = fontSizeColumn;
|
|
949
|
+
}
|
|
950
|
+
if (iminPrintUtils == null) {
|
|
951
|
+
PrinterHelper.getInstance().printColumnsString(colsText, colsWidth, colsAlign, colsFontSize, null);
|
|
952
|
+
}
|
|
953
|
+
promise.resolve(null);
|
|
954
|
+
} catch (Exception e) {
|
|
955
|
+
promise.reject("printColumnsString_failed", e.getMessage());
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
@ReactMethod
|
|
960
|
+
public void unBindService(final Promise promise) {
|
|
961
|
+
try {
|
|
962
|
+
if (iminPrintUtils == null) {
|
|
963
|
+
PrinterHelper.getInstance().deInitPrinterService(reactContext);
|
|
964
|
+
}
|
|
965
|
+
} catch (Exception e) {
|
|
966
|
+
promise.reject("unBindService_failed", e.getMessage());
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
@ReactMethod
|
|
971
|
+
public void initPrinterParams(final Promise promise) {
|
|
972
|
+
try {
|
|
973
|
+
if (iminPrintUtils == null) {
|
|
974
|
+
PrinterHelper.getInstance().initPrinterParams();
|
|
975
|
+
}
|
|
976
|
+
promise.resolve(null);
|
|
977
|
+
} catch (Exception e) {
|
|
978
|
+
promise.reject("initPrinterParams_failed", e.getMessage());
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
@ReactMethod
|
|
983
|
+
public void getFontCodepage(final Promise promise) {
|
|
984
|
+
try {
|
|
985
|
+
if (iminPrintUtils == null) {
|
|
986
|
+
List<String> fontCodepage = PrinterHelper.getInstance().getFontCodepage();
|
|
987
|
+
promise.resolve(fontCodepage);
|
|
988
|
+
} else {
|
|
989
|
+
promise.resolve(null);
|
|
990
|
+
}
|
|
991
|
+
} catch (Exception e) {
|
|
992
|
+
promise.reject("getFontCodepage_failed", e.getMessage());
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
@ReactMethod
|
|
997
|
+
public void setFontCodepage(int codepage, final Promise promise) {
|
|
998
|
+
try {
|
|
999
|
+
if (iminPrintUtils == null) {
|
|
1000
|
+
PrinterHelper.getInstance().setFontCodepage(codepage);
|
|
1001
|
+
}
|
|
1002
|
+
promise.resolve(null);
|
|
1003
|
+
} catch (Exception e) {
|
|
1004
|
+
promise.reject("setFontCodepage_failed", e.getMessage());
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
@ReactMethod
|
|
1009
|
+
public void getCurCodepage(final Promise promise) {
|
|
1010
|
+
try {
|
|
1011
|
+
if (iminPrintUtils == null) {
|
|
1012
|
+
String curCodepage = PrinterHelper.getInstance().getCurCodepage();
|
|
1013
|
+
promise.resolve(curCodepage);
|
|
1014
|
+
} else {
|
|
1015
|
+
promise.resolve(null);
|
|
1016
|
+
}
|
|
1017
|
+
} catch (Exception e) {
|
|
1018
|
+
promise.reject("getCurCodepage_failed", e.getMessage());
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
@ReactMethod
|
|
1023
|
+
public void getEncodeList(final Promise promise) {
|
|
1024
|
+
try {
|
|
1025
|
+
if (iminPrintUtils == null) {
|
|
1026
|
+
List<String> encodeList = PrinterHelper.getInstance().getEncodeList();
|
|
1027
|
+
promise.resolve(encodeList);
|
|
1028
|
+
} else {
|
|
1029
|
+
promise.resolve(null);
|
|
1030
|
+
}
|
|
1031
|
+
} catch (Exception e) {
|
|
1032
|
+
promise.reject("getEncodeList_failed", e.getMessage());
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
@ReactMethod
|
|
1037
|
+
public void setPrinterEncode(int encode, final Promise promise) {
|
|
1038
|
+
try {
|
|
1039
|
+
if (iminPrintUtils == null) {
|
|
1040
|
+
PrinterHelper.getInstance().setPrinterEncode(encode);
|
|
1041
|
+
}
|
|
1042
|
+
promise.resolve(null);
|
|
1043
|
+
} catch (Exception e) {
|
|
1044
|
+
promise.reject("setPrinterEncode_failed", e.getMessage());
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
@ReactMethod
|
|
1049
|
+
public void getCurEncode(final Promise promise) {
|
|
1050
|
+
try {
|
|
1051
|
+
if (iminPrintUtils == null) {
|
|
1052
|
+
String curEncode = PrinterHelper.getInstance().getCurEncode();
|
|
1053
|
+
promise.resolve(curEncode);
|
|
1054
|
+
} else {
|
|
1055
|
+
promise.resolve(null);
|
|
1056
|
+
}
|
|
1057
|
+
} catch (Exception e) {
|
|
1058
|
+
promise.reject("getCurEncode_failed", e.getMessage());
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
@ReactMethod
|
|
1063
|
+
public void getPrinterDensityList(final Promise promise) {
|
|
1064
|
+
try {
|
|
1065
|
+
if (iminPrintUtils == null) {
|
|
1066
|
+
List<String> printerDensityList = PrinterHelper.getInstance().getPrinterDensityList();
|
|
1067
|
+
promise.resolve(printerDensityList);
|
|
1068
|
+
} else {
|
|
1069
|
+
promise.resolve(null);
|
|
1070
|
+
}
|
|
1071
|
+
} catch (Exception e) {
|
|
1072
|
+
promise.reject("getPrinterDensityList_failed", e.getMessage());
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
@ReactMethod
|
|
1077
|
+
public void setPrinterDensity(int density, final Promise promise) {
|
|
1078
|
+
try {
|
|
1079
|
+
if (iminPrintUtils == null) {
|
|
1080
|
+
PrinterHelper.getInstance().setPrinterDensity(density);
|
|
1081
|
+
}
|
|
1082
|
+
promise.resolve(null);
|
|
1083
|
+
} catch (Exception e) {
|
|
1084
|
+
promise.reject("setPrinterDensity_failed", e.getMessage());
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
@ReactMethod
|
|
1089
|
+
public void getPrinterDensity(final Promise promise) {
|
|
1090
|
+
try {
|
|
1091
|
+
if (iminPrintUtils == null) {
|
|
1092
|
+
promise.resolve(PrinterHelper.getInstance().getPrinterDensity());
|
|
1093
|
+
} else {
|
|
1094
|
+
promise.resolve(null);
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
} catch (Exception e) {
|
|
1098
|
+
promise.reject("getPrinterDensity_failed", e.getMessage());
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
@ReactMethod
|
|
1103
|
+
public void getPrinterSpeedList(final Promise promise) {
|
|
1104
|
+
try {
|
|
1105
|
+
if (iminPrintUtils == null) {
|
|
1106
|
+
List<String> printerSpeedList = PrinterHelper.getInstance().getPrinterSpeedList();
|
|
1107
|
+
promise.resolve(printerSpeedList);
|
|
1108
|
+
} else {
|
|
1109
|
+
promise.resolve(null);
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
} catch (Exception e) {
|
|
1113
|
+
promise.reject("getPrinterSpeedList_failed", e.getMessage());
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
@ReactMethod
|
|
1118
|
+
public void setPrinterSpeed(int speed, final Promise promise) {
|
|
1119
|
+
try {
|
|
1120
|
+
if (iminPrintUtils == null) {
|
|
1121
|
+
PrinterHelper.getInstance().setPrinterSpeed(speed);
|
|
1122
|
+
}
|
|
1123
|
+
promise.resolve(null);
|
|
1124
|
+
} catch (Exception e) {
|
|
1125
|
+
promise.reject("setPrinterSpeed_failed", e.getMessage());
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
@ReactMethod
|
|
1130
|
+
public void getPrinterSpeed(final Promise promise) {
|
|
1131
|
+
try {
|
|
1132
|
+
if (iminPrintUtils == null) {
|
|
1133
|
+
int printerSpeed = PrinterHelper.getInstance().getPrinterSpeed();
|
|
1134
|
+
promise.resolve(printerSpeed);
|
|
1135
|
+
} else {
|
|
1136
|
+
promise.resolve(null);
|
|
1137
|
+
}
|
|
1138
|
+
} catch (Exception e) {
|
|
1139
|
+
promise.reject("getPrinterSpeed_failed", e.getMessage());
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
@ReactMethod
|
|
1144
|
+
public void getPrinterPaperTypeList(final Promise promise) {
|
|
1145
|
+
try {
|
|
1146
|
+
if (iminPrintUtils == null) {
|
|
1147
|
+
List<String> printerPaperTypeList = PrinterHelper.getInstance().getPrinterPaperTypeList();
|
|
1148
|
+
promise.resolve(printerPaperTypeList);
|
|
1149
|
+
} else {
|
|
1150
|
+
promise.resolve(null);
|
|
1151
|
+
}
|
|
1152
|
+
} catch (Exception e) {
|
|
1153
|
+
promise.reject("getPrinterPaperTypeList_failed", e.getMessage());
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
@ReactMethod
|
|
1158
|
+
public void getPrinterPaperType(final Promise promise) {
|
|
1159
|
+
try {
|
|
1160
|
+
if (iminPrintUtils == null) {
|
|
1161
|
+
promise.resolve(PrinterHelper.getInstance().getPrinterPaperType());
|
|
1162
|
+
} else {
|
|
1163
|
+
promise.resolve(null);
|
|
1164
|
+
}
|
|
1165
|
+
} catch (Exception e) {
|
|
1166
|
+
promise.reject("getPrinterPaperType_failed", e.getMessage());
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
@ReactMethod
|
|
1171
|
+
public void getPrinterSerialNumber(final Promise promise) {
|
|
1172
|
+
try {
|
|
1173
|
+
if (iminPrintUtils == null) {
|
|
1174
|
+
PrinterHelper.getInstance().getPrinterSerialNumber(new INeoPrinterCallback() {
|
|
1175
|
+
@Override
|
|
1176
|
+
public void onRunResult(boolean isSuccess) throws RemoteException {
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
@Override
|
|
1180
|
+
public void onReturnString(String s) throws RemoteException {
|
|
1181
|
+
promise.resolve(s);
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
@Override
|
|
1185
|
+
public void onRaiseException(int code, String msg) throws RemoteException {
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
@Override
|
|
1189
|
+
public void onPrintResult(int code, String msg) throws RemoteException {
|
|
1190
|
+
}
|
|
1191
|
+
});
|
|
1192
|
+
} else {
|
|
1193
|
+
promise.resolve(null);
|
|
1194
|
+
}
|
|
1195
|
+
} catch (Exception e) {
|
|
1196
|
+
promise.reject("getPrinterSerialNumber_failed", e.getMessage());
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
@ReactMethod
|
|
1201
|
+
public void getPrinterModelName(final Promise promise) {
|
|
1202
|
+
try {
|
|
1203
|
+
if (iminPrintUtils == null) {
|
|
1204
|
+
PrinterHelper.getInstance().getPrinterModelName(new INeoPrinterCallback() {
|
|
1205
|
+
@Override
|
|
1206
|
+
public void onRunResult(boolean isSuccess) throws RemoteException {
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
@Override
|
|
1210
|
+
public void onReturnString(String s) throws RemoteException {
|
|
1211
|
+
promise.resolve(s);
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
@Override
|
|
1215
|
+
public void onRaiseException(int code, String msg) throws RemoteException {
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
@Override
|
|
1219
|
+
public void onPrintResult(int code, String msg) throws RemoteException {
|
|
1220
|
+
}
|
|
1221
|
+
});
|
|
1222
|
+
} else {
|
|
1223
|
+
promise.resolve(null);
|
|
1224
|
+
}
|
|
1225
|
+
} catch (Exception e) {
|
|
1226
|
+
promise.reject("getPrinterModelName_failed", e.getMessage());
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
@ReactMethod
|
|
1231
|
+
public void getPrinterThermalHead(final Promise promise) {
|
|
1232
|
+
try {
|
|
1233
|
+
if (iminPrintUtils == null) {
|
|
1234
|
+
PrinterHelper.getInstance().getPrinterThermalHead(new INeoPrinterCallback() {
|
|
1235
|
+
@Override
|
|
1236
|
+
public void onRunResult(boolean isSuccess) throws RemoteException {
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
@Override
|
|
1240
|
+
public void onReturnString(String s) throws RemoteException {
|
|
1241
|
+
promise.resolve(s);
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
@Override
|
|
1245
|
+
public void onRaiseException(int code, String msg) throws RemoteException {
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1248
|
+
@Override
|
|
1249
|
+
public void onPrintResult(int code, String msg) throws RemoteException {
|
|
1250
|
+
}
|
|
1251
|
+
});
|
|
1252
|
+
} else {
|
|
1253
|
+
promise.resolve(null);
|
|
1254
|
+
}
|
|
1255
|
+
} catch (Exception e) {
|
|
1256
|
+
promise.reject("getPrinterThermalHead_failed", e.getMessage());
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
@ReactMethod
|
|
1261
|
+
public void getPrinterFirmwareVersion(final Promise promise) {
|
|
1262
|
+
try {
|
|
1263
|
+
if (iminPrintUtils == null) {
|
|
1264
|
+
PrinterHelper.getInstance().getPrinterFirmwareVersion(new INeoPrinterCallback() {
|
|
1265
|
+
@Override
|
|
1266
|
+
public void onRunResult(boolean isSuccess) throws RemoteException {
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
@Override
|
|
1270
|
+
public void onReturnString(String s) throws RemoteException {
|
|
1271
|
+
promise.resolve(s);
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
@Override
|
|
1275
|
+
public void onRaiseException(int code, String msg) throws RemoteException {
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
@Override
|
|
1279
|
+
public void onPrintResult(int code, String msg) throws RemoteException {
|
|
1280
|
+
}
|
|
1281
|
+
});
|
|
1282
|
+
} else {
|
|
1283
|
+
promise.resolve(null);
|
|
1284
|
+
}
|
|
1285
|
+
} catch (Exception e) {
|
|
1286
|
+
promise.reject("getPrinterFirmwareVersion_failed", e.getMessage());
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
@ReactMethod
|
|
1291
|
+
public void getPrinterHardwareVersion(final Promise promise) {
|
|
1292
|
+
try {
|
|
1293
|
+
if (iminPrintUtils == null) {
|
|
1294
|
+
PrinterHelper.getInstance().getPrinterHardwareVersion(new INeoPrinterCallback() {
|
|
1295
|
+
@Override
|
|
1296
|
+
public void onRunResult(boolean isSuccess) throws RemoteException {
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
@Override
|
|
1300
|
+
public void onReturnString(String s) throws RemoteException {
|
|
1301
|
+
promise.resolve(s);
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
@Override
|
|
1305
|
+
public void onRaiseException(int code, String msg) throws RemoteException {
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1308
|
+
@Override
|
|
1309
|
+
public void onPrintResult(int code, String msg) throws RemoteException {
|
|
1310
|
+
}
|
|
1311
|
+
});
|
|
1312
|
+
} else {
|
|
1313
|
+
promise.resolve(null);
|
|
1314
|
+
}
|
|
1315
|
+
} catch (Exception e) {
|
|
1316
|
+
promise.reject("getPrinterHardwareVersion_failed", e.getMessage());
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
@ReactMethod
|
|
1321
|
+
public void getPrinterPaperDistance(final Promise promise) {
|
|
1322
|
+
try {
|
|
1323
|
+
if (iminPrintUtils == null) {
|
|
1324
|
+
PrinterHelper.getInstance().getPrinterPaperDistance(new INeoPrinterCallback() {
|
|
1325
|
+
@Override
|
|
1326
|
+
public void onRunResult(boolean isSuccess) throws RemoteException {
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
@Override
|
|
1330
|
+
public void onReturnString(String s) throws RemoteException {
|
|
1331
|
+
promise.resolve(s);
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1334
|
+
@Override
|
|
1335
|
+
public void onRaiseException(int code, String msg) throws RemoteException {
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
@Override
|
|
1339
|
+
public void onPrintResult(int code, String msg) throws RemoteException {
|
|
1340
|
+
}
|
|
1341
|
+
});
|
|
1342
|
+
} else {
|
|
1343
|
+
promise.resolve(null);
|
|
1344
|
+
}
|
|
1345
|
+
} catch (Exception e) {
|
|
1346
|
+
promise.reject("getPrinterPaperDistance_failed", e.getMessage());
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1350
|
+
@ReactMethod
|
|
1351
|
+
public void getPrinterCutTimes(final Promise promise) {
|
|
1352
|
+
try {
|
|
1353
|
+
if (iminPrintUtils == null) {
|
|
1354
|
+
PrinterHelper.getInstance().getPrinterCutTimes(new INeoPrinterCallback() {
|
|
1355
|
+
@Override
|
|
1356
|
+
public void onRunResult(boolean isSuccess) throws RemoteException {
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
@Override
|
|
1360
|
+
public void onReturnString(String s) throws RemoteException {
|
|
1361
|
+
promise.resolve(s);
|
|
1362
|
+
}
|
|
1363
|
+
|
|
1364
|
+
@Override
|
|
1365
|
+
public void onRaiseException(int code, String msg) throws RemoteException {
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
@Override
|
|
1369
|
+
public void onPrintResult(int code, String msg) throws RemoteException {
|
|
1370
|
+
}
|
|
1371
|
+
});
|
|
1372
|
+
} else {
|
|
1373
|
+
promise.resolve(null);
|
|
1374
|
+
}
|
|
1375
|
+
} catch (Exception e) {
|
|
1376
|
+
promise.reject("getPrinterCutTimes_failed", e.getMessage());
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
|
|
1381
|
+
@ReactMethod
|
|
1382
|
+
public void getPrinterMode(final Promise promise) {
|
|
1383
|
+
try {
|
|
1384
|
+
if (iminPrintUtils == null) {
|
|
1385
|
+
Log.e("IminPrinter", "getPrintModel: 获取当前打印机模式");
|
|
1386
|
+
// WritableMap payload = Arguments.createMap();
|
|
1387
|
+
PrinterHelper.getInstance().labelGetPrinterMode(new INeoPrinterCallback() {
|
|
1388
|
+
@Override
|
|
1389
|
+
public void onRunResult(boolean isSuccess) throws RemoteException {
|
|
1390
|
+
|
|
1391
|
+
}
|
|
1392
|
+
|
|
1393
|
+
@Override
|
|
1394
|
+
public void onReturnString(String string) throws RemoteException {
|
|
1395
|
+
Log.e("IminPrinter", "getPrintModel: 获取当前打印机模式" + string);
|
|
1396
|
+
if (string != null && !string.isEmpty()) {
|
|
1397
|
+
// payload.putString("result",string);
|
|
1398
|
+
if (string.equalsIgnoreCase("Label")) {
|
|
1399
|
+
promise.resolve(1);
|
|
1400
|
+
} else {
|
|
1401
|
+
promise.resolve(0);
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
@Override
|
|
1407
|
+
public void onRaiseException(int code, String msg) throws RemoteException {
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
@Override
|
|
1411
|
+
public void onPrintResult(int code, String msg) throws RemoteException {
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
@Override
|
|
1415
|
+
public IBinder asBinder() {
|
|
1416
|
+
return null;
|
|
1417
|
+
}
|
|
1418
|
+
});
|
|
1419
|
+
|
|
1420
|
+
// promise.resolve(PrinterHelper.getInstance().getPrinterMode());
|
|
1421
|
+
} else {
|
|
1422
|
+
promise.resolve(null);
|
|
1423
|
+
}
|
|
1424
|
+
} catch (Exception e) {
|
|
1425
|
+
promise.reject("getPrinterMode_failed", e.getMessage());
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
@ReactMethod
|
|
1430
|
+
public void getDrawerStatus(final Promise promise) {
|
|
1431
|
+
try {
|
|
1432
|
+
if (iminPrintUtils == null) {
|
|
1433
|
+
promise.resolve(PrinterHelper.getInstance().getDrawerStatus());
|
|
1434
|
+
} else {
|
|
1435
|
+
promise.resolve(null);
|
|
1436
|
+
}
|
|
1437
|
+
} catch (Exception e) {
|
|
1438
|
+
promise.reject("getDrawerStatus_failed", e.getMessage());
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1442
|
+
@ReactMethod
|
|
1443
|
+
public void getOpenDrawerTimes(final Promise promise) {
|
|
1444
|
+
try {
|
|
1445
|
+
if (iminPrintUtils == null) {
|
|
1446
|
+
promise.resolve(PrinterHelper.getInstance().getOpenDrawerTimes());
|
|
1447
|
+
} else {
|
|
1448
|
+
promise.resolve(null);
|
|
1449
|
+
}
|
|
1450
|
+
} catch (Exception e) {
|
|
1451
|
+
promise.reject("getOpenDrawerTimes_failed", e.getMessage());
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
@ReactMethod
|
|
1456
|
+
public void getServiceVersion(final Promise promise) {
|
|
1457
|
+
try {
|
|
1458
|
+
if (iminPrintUtils == null) {
|
|
1459
|
+
promise.resolve(PrinterHelper.getInstance().getServiceVersion());
|
|
1460
|
+
} else {
|
|
1461
|
+
promise.resolve(null);
|
|
1462
|
+
}
|
|
1463
|
+
} catch (Exception e) {
|
|
1464
|
+
promise.reject("getServiceVersion_failed", e.getMessage());
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
@ReactMethod
|
|
1469
|
+
public void getUsbPrinterVidPid(final Promise promise) {
|
|
1470
|
+
try {
|
|
1471
|
+
if (iminPrintUtils == null) {
|
|
1472
|
+
promise.resolve(PrinterHelper.getInstance().getUsbPrinterVidPid());
|
|
1473
|
+
} else {
|
|
1474
|
+
promise.resolve(null);
|
|
1475
|
+
}
|
|
1476
|
+
} catch (Exception e) {
|
|
1477
|
+
promise.reject("getUsbPrinterVidPid_failed", e.getMessage());
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
@ReactMethod
|
|
1482
|
+
public void getUsbDevicesName(final Promise promise) {
|
|
1483
|
+
try {
|
|
1484
|
+
if (iminPrintUtils == null) {
|
|
1485
|
+
promise.resolve(PrinterHelper.getInstance().getUsbDevicesName());
|
|
1486
|
+
} else {
|
|
1487
|
+
promise.resolve(null);
|
|
1488
|
+
}
|
|
1489
|
+
} catch (Exception e) {
|
|
1490
|
+
promise.reject("getUsbDevicesName_failed", e.getMessage());
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1494
|
+
|
|
1495
|
+
@ReactMethod
|
|
1496
|
+
public void setCodeAlignment(int align, final Promise promise) {
|
|
1497
|
+
try {
|
|
1498
|
+
if (iminPrintUtils == null) {
|
|
1499
|
+
PrinterHelper.getInstance().setCodeAlignment(align);
|
|
1500
|
+
}
|
|
1501
|
+
promise.resolve(null);
|
|
1502
|
+
} catch (Exception e) {
|
|
1503
|
+
promise.reject("setCodeAlignment_failed", e.getMessage());
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
|
|
1507
|
+
@ReactMethod
|
|
1508
|
+
public void setTextBitmapTypeface(int typeface, final Promise promise) {
|
|
1509
|
+
try {
|
|
1510
|
+
if (iminPrintUtils == null) {
|
|
1511
|
+
switch (typeface) {
|
|
1512
|
+
case 1:
|
|
1513
|
+
PrinterHelper.getInstance().setTextBitmapTypeface("Typeface.MONOSPACE");
|
|
1514
|
+
break;
|
|
1515
|
+
case 2:
|
|
1516
|
+
PrinterHelper.getInstance().setTextBitmapTypeface("Typeface.DEFAULT_BOLD");
|
|
1517
|
+
break;
|
|
1518
|
+
case 3:
|
|
1519
|
+
PrinterHelper.getInstance().setTextBitmapTypeface("Typeface.SANS_SERIF");
|
|
1520
|
+
break;
|
|
1521
|
+
case 4:
|
|
1522
|
+
PrinterHelper.getInstance().setTextBitmapTypeface("Typeface.SERIF");
|
|
1523
|
+
break;
|
|
1524
|
+
default:
|
|
1525
|
+
PrinterHelper.getInstance().setTextBitmapTypeface("Typeface.DEFAULT");
|
|
1526
|
+
break;
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1529
|
+
promise.resolve(null);
|
|
1530
|
+
} catch (Exception e) {
|
|
1531
|
+
promise.reject("setTextBitmapTypeface_failed", e.getMessage());
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
@ReactMethod
|
|
1536
|
+
public void setTextBitmapSize(int size, final Promise promise) {
|
|
1537
|
+
try {
|
|
1538
|
+
if (iminPrintUtils == null) {
|
|
1539
|
+
PrinterHelper.getInstance().setTextBitmapSize(size);
|
|
1540
|
+
}
|
|
1541
|
+
promise.resolve(null);
|
|
1542
|
+
} catch (Exception e) {
|
|
1543
|
+
promise.reject("setTextBitmapSize_failed", e.getMessage());
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
@ReactMethod
|
|
1548
|
+
public void setTextBitmapStyle(int style, final Promise promise) {
|
|
1549
|
+
try {
|
|
1550
|
+
if (iminPrintUtils == null) {
|
|
1551
|
+
PrinterHelper.getInstance().setTextBitmapStyle(style);
|
|
1552
|
+
}
|
|
1553
|
+
promise.resolve(null);
|
|
1554
|
+
} catch (Exception e) {
|
|
1555
|
+
promise.reject("setTextBitmapStyle_failed", e.getMessage());
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
@ReactMethod
|
|
1560
|
+
public void setTextBitmapStrikeThru(boolean strikeThru, final Promise promise) {
|
|
1561
|
+
try {
|
|
1562
|
+
if (iminPrintUtils == null) {
|
|
1563
|
+
PrinterHelper.getInstance().setTextBitmapStrikeThru(strikeThru);
|
|
1564
|
+
}
|
|
1565
|
+
promise.resolve(null);
|
|
1566
|
+
} catch (Exception e) {
|
|
1567
|
+
promise.reject("setTextBitmapStrikeThru_failed", e.getMessage());
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1570
|
+
|
|
1571
|
+
@ReactMethod
|
|
1572
|
+
public void setTextBitmapUnderline(boolean haveUnderline, final Promise promise) {
|
|
1573
|
+
try {
|
|
1574
|
+
if (iminPrintUtils == null) {
|
|
1575
|
+
PrinterHelper.getInstance().setTextBitmapUnderline(haveUnderline);
|
|
1576
|
+
}
|
|
1577
|
+
promise.resolve(null);
|
|
1578
|
+
} catch (Exception e) {
|
|
1579
|
+
promise.reject("setTextBitmapUnderline_failed", e.getMessage());
|
|
1580
|
+
}
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1583
|
+
@ReactMethod
|
|
1584
|
+
public void setTextBitmapLineSpacing(float lineHeight, final Promise promise) {
|
|
1585
|
+
try {
|
|
1586
|
+
if (iminPrintUtils == null) {
|
|
1587
|
+
PrinterHelper.getInstance().setTextBitmapLineSpacing(lineHeight);
|
|
1588
|
+
}
|
|
1589
|
+
promise.resolve(null);
|
|
1590
|
+
} catch (Exception e) {
|
|
1591
|
+
promise.reject("setTextBitmapLineSpacing_failed", e.getMessage());
|
|
1592
|
+
}
|
|
1593
|
+
}
|
|
1594
|
+
|
|
1595
|
+
@ReactMethod
|
|
1596
|
+
public void setTextBitmapLetterSpacing(float space, final Promise promise) {
|
|
1597
|
+
try {
|
|
1598
|
+
if (iminPrintUtils == null) {
|
|
1599
|
+
PrinterHelper.getInstance().setTextBitmapLetterSpacing(space);
|
|
1600
|
+
}
|
|
1601
|
+
promise.resolve(null);
|
|
1602
|
+
} catch (Exception e) {
|
|
1603
|
+
promise.reject("setTextBitmapLetterSpacing_failed", e.getMessage());
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
|
|
1607
|
+
@ReactMethod
|
|
1608
|
+
public void setTextBitmapAntiWhite(boolean antiWhite, final Promise promise) {
|
|
1609
|
+
try {
|
|
1610
|
+
if (iminPrintUtils == null) {
|
|
1611
|
+
PrinterHelper.getInstance().setTextBitmapAntiWhite(antiWhite);
|
|
1612
|
+
}
|
|
1613
|
+
promise.resolve(null);
|
|
1614
|
+
} catch (Exception e) {
|
|
1615
|
+
promise.reject("setTextBitmapAntiWhite_failed", e.getMessage());
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
|
|
1619
|
+
@ReactMethod
|
|
1620
|
+
public void printTextBitmap(ReadableMap config, final Promise promise) {
|
|
1621
|
+
try {
|
|
1622
|
+
if (iminPrintUtils == null) {
|
|
1623
|
+
String text = config.getString("text");
|
|
1624
|
+
if (config.hasKey("align")) {
|
|
1625
|
+
int align = config.getInt("align");
|
|
1626
|
+
PrinterHelper.getInstance().printTextBitmapWithAli(text + "\n", align, null);
|
|
1627
|
+
} else {
|
|
1628
|
+
PrinterHelper.getInstance().printTextBitmap(text + "\n", null);
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
promise.resolve(null);
|
|
1632
|
+
} catch (Exception e) {
|
|
1633
|
+
promise.reject("printTextBitmap_failed", e.getMessage());
|
|
1634
|
+
}
|
|
1635
|
+
}
|
|
1636
|
+
|
|
1637
|
+
@ReactMethod
|
|
1638
|
+
public void enterPrinterBuffer(boolean isClean, final Promise promise) {
|
|
1639
|
+
try {
|
|
1640
|
+
if (iminPrintUtils == null) {
|
|
1641
|
+
PrinterHelper.getInstance().enterPrinterBuffer(isClean);
|
|
1642
|
+
}
|
|
1643
|
+
promise.resolve(null);
|
|
1644
|
+
} catch (Exception e) {
|
|
1645
|
+
promise.reject("enterPrinterBuffer_failed", e.getMessage());
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
@ReactMethod
|
|
1650
|
+
public void commitPrinterBuffer(final Promise promise) {
|
|
1651
|
+
try {
|
|
1652
|
+
if (iminPrintUtils == null) {
|
|
1653
|
+
PrinterHelper.getInstance().commitPrinterBuffer(null);
|
|
1654
|
+
}
|
|
1655
|
+
promise.resolve(null);
|
|
1656
|
+
} catch (Exception e) {
|
|
1657
|
+
promise.reject("commitPrinterBuffer_failed", e.getMessage());
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
@ReactMethod
|
|
1662
|
+
public void exitPrinterBuffer(boolean isCommit, final Promise promise) {
|
|
1663
|
+
try {
|
|
1664
|
+
if (iminPrintUtils == null) {
|
|
1665
|
+
PrinterHelper.getInstance().exitPrinterBuffer(isCommit);
|
|
1666
|
+
}
|
|
1667
|
+
promise.resolve(null);
|
|
1668
|
+
} catch (Exception e) {
|
|
1669
|
+
promise.reject("exitPrinterBuffer_failed", e.getMessage());
|
|
1670
|
+
}
|
|
1671
|
+
}
|
|
1672
|
+
|
|
1673
|
+
//标签相关的API
|
|
1674
|
+
//标签初始化
|
|
1675
|
+
@ReactMethod
|
|
1676
|
+
public void labelInitCanvas(ReadableMap config, final Promise promise) {
|
|
1677
|
+
if (iminPrintUtils == null) {
|
|
1678
|
+
Integer width = (Integer) config.getInt("width");
|
|
1679
|
+
Integer height1 = (Integer) config.getInt("height");
|
|
1680
|
+
Integer posX = (Integer) config.getInt("posX");
|
|
1681
|
+
Integer posY = (Integer) config.getInt("posY");
|
|
1682
|
+
|
|
1683
|
+
// 使用解析后的数据
|
|
1684
|
+
Log.e("IminPrinter", "labelInitCanvas:" + width + " " + height1 + " " + posX + " ,y= " + posY);
|
|
1685
|
+
PrinterHelper.getInstance().labelInitCanvas(LabelCanvasStyle.getCanvasStyle()
|
|
1686
|
+
.setWidth(width)
|
|
1687
|
+
.setHeight(height1)
|
|
1688
|
+
.setPosX(posX)
|
|
1689
|
+
.setPosY(posY)
|
|
1690
|
+
);
|
|
1691
|
+
|
|
1692
|
+
promise.resolve(true);
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1696
|
+
//绘制文本内容
|
|
1697
|
+
@ReactMethod
|
|
1698
|
+
public void labelAddText(ReadableMap config, final Promise promise) {
|
|
1699
|
+
Log.e("IminPrinter", "labelAddText: 点击绘制文本");
|
|
1700
|
+
if (iminPrintUtils == null) {
|
|
1701
|
+
String textLabel = config.getString("text");
|
|
1702
|
+
// 手动解析每个参数
|
|
1703
|
+
Integer posX = (Integer) config.getInt("posX");
|
|
1704
|
+
Integer posY = (Integer) config.getInt("posY");
|
|
1705
|
+
Integer textSize = (Integer) config.getInt("textSize");
|
|
1706
|
+
Integer textWidthRatio = (Integer) config.getInt("textWidthRatio");
|
|
1707
|
+
Integer textHeightRatio = (Integer) config.getInt("textHeightRatio");
|
|
1708
|
+
Integer width = (Integer) config.getInt("width");
|
|
1709
|
+
Integer height1 = (Integer) config.getInt("height");
|
|
1710
|
+
Integer alignStr = config.getInt("align");
|
|
1711
|
+
Integer rotateStr = config.getInt("rotate");
|
|
1712
|
+
Integer textSpace = (Integer) config.getInt("textSpace");
|
|
1713
|
+
Boolean enableBold = (Boolean) config.getBoolean("enableBold");
|
|
1714
|
+
Boolean enableUnderline = (Boolean) config.getBoolean("enableUnderline");
|
|
1715
|
+
Boolean enableStrikethrough = (Boolean) config.getBoolean("enableStrikethrough");
|
|
1716
|
+
Boolean enableItalics = (Boolean) config.getBoolean("enableItalics");
|
|
1717
|
+
Boolean enAntiColor = (Boolean) config.getBoolean("enAntiColor");
|
|
1718
|
+
|
|
1719
|
+
// 将字符串转换为枚举类型
|
|
1720
|
+
Align align = Align.values()[alignStr];
|
|
1721
|
+
Rotate rotate = Rotate.values()[rotateStr];
|
|
1722
|
+
|
|
1723
|
+
|
|
1724
|
+
Log.e("IminPrinter", "labelAddText: 点击绘制文本 " + textLabel + ",width=" +
|
|
1725
|
+
width + " ,height1= " + height1 + " ,posX= " + posX + " ,posY= " + posY +
|
|
1726
|
+
" ,rotateStr= " + rotateStr + " ,enableBold= " + enableBold + " " + align + " " + rotate);
|
|
1727
|
+
|
|
1728
|
+
|
|
1729
|
+
PrinterHelper.getInstance().labelAddText(textLabel, LabelTextStyle.getTextStyle()
|
|
1730
|
+
.setPosX(posX)
|
|
1731
|
+
.setPosY(posY)
|
|
1732
|
+
.setTextSize(textSize)
|
|
1733
|
+
.setTextWidthRatio(textWidthRatio)
|
|
1734
|
+
.setTextHeightRatio(textHeightRatio)
|
|
1735
|
+
.setWidth(width)
|
|
1736
|
+
.setHeight(height1)
|
|
1737
|
+
.setAlign(align)
|
|
1738
|
+
.setRotate(rotate)
|
|
1739
|
+
.setTextSpace(textSpace)
|
|
1740
|
+
.setEnableBold(enableBold)
|
|
1741
|
+
.setEnableUnderline(enableUnderline)
|
|
1742
|
+
.setEnableStrikethrough(enableStrikethrough)
|
|
1743
|
+
.setEnableItalics(enableItalics)
|
|
1744
|
+
.setEnAntiColor(enAntiColor)
|
|
1745
|
+
|
|
1746
|
+
);
|
|
1747
|
+
promise.resolve(true);
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
1750
|
+
|
|
1751
|
+
//绘制条形码内容
|
|
1752
|
+
@ReactMethod
|
|
1753
|
+
public void labelAddBarCode(ReadableMap config, final Promise promise) {
|
|
1754
|
+
if (iminPrintUtils == null) {
|
|
1755
|
+
String barCode = config.getString("barCode");
|
|
1756
|
+
// 直接从 map 获取各个属性
|
|
1757
|
+
Integer posX = (Integer) config.getInt("posX");
|
|
1758
|
+
Integer posY = (Integer) config.getInt("posY");
|
|
1759
|
+
Integer dotWidth = (Integer) config.getInt("dotWidth");
|
|
1760
|
+
Integer barHeight = (Integer) config.getInt("barHeight");
|
|
1761
|
+
Integer readable = config.getInt("readable");
|
|
1762
|
+
Integer symbology = config.getInt("symbology");
|
|
1763
|
+
Integer alignStr = config.getInt("align");
|
|
1764
|
+
Integer rotateStr = config.getInt("rotate");
|
|
1765
|
+
Integer width = (Integer) config.getInt("width");
|
|
1766
|
+
Integer height1 = (Integer) config.getInt("height");
|
|
1767
|
+
|
|
1768
|
+
Rotate rotate = Rotate.values()[rotateStr];
|
|
1769
|
+
Align align = Align.values()[alignStr];
|
|
1770
|
+
HumanReadable readable1 = HumanReadable.values()[readable];
|
|
1771
|
+
Symbology symbology1 = Symbology.values()[symbology];
|
|
1772
|
+
|
|
1773
|
+
Log.e("IminPrinter", "labelAddBarCode: 绘制条形码内容 " + barCode + ",width=" +
|
|
1774
|
+
width + " ,height1= " + height1 + " ,posX= " + posX + " ,posY= " + posY + " ,readable= " + readable + " ,symbology= " + symbology + " ,HumanReadable=> " + readable1);
|
|
1775
|
+
|
|
1776
|
+
PrinterHelper.getInstance().labelAddBarCode(barCode, LabelBarCodeStyle.getBarCodeStyle()
|
|
1777
|
+
.setPosX(posX)
|
|
1778
|
+
.setPosY(posY)
|
|
1779
|
+
.setSymbology(symbology1)
|
|
1780
|
+
.setDotWidth(dotWidth)
|
|
1781
|
+
.setBarHeight(barHeight)
|
|
1782
|
+
.setReadable(readable1)
|
|
1783
|
+
.setAlign(align)
|
|
1784
|
+
.setRotate(rotate)
|
|
1785
|
+
.setWidth(width)
|
|
1786
|
+
.setHeight(height1)
|
|
1787
|
+
);
|
|
1788
|
+
|
|
1789
|
+
promise.resolve(true);
|
|
1790
|
+
}
|
|
1791
|
+
|
|
1792
|
+
Log.e("IminPrinter", "labelAddBarCode: 绘制条形码内容");
|
|
1793
|
+
}
|
|
1794
|
+
|
|
1795
|
+
//绘制二维码内容
|
|
1796
|
+
@ReactMethod
|
|
1797
|
+
public void labelAddQrCode(ReadableMap config, final Promise promise) {
|
|
1798
|
+
Log.e("IminPrinter", "labelAddQrCode: 绘制二维码内容");
|
|
1799
|
+
if (iminPrintUtils == null) {
|
|
1800
|
+
|
|
1801
|
+
if (config != null) {
|
|
1802
|
+
String qrCode = config.getString("qrCode");
|
|
1803
|
+
|
|
1804
|
+
// 直接从 map 获取各个属性
|
|
1805
|
+
Integer posX = (Integer) config.getInt("posX");
|
|
1806
|
+
Integer posY = (Integer) config.getInt("posY");
|
|
1807
|
+
Integer size1 = (Integer) config.getInt("size");
|
|
1808
|
+
Integer errorLevelStr = config.getInt("errorLevel");
|
|
1809
|
+
Integer rotateStr = config.getInt("rotate");
|
|
1810
|
+
Integer width = (Integer) config.getInt("width");
|
|
1811
|
+
Integer height1 = (Integer) config.getInt("height");
|
|
1812
|
+
Log.e("IminPrinter", "labelAddQrCode: 绘制二维码内容 " + qrCode + ",width=" +
|
|
1813
|
+
width + " ,height1= " + height1 + " ,posX= " + posX + " ,posY= " + posY + " ,errorLevelStr= " + errorLevelStr + " ,size= " + size1);
|
|
1814
|
+
|
|
1815
|
+
Rotate rotate = Rotate.values()[rotateStr];
|
|
1816
|
+
ErrorLevel errorLevel = ErrorLevel.values()[errorLevelStr];
|
|
1817
|
+
|
|
1818
|
+
|
|
1819
|
+
PrinterHelper.getInstance().labelAddQrCode(qrCode, LabelQrCodeStyle.getQrCodeStyle()
|
|
1820
|
+
.setPosX(posX)
|
|
1821
|
+
.setPosY(posY)
|
|
1822
|
+
.setSize(size1)
|
|
1823
|
+
.setErrorLevel(errorLevel)
|
|
1824
|
+
.setRotate(rotate)
|
|
1825
|
+
.setWidth(width)
|
|
1826
|
+
.setHeight(height1)
|
|
1827
|
+
);
|
|
1828
|
+
|
|
1829
|
+
}
|
|
1830
|
+
promise.resolve(true);
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
|
|
1834
|
+
//绘制图像
|
|
1835
|
+
@ReactMethod
|
|
1836
|
+
public void labelAddBitmap(ReadableMap config, final Promise promise) {
|
|
1837
|
+
Log.e("IminPrinter", "labelAddBitmap: 绘制图像");
|
|
1838
|
+
if (iminPrintUtils == null) {
|
|
1839
|
+
try {
|
|
1840
|
+
String bitmapUrl = config.getString("bitmapUrl");
|
|
1841
|
+
Integer posX = (Integer) config.getInt("posX");
|
|
1842
|
+
Integer posY = (Integer) config.getInt("posY");
|
|
1843
|
+
Integer algorithm = config.getInt("algorithm");
|
|
1844
|
+
Integer value = (Integer) config.getInt("value");
|
|
1845
|
+
Integer width = (Integer) config.getInt("width");
|
|
1846
|
+
Integer height1 = (Integer) config.getInt("height");
|
|
1847
|
+
|
|
1848
|
+
ImageAlgorithm imageAlgorithm = ImageAlgorithm.values()[algorithm];
|
|
1849
|
+
|
|
1850
|
+
Log.e("IminPrinter", "labelAddBitmap: 绘制图像 " + bitmapUrl + " ,width=" + width + " ,height1= " + height1 + " ,posX= " + posX + " ,posY= " + posY + " ,algorithm= " + algorithm + " ,value= " + value);
|
|
1851
|
+
|
|
1852
|
+
Bitmap bitmap = null;
|
|
1853
|
+
if (bitmapUrl == null || bitmapUrl.isEmpty()) {
|
|
1854
|
+
promise.resolve(false);
|
|
1855
|
+
} else {
|
|
1856
|
+
bitmap = Glide.with(reactContext).asBitmap().load(bitmapUrl).diskCacheStrategy(DiskCacheStrategy.NONE).skipMemoryCache(true).submit(width, height1).get();
|
|
1857
|
+
}
|
|
1858
|
+
|
|
1859
|
+
PrinterHelper.getInstance().labelAddBitmap(bitmap, LabelBitmapStyle.getBitmapStyle()
|
|
1860
|
+
.setPosX(posX)
|
|
1861
|
+
.setPosY(posY)
|
|
1862
|
+
.setAlgorithm(imageAlgorithm)
|
|
1863
|
+
.setValue(value)
|
|
1864
|
+
.setWidth(width)
|
|
1865
|
+
.setHeight(height1)
|
|
1866
|
+
);
|
|
1867
|
+
promise.resolve(true);
|
|
1868
|
+
}catch (Exception e){
|
|
1869
|
+
Log.e("IminPrinter", "labelAddBitmap: "+e.getMessage());
|
|
1870
|
+
promise.resolve(false);
|
|
1871
|
+
}
|
|
1872
|
+
|
|
1873
|
+
}
|
|
1874
|
+
}
|
|
1875
|
+
|
|
1876
|
+
//打印标签样式的图片
|
|
1877
|
+
@ReactMethod
|
|
1878
|
+
public void printLabelBitmap(ReadableMap config, final Promise promise) {
|
|
1879
|
+
Log.e("IminPrinter", "printLabelBitmap: 打印标签样式的图片");
|
|
1880
|
+
if (iminPrintUtils == null) {
|
|
1881
|
+
|
|
1882
|
+
try {
|
|
1883
|
+
String bitmapUrl = config.getString("bitmapUrl");
|
|
1884
|
+
Integer width = (Integer) config.getInt("width");
|
|
1885
|
+
Integer height1 = (Integer) config.getInt("height");
|
|
1886
|
+
|
|
1887
|
+
Log.e("IminPrinter", "labelAddArea: 绘制特殊图形 " + ",width=" +
|
|
1888
|
+
width + " ,height1= " + height1 + " ,bitmapUrl= " + bitmapUrl );
|
|
1889
|
+
|
|
1890
|
+
Bitmap bitmap = null;
|
|
1891
|
+
if (bitmapUrl == null || bitmapUrl.isEmpty()) {
|
|
1892
|
+
promise.resolve(false);
|
|
1893
|
+
} else {
|
|
1894
|
+
bitmap = Glide.with(reactContext).asBitmap().load(bitmapUrl).diskCacheStrategy(DiskCacheStrategy.NONE).skipMemoryCache(true).submit(width, height1).get();
|
|
1895
|
+
}
|
|
1896
|
+
|
|
1897
|
+
PrinterHelper.getInstance().labelAddBitmap(bitmap, LabelBitmapStyle.getBitmapStyle()
|
|
1898
|
+
.setWidth(width)
|
|
1899
|
+
.setHeight(height1)
|
|
1900
|
+
);
|
|
1901
|
+
|
|
1902
|
+
promise.resolve(true);
|
|
1903
|
+
|
|
1904
|
+
} catch (Exception e) {
|
|
1905
|
+
Log.e("IminPrinter", "printLabelBitmap: 打印标签样式的图片 e " + e.getMessage());
|
|
1906
|
+
promise.resolve(false);
|
|
1907
|
+
}
|
|
1908
|
+
|
|
1909
|
+
}
|
|
1910
|
+
}
|
|
1911
|
+
|
|
1912
|
+
//绘制特殊图形
|
|
1913
|
+
@ReactMethod
|
|
1914
|
+
public void labelAddArea(ReadableMap config, final Promise promise) {
|
|
1915
|
+
if (iminPrintUtils == null) {
|
|
1916
|
+
Log.e("IminPrinter", "labelAddArea: 绘制特殊图形 " + config.getInt("style"));
|
|
1917
|
+
// 获取具体的参数
|
|
1918
|
+
if (config != null) {
|
|
1919
|
+
Integer style = config.getInt("style");
|
|
1920
|
+
Integer width = (Integer) config.getInt("width");
|
|
1921
|
+
Integer height1 = (Integer) config.getInt("height");
|
|
1922
|
+
Integer posX = (Integer) config.getInt("posX");
|
|
1923
|
+
Integer posY = (Integer) config.getInt("posY");
|
|
1924
|
+
Integer endX = (Integer) config.getInt("endX");
|
|
1925
|
+
Integer endY = (Integer) config.getInt("endY");
|
|
1926
|
+
Integer thick = (Integer) config.getInt("thick");
|
|
1927
|
+
Log.e("IminPrinter", "labelAddArea: 绘制特殊图形 " + style + ",width=" +
|
|
1928
|
+
width + " ,height1= " + height1 + " ,posX= " + posX + " ,posY= " + posY + " ,endX= " + endX + " ,endY= " + endY + " ,thick= " + thick);
|
|
1929
|
+
// 转换字符串到枚举
|
|
1930
|
+
Shape styleShape = Shape.values()[style];
|
|
1931
|
+
Log.e("IminPrinter", "labelAddArea: 绘制特殊图形 " + styleShape);
|
|
1932
|
+
PrinterHelper.getInstance().labelAddArea(LabelAreaStyle.getAreaStyle()
|
|
1933
|
+
.setStyle(styleShape)
|
|
1934
|
+
.setWidth(width)
|
|
1935
|
+
.setHeight(height1)
|
|
1936
|
+
.setPosX(posX)
|
|
1937
|
+
.setPosY(posY)
|
|
1938
|
+
.setEndX(endX)
|
|
1939
|
+
.setEndY(endY)
|
|
1940
|
+
.setThick(thick));
|
|
1941
|
+
promise.resolve(true);
|
|
1942
|
+
}
|
|
1943
|
+
}
|
|
1944
|
+
}
|
|
1945
|
+
|
|
1946
|
+
//打印绘制的内容
|
|
1947
|
+
@ReactMethod
|
|
1948
|
+
public void labelPrintCanvas(int printCount, final Promise promise) {
|
|
1949
|
+
if (iminPrintUtils == null) {
|
|
1950
|
+
Log.e("IminPrinter", "labelPrintCanvas: 打印绘制的内容 =>" + printCount);
|
|
1951
|
+
WritableMap payload = Arguments.createMap();
|
|
1952
|
+
PrinterHelper.getInstance().labelPrintCanvas(printCount, new ILabelPrintResult() {
|
|
1953
|
+
@Override
|
|
1954
|
+
public void onResult(int resultCode, String message) throws RemoteException {
|
|
1955
|
+
payload.putString("result", message);
|
|
1956
|
+
payload.putInt("resultCode",resultCode);
|
|
1957
|
+
promise.resolve(payload);
|
|
1958
|
+
}
|
|
1959
|
+
|
|
1960
|
+
@Override
|
|
1961
|
+
public IBinder asBinder() {
|
|
1962
|
+
return null;
|
|
1963
|
+
}
|
|
1964
|
+
});
|
|
1965
|
+
}
|
|
1966
|
+
}
|
|
1967
|
+
|
|
1968
|
+
//标签学习
|
|
1969
|
+
@ReactMethod
|
|
1970
|
+
public void labelLearning(final Promise promise) {
|
|
1971
|
+
if (iminPrintUtils == null) {
|
|
1972
|
+
WritableMap payload = Arguments.createMap();
|
|
1973
|
+
PrinterHelper.getInstance().labelPaperLearning(new INeoPrinterCallback() {
|
|
1974
|
+
@Override
|
|
1975
|
+
public void onRunResult(boolean isSuccess) throws RemoteException {
|
|
1976
|
+
|
|
1977
|
+
}
|
|
1978
|
+
|
|
1979
|
+
@Override
|
|
1980
|
+
public void onReturnString(String s) throws RemoteException {
|
|
1981
|
+
Log.e("IminPrinter", "labelLearning: 标签学习" + s);
|
|
1982
|
+
payload.putString("result", s);
|
|
1983
|
+
promise.resolve(payload);
|
|
1984
|
+
}
|
|
1985
|
+
|
|
1986
|
+
@Override
|
|
1987
|
+
public void onRaiseException(int code, String msg) throws RemoteException {
|
|
1988
|
+
|
|
1989
|
+
}
|
|
1990
|
+
|
|
1991
|
+
@Override
|
|
1992
|
+
public void onPrintResult(int code, String msg) throws RemoteException {
|
|
1993
|
+
|
|
1994
|
+
}
|
|
1995
|
+
});
|
|
1996
|
+
}
|
|
1997
|
+
}
|
|
1998
|
+
|
|
1999
|
+
//设置打印模式
|
|
2000
|
+
@ReactMethod
|
|
2001
|
+
public void setPrintModel(int printModel, final Promise promise) {
|
|
2002
|
+
if (iminPrintUtils == null) {
|
|
2003
|
+
Log.e("IminPrinter", "setPrintModel: 设置打印模式" + printModel);
|
|
2004
|
+
PrinterHelper.getInstance().setPrinterMode(printModel);
|
|
2005
|
+
promise.resolve(true);
|
|
2006
|
+
}
|
|
2007
|
+
}
|
|
2008
|
+
|
|
2009
|
+
private BroadcastReceiver createChargingStateBroadcastReceiver() {
|
|
2010
|
+
return new BroadcastReceiver() {
|
|
2011
|
+
@Override
|
|
2012
|
+
public void onReceive(Context context, Intent intent) {
|
|
2013
|
+
int status = intent.getIntExtra(ACTION_PRITER_STATUS, -1);
|
|
2014
|
+
Log.d(TAG, "打印机状态:" + intent.getAction());
|
|
2015
|
+
// 发送事件到React Native
|
|
2016
|
+
if (intent.getAction().equals(ACTION_PRITER_STATUS_CHANGE)) {
|
|
2017
|
+
WritableMap result = Arguments.createMap();
|
|
2018
|
+
WritableMap payload = Arguments.createMap();
|
|
2019
|
+
payload.putString("message", Utils.getInstance().getPrinterStatusText(status));
|
|
2020
|
+
payload.putString("code", String.format("%d", status));
|
|
2021
|
+
result.putMap("eventData", payload);
|
|
2022
|
+
result.putString("eventName", "printer_status");
|
|
2023
|
+
sendEvent(reactContext, "eventBroadcast", result);
|
|
2024
|
+
}
|
|
2025
|
+
}
|
|
2026
|
+
};
|
|
2027
|
+
}
|
|
2028
|
+
|
|
2029
|
+
private void initializeBroadcastReceiver() {
|
|
2030
|
+
IntentFilter intentFilter = new IntentFilter();
|
|
2031
|
+
mBroadcastReceiver = createChargingStateBroadcastReceiver();
|
|
2032
|
+
intentFilter.addAction(ACTION_PRITER_STATUS_CHANGE);
|
|
2033
|
+
intentFilter.addAction(ACTION_POGOPIN_STATUS_CHANGE);
|
|
2034
|
+
getReactApplicationContext().registerReceiver(mBroadcastReceiver, intentFilter);
|
|
2035
|
+
}
|
|
2036
|
+
|
|
2037
|
+
@ReactMethod
|
|
2038
|
+
public void addListener(String eventName) {
|
|
2039
|
+
}
|
|
2040
|
+
|
|
2041
|
+
@ReactMethod
|
|
2042
|
+
public void removeListeners(Integer count) {
|
|
2043
|
+
}
|
|
2044
|
+
|
|
2045
|
+
@Override
|
|
2046
|
+
public Map<String, Object> getConstants() {
|
|
2047
|
+
final Map<String, Object> constants = new HashMap<>();
|
|
2048
|
+
constants.put("SDK_VERSION_IMIN", sdkVersion);
|
|
2049
|
+
return constants;
|
|
2050
|
+
}
|
|
2051
|
+
|
|
2052
|
+
}
|