@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(
|
|
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
|
-
|
|
96
|
-
BarcodeReaderInfo readerInfo = event.getBarcodeReaderInfo();
|
|
101
|
+
String connected;
|
|
97
102
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
// }
|
|
111
|
+
Toast.makeText(reactContext, message, Toast.LENGTH_LONG).show();
|
|
112
|
+
}
|
|
113
|
+
})
|
|
110
114
|
}
|
|
111
115
|
}
|
|
112
116
|
});
|
package/package.json
CHANGED