inventree / inventree-app

InvenTree mobile app
https://docs.inventree.org/en/latest/app/app/
MIT License
57 stars 48 forks source link

Implement "wedge" mode for barcode scanning #364

Closed SchrodingersGat closed 1 year ago

SchrodingersGat commented 1 year ago

With https://github.com/inventree/inventree-app/pull/363 closed it is now possible to implement alternate barcode scanning methods.

While flutter does have some libraries for some native scanning libraries, they are piece-meal and don't fully cover all available devices.

A much simpler approach (both implementation and support) is to implement a "wedge" input (which is really just a text input) and let external scanners insert data as a virtual keyboard. This will support the widest range of scanner inputs without requiring custom SDK etc

Ref: https://github.com/inventree/inventree-app/issues/344

External References

horbix28 commented 1 year ago

How does it look, is there already something going on? I could really use the feature as I have an OTG scanner and a Blutetooth scanner that I would like to use on my phone. It simply works as a bluetooth/otg keyboard.

SchrodingersGat commented 1 year ago

@horbix28 there has to date been no movement on this. There are a few flutter libraries that look promising and should make it pretty simple to implement.

What has been done is a refactor of the barcode scanning code to allow for custom scanners to be dropped in, and controlled by a configurable setting (i.e. user can select to use built-in camera or wedge).

lfg-seth commented 1 year ago

Hi @SchrodingersGat

Any update? I have been using inventree for a while now and love it. So much so that I bought one of these off amazon to use with it. The app runs well enough on it but I cannot use the built in barcode scanner and the camera on the device is quite buggy.

Would I be able to donate to your cause to help move this feature forward? I'm also willing to learn flutter and get a dev instance going and tinker with it myself. In that case would you be able to let me know how far you got or at least help get me pointed in the right direction? Many thanks!

SchrodingersGat commented 1 year ago

@lfg-seth thanks for reaching out! While there has been no implementation of "wedge" mode, the code has been refactored to allow for scanning methods other than the camera input. So, as long as we can capture the scanned data, it will work.

Do you have any information on how the "wedge" mode works on your device? The links in the original post here relate to zebra and honeywell devices, which may be quite diferent than your device.

lfg-seth commented 1 year ago

Hi @SchrodingersGat, Thanks for getting back to me. The device has some settings regarding the barcode output. It can do either: Broadcast, Inputbox, Keyboard, Single Input, or Clipboard. Ill get to Broadcast last, but Inputbox, Keyboard, and Single Input all seem to just place the barcode contents wherever the "cursor" is. Im sure there are nuances between each of them, but in my limited testing options they all seem to do the same, except keyboard mode places characters one by one, the others seem to dump the full content at once. Clipboard mode stores the output to the clipboard, then you can paste it anywhere you'd like. Broadcast mode I have no idea really. With broadcast mode another setting shows up "Broadcast" in it are two sub settings, "name" and "Key-Value" with the defaults being "scan.rcv.message" and "barcodeData" respectfully.

For implementing this into Inventree I have two thoughts, one would be to have a input box somewhere (or even hidden) that is always waiting for input, then when a barcode is scanned it can decode the info and do what it needs to. The other thought is to maybe use the clipboard mode? Would the app be able to listen to the clipboard and take action when an inventree barcode is scanned?

I'll try in the meantime to get a dev instance going locally and see if I can even build the app and get it on the device to test.

SchrodingersGat commented 1 year ago

Would the app be able to listen to the clipboard and take action when an inventree barcode is scanned?

It looks like it should be pretty achievable using something like this library

Would I be able to donate to your cause to help move this feature forward?

Certainly - check out the sponsorship page - I'll start a branch where we can work on this and hopefully get something going that will benefit everyone who is using these generic scanners

30350n commented 1 year ago

Wouldn't it be better to just support the "Keyboard" mode though? From what I can tell, that's what most of the cheaper bluetooth scanners use aswell, so it's probably more universal than the clipboard option I'd guess.

30350n commented 1 year ago

Aha, this library seems promising I guess: flutter_barcode_listener

SchrodingersGat commented 1 year ago

@30350n you are probably right, starting to dive into some reading here and it looks like keyboard approach would support more devices across the board.

@lfg-seth wih your device in mind:

keyboard mode places characters one by one

Do you know what the delay betwteen charater input is?

Inputbox, Keyboard, and Single Input all seem to just place the barcode contents wherever the "cursor" is.

Are there any leading, trailing, or other associated control characters?

SchrodingersGat commented 1 year ago

@30350n great find on that library, that looks perfect. Will investigate

horbix28 commented 1 year ago

keyboard mode places characters one by one Do you know what the delay betwteen charater input is?

I can speak for my Scanner devices: It's all configurable and they all work with the web Implementation of the barcode field. So the frontend Implementation should be a good starting point.

SchrodingersGat commented 1 year ago

@horbix28 thanks for the data!

SchrodingersGat commented 1 year ago

https://pub.dev/packages/code_scan_listener/example seems to work, it is a modern fork of https://pub.dev/packages/flutter_barcode_listener (which is quite old and doesn't work for me)

SchrodingersGat commented 1 year ago

All, comments welcome over at https://github.com/inventree/inventree-app/pull/437