correctly scale gifs in FocusDialog (#4537)
Found while testing #4528 The problem seems to be that Glide does not scale GIFs as it does static images. This workaround makes sure they still show up correctly. before / after <img src="https://github.com/tuskyapp/Tusky/assets/10157047/92c5e423-fa69-4bd5-b353-d5fac46f3074" width="260" /> <img src="https://github.com/tuskyapp/Tusky/assets/10157047/200f801b-0910-44dd-aa8b-39c383f07107" width="260" />
This commit is contained in:
parent
a371edbe87
commit
81d1722731
|
@ -50,10 +50,10 @@ fun <T> T.makeFocusDialog(
|
||||||
.downsample(DownsampleStrategy.CENTER_INSIDE)
|
.downsample(DownsampleStrategy.CENTER_INSIDE)
|
||||||
.listener(object : RequestListener<Drawable> {
|
.listener(object : RequestListener<Drawable> {
|
||||||
override fun onLoadFailed(
|
override fun onLoadFailed(
|
||||||
p0: GlideException?,
|
error: GlideException?,
|
||||||
p1: Any?,
|
model: Any?,
|
||||||
p2: Target<Drawable?>,
|
target: Target<Drawable?>,
|
||||||
p3: Boolean
|
isFirstResource: Boolean
|
||||||
): Boolean {
|
): Boolean {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -68,15 +68,20 @@ fun <T> T.makeFocusDialog(
|
||||||
val width = resource.intrinsicWidth
|
val width = resource.intrinsicWidth
|
||||||
val height = resource.intrinsicHeight
|
val height = resource.intrinsicHeight
|
||||||
|
|
||||||
dialogBinding.focusIndicator.setImageSize(width, height)
|
val viewWidth = dialogBinding.imageView.width
|
||||||
|
val viewHeight = dialogBinding.imageView.height
|
||||||
|
|
||||||
|
val scaledHeight = (viewWidth.toFloat() / width.toFloat()) * height
|
||||||
|
|
||||||
|
dialogBinding.focusIndicator.setImageSize(viewWidth, scaledHeight.toInt())
|
||||||
|
|
||||||
// We want the dialog to be a little taller than the image, so you can slide your thumb past the image border,
|
// We want the dialog to be a little taller than the image, so you can slide your thumb past the image border,
|
||||||
// but if it's *too* much taller that looks weird. See if a threshold has been crossed:
|
// but if it's *too* much taller that looks weird. See if a threshold has been crossed:
|
||||||
if (width > height) {
|
if (width > height) {
|
||||||
val maxHeight = dialogBinding.focusIndicator.maxAttractiveHeight()
|
val maxHeight = dialogBinding.focusIndicator.maxAttractiveHeight()
|
||||||
|
|
||||||
if (dialogBinding.imageView.height > maxHeight) {
|
if (viewHeight > maxHeight) {
|
||||||
val verticalShrinkLayout = FrameLayout.LayoutParams(width, maxHeight)
|
val verticalShrinkLayout = FrameLayout.LayoutParams(viewWidth, maxHeight)
|
||||||
dialogBinding.imageView.layoutParams = verticalShrinkLayout
|
dialogBinding.imageView.layoutParams = verticalShrinkLayout
|
||||||
dialogBinding.focusIndicator.layoutParams = verticalShrinkLayout
|
dialogBinding.focusIndicator.layoutParams = verticalShrinkLayout
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue