brarcher / loyalty-card-locker

Stores your barcode-based store/loyalty cards on your phone
GNU General Public License v3.0
172 stars 29 forks source link

Feature: Manually add card barcodes #4

Closed SecUpwN closed 8 years ago

SecUpwN commented 8 years ago

Not sure if it is due to my camera app being broken or because your app causes an error, but I cannot add a card via scanning it. Would you please implement that users can manually add card barcodes? Thanks!

brucedroid007 commented 8 years ago

Same issue here. Could you please add manual mode to enter card info. But I wass able to add 2 of my cards but numbers doesnt seem to match the ones on the card. (Dont know if that matter but coming from Stocard i had my numbers match when scanned). Ive been waiting for an open source app to replace stocard, thanks for the app. Hope to see more exciting updates in the future.

brarcher commented 8 years ago

@SecUpwN Can you provide logs from your device when you attempt to take a picture of the barcode? I've only one test device, so for a sample size of one it always works. (: It would be helpful to see how the zxing library for capturing barcodes interacts with other hardware platforms and android versions.

I'll look into a manual mode for entering the barcodes as well. I'll need to figure out what type of barcode to generate for a given sequence of numbers. Perhaps Stocard knows internally the barcode type for each card, not sure. The zxing library supports at least 9 different 1D barcode formats. I have only two such cards myself, and each turns out to be a different format (UPC_A and EAN_13).

@brucedroid007 would you be comfortable sending an image of the barcode which has difficulty scanning? It would be interesting to see what is going on when the scan data is incorrect.

brarcher commented 8 years ago

Here is a question for both @SecUpwN and @brucedroid007.

A given sequence of digits may be manifestable as multiple types of barcodes. From my limited knowledge of barcodes, it is not clear if one happens to use the wrong type that a barcode reader at a store will be able to recognize it.

Looking at how Stocard may handle this, when manually inputing a code for an unknown store it happens to generate a barcode of one specific type. The app also has a mapping between stores and the barcode types they use, so a better guess can be made if information is available. The following are the frequencies and barcode types from all cards that Stocard recognizes:

1471 unknown
 204 'CODE_128'
 194 'CODE_39'
   5 'DATA_MATRIX'
 847 'EAN_13'
  30 'EAN_8'
  27 'GS1_128'
 131 'ITF'
  12 'PDF_417'
  31 'QR_CODE'
 106 'UPC_A'

Looking at this list, I realize that I configured Loyalty Card Locker to only attempt to scan a subset of these. It is an easy change to scan for all 1D barcodes, and I've submitted this change already.

To the question: if a user manually inputs a code for the barcode, how should the barcode type be determined? Namely, should:

  1. Always use the most general barcode type possible, although it may not be the type the store expects
  2. Allow user to select from a list of barcode types, and generate the barcode for each, until the user can determine that the barcode type matches the card
  3. Some other option
berniegp commented 8 years ago

Casual visitor here. It seems to me that if you support all the known types of barcodes, manual entry would not be necessary. In case of a collision (i.e. a barcode can be interpreted differently by multiple code types), prompt the user to select the right number sequence.

Example: Your barcode can be interpreted in multiple ways. Which of these choices is the correct card number? 1- [number according to type 1] 2- [number according to type 2] etc.

Cheers

SecUpwN commented 8 years ago

Can you provide logs from your device when you attempt to take a picture of the barcode? I've only one test device, so for a sample size of one it always works. (: It would be helpful to see how the zxing library for capturing barcodes interacts with other hardware platforms and android versions.

@brarcher, you may find my logcat with multiple failed attempts to scan a card here. Hope it helps.

brarcher commented 8 years ago

@SecUpwN The interesting part of the log is this:

 02-05 08:44:04.638 D/CameraInstance(12633): Opening camera
 02-05 08:44:04.650 W/ServiceManager(  226): Permission failure: android.permission.CAMERA from uid=10026 pid=12633
 02-05 08:44:04.650 E/CameraService(  226): Permission Denial: can't use the camera pid=12633, uid=10026
 02-05 08:44:04.650 W/CameraBase(12633): An error occurred while connecting to camera: 0
 02-05 08:44:04.651 E/CameraInstance(12633): Failed to open camera

It appears that the app was not given permission to access the camera. Have you by chance disabled the ability for the app to access the camera? The manifest does declare usage of the camera.

SecUpwN commented 8 years ago

Have you by chance disabled the ability for the app to access the camera?

@brarcher, in fact, I am running Xprivacy. But no, those permissions have not been restricted on my behalf. The same Issue appears when turning off all restrictions for your app. Any other possible cause?

brarcher commented 8 years ago

Oh, I think I may see the issue. The manifest declared that it used the camera, but did not declare the actual permission. This PR should resolve that.

@SecUpwN Are you able to try building the project locally, installing it, and seeing if it now works on your device? Otherwise, I'll need to release it to F-Droid and hope it resolves the issue.

brarcher commented 8 years ago

I've rolled the dice. The changes which have been added thus far are now in the v0.2 release. A merge request is currently pending with F-Droid to add this release.

Kindly let me know if v0.2 resolves the known issues with the camera permission (@SecUpwN) and with capturing any 1D barcodes (@brucedroid007).

SecUpwN commented 8 years ago

Kindly let me know if v0.2 resolves the known issues with the camera permission (@SecUpwN)

Version 0.2 did not resolve this Issue, but Version 0.3 finally did. Thanks for your great work! :+1: