diff --git a/app/src/main/java/eu/faircode/email/ActivitySignature.java b/app/src/main/java/eu/faircode/email/ActivitySignature.java index ae8b312763..bc95466640 100644 --- a/app/src/main/java/eu/faircode/email/ActivitySignature.java +++ b/app/src/main/java/eu/faircode/email/ActivitySignature.java @@ -134,7 +134,7 @@ public class ActivitySignature extends ActivityBase { etText.setText(HtmlHelper.fromHtml(html, new Html.ImageGetter() { @Override public Drawable getDrawable(String source) { - return getDrawableByUri(Uri.parse(source)); + return getDrawableByUri(ActivitySignature.this, Uri.parse(source)); } }, null)); } @@ -207,26 +207,32 @@ public class ActivitySignature extends ActivityBase { int start = etText.getSelectionStart(); SpannableStringBuilder ssb = new SpannableStringBuilder(etText.getText()); ssb.insert(start, " "); - ImageSpan is = new ImageSpan(getDrawableByUri(uri), uri.toString(), ImageSpan.ALIGN_BASELINE); + ImageSpan is = new ImageSpan(getDrawableByUri(this, uri), uri.toString(), ImageSpan.ALIGN_BASELINE); ssb.setSpan(is, start, start + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); etText.setText(ssb); } - private Drawable getDrawableByUri(Uri uri) { - Drawable d; - try { - Log.i("Loading image source=" + uri); - InputStream inputStream = getContentResolver().openInputStream(uri); - d = Drawable.createFromStream(inputStream, uri.toString()); - } catch (FileNotFoundException ex) { - Log.w(ex); - d = getResources().getDrawable(R.drawable.baseline_broken_image_24); - } + static Drawable getDrawableByUri(Context context, Uri uri) { + if ("content".equals(uri.getScheme())) { + Drawable d; + try { + Log.i("Loading image source=" + uri); + InputStream inputStream = context.getContentResolver().openInputStream(uri); + d = Drawable.createFromStream(inputStream, uri.toString()); + } catch (FileNotFoundException ex) { + Log.w(ex); + d = context.getResources().getDrawable(R.drawable.baseline_broken_image_24); + } - int w = Helper.dp2pixels(this, d.getIntrinsicWidth()); - int h = Helper.dp2pixels(this, d.getIntrinsicHeight()); + int w = Helper.dp2pixels(context, d.getIntrinsicWidth()); + int h = Helper.dp2pixels(context, d.getIntrinsicHeight()); - d.setBounds(0, 0, w, h); - return d; + d.setBounds(0, 0, w, h); + return d; + } else { + Drawable d = context.getResources().getDrawable(R.drawable.baseline_image_24); + d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight()); + return d; + } } } diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index c8ba9a0fc2..e8b657b1e4 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -4185,11 +4185,7 @@ public class FragmentCompose extends FragmentBase { signature = HtmlHelper.fromHtml(identity.signature, new Html.ImageGetter() { @Override public Drawable getDrawable(String source) { - int px = Helper.dp2pixels(getContext(), 24); - Drawable d = getContext().getResources() - .getDrawable(R.drawable.baseline_image_24, getContext().getTheme()); - d.setBounds(0, 0, px, px); - return d; + return ActivitySignature.getDrawableByUri(getContext(), Uri.parse(source)); } }, null); tvSignature.setText(signature);