diff --git a/CHANGELOG.md b/CHANGELOG.md index 05a036602..d55d14111 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Unreleased - 104 - Save card detail expansion state +- Minor UI fixes ## v2.15.2 - 103 (2022-02-11) diff --git a/app/src/main/java/protect/card_locker/BarcodeImageWriterTask.java b/app/src/main/java/protect/card_locker/BarcodeImageWriterTask.java index 62f1e1826..f3f66c926 100644 --- a/app/src/main/java/protect/card_locker/BarcodeImageWriterTask.java +++ b/app/src/main/java/protect/card_locker/BarcodeImageWriterTask.java @@ -5,6 +5,7 @@ import android.graphics.Bitmap; import android.graphics.Color; import android.graphics.PorterDuff; import android.util.Log; +import android.util.TypedValue; import android.view.View; import android.widget.ImageView; import android.widget.TextView; @@ -46,7 +47,7 @@ public class BarcodeImageWriterTask implements CompatCallable { BarcodeImageWriterTask( Context context, ImageView imageView, String cardIdString, CatimaBarcode barcodeFormat, TextView textView, - boolean showFallback, Runnable callback + boolean showFallback, Runnable callback, boolean roundCornerPadding ) { mContext = context; @@ -60,18 +61,27 @@ public class BarcodeImageWriterTask implements CompatCallable { cardId = cardIdString; format = barcodeFormat; + int padding = roundCornerPadding ? Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, context.getResources().getDisplayMetrics())) : 0; + final int MAX_WIDTH = getMaxWidth(format); + int tempImageHeight; + int tempImageWidth; + if (imageView.getWidth() < MAX_WIDTH) { - imageHeight = imageView.getHeight(); - imageWidth = imageView.getWidth(); + tempImageHeight = imageView.getHeight(); + tempImageWidth = imageView.getWidth(); } else { // Scale down the image to reduce the memory needed to produce it - imageWidth = MAX_WIDTH; + tempImageWidth = MAX_WIDTH; double ratio = (double) MAX_WIDTH / (double) imageView.getWidth(); - imageHeight = (int) (imageView.getHeight() * ratio); + tempImageHeight = (int) (imageView.getHeight() * ratio); } + // Ensure space for padding if wanted + imageWidth = tempImageWidth; + imageHeight = tempImageHeight - padding; + this.showFallback = showFallback; } diff --git a/app/src/main/java/protect/card_locker/BarcodeSelectorAdapter.java b/app/src/main/java/protect/card_locker/BarcodeSelectorAdapter.java index ff0e223a4..def91e389 100644 --- a/app/src/main/java/protect/card_locker/BarcodeSelectorAdapter.java +++ b/app/src/main/java/protect/card_locker/BarcodeSelectorAdapter.java @@ -76,6 +76,7 @@ public class BarcodeSelectorAdapter extends ArrayAdapter final CatimaBarcode format = CatimaBarcode.fromName(formatType); image.setImageBitmap(null); + image.setClipToOutline(true); if (image.getHeight() == 0) { // The size of the ImageView is not yet available as it has not @@ -89,13 +90,13 @@ public class BarcodeSelectorAdapter extends ArrayAdapter Log.d(TAG, "Generating barcode for type " + formatType); - BarcodeImageWriterTask barcodeWriter = new BarcodeImageWriterTask(getContext(), image, cardId, format, text, true, null); + BarcodeImageWriterTask barcodeWriter = new BarcodeImageWriterTask(getContext(), image, cardId, format, text, true, null, true); mTasks.executeTask(TaskHandler.TYPE.BARCODE, barcodeWriter); } }); } else { Log.d(TAG, "Generating barcode for type " + formatType); - BarcodeImageWriterTask barcodeWriter = new BarcodeImageWriterTask(getContext(), image, cardId, format, text, true, null); + BarcodeImageWriterTask barcodeWriter = new BarcodeImageWriterTask(getContext(), image, cardId, format, text, true, null, true); mTasks.executeTask(TaskHandler.TYPE.BARCODE, barcodeWriter); } } diff --git a/app/src/main/java/protect/card_locker/LoyaltyCardEditActivity.java b/app/src/main/java/protect/card_locker/LoyaltyCardEditActivity.java index 373d1a4d8..7cd6ed737 100644 --- a/app/src/main/java/protect/card_locker/LoyaltyCardEditActivity.java +++ b/app/src/main/java/protect/card_locker/LoyaltyCardEditActivity.java @@ -323,6 +323,7 @@ public class LoyaltyCardEditActivity extends CatimaAppCompatActivity { barcodeIdField = findViewById(R.id.barcodeIdField); barcodeTypeField = findViewById(R.id.barcodeTypeField); barcodeImage = findViewById(R.id.barcode); + barcodeImage.setClipToOutline(true); barcodeImageLayout = findViewById(R.id.barcodeLayout); barcodeCaptureLayout = findViewById(R.id.barcodeCaptureLayout); cardImageFrontHolder = findViewById(R.id.frontImageHolder); @@ -1449,13 +1450,13 @@ public class LoyaltyCardEditActivity extends CatimaAppCompatActivity { barcodeImage.getViewTreeObserver().removeOnGlobalLayoutListener(this); Log.d(TAG, "ImageView size now known"); - BarcodeImageWriterTask barcodeWriter = new BarcodeImageWriterTask(getApplicationContext(), barcodeImage, cardIdString, barcodeFormat, null, false, barcodeImageGenerationFinishedCallback); + BarcodeImageWriterTask barcodeWriter = new BarcodeImageWriterTask(getApplicationContext(), barcodeImage, cardIdString, barcodeFormat, null, false, barcodeImageGenerationFinishedCallback, true); mTasks.executeTask(TaskHandler.TYPE.BARCODE, barcodeWriter); } }); } else { Log.d(TAG, "ImageView size known known, creating barcode"); - BarcodeImageWriterTask barcodeWriter = new BarcodeImageWriterTask(getApplicationContext(), barcodeImage, cardIdString, barcodeFormat, null, false, barcodeImageGenerationFinishedCallback); + BarcodeImageWriterTask barcodeWriter = new BarcodeImageWriterTask(getApplicationContext(), barcodeImage, cardIdString, barcodeFormat, null, false, barcodeImageGenerationFinishedCallback, true); mTasks.executeTask(TaskHandler.TYPE.BARCODE, barcodeWriter); } } diff --git a/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java b/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java index 6bb8c7096..caa53f928 100644 --- a/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java +++ b/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java @@ -278,6 +278,7 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements storeName = findViewById(R.id.storeName); maximizeButton = findViewById(R.id.maximizeButton); mainImage = findViewById(R.id.mainImage); + mainImage.setClipToOutline(true); dotIndicator = findViewById(R.id.dotIndicator); minimizeButton = findViewById(R.id.minimizeButton); collapsingToolbarLayout = findViewById(R.id.collapsingToolbarLayout); @@ -304,7 +305,7 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements setCenterGuideline(loyaltyCard.zoomLevel); - drawMainImage(mainImageIndex, true); + drawMainImage(mainImageIndex, true, isFullscreen); } @Override @@ -807,7 +808,7 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements } } - private void drawBarcode() { + private void drawBarcode(boolean addPadding) { mTasks.flushTaskList(TaskHandler.TYPE.BARCODE, true, false, false); if (format != null) { BarcodeImageWriterTask barcodeWriter = new BarcodeImageWriterTask( @@ -817,12 +818,13 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements format, null, false, - null); + null, + addPadding); mTasks.executeTask(TaskHandler.TYPE.BARCODE, barcodeWriter); } } - private void redrawBarcodeAfterResize() { + private void redrawBarcodeAfterResize(boolean addPadding) { if (format != null) { mainImage.getViewTreeObserver().addOnGlobalLayoutListener( new ViewTreeObserver.OnGlobalLayoutListener() { @@ -831,13 +833,13 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements mainImage.getViewTreeObserver().removeOnGlobalLayoutListener(this); Log.d(TAG, "ImageView size now known"); - drawBarcode(); + drawBarcode(addPadding); } }); } } - private void drawMainImage(int index, boolean waitForResize) { + private void drawMainImage(int index, boolean waitForResize, boolean isFullscreen) { if (imageTypes.isEmpty()) { mainImage.setVisibility(View.GONE); return; @@ -853,12 +855,19 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements ImageType wantedImageType = imageTypes.get(index); if (wantedImageType == ImageType.BARCODE) { - if (waitForResize) { - redrawBarcodeAfterResize(); + // Use border in non-fullscreen mode + if (!isFullscreen) { + mainImage.setBackground(AppCompatResources.getDrawable(this, R.drawable.round_outline)); } else { - drawBarcode(); + mainImage.setBackgroundColor(Color.WHITE); } - mainImage.setBackgroundColor(Color.WHITE); + + if (waitForResize) { + redrawBarcodeAfterResize(!isFullscreen); + } else { + drawBarcode(!isFullscreen); + } + mainImage.setContentDescription(getString(R.string.barcodeImageDescriptionWithType, format.prettyName())); } else if (wantedImageType == ImageType.IMAGE_FRONT) { mainImage.setImageBitmap(frontImageBitmap); @@ -888,7 +897,7 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements mainImageIndex = newIndex; - drawMainImage(newIndex, false); + drawMainImage(newIndex, false, isFullscreen); } /** @@ -904,7 +913,7 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements if (enabled && !imageTypes.isEmpty()) { Log.d(TAG, "Move into fullscreen"); - drawMainImage(mainImageIndex, true); + drawMainImage(mainImageIndex, true, isFullscreen); barcodeScaler.setProgress(loyaltyCard.zoomLevel); setCenterGuideline(loyaltyCard.zoomLevel); @@ -950,7 +959,7 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements // Reset center guideline setCenterGuideline(100); - drawMainImage(mainImageIndex, true); + drawMainImage(mainImageIndex, true, isFullscreen); // Show maximize and hide minimize button and scaler maximizeButton.setVisibility(imageTypes.isEmpty() ? View.GONE : View.VISIBLE); diff --git a/app/src/main/res/drawable/round_outline.xml b/app/src/main/res/drawable/round_outline.xml new file mode 100644 index 000000000..672294b89 --- /dev/null +++ b/app/src/main/res/drawable/round_outline.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/barcode_layout.xml b/app/src/main/res/layout/barcode_layout.xml index 8ee0dd4ce..965c6a9cc 100644 --- a/app/src/main/res/layout/barcode_layout.xml +++ b/app/src/main/res/layout/barcode_layout.xml @@ -5,6 +5,7 @@ android:layout_height="wrap_content" xmlns:android="http://schemas.android.com/apk/res/android"> diff --git a/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-02.png b/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-02.png index 2c36a0280..3e1e3ed79 100644 Binary files a/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-02.png and b/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-02.png differ diff --git a/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-04.png b/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-04.png index 8887a23a3..00fcbede9 100644 Binary files a/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-04.png and b/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-04.png differ diff --git a/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-06.png b/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-06.png index d58e94b27..97bfa5e78 100644 Binary files a/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-06.png and b/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-06.png differ diff --git a/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-08.png b/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-08.png index 6d57079eb..29c21cf0b 100644 Binary files a/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-08.png and b/fastlane/metadata/android/en-US/images/phoneScreenshots/screenshot-08.png differ