@ruhiverse/thermal-printer-plugin 1.0.13 → 1.0.15

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.
@@ -1,7 +1,5 @@
1
1
  package com.ruhiverse.thermalprinter;
2
2
 
3
- import android.app.AlertDialog;
4
- import android.app.ProgressDialog;
5
3
  import android.content.Context;
6
4
  import android.os.AsyncTask;
7
5
 
@@ -28,7 +26,6 @@ public abstract class AsyncEscPosPrint extends AsyncTask<AsyncEscPosPrinter, Int
28
26
  protected final static int PROGRESS_PRINTING = 3;
29
27
  protected final static int PROGRESS_PRINTED = 4;
30
28
 
31
- protected ProgressDialog dialog;
32
29
  protected WeakReference<Context> weakContext;
33
30
  protected OnPrintFinished onPrintFinished;
34
31
 
@@ -95,91 +92,14 @@ public abstract class AsyncEscPosPrint extends AsyncTask<AsyncEscPosPrinter, Int
95
92
  }
96
93
 
97
94
  protected void onPreExecute() {
98
- if (this.dialog == null) {
99
- Context context = weakContext.get();
100
-
101
- if (context == null) {
102
- return;
103
- }
104
-
105
- this.dialog = new ProgressDialog(context);
106
- this.dialog.setTitle("Printing in progress...");
107
- this.dialog.setMessage("...");
108
- this.dialog.setProgressNumberFormat("%1d / %2d");
109
- this.dialog.setCancelable(false);
110
- this.dialog.setIndeterminate(false);
111
- this.dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
112
- this.dialog.show();
113
- }
95
+ // No UI progress is handled silently
114
96
  }
115
97
 
116
98
  protected void onProgressUpdate(Integer... progress) {
117
- switch (progress[0]) {
118
- case AsyncEscPosPrint.PROGRESS_CONNECTING:
119
- this.dialog.setMessage("Connecting printer...");
120
- break;
121
- case AsyncEscPosPrint.PROGRESS_CONNECTED:
122
- this.dialog.setMessage("Printer is connected...");
123
- break;
124
- case AsyncEscPosPrint.PROGRESS_PRINTING:
125
- this.dialog.setMessage("Printer is printing...");
126
- break;
127
- case AsyncEscPosPrint.PROGRESS_PRINTED:
128
- this.dialog.setMessage("Printer has finished...");
129
- break;
130
- }
131
- this.dialog.setProgress(progress[0]);
132
- this.dialog.setMax(4);
99
+ // No UI — progress is handled silently
133
100
  }
134
101
 
135
102
  protected void onPostExecute(PrinterStatus result) {
136
- this.dialog.dismiss();
137
- this.dialog = null;
138
-
139
- Context context = weakContext.get();
140
-
141
- if (context == null) {
142
- return;
143
- }
144
-
145
- switch (result.getPrinterStatus()) {
146
- case AsyncEscPosPrint.FINISH_SUCCESS:
147
- new AlertDialog.Builder(context)
148
- .setTitle("Success")
149
- .setMessage("Print completed successfully!")
150
- .show();
151
- break;
152
- case AsyncEscPosPrint.FINISH_NO_PRINTER:
153
- new AlertDialog.Builder(context)
154
- .setTitle("No printer")
155
- .setMessage("The application can't find any printer connected.")
156
- .show();
157
- break;
158
- case AsyncEscPosPrint.FINISH_PRINTER_DISCONNECTED:
159
- new AlertDialog.Builder(context)
160
- .setTitle("Broken connection")
161
- .setMessage("Unable to connect the printer.")
162
- .show();
163
- break;
164
- case AsyncEscPosPrint.FINISH_PARSER_ERROR:
165
- new AlertDialog.Builder(context)
166
- .setTitle("Invalid formatted text")
167
- .setMessage("It seems to be an invalid syntax problem.")
168
- .show();
169
- break;
170
- case AsyncEscPosPrint.FINISH_ENCODING_ERROR:
171
- new AlertDialog.Builder(context)
172
- .setTitle("Bad selected encoding")
173
- .setMessage("The selected encoding character returning an error.")
174
- .show();
175
- break;
176
- case AsyncEscPosPrint.FINISH_BARCODE_ERROR:
177
- new AlertDialog.Builder(context)
178
- .setTitle("Invalid barcode")
179
- .setMessage("Data send to be converted to barcode or QR code seems to be invalid.")
180
- .show();
181
- break;
182
- }
183
103
  if(this.onPrintFinished != null) {
184
104
  if (result.getPrinterStatus() == AsyncEscPosPrint.FINISH_SUCCESS) {
185
105
  this.onPrintFinished.onSuccess(result.getAsyncEscPosPrinter());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ruhiverse/thermal-printer-plugin",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "Capacitor plugin for thermal printing via USB and Bluetooth",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",