From 1ad7142a3fa760ffea634d7c13caf97013292198 Mon Sep 17 00:00:00 2001 From: Vishwajith-Shettigar Date: Fri, 17 Nov 2023 16:15:54 +0530 Subject: [PATCH 1/2] modified drawable width --- .../org/oppia/android/util/parser/image/UrlImageParser.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/utility/src/main/java/org/oppia/android/util/parser/image/UrlImageParser.kt b/utility/src/main/java/org/oppia/android/util/parser/image/UrlImageParser.kt index b18934a1897..b3e95ae5e02 100644 --- a/utility/src/main/java/org/oppia/android/util/parser/image/UrlImageParser.kt +++ b/utility/src/main/java/org/oppia/android/util/parser/image/UrlImageParser.kt @@ -268,6 +268,8 @@ class UrlImageParser private constructor( var drawableWidth = drawable.intrinsicWidth.toFloat() var drawableHeight = drawable.intrinsicHeight.toFloat() + val maxContentItemPadding = + context.resources.getDimensionPixelSize(R.dimen.maximum_content_item_padding) if (autoResizeImage) { // Treat the drawable's dimensions as dp so that the image scales for higher density // displays. @@ -291,8 +293,7 @@ class UrlImageParser private constructor( drawableHeight *= multipleFactor drawableWidth *= multipleFactor } - val maxContentItemPadding = - context.resources.getDimensionPixelSize(R.dimen.maximum_content_item_padding) + val maximumImageSize = maxAvailableWidth - maxContentItemPadding if (drawableWidth >= maximumImageSize) { // The multipleFactor value is used to make sure that the aspect ratio of the image @@ -311,6 +312,8 @@ class UrlImageParser private constructor( } } + drawableWidth-=maxContentItemPadding + val drawableLeft = if (imageCenterAlign && !isRTLMode()) { calculateInitialMargin(maxAvailableWidth, drawableWidth) } else { From 65c7e2a9c987481cfe0f3379c6427096f2dcabbe Mon Sep 17 00:00:00 2001 From: Vishwajith-Shettigar Date: Tue, 21 Nov 2023 16:02:37 +0530 Subject: [PATCH 2/2] drawable width calculated --- .../org/oppia/android/util/parser/image/UrlImageParser.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/utility/src/main/java/org/oppia/android/util/parser/image/UrlImageParser.kt b/utility/src/main/java/org/oppia/android/util/parser/image/UrlImageParser.kt index b3e95ae5e02..137652bd013 100644 --- a/utility/src/main/java/org/oppia/android/util/parser/image/UrlImageParser.kt +++ b/utility/src/main/java/org/oppia/android/util/parser/image/UrlImageParser.kt @@ -312,7 +312,9 @@ class UrlImageParser private constructor( } } - drawableWidth-=maxContentItemPadding + if (drawableWidth >= (maxAvailableWidth - maxContentItemPadding)) { + drawableWidth -= maxContentItemPadding + } val drawableLeft = if (imageCenterAlign && !isRTLMode()) { calculateInitialMargin(maxAvailableWidth, drawableWidth)