mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-01 04:35:57 +00:00
Limit image width to screen width
This commit is contained in:
parent
c0ed1c6e38
commit
13c16bb7ac
2 changed files with 24 additions and 2 deletions
|
@ -1760,7 +1760,18 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
Spanned spanned = HtmlHelper.fromHtml(html, new Html.ImageGetter() {
|
Spanned spanned = HtmlHelper.fromHtml(html, new Html.ImageGetter() {
|
||||||
@Override
|
@Override
|
||||||
public Drawable getDrawable(String source) {
|
public Drawable getDrawable(String source) {
|
||||||
return HtmlHelper.decodeImage(source, message.id, show_images, tvBody);
|
Drawable image = HtmlHelper.decodeImage(source, message.id, show_images, tvBody);
|
||||||
|
|
||||||
|
float width = context.getResources().getDisplayMetrics().widthPixels -
|
||||||
|
Helper.dp2pixels(context, 12); // margins
|
||||||
|
if (image.getIntrinsicWidth() > width) {
|
||||||
|
float scale = width / image.getIntrinsicWidth();
|
||||||
|
image.setBounds(0, 0,
|
||||||
|
Math.round(image.getIntrinsicWidth() * scale),
|
||||||
|
Math.round(image.getIntrinsicHeight() * scale));
|
||||||
|
}
|
||||||
|
|
||||||
|
return image;
|
||||||
}
|
}
|
||||||
}, null);
|
}, null);
|
||||||
|
|
||||||
|
|
|
@ -2760,7 +2760,18 @@ public class FragmentCompose extends FragmentBase {
|
||||||
new Html.ImageGetter() {
|
new Html.ImageGetter() {
|
||||||
@Override
|
@Override
|
||||||
public Drawable getDrawable(String source) {
|
public Drawable getDrawable(String source) {
|
||||||
return HtmlHelper.decodeImage(source, id, show_images, tvReference);
|
Drawable image = HtmlHelper.decodeImage(source, id, show_images, tvReference);
|
||||||
|
|
||||||
|
float width = context.getResources().getDisplayMetrics().widthPixels -
|
||||||
|
Helper.dp2pixels(context, 12); // margins;
|
||||||
|
if (image.getIntrinsicWidth() > width) {
|
||||||
|
float scale = width / image.getIntrinsicWidth();
|
||||||
|
image.setBounds(0, 0,
|
||||||
|
Math.round(image.getIntrinsicWidth() * scale),
|
||||||
|
Math.round(image.getIntrinsicHeight() * scale));
|
||||||
|
}
|
||||||
|
|
||||||
|
return image;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
null);
|
null);
|
||||||
|
|
Loading…
Reference in a new issue