diff --git a/app/src/main/java/protect/card_locker/BarcodeValues.java b/app/src/main/java/protect/card_locker/BarcodeValues.java index 681d1572fd..e9b745fd54 100644 --- a/app/src/main/java/protect/card_locker/BarcodeValues.java +++ b/app/src/main/java/protect/card_locker/BarcodeValues.java @@ -3,12 +3,17 @@ public class BarcodeValues { private final String mFormat; private final String mContent; + private String mNote; public BarcodeValues(String format, String content) { mFormat = format; mContent = content; } + public void setNote(String note) { + mNote = note; + } + public String format() { return mFormat; } @@ -17,7 +22,5 @@ public String content() { return mContent; } - public boolean isEmpty() { - return mFormat == null && mContent == null; - } -} + public String note() { return mNote; } +} \ No newline at end of file diff --git a/app/src/main/java/protect/card_locker/Utils.java b/app/src/main/java/protect/card_locker/Utils.java index 7ebf43c3fc..f3df29134b 100644 --- a/app/src/main/java/protect/card_locker/Utils.java +++ b/app/src/main/java/protect/card_locker/Utils.java @@ -187,7 +187,7 @@ static public List retrieveBarcodesFromPdf(Context context, Uri u return new ArrayList<>(); } - // Loop over all pages to find a barcode + // Loop over all pages to find barcodes List barcodesFromPdfPages = new ArrayList<>(); Bitmap renderedPage; for (int i = 0; i < renderer.getPageCount(); i++) { @@ -196,7 +196,11 @@ static public List retrieveBarcodesFromPdf(Context context, Uri u page.render(renderedPage, null, null, PdfRenderer.Page.RENDER_MODE_FOR_DISPLAY); page.close(); - barcodesFromPdfPages.addAll(getBarcodesFromBitmap(renderedPage)); + List barcodesFromPage = getBarcodesFromBitmap(renderedPage); + for (BarcodeValues barcodeValues : barcodesFromPage) { + barcodeValues.setNote(String.format(context.getString(R.string.pageWithNumber), i+1)); + barcodesFromPdfPages.add(barcodeValues); + } } renderer.close(); @@ -323,12 +327,24 @@ static public void makeUserChooseBarcodeFromList(Context context, List 22) { + barcodeContent = barcodeContent.substring(0, 20) + "…"; + } + + if (barcodeValues.note() != null) { + barcodeDescriptions[i] = String.format("%s: %s (%s)", barcodeValues.note(), catimaBarcode.prettyName(), barcodeContent); + } else { + barcodeDescriptions[i] = String.format("%s (%s)", catimaBarcode.prettyName(), barcodeContent); + } } MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(context); - builder.setTitle(context.getString(R.string.multiple_barcodes_found_choose_one)); + builder.setTitle(context.getString(R.string.multipleBarcodesFoundPleaseChooseOne)); builder.setItems( barcodeDescriptions, (dialogInterface, i) -> callback.onUserChoseBarcode(barcodeValuesList.get(i)) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a67df074ad..0c6473e256 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -344,5 +344,6 @@ Select a PDF file Could not read the file Could not find a supported file manager - Which of the found barcodes do you want to use? + Which of the found barcodes do you want to use? + Page %d