@captureid/capacitor-cidprint 5.0.15 → 5.0.17
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.
|
Binary file
|
|
@@ -3,6 +3,7 @@ package app.captureid.plugins.cidprint;
|
|
|
3
3
|
import android.Manifest;
|
|
4
4
|
import android.content.Intent;
|
|
5
5
|
import android.content.pm.ApplicationInfo;
|
|
6
|
+
import android.os.Build;
|
|
6
7
|
import android.util.Log;
|
|
7
8
|
import android.util.Size;
|
|
8
9
|
import android.view.Window;
|
|
@@ -24,9 +25,9 @@ import org.json.JSONException;
|
|
|
24
25
|
import org.json.JSONObject;
|
|
25
26
|
import java.util.HashMap;
|
|
26
27
|
import java.util.Iterator;
|
|
27
|
-
import java.util.List;
|
|
28
28
|
|
|
29
29
|
import androidx.activity.result.ActivityResult;
|
|
30
|
+
import androidx.annotation.RequiresApi;
|
|
30
31
|
import androidx.appcompat.app.AppCompatActivity;
|
|
31
32
|
import androidx.core.view.WindowCompat;
|
|
32
33
|
import androidx.core.view.WindowInsetsCompat;
|
|
@@ -40,13 +41,14 @@ import app.captureid.cidprinterlibrary.notifications.PrinterLibraryListener;
|
|
|
40
41
|
import app.captureid.cidprinterlibrary.printers.PrinterInformation;
|
|
41
42
|
import app.captureid.cidprinterlibrary.utils.PrinterUtils;
|
|
42
43
|
|
|
44
|
+
@RequiresApi(api = Build.VERSION_CODES.S)
|
|
43
45
|
@CapacitorPlugin(
|
|
44
46
|
permissions = {
|
|
45
47
|
@Permission(strings = { Manifest.permission.ACCESS_COARSE_LOCATION }, alias = "android.permission.ACCESS_COARSE_LOCATION"),
|
|
46
48
|
@Permission(strings = { Manifest.permission.BLUETOOTH_ADMIN }, alias = "android.permission.BLUETOOTH_ADMIN"),
|
|
47
49
|
@Permission(strings = { Manifest.permission.BLUETOOTH }, alias = "android.permission.BLUETOOTH"),
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
@Permission(strings = { Manifest.permission.BLUETOOTH_CONNECT }, alias = "bluetooth_connect"),
|
|
51
|
+
@Permission(strings = { Manifest.permission.BLUETOOTH_SCAN }, alias = "bluetooth_scan"),
|
|
50
52
|
@Permission(strings = { Manifest.permission.ACCESS_FINE_LOCATION }, alias = "android.permission.ACCESS_FINE_LOCATION"),
|
|
51
53
|
@Permission(strings = { Manifest.permission.INTERNET }, alias = "Manifest.permission.INTERNET"),
|
|
52
54
|
@Permission(strings = { Manifest.permission.WRITE_EXTERNAL_STORAGE }, alias = "Manifest.permission.WRITE_EXTERNAL_STORAGE"),
|
|
@@ -156,7 +158,11 @@ public class CIDPrint extends Plugin {
|
|
|
156
158
|
if(_isInitialized) {
|
|
157
159
|
// store the PluginCall instance to notify the caller in a later step
|
|
158
160
|
addCallback("connectToPreferredPrinter", call);
|
|
159
|
-
_printerlibrary.connectToPreferredPrinter(
|
|
161
|
+
_printerlibrary.connectToPreferredPrinter(
|
|
162
|
+
call.getString("mac"),
|
|
163
|
+
call.getBoolean("autoreconnect") == null? false:call.getBoolean("autoreconnect"),
|
|
164
|
+
call.getInt("timeout", 15000)
|
|
165
|
+
);
|
|
160
166
|
}
|
|
161
167
|
}
|
|
162
168
|
|
|
@@ -171,7 +177,11 @@ public class CIDPrint extends Plugin {
|
|
|
171
177
|
public void connectToPrinter(PluginCall call) {
|
|
172
178
|
if(_isInitialized) {
|
|
173
179
|
boolean reconnect = call.getBoolean("autoreconnect") == null?false:call.getBoolean("autoreconnect");
|
|
174
|
-
_printerlibrary.connectToPrinter(
|
|
180
|
+
_printerlibrary.connectToPrinter(
|
|
181
|
+
call.getString("address"),
|
|
182
|
+
reconnect,
|
|
183
|
+
call.getInt("timeout", 15000)
|
|
184
|
+
);
|
|
175
185
|
}
|
|
176
186
|
}
|
|
177
187
|
|
|
@@ -580,11 +590,11 @@ public class CIDPrint extends Plugin {
|
|
|
580
590
|
_printerlibrary.print(call.getString("label"), call.getArray("data").toList().toArray(new String[call.getArray("data").toList().size()]));
|
|
581
591
|
}
|
|
582
592
|
} catch(JSONException ex) {
|
|
583
|
-
Log.
|
|
593
|
+
Log.e(TAG, "printLabelWithData: " + ex.getMessage());
|
|
584
594
|
} catch(ClassCastException ex) {
|
|
585
|
-
Log.
|
|
595
|
+
Log.e(TAG, "printLabelWithData: " + ex.getMessage());
|
|
586
596
|
} catch(Exception ex) {
|
|
587
|
-
Log.
|
|
597
|
+
Log.e(TAG, "printLabelWithData: " + ex.getMessage());
|
|
588
598
|
}
|
|
589
599
|
}
|
|
590
600
|
|
|
@@ -606,11 +616,11 @@ public class CIDPrint extends Plugin {
|
|
|
606
616
|
LOG("print command sent to library");
|
|
607
617
|
}
|
|
608
618
|
} catch(JSONException ex) {
|
|
609
|
-
Log.
|
|
619
|
+
Log.e(TAG, "printLabelWithData: " + ex.getMessage());
|
|
610
620
|
} catch(ClassCastException ex) {
|
|
611
|
-
Log.
|
|
621
|
+
Log.e(TAG, "printLabelWithData: " + ex.getMessage());
|
|
612
622
|
} catch(Exception ex) {
|
|
613
|
-
Log.
|
|
623
|
+
Log.e(TAG, "printLabelWithData: " + ex.getMessage());
|
|
614
624
|
}
|
|
615
625
|
}
|
|
616
626
|
|
|
@@ -639,11 +649,11 @@ public class CIDPrint extends Plugin {
|
|
|
639
649
|
_printerlibrary.printReceipt(call.getString("label"), call.getData().getJSONObject("data"));
|
|
640
650
|
}
|
|
641
651
|
} catch(JSONException ex) {
|
|
642
|
-
Log.
|
|
652
|
+
Log.e(TAG, "printReceiptWithObject: " + ex.getMessage());
|
|
643
653
|
} catch(ClassCastException ex) {
|
|
644
|
-
Log.
|
|
654
|
+
Log.e(TAG, "printReceiptWithObject: " + ex.getMessage());
|
|
645
655
|
} catch(Exception ex) {
|
|
646
|
-
Log.
|
|
656
|
+
Log.e(TAG, "printReceiptWithObject: " + ex.getMessage());
|
|
647
657
|
}
|
|
648
658
|
}
|
|
649
659
|
|
|
@@ -772,7 +782,7 @@ public class CIDPrint extends Plugin {
|
|
|
772
782
|
// break;
|
|
773
783
|
// }
|
|
774
784
|
} catch(Exception ex) {
|
|
775
|
-
Log.
|
|
785
|
+
Log.e(TAG, "handleSuccess: " + ex.getMessage());
|
|
776
786
|
}
|
|
777
787
|
}
|
|
778
788
|
|