From c99bf206cce02dc7df44da99c534e66db57f6d56 Mon Sep 17 00:00:00 2001 From: Ankit Tiwari <55471438+ankittiwari101@users.noreply.github.com> Date: Sun, 17 Oct 2021 18:12:56 +0530 Subject: [PATCH] Dynamically size barcode based on their shape (square or rectangle) (#501) --- .../main/java/protect/card_locker/CatimaBarcode.java | 7 +++++++ .../protect/card_locker/LoyaltyCardViewActivity.java | 11 ++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/protect/card_locker/CatimaBarcode.java b/app/src/main/java/protect/card_locker/CatimaBarcode.java index 59a1d5305..2b295f5c5 100644 --- a/app/src/main/java/protect/card_locker/CatimaBarcode.java +++ b/app/src/main/java/protect/card_locker/CatimaBarcode.java @@ -63,6 +63,13 @@ public class CatimaBarcode { return barcodeFormats.contains(mBarcodeFormat); } + public boolean isSquare(){ + return mBarcodeFormat == BarcodeFormat.AZTEC + || mBarcodeFormat == BarcodeFormat.DATA_MATRIX + || mBarcodeFormat == BarcodeFormat.MAXICODE + || mBarcodeFormat == BarcodeFormat.QR_CODE; + } + public BarcodeFormat format() { return mBarcodeFormat; } diff --git a/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java b/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java index 11bb5bd25..91bbb2b2b 100644 --- a/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java +++ b/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java @@ -268,7 +268,10 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements if (imageTypes.get(mainImageIndex) == ImageType.BARCODE) { redrawBarcodeAfterResize(); } - centerGuideline.setGuidelinePercent(0.5f * scale); + if(loyaltyCard!=null && format!=null && format.isSquare()) + centerGuideline.setGuidelinePercent(0.75f * scale); + else + centerGuideline.setGuidelinePercent(0.5f * scale); } @Override @@ -417,6 +420,12 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements setupOrientation(); format = loyaltyCard.barcodeType; + if(format != null && format.isSquare()){ + centerGuideline.setGuidelinePercent(0.75f); + } + else{ + centerGuideline.setGuidelinePercent(0.5f); + } cardIdString = loyaltyCard.cardId; barcodeIdString = loyaltyCard.barcodeId;