From db31087aae91d00c2172897d0bba5d6ba500e940 Mon Sep 17 00:00:00 2001 From: benomaire Date: Thu, 21 Apr 2022 00:20:03 +0300 Subject: [PATCH] hide margins if no overlay text --- .../view/HighlightingImageView.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/quran/labs/androidquran/view/HighlightingImageView.java b/app/src/main/java/com/quran/labs/androidquran/view/HighlightingImageView.java index c6b5834f28..bd2484344b 100644 --- a/app/src/main/java/com/quran/labs/androidquran/view/HighlightingImageView.java +++ b/app/src/main/java/com/quran/labs/androidquran/view/HighlightingImageView.java @@ -69,6 +69,7 @@ public class HighlightingImageView extends AppCompatImageView { private boolean isNightMode; private boolean isColorFilterOn; private int nightModeTextBrightness = Constants.DEFAULT_NIGHT_MODE_TEXT_BRIGHTNESS; + private int topBottom; // Params for drawing text private int fontSize; @@ -143,13 +144,9 @@ public HighlightingImageView(Context context, AttributeSet attrs) { } public void setIsScrollable(boolean scrollable, boolean landscape) { - int topBottom = scrollable ? scrollableHeaderFooterSize : - landscape ? dualPageHeaderFooterSize : headerFooterSize; + topBottom = scrollable ? scrollableHeaderFooterSize : + landscape ? dualPageHeaderFooterSize : headerFooterSize; verticalOffsetForScrolling = topBottom; - setPadding(horizontalSafeOffset, - topBottom + topSafeOffset, - horizontalSafeOffset, - topBottom + bottomSafeOffset); fontSize = scrollable ? scrollableHeaderFooterFontSize : landscape ? dualPageHeaderFooterFontSize : headerFooterFontSize; } @@ -525,6 +522,15 @@ protected void onDraw(@NonNull Canvas canvas) { overlayText(canvas, getImageMatrix()); } + if(!didDraw){ + setPadding(horizontalSafeOffset, topSafeOffset, horizontalSafeOffset, bottomSafeOffset); + } else { + setPadding(horizontalSafeOffset, + topBottom + topSafeOffset, + horizontalSafeOffset, + topBottom + bottomSafeOffset); + } + // run additional image draw helpers if any if (imageDrawHelpers != null && pageCoordinates != null) { for (ImageDrawHelper imageDrawHelper : imageDrawHelpers) {