Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Printer reworked #138

Closed
wants to merge 108 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
d455f6e
chore: release 1.5.0
tr3v3r Nov 22, 2021
a2b5c5f
refactor: move ios sdk to separate package
tr3v3r Jan 15, 2022
e774b7e
fix: remove sdk files from repo
tr3v3r Jan 15, 2022
40190c9
fix: bump version
tr3v3r Jan 16, 2022
9c5a96f
chore: release 1.7.0
tr3v3r Jan 16, 2022
1898db8
fix: npm script
tr3v3r Jan 26, 2022
b2d25a9
chore: release 1.7.1
tr3v3r Jan 26, 2022
608628e
feat: update android SDK to v.2.19.0
tr3v3r Jan 28, 2022
67fcd5b
chore: release 1.8.0
tr3v3r Jan 28, 2022
ec86512
[fix]typo
Feb 9, 2022
1df48c5
Merge pull request #48 from kiyohken2000/PullRequest
tr3v3r Feb 9, 2022
71c2d33
feat: add the option in android to finish discovery when the first pr…
israelko Mar 20, 2022
9ef8572
feat: add the option to specify the print command (send) timeout
israelko Mar 20, 2022
6ffb1ef
lint fixes
israelko Mar 20, 2022
25379f2
pr fixes:
israelko Mar 21, 2022
61485ec
more pr fixes - moved consts to constants.ts and added the android di…
israelko Mar 21, 2022
7c697e8
Merge pull request #52 from wix-playground/main
tr3v3r Mar 21, 2022
ce75325
fix: bump to 1.9.0
tr3v3r Mar 21, 2022
cc33d7c
chore: release 1.10.0
tr3v3r Mar 21, 2022
2f47f7b
feat: extract android and iOS SDK to separate npm package
tr3v3r Mar 22, 2022
be421e0
docs: update docs and scripts
tr3v3r Mar 23, 2022
9dfc162
chore: release 1.11.0
tr3v3r Mar 23, 2022
dc3ed78
Update SDK.md
tr3v3r Mar 23, 2022
0d88a40
Update SDK.md
tr3v3r Mar 23, 2022
d9a4a2c
Fix move lib script.
fragilehm Jun 22, 2022
7d18ab1
Update pod version.
fragilehm Jun 23, 2022
959d432
Added react, react-native types to the example
fragilehm Jun 23, 2022
806fb0a
Added multi print files
fragilehm Jun 23, 2022
f51a911
Added instantiate function that will create a new instance for the ta…
fragilehm Jun 28, 2022
3ddbbf2
Added target to IPrint params for routing the print job to a specific…
fragilehm Jun 28, 2022
efe87c8
Expose connect printer by target method.
fragilehm Jun 28, 2022
c09233b
Assing the new instance once after initialising a printer if already …
fragilehm Jun 28, 2022
50390f5
Connect the printer after initialising.
fragilehm Jun 28, 2022
35a48a2
Updated ios info plist to support bluetooth printers for example projec.
fragilehm Jun 30, 2022
e346177
Do not add the new instance of a printer if already exists.
fragilehm Jun 30, 2022
d734769
Prevent initializing the printer if already initialized.
fragilehm Jun 30, 2022
8a7c837
Expose printer disconnect printer.
fragilehm Jun 30, 2022
38516b6
Rename to disconnectPrinter
fragilehm Jun 30, 2022
0b63a17
Upgrade react-native-builder-bob
fragilehm Jul 7, 2022
797e6f9
Added multi print to example.
fragilehm Jul 7, 2022
b1f1e7f
Upgrade the IPHONEOS_DEPLOYMENT_TARGET to 11.0
fragilehm Jul 7, 2022
5098153
Update Test multi print title -> Test multi-print.
fragilehm Jul 7, 2022
06a1efb
Added init all button.
fragilehm Jul 7, 2022
9bc74bb
Address comments.
fragilehm Jul 16, 2022
092574b
Merge pull request #66 from fragilehm/feature/multi-print-ios
tr3v3r Jul 17, 2022
8f8fe52
fix: comment unussed code
Jul 17, 2022
e9f7e81
chore: release 1.11.2
Jul 17, 2022
ac8c804
chore: release 2.0.0
Jul 17, 2022
2816966
Increase the jvmargs to prevent OutOfMemory when runnning and Android…
fragilehm Aug 25, 2022
bd0a077
Upgrade react-native-esc-pos-printer version (2.0.0)
fragilehm Aug 31, 2022
b3e548e
Update Android project settings
fragilehm Aug 31, 2022
78c00c9
on Android discover paired bluetooth printers, display usb names.
fragilehm Aug 31, 2022
39cf886
Add Android helper classes.
fragilehm Aug 31, 2022
479c0ba
Extend printer series list.
fragilehm Aug 31, 2022
7f0de8a
Expose ThePrinterWrapper Android native module.
fragilehm Aug 31, 2022
66c3765
Implemented Android epson module methods to support multi-print.
fragilehm Aug 31, 2022
e010277
Remove OS check when printing with printer target.
fragilehm Aug 31, 2022
3e13913
Added try catch on connect/disconnect multi-print example.
fragilehm Aug 31, 2022
7c34000
Catch the print errors on multi-print.
fragilehm Aug 31, 2022
f4ae86f
Make sure the resolve/reject when disconnectAndDeallocate is called o…
fragilehm Aug 31, 2022
818aed4
Fix handleCommand declaration.
fragilehm Aug 31, 2022
191570d
Extend support printer list iOS
fragilehm Aug 31, 2022
9d4582c
Update docs.
fragilehm Aug 31, 2022
75f1a27
Skip local printers on Android.
fragilehm Aug 31, 2022
18c976f
Merge pull request #68 from fragilehm/feature/multi-print-android
tr3v3r Sep 10, 2022
d0c2927
chore: release v2.1.0
tr3v3r Sep 10, 2022
c778426
feat(updated): update SDK to 2.22
tr3v3r Nov 10, 2022
990ddad
chore: release 2.2.0
tr3v3r Nov 10, 2022
b2577e2
fix(updated): update example react-native version to 0.70.5, update b…
tr3v3r Nov 11, 2022
12fccc4
chore: release 2.2.1
tr3v3r Nov 11, 2022
1325b9e
docs(added): add docs how to run lib with expo go
tr3v3r Nov 13, 2022
02c4945
feat: adds textLine method to render text aligned on left and right
tr3v3r Nov 25, 2022
20d5bd5
docs: update docs for textLine
tr3v3r Nov 26, 2022
97c05e1
feat: adds android x86_64 arch support
tr3v3r Nov 26, 2022
c454394
docs: align image
tr3v3r Nov 26, 2022
e57f9e6
chore: release 2.3.0
tr3v3r Nov 26, 2022
74c6a3d
Update README.md
tr3v3r Nov 26, 2022
335ec5d
Update README.md
tr3v3r Dec 4, 2022
d3f8526
Update INSTALLATION.md
tr3v3r Jan 31, 2023
ae8c7b4
feat: upgrade SDK version to 2.23 for iOS and Android
tr3v3r Feb 16, 2023
3208e86
chore: release 2.4.0
tr3v3r Feb 16, 2023
96e83a8
fix Readme SDK version
tr3v3r Feb 16, 2023
80e163a
feat(types): change type.
chenzesam Mar 7, 2023
c4d8ad7
Merge pull request #103 from chenzesam/feature/types
tr3v3r Mar 10, 2023
06b6709
fix(fixed): ask required permission for Android before discover
tr3v3r Mar 26, 2023
3cce776
chore: release 2.5.0
tr3v3r Mar 26, 2023
0acbb6e
fix(fixed): fixed iOS duplicate headers issues
tr3v3r Mar 26, 2023
f3bca7e
chore: release 2.5.1
tr3v3r Mar 26, 2023
d8570d6
fix: no trim for wordwrap
tolypash Aug 28, 2023
f3aca79
fix: tests
tolypash Aug 28, 2023
194babe
feat: no trim in ISpaceBetweenParams
tolypash Aug 30, 2023
b4d788e
Merge pull request #117 from tolypash/text-line-no-trim-fix
tr3v3r Aug 30, 2023
76a420d
chore: release 2.6.0
tr3v3r Aug 30, 2023
13f4cee
fix(fixed): add workaround example
tr3v3r Sep 2, 2023
bed5d00
feat(changed): update discovery API
tr3v3r Nov 11, 2023
e8fd49c
feat: update example folder. up react-native to latest one, up iOS an…
tr3v3r Nov 11, 2023
7d83e8b
docs: update docs
tr3v3r Nov 11, 2023
78e95b0
fix: update android and docs
tr3v3r Nov 12, 2023
538eee5
Merge pull request #123 from tr3v3r/new-discovery-api
tr3v3r Nov 12, 2023
fd0eb4f
fix typescripy error
tr3v3r Nov 12, 2023
44fff8a
chore: release v3.0.0
tr3v3r Nov 12, 2023
07d0adb
Update QUICK_START.md
tr3v3r Nov 13, 2023
20a9b54
inlcude scripts to bundled package
tr3v3r Nov 17, 2023
760fe86
inlcude scripts to bundled package
tr3v3r Nov 17, 2023
5502037
chore: release v3.0.1
tr3v3r Nov 17, 2023
192ddbe
add support of using multiple printing but with init
tr3v3r Nov 22, 2023
11723c6
feat(changed): rework printer architecture
tr3v3r Mar 11, 2024
45db33b
resolve conflicts
tr3v3r Mar 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
286 changes: 34 additions & 252 deletions android/src/main/java/com/reactnativeescposprinter/EposStringHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,254 +15,34 @@
import org.json.JSONObject;

import java.util.Locale;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.WritableMap;

public class EposStringHelper {

public static JSONObject makeStatusMessage(PrinterStatusInfo statusInfo) {

String connection = "";
String online = "";
String coverOpen = "";
String paper = "";
String paperFeed = "";
String panelSwitch = "";
String drawer = "";
String errorStatus = "";
String autoRecoverErr = "";
String adapter = "";
String batteryLevel = "";
String paperWait = "";


switch (statusInfo.getConnection()) {
case Printer.TRUE:
connection = "CONNECT";
break;
case Printer.FALSE:
connection = "DISCONNECT";
break;
case Printer.UNKNOWN:
connection = "UNKNOWN";
break;
default:
break;
}

switch (statusInfo.getOnline()) {
case Printer.TRUE:
online = "ONLINE";
break;
case Printer.FALSE:
online = "OFFLINE";
break;
case Printer.UNKNOWN:
online = "UNKNOWN";
break;
default:
break;
}

switch (statusInfo.getCoverOpen()) {
case Printer.TRUE:
coverOpen = "COVER_OPEN";
break;
case Printer.FALSE:
coverOpen = "COVER_CLOSE";
break;
case Printer.UNKNOWN:
coverOpen = "UNKNOWN";
break;
default:
break;
}

switch (statusInfo.getPaper()) {
case Printer.PAPER_OK:
paper = "PAPER_OK";
break;
case Printer.PAPER_NEAR_END:
paper = "PAPER_NEAR_END";
break;
case Printer.PAPER_EMPTY:
paper = "PAPER_EMPTY";
break;
case Printer.UNKNOWN:
paper = "UNKNOWN";
break;
default:
break;
}

switch (statusInfo.getPaperFeed()) {
case Printer.TRUE:
paperFeed = "PAPER_FEED";
break;
case Printer.FALSE:
paperFeed = "PAPER_STOP";
break;
case Printer.UNKNOWN:
paperFeed = "UNKNOWN";
break;
default:
break;
}

switch (statusInfo.getPanelSwitch()) {
case Printer.TRUE:
panelSwitch = "SWITCH_ON";
break;
case Printer.FALSE:
panelSwitch = "SWITCH_OFF";
break;
case Printer.UNKNOWN:
panelSwitch = "UNKNOWN";
break;
default:
break;
}

switch (statusInfo.getDrawer()) {
case Printer.DRAWER_HIGH:
//This status depends on the drawer setting.
drawer = "DRAWER_HIGH(Drawer close)";
break;
case Printer.DRAWER_LOW:
//This status depends on the drawer setting.
drawer = "DRAWER_LOW(Drawer open)";
break;
case Printer.UNKNOWN:
drawer = "UNKNOWN";
break;
default:
break;
}

switch (statusInfo.getErrorStatus()) {
case Printer.NO_ERR:
errorStatus = "NO_ERR";
break;
case Printer.MECHANICAL_ERR:
errorStatus = "MECHANICAL_ERR";
break;
case Printer.AUTOCUTTER_ERR:
errorStatus = "AUTOCUTTER_ERR";
break;
case Printer.UNRECOVER_ERR:
errorStatus = "UNRECOVER_ERR";
break;
case Printer.AUTORECOVER_ERR:
errorStatus = "AUTOCUTTER_ERR";
break;
case Printer.UNKNOWN:
errorStatus = "UNKNOWN";
break;
default:
break;
}

switch (statusInfo.getAutoRecoverError()) {
case Printer.HEAD_OVERHEAT:
autoRecoverErr = "HEAD_OVERHEAT";
break;
case Printer.MOTOR_OVERHEAT:
autoRecoverErr = "MOTOR_OVERHEAT";
break;
case Printer.BATTERY_OVERHEAT:
autoRecoverErr = "BATTERY_OVERHEAT";
break;
case Printer.WRONG_PAPER:
autoRecoverErr = "WRONG_PAPER";
break;
case Printer.COVER_OPEN:
autoRecoverErr = "COVER_OPEN";
break;
case Printer.UNKNOWN:
autoRecoverErr = "UNKNOWN";
break;
default:
break;
}

switch (statusInfo.getAdapter()) {
case Printer.TRUE:
adapter = "AC ADAPTER CONNECT";
break;
case Printer.FALSE:
adapter = "AC ADAPTER DISCONNECT";
break;
case Printer.UNKNOWN:
adapter = "UNKNOWN";
break;
default:
break;
}

switch (statusInfo.getBatteryLevel()) {
case Printer.BATTERY_LEVEL_0:
batteryLevel = "BATTERY_LEVEL_0";
break;
case Printer.BATTERY_LEVEL_1:
batteryLevel = "BATTERY_LEVEL_1";
break;
case Printer.BATTERY_LEVEL_2:
batteryLevel = "BATTERY_LEVEL_2";
break;
case Printer.BATTERY_LEVEL_3:
batteryLevel = "BATTERY_LEVEL_3";
break;
case Printer.BATTERY_LEVEL_4:
batteryLevel = "BATTERY_LEVEL_4";
break;
case Printer.BATTERY_LEVEL_5:
batteryLevel = "BATTERY_LEVEL_5";
break;
case Printer.BATTERY_LEVEL_6:
batteryLevel = "BATTERY_LEVEL_6";
break;
case Printer.UNKNOWN:
batteryLevel = "UNKNOWN";
break;
default:
break;
}

switch (statusInfo.getRemovalWaiting()) {
case Printer.EVENT_REMOVAL_WAIT_PAPER:
paperWait = "WAITING_FOR_PAPER_REMOVAL";
break;
case Printer.EVENT_REMOVAL_WAIT_NONE:
paperWait = "NOT_WAITING_FOR_PAPER_REMOVAL";
break;
case Printer.UNKNOWN:
paperWait = "UNKNOWN";
break;
default:
break;
}

JSONObject jsonStatus = new JSONObject();
try {
jsonStatus.put("connection", connection);
jsonStatus.put("online",online);
jsonStatus.put("coverOpen",coverOpen);
jsonStatus.put("paper",paper);
jsonStatus.put("paperFeed",paperFeed);
jsonStatus.put("panelSwitch",panelSwitch);
jsonStatus.put("drawer",drawer);
jsonStatus.put("errorStatus",errorStatus);
jsonStatus.put("autoRecoverErr",autoRecoverErr);
jsonStatus.put("adapter",adapter);
jsonStatus.put("batteryLevel",batteryLevel);
jsonStatus.put("paperWait",paperWait);

} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

return jsonStatus;
public static WritableMap convertStatusInfoToWritableMap(PrinterStatusInfo statusInfo) {
WritableMap statusMessage = Arguments.createMap();

statusMessage.putInt("connection",statusInfo.getConnection());
statusMessage.putInt("online",statusInfo.getOnline());
statusMessage.putInt("coverOpen",statusInfo.getCoverOpen());
statusMessage.putInt("paper",statusInfo.getPaper());
statusMessage.putInt("paperFeed",statusInfo.getPaperFeed());
statusMessage.putInt("panelSwitch",statusInfo.getPanelSwitch());
statusMessage.putInt("drawer",statusInfo.getDrawer());
statusMessage.putInt("errorStatus",statusInfo.getErrorStatus());
statusMessage.putInt("autoRecoverError",statusInfo.getAutoRecoverError());
statusMessage.putInt("buzzer",statusInfo.getBuzzer());
statusMessage.putInt("adapter",statusInfo.getAdapter());
statusMessage.putInt("batteryLevel", statusInfo.getBatteryLevel());
statusMessage.putInt("removalWaiting", statusInfo.getRemovalWaiting());
statusMessage.putInt("paperTakenSensor", statusInfo.getPaperTakenSensor());
statusMessage.putInt("unrecoverError", statusInfo.getUnrecoverError());

return statusMessage;
}

}

public static String convertPrintSpeedEnum2String(int speedEnum, @NonNull Context context) {

Expand Down Expand Up @@ -699,17 +479,17 @@ public static int getPrinterSeries(final String deviceName) {

if (deviceName == null || deviceName.isEmpty()) return Printer.TM_T88;

if (deviceName.startsWith("TM-T88VII")) return Printer.TM_T88VII;
if (deviceName.startsWith("TM-m30II")) return Printer.TM_M30II;
if (deviceName.startsWith("TM-m10")) return Printer.TM_M10;
if (deviceName.startsWith("TM-m30")) return Printer.TM_M30;
if (deviceName.startsWith("TM-L90LFC")) return Printer.TM_L90LFC;
if (deviceName.startsWith("TM-L90")) return Printer.TM_L90;
if (deviceName.startsWith("TM-m30III")) return Printer.TM_M30III;
if (deviceName.startsWith("TM-m30II")) return Printer.TM_M30II;
if (deviceName.startsWith("TM-m50II")) return Printer.TM_M50II;
if (deviceName.startsWith("TM-m50")) return Printer.TM_M50;
if (deviceName.startsWith("TM-L100")) return Printer.TM_L100;
if (deviceName.startsWith("TM-m10")) return Printer.TM_M10;
if (deviceName.startsWith("TM-P20II")) return Printer.TM_P20II;
if (deviceName.startsWith("TM-P20")) return Printer.TM_P20;
if (deviceName.startsWith("TM-P60II")) return Printer.TM_P60II;
if (deviceName.startsWith("TM-P60")) return Printer.TM_P60;
if (deviceName.startsWith("TM-P80II")) return Printer.TM_P80II;
if (deviceName.startsWith("TM-P80")) return Printer.TM_P80;
if (deviceName.startsWith("TM-T20")) return Printer.TM_T20;
if (deviceName.startsWith("TM-T60")) return Printer.TM_T60;
Expand All @@ -718,14 +498,16 @@ public static int getPrinterSeries(final String deviceName) {
if (deviceName.startsWith("TM-T82")) return Printer.TM_T82;
if (deviceName.startsWith("TM-T83III")) return Printer.TM_T83III;
if (deviceName.startsWith("TM-T83")) return Printer.TM_T83;
if (deviceName.startsWith("TM-T88VII")) return Printer.TM_T88VII;
if (deviceName.startsWith("TM-T88")) return Printer.TM_T88;
if (deviceName.startsWith("TM-T90KP")) return Printer.TM_T90KP;
if (deviceName.startsWith("TM-T90")) return Printer.TM_T90;
if (deviceName.startsWith("TM-T100")) return Printer.TM_T100;
if (deviceName.startsWith("TM-U220")) return Printer.TM_U220;
if (deviceName.startsWith("TM-U330")) return Printer.TM_U330;
if (deviceName.startsWith("TM-L90LFC")) return Printer.TM_L90LFC;
if (deviceName.startsWith("TM-L90")) return Printer.TM_L90;
if (deviceName.startsWith("TM-L100")) return Printer.TM_L100;
if (deviceName.startsWith("TM-H6000")) return Printer.TM_H6000;
if (deviceName.startsWith("TM-T100")) return Printer.TM_T100;
if (deviceName.startsWith("TS-100")) return Printer.TS_100;

return Printer.TM_T88;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,11 @@
import com.google.android.gms.common.api.ResolvableApiException;
import com.google.android.gms.common.api.CommonStatusCodes;

import com.google.android.gms.common.GoogleApiAvailability;
import com.google.android.gms.common.ConnectionResult;


@ReactModule(name = EscPosPrinterDiscoveryModule.NAME)
public class EscPosPrinterDiscoveryModule extends ReactContextBaseJavaModule implements ActivityEventListener {

private Context mContext;
private WritableArray mPrinterList = null;
private final ReactApplicationContext reactContext;

public static final String NAME = "EscPosPrinterDiscovery";
Expand Down Expand Up @@ -113,20 +110,8 @@ public void onNewIntent(Intent intent) {

}


public boolean isGoogleServiceAvailable() {
return GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(reactContext) == ConnectionResult.SUCCESS;
}

@ReactMethod
public void enableLocationSetting(Promise promise) {
boolean isGoogleServiceAvailable = isGoogleServiceAvailable();

if (!isGoogleServiceAvailable) {
promise.resolve("SUCCESS");
return;
}

Activity currentActivity = getCurrentActivity();
if (currentActivity == null) {
promise.reject("Activity doesn't exist", "");
Expand Down Expand Up @@ -181,6 +166,7 @@ private void sendEvent(ReactApplicationContext reactContext, String eventName, @
@ReactMethod
private void startDiscovery(final ReadableMap paramsMap, Promise promise) {
FilterOption mFilterOption = getFilterOptionsFromParams(paramsMap);
mPrinterList = Arguments.createArray();

try {
Discovery.start(mContext, mFilterOption, mDiscoveryListener);
Expand Down Expand Up @@ -244,7 +230,6 @@ public void onDiscovery(final DeviceInfo deviceInfo) {
UiThreadUtil.runOnUiThread(new Runnable() {
@Override
public synchronized void run() {
WritableArray mPrinterList = Arguments.createArray();
WritableMap printerData = Arguments.createMap();


Expand Down
Loading
Loading