From fb488af2b7df56a6558ccfd3de47346f2440871b Mon Sep 17 00:00:00 2001 From: Sylvia van Os Date: Sat, 3 Jun 2023 14:32:53 +0200 Subject: [PATCH] Fix barcode being invisible on square screens See https://github.com/CatimaLoyalty/Android/issues/1339 --- CHANGELOG.md | 1 + .../card_locker/LoyaltyCardViewActivity.java | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e61d4d59a..3053f47fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Unreleased - 123 - Minor UI improvements +- Fix new design not being usable on devices with square screens ## v2.23.2 - 122 diff --git a/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java b/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java index 055643c36..8d93879cc 100644 --- a/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java +++ b/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java @@ -587,7 +587,7 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements loyaltyCardGroups = DBHelper.getLoyaltyCardGroups(database, loyaltyCardId); - setupOrientation(); + showHideElementsForScreenSize(); format = loyaltyCard.barcodeType; cardIdString = loyaltyCard.cardId; @@ -819,13 +819,17 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements return super.onOptionsItemSelected(item); } - private void setupOrientation() { + private void showHideElementsForScreenSize() { int orientation = getResources().getConfiguration().orientation; - if (orientation == Configuration.ORIENTATION_LANDSCAPE) { - Log.d(TAG, "Detected landscape mode"); + // Detect square-ish screens like the Unihertz Titan + boolean isSmallHeight = getResources().getDisplayMetrics().heightPixels < (getResources().getDisplayMetrics().widthPixels * 1.5); + + // Treat sqaure-ish screens as + if (orientation == Configuration.ORIENTATION_LANDSCAPE || isSmallHeight) { + Log.d(TAG, "Detected landscape mode or square-ish screen"); binding.iconContainer.setVisibility(View.GONE); } else { - Log.d(TAG, "Detected portrait mode"); + Log.d(TAG, "Detected portrait mode on non square-ish screen"); binding.iconContainer.setVisibility(View.VISIBLE); }