@scrumble-nl/react-native-honeywell-scanner 1.0.66 → 1.0.68

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.
@@ -5,6 +5,8 @@ import android.util.Log;
5
5
  import android.os.Bundle;
6
6
  import android.app.AlertDialog;
7
7
  import android.content.DialogInterface;
8
+ import android.widget.Toast;
9
+ import android.app.Activity;
8
10
 
9
11
  import com.facebook.react.bridge.*;
10
12
  import com.facebook.react.modules.core.DeviceEventManagerModule;
@@ -75,38 +77,40 @@ public class HoneywellScannerModule extends ReactContextBaseJavaModule implement
75
77
  sendEvent(BARCODE_READ_FAIL, params);
76
78
  }
77
79
 
80
+ public void onDeviceChange(BarcodeReaderInfo barcodeReaderInfo) {
81
+ WritableMap params = Arguments.createMap();
82
+ params.putString("data", barcodeReaderInfo.getName());
83
+ sendEvent(DEVICE_CHANGE, params);
84
+ }
85
+
78
86
  /*******************************/
79
87
  /** Methods Available from JS **/
80
88
  /*******************************/
81
89
 
82
90
  @ReactMethod
83
- public void startReader(final Promise promise) {
91
+ public void startReader() {
84
92
  AidcManager.create(reactContext, new CreatedCallback() {
85
93
  @Override
86
94
  public void onCreated(AidcManager aidcManager) {
87
95
  manager = aidcManager;
88
96
 
89
97
  if (manager != null) {
90
- promise.resolve(true);
91
-
92
98
  manager.addBarcodeDeviceListener(new BarcodeDeviceListener() {
93
99
  @Override
94
100
  public void onBarcodeDeviceConnectionEvent(BarcodeDeviceConnectionEvent event) {
95
- if (event.getConnectionStatus() == manager.BARCODE_DEVICE_CONNECTED) {
96
- BarcodeReaderInfo readerInfo = event.getBarcodeReaderInfo();
101
+ String connected;
97
102
 
98
- WritableMap params = Arguments.createMap();
99
- params.putString("data", readerInfo.getName());
100
- sendEvent(DEVICE_CHANGE, params);
103
+ if (event.getConnectionStatus() == manager.BARCODE.DEVICE.DISCONNECTED) {
104
+ connected = "Disconnected";
105
+ } else {
106
+ connected = "Connected";
101
107
  }
102
- }
103
- });
104
108
 
109
+ final String message = "Scanner: " + event.getBarcodeReaderInfo().getName() + " is " + connected;
105
110
 
106
- // manager.addBarcodeDeviceListener(BarcodeDeviceListener listener) {
107
- // listener.onBarcodeDeviceConnectionEvent(BarcodeDeviceConnectionEvent event) {
108
- // }
109
- // }
111
+ Toast.makeText(reactContext, message, Toast.LENGTH_LONG).show();
112
+ }
113
+ })
110
114
  }
111
115
  }
112
116
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@scrumble-nl/react-native-honeywell-scanner",
3
3
  "title": "React Native Honeywell Scanner-v2",
4
- "version": "1.0.66",
4
+ "version": "1.0.68",
5
5
  "description": "Bridge to use the Honeywell scanner",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",