Skip to content

Commit 6870774

Browse files
committed
Revert 'Remove px to dp stretching'
1 parent f79e23f commit 6870774

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

aztec/src/main/kotlin/org/wordpress/aztec/spans/AztecMediaSpan.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,16 @@ class AztecMediaSpan @JvmOverloads constructor(val context: Context?, private va
6161
private fun setBounds(drawable: Drawable?) {
6262
if (drawable != null && context != null) {
6363
/*
64+
* Account for device density by getting width from DisplayUtils.dpToPx. In other words,
65+
* a 300px image becomes 300dp.
66+
*
6467
* Following Android guidelines for keylines and spacing, screen edge margins should be
6568
* 16dp. Therefore, the width of images should be the width of the screen minus 16dp on
6669
* both sides (i.e. 16 * 2 = 32).
6770
*
6871
* https://material.io/guidelines/layout/metrics-keylines.html#metrics-keylines-baseline-grids
6972
*/
70-
val width = Math.min(drawable.intrinsicWidth, DisplayUtils.getDisplayPixelWidth(context) - DisplayUtils.dpToPx(context, 32))
73+
val width = Math.min(DisplayUtils.dpToPx(context, drawable.intrinsicWidth), DisplayUtils.getDisplayPixelWidth(context) - DisplayUtils.dpToPx(context, 32))
7174
val height = drawable.intrinsicHeight * width / drawable.intrinsicWidth
7275
drawable.setBounds(0, 0, width, height)
7376
}

0 commit comments

Comments
 (0)