mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-23 22:51:02 +00:00
Added relative image sizes
This commit is contained in:
parent
7c0b5a505b
commit
b247745b4d
1 changed files with 8 additions and 2 deletions
|
@ -49,6 +49,7 @@ import android.text.style.TypefaceSpan;
|
|||
import android.text.style.URLSpan;
|
||||
import android.text.style.UnderlineSpan;
|
||||
import android.util.Base64;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Patterns;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
@ -992,6 +993,7 @@ public class HtmlHelper {
|
|||
|
||||
// Images
|
||||
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img
|
||||
DisplayMetrics dm = context.getResources().getDisplayMetrics();
|
||||
for (Element img : document.select("img")) {
|
||||
String alt = img.attr("alt");
|
||||
String src = img.attr("src");
|
||||
|
@ -1041,19 +1043,23 @@ public class HtmlHelper {
|
|||
int width = 0;
|
||||
int height = 0;
|
||||
|
||||
String awidth = img.attr("width");
|
||||
String awidth = img.attr("width").replace(" ", "");
|
||||
for (int i = 0; i < awidth.length(); i++)
|
||||
if (Character.isDigit(awidth.charAt(i)))
|
||||
width = width * 10 + (byte) awidth.charAt(i) - (byte) '0';
|
||||
else
|
||||
break;
|
||||
if (awidth.endsWith("%"))
|
||||
width = Math.round(dm.widthPixels / dm.density * width / 100);
|
||||
|
||||
String aheight = img.attr("height");
|
||||
String aheight = img.attr("height").replace(" ", "");
|
||||
for (int i = 0; i < aheight.length(); i++)
|
||||
if (Character.isDigit(aheight.charAt(i)))
|
||||
height = height * 10 + (byte) aheight.charAt(i) - (byte) '0';
|
||||
else
|
||||
break;
|
||||
if (aheight.endsWith("%"))
|
||||
height = Math.round(dm.heightPixels / dm.density * height / 100);
|
||||
|
||||
if (width != 0 || height != 0) {
|
||||
ImageHelper.AnnotatedSource a = new ImageHelper.AnnotatedSource(
|
||||
|
|
Loading…
Reference in a new issue