Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Fix #1398: Set minimum image size to 48dp" #1401

Merged
merged 1 commit into from
Jun 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 2 additions & 19 deletions utility/src/main/java/org/oppia/util/parser/UrlImageParser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import android.view.ViewTreeObserver
import android.widget.TextView
import com.bumptech.glide.request.target.CustomTarget
import com.bumptech.glide.request.transition.Transition
import org.oppia.util.R
import javax.inject.Inject

// TODO(#169): Replace this with exploration asset downloader.
Expand Down Expand Up @@ -70,24 +69,8 @@ class UrlImageParser private constructor(
val drawable = drawableFactory(resource)
htmlContentTextView.post {
htmlContentTextView.width {
var drawableHeight = drawable.intrinsicHeight
var drawableWidth = drawable.intrinsicWidth
val minimumImageSize = context.resources.getDimensionPixelSize(R.dimen.minimum_image_size)
if (drawableHeight <= minimumImageSize || drawableWidth <= minimumImageSize) {
// The multipleFactor value is used to make sure that the aspect ratio of the image remains the same.
// Example: Height is 90, width is 60 and minimumImageSize is 120.
// Then multipleFactor will be 2 (120/60).
// The new height will be 180 and new width will be 120.
val multipleFactor = if (drawableHeight <= drawableWidth) {
// If height is less then the multipleFactor, value is determined by height.
(minimumImageSize.toDouble() / drawableHeight.toDouble())
} else {
// If width is less then the multipleFactor, value is determined by width.
(minimumImageSize.toDouble() / drawableWidth.toDouble())
}
drawableHeight = (drawableHeight.toDouble() * multipleFactor).toInt()
drawableWidth = (drawableWidth.toDouble() * multipleFactor).toInt()
}
val drawableHeight = drawable.intrinsicHeight
val drawableWidth = drawable.intrinsicWidth
val initialDrawableMargin = if (imageCenterAlign) {
calculateInitialMargin(it, drawableWidth)
} else {
Expand Down
1 change: 0 additions & 1 deletion utility/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@
<dimen name="bullet_gap_width">16dp</dimen>
<dimen name="bullet_y_offset">2dp</dimen>
<dimen name="bullet_leading_margin">24dp</dimen>
<dimen name="minimum_image_size">48dp</dimen>
</resources>