CatimaLoyalty / Android

Catima, a Loyalty Card & Ticket Manager for Android
https://catima.app
GNU General Public License v3.0
807 stars 146 forks source link

Width of Barcode Display #1945

Open AndyM48 opened 2 months ago

AndyM48 commented 2 months ago

I have some more questions concerning the principal screen showing the chosen card and barcode. The screen is very nicely presented in two parts: above is the image of the card, and below is the barcode, in a box which is the same width as the card above.

It happens that I only have two types of barcode to display, EAN 13 (13 characters) and Code 128 (19 characters).

So I wonder:

Why is the longer Code 128 code shown in a space which is narrower than the shorter EAN 13 code?

Why is the long, Code 128, number truncated to 17 characters on the display? If I tap the truncated code it is displayed in full in a new window, but in a smaller typeface. Why is it not displayed in full in the principal screen, in a size to fit the space available?

TheLastProject commented 2 months ago

From the top of my head, the basic logic is as follows:

  1. Draw the barcode text in a big font, using ellipsis if it's too long
  2. Ask the zxing library to generate the best-fit barcode for the remaining space

So in general zxing should decide how to best use the space and in general it uses it quite well (there are a few tweaks in Catima to override some behaviour).

Based on that info, we get the following question:

Why is the longer Code 128 code shown in a space which is narrower than the shorter EAN 13 code?

Because zxing considers this the most optimal use of the space based on some internal settings. If this is correct, well, we'd need to discuss some actual examples and look at the specs (several barcode formats have specs about how much spacing there needs to be around it and if you manually tweak that you risk breaking some scanners).

Why is the long, Code 128, number truncated to 17 characters on the display? If I tap the truncated code it is displayed in full in a new window, but in a smaller typeface. Why is it not displayed in full in the principal screen, in a size to fit the space available?

It's truncated to 17 characters because more than 17 apparently doesn't fit in the font size. It used to scale automatically based on content size (6e526de0873135ccc26fa369e788fd182a654324) but it seems that was lost in the UI redesign last year (b48de921fc36e62935e85b5549d57461bf2cddfc). Automatically scaling the font size might be worth trying to bring back within a certain range, but we'd have to see how complex it is and if it doesn't act weird with anything else (especially after #1894 got merged)

AndyM48 commented 2 months ago

Thanks for the reply.

I see that you use zxing, which does not seem to be developed any more. It might also explain the slightly unusual layout of the EAN 13 image.

The truncated text is not really a problem, just a bit strange :)

TheLastProject commented 2 months ago

zxing is still being developed

AndyM48 commented 2 months ago

Very good. I was confused by Project in Maintenance Mode Only at https://github.com/zxing/zxing