mirror of https://github.com/M66B/FairEmail.git
Use image size for relative sizes
This commit is contained in:
parent
e8df52fc8c
commit
c040b8206c
|
@ -49,7 +49,6 @@ import android.text.style.TypefaceSpan;
|
||||||
import android.text.style.URLSpan;
|
import android.text.style.URLSpan;
|
||||||
import android.text.style.UnderlineSpan;
|
import android.text.style.UnderlineSpan;
|
||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
import android.util.DisplayMetrics;
|
|
||||||
import android.util.Patterns;
|
import android.util.Patterns;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
@ -993,7 +992,6 @@ public class HtmlHelper {
|
||||||
|
|
||||||
// Images
|
// Images
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img
|
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img
|
||||||
DisplayMetrics dm = context.getResources().getDisplayMetrics();
|
|
||||||
for (Element img : document.select("img")) {
|
for (Element img : document.select("img")) {
|
||||||
String alt = img.attr("alt");
|
String alt = img.attr("alt");
|
||||||
String src = img.attr("src");
|
String src = img.attr("src");
|
||||||
|
@ -1043,23 +1041,25 @@ public class HtmlHelper {
|
||||||
int width = 0;
|
int width = 0;
|
||||||
int height = 0;
|
int height = 0;
|
||||||
|
|
||||||
|
// Relative sizes (%) = use image size
|
||||||
|
|
||||||
String awidth = img.attr("width").replace(" ", "");
|
String awidth = img.attr("width").replace(" ", "");
|
||||||
for (int i = 0; i < awidth.length(); i++)
|
for (int i = 0; i < awidth.length(); i++)
|
||||||
if (Character.isDigit(awidth.charAt(i)))
|
if (Character.isDigit(awidth.charAt(i)))
|
||||||
width = width * 10 + (byte) awidth.charAt(i) - (byte) '0';
|
width = width * 10 + (byte) awidth.charAt(i) - (byte) '0';
|
||||||
else
|
else {
|
||||||
|
width = 0;
|
||||||
break;
|
break;
|
||||||
if (awidth.endsWith("%"))
|
}
|
||||||
width = Math.round(dm.widthPixels / dm.density * width / 100);
|
|
||||||
|
|
||||||
String aheight = img.attr("height").replace(" ", "");
|
String aheight = img.attr("height").replace(" ", "");
|
||||||
for (int i = 0; i < aheight.length(); i++)
|
for (int i = 0; i < aheight.length(); i++)
|
||||||
if (Character.isDigit(aheight.charAt(i)))
|
if (Character.isDigit(aheight.charAt(i)))
|
||||||
height = height * 10 + (byte) aheight.charAt(i) - (byte) '0';
|
height = height * 10 + (byte) aheight.charAt(i) - (byte) '0';
|
||||||
else
|
else {
|
||||||
|
height = 0;
|
||||||
break;
|
break;
|
||||||
if (aheight.endsWith("%"))
|
}
|
||||||
height = Math.round(dm.heightPixels / dm.density * height / 100);
|
|
||||||
|
|
||||||
if (width != 0 || height != 0) {
|
if (width != 0 || height != 0) {
|
||||||
ImageHelper.AnnotatedSource a = new ImageHelper.AnnotatedSource(
|
ImageHelper.AnnotatedSource a = new ImageHelper.AnnotatedSource(
|
||||||
|
|
Loading…
Reference in New Issue