Skip to content

Commit

Permalink
Merge branch 'technical-analytics-milestone-2' of github.com:kkmurerw…
Browse files Browse the repository at this point in the history
…a/oppia-android into technical-analytics-milestone-2
  • Loading branch information
kkmurerwa committed Nov 24, 2023
2 parents 493d4c1 + 4de5981 commit f8f0062
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -311,6 +312,10 @@ class UrlImageParser private constructor(
}
}

if (drawableWidth >= (maxAvailableWidth - maxContentItemPadding)) {
drawableWidth -= maxContentItemPadding
}

val drawableLeft = if (imageCenterAlign && !isRTLMode()) {
calculateInitialMargin(maxAvailableWidth, drawableWidth)
} else {
Expand Down

0 comments on commit f8f0062

Please sign in to comment.