mirror of
https://github.com/CatimaLoyalty/Android.git
synced 2026-04-04 07:41:40 -04:00
Padding improvements
This commit is contained in:
@@ -304,7 +304,7 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements
|
||||
|
||||
setCenterGuideline(loyaltyCard.zoomLevel);
|
||||
|
||||
drawMainImage(mainImageIndex, true);
|
||||
drawMainImage(mainImageIndex, true, isFullscreen);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -837,7 +837,7 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements
|
||||
}
|
||||
}
|
||||
|
||||
private void drawMainImage(int index, boolean waitForResize) {
|
||||
private void drawMainImage(int index, boolean waitForResize, boolean isFullscreen) {
|
||||
if (imageTypes.isEmpty()) {
|
||||
mainImage.setVisibility(View.GONE);
|
||||
return;
|
||||
@@ -852,13 +852,31 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements
|
||||
|
||||
ImageType wantedImageType = imageTypes.get(index);
|
||||
|
||||
// Use padding in non-fullscreen mode
|
||||
int px = Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, getResources().getDisplayMetrics()));
|
||||
ConstraintLayout.LayoutParams layoutParams = (ConstraintLayout.LayoutParams) mainImage.getLayoutParams();
|
||||
layoutParams.topMargin = isFullscreen ? 0 : px;
|
||||
if (!isFullscreen && wantedImageType == ImageType.BARCODE) {
|
||||
mainImage.setPadding(0, px, 0, px);
|
||||
} else {
|
||||
mainImage.setPadding(0, 0, 0, 0);
|
||||
}
|
||||
mainImage.setLayoutParams(layoutParams);
|
||||
|
||||
if (wantedImageType == ImageType.BARCODE) {
|
||||
// Use border in non-fullscreen mode
|
||||
if (!isFullscreen) {
|
||||
mainImage.setBackground(AppCompatResources.getDrawable(this, R.drawable.round_outline));
|
||||
} else {
|
||||
mainImage.setBackgroundColor(Color.WHITE);
|
||||
}
|
||||
|
||||
if (waitForResize) {
|
||||
redrawBarcodeAfterResize();
|
||||
} else {
|
||||
drawBarcode();
|
||||
}
|
||||
mainImage.setBackgroundColor(Color.WHITE);
|
||||
|
||||
mainImage.setContentDescription(getString(R.string.barcodeImageDescriptionWithType, format.prettyName()));
|
||||
} else if (wantedImageType == ImageType.IMAGE_FRONT) {
|
||||
mainImage.setImageBitmap(frontImageBitmap);
|
||||
@@ -888,7 +906,7 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements
|
||||
|
||||
mainImageIndex = newIndex;
|
||||
|
||||
drawMainImage(newIndex, false);
|
||||
drawMainImage(newIndex, false, isFullscreen);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -904,7 +922,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 +968,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);
|
||||
|
||||
Reference in New Issue
Block a user