From 7a2ff0995fc21e8da52d79eb80ddd50433f20441 Mon Sep 17 00:00:00 2001 From: Sylvia van Os Date: Mon, 20 May 2024 17:21:58 +0200 Subject: [PATCH] Show image type on view screen when not viewing barcode --- .../card_locker/LoyaltyCardViewActivity.java | 26 ++++++++++++++----- .../res/layout/loyalty_card_view_layout.xml | 2 +- .../LoyaltyCardViewActivityTest.java | 2 +- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java b/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java index 92d5cd7ab..51221e49e 100644 --- a/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java +++ b/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java @@ -651,10 +651,15 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements cardIdString = loyaltyCard.cardId; barcodeIdString = loyaltyCard.barcodeId; - binding.cardIdView.setText(loyaltyCard.cardId); + binding.mainImageDescription.setText(loyaltyCard.cardId); // Display full text on click in case it doesn't fit in a single line - binding.cardIdView.setOnClickListener(v -> { + binding.mainImageDescription.setOnClickListener(v -> { + if (mainImageIndex != 0) { + // Don't show cardId dialog, we're displaying something else + return; + } + TextView cardIdView = new TextView(LoyaltyCardViewActivity.this); cardIdView.setText(loyaltyCard.cardId); cardIdView.setTextIsSelectable(true); @@ -927,7 +932,9 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements if (imageTypes.isEmpty()) { barcodeRenderTarget.setVisibility(View.GONE); binding.mainCardView.setCardBackgroundColor(Color.TRANSPARENT); - binding.cardIdView.setTextColor(MaterialColors.getColor(binding.cardIdView, com.google.android.material.R.attr.colorOnSurfaceVariant)); + binding.mainImageDescription.setTextColor(MaterialColors.getColor(binding.mainImageDescription, com.google.android.material.R.attr.colorOnSurfaceVariant)); + + binding.mainImageDescription.setText(loyaltyCard.cardId); return; } @@ -936,7 +943,7 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements if (wantedImageType == ImageType.BARCODE) { barcodeRenderTarget.setBackgroundColor(Color.WHITE); binding.mainCardView.setCardBackgroundColor(Color.WHITE); - binding.cardIdView.setTextColor(getResources().getColor(R.color.md_theme_light_onSurfaceVariant)); + binding.mainImageDescription.setTextColor(getResources().getColor(R.color.md_theme_light_onSurfaceVariant)); if (waitForResize) { redrawBarcodeAfterResize(!isFullscreen); @@ -944,19 +951,24 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements drawBarcode(!isFullscreen); } + binding.mainImageDescription.setText(loyaltyCard.cardId); barcodeRenderTarget.setContentDescription(getString(R.string.barcodeImageDescriptionWithType, format.prettyName())); } else if (wantedImageType == ImageType.IMAGE_FRONT) { barcodeRenderTarget.setImageBitmap(frontImageBitmap); barcodeRenderTarget.setBackgroundColor(Color.TRANSPARENT); binding.mainCardView.setCardBackgroundColor(Color.TRANSPARENT); - binding.cardIdView.setTextColor(MaterialColors.getColor(binding.cardIdView, com.google.android.material.R.attr.colorOnSurfaceVariant)); + binding.mainImageDescription.setTextColor(MaterialColors.getColor(binding.mainImageDescription, com.google.android.material.R.attr.colorOnSurfaceVariant)); + + binding.mainImageDescription.setText(getString(R.string.frontImageDescription)); barcodeRenderTarget.setContentDescription(getString(R.string.frontImageDescription)); } else if (wantedImageType == ImageType.IMAGE_BACK) { barcodeRenderTarget.setImageBitmap(backImageBitmap); barcodeRenderTarget.setBackgroundColor(Color.TRANSPARENT); binding.mainCardView.setCardBackgroundColor(Color.TRANSPARENT); - binding.cardIdView.setTextColor(MaterialColors.getColor(binding.cardIdView, com.google.android.material.R.attr.colorOnSurfaceVariant)); - barcodeRenderTarget.setContentDescription(getString(R.string.backImageDescription)); + binding.mainImageDescription.setTextColor(MaterialColors.getColor(binding.mainImageDescription, com.google.android.material.R.attr.colorOnSurfaceVariant)); + + binding.mainImageDescription.setText(getString(R.string.frontImageDescription)); + barcodeRenderTarget.setContentDescription(getString(R.string.frontImageDescription)); } else { throw new IllegalArgumentException("Unknown image type: " + wantedImageType); } diff --git a/app/src/main/res/layout/loyalty_card_view_layout.xml b/app/src/main/res/layout/loyalty_card_view_layout.xml index 632ef6b46..1cfbc32ec 100644 --- a/app/src/main/res/layout/loyalty_card_view_layout.xml +++ b/app/src/main/res/layout/loyalty_card_view_layout.xml @@ -121,7 +121,7 @@ android:layout_weight="1"/>