diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index 17892077e2..7c771a3f53 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -2540,15 +2540,23 @@ public class AdapterMessage extends RecyclerView.Adapter= Build.VERSION_CODES.O) ibImages.setTooltipText(ibImages.getContentDescription()); - if (show_full) { - // Create web view - WebViewEx webView; - if (wvBody instanceof WebView) - webView = (WebViewEx) wvBody; - else { - try { - webView = new WebViewEx(context); - } catch (Throwable ex) { + if (message.isEncrypted() && !message.isUnlocked()) { + SpannableStringBuilder ssb = new SpannableStringBuilderEx("..."); + ssb.setSpan(new StyleSpan(Typeface.BOLD), 0, ssb.length(), 0); + tvBody.setText(ssb); + tvBody.setVisibility(View.VISIBLE); + wvBody.setVisibility(View.GONE); + bindExtras(message); + } else { + if (show_full) { + // Create web view + WebViewEx webView; + if (wvBody instanceof WebView) + webView = (WebViewEx) wvBody; + else { + try { + webView = new WebViewEx(context); + } catch (Throwable ex) { /* android.util.AndroidRuntimeException: java.lang.reflect.InvocationTargetException at android.webkit.WebViewFactory.getProvider(WebViewFactory.java:270) @@ -2565,83 +2573,84 @@ public class AdapterMessage extends RecyclerView.Adapter(WebView.java:574) at android.webkit.WebView.(WebView.java:564) */ - Log.unexpectedError(parentFragment.getParentFragmentManager(), ex, false); - return; + Log.unexpectedError(parentFragment.getParentFragmentManager(), ex, false); + return; + } + + webView.setId(wvBody.getId()); + + ConstraintLayout cl = (ConstraintLayout) vsBody; + cl.removeView(wvBody); + cl.addView(webView, wvBody.getLayoutParams()); + cl.setPadding( + wvBody.getPaddingLeft(), wvBody.getPaddingTop(), + wvBody.getPaddingRight(), wvBody.getPaddingBottom()); + + wvBody = webView; } - webView.setId(wvBody.getId()); + webView.setMinimumHeight(dp60); - ConstraintLayout cl = (ConstraintLayout) vsBody; - cl.removeView(wvBody); - cl.addView(webView, wvBody.getLayoutParams()); - cl.setPadding( - wvBody.getPaddingLeft(), wvBody.getPaddingTop(), - wvBody.getPaddingRight(), wvBody.getPaddingBottom()); - - wvBody = webView; - } - - webView.setMinimumHeight(dp60); - - int maxHeight = (rv == null ? 0 : rv.getHeight() - rv.getPaddingTop()); - webView.init(height, maxHeight, size, position, force_light, - new WebViewEx.IWebView() { - @Override - public void onSizeChanged(int w, int h, int ow, int oh) { - if (h > dp60) - properties.setHeight(message.id, h); - } - - @Override - public void onScaleChanged(float newScale) { - properties.setSize(message.id, newScale); - } - - @Override - public void onScrollChange(int scrollX, int scrollY) { - properties.setPosition(message.id, new Pair(scrollX, scrollY)); - } - - @Override - public void onOverScrolled(int scrollX, int scrollY, int dx, int dy, boolean clampedX, boolean clampedY) { - if (clampedY && ((WebViewEx) wvBody).isZoomedY()) { - boolean flinged = false; - try { - if (!webview_legacy && rv != null) - flinged = rv.fling(dx * 10, dy * 10); - } catch (Throwable ex) { - Log.e(ex); - } - if (!flinged) - properties.scrollBy(dx, dy); + int maxHeight = (rv == null ? 0 : rv.getHeight() - rv.getPaddingTop()); + webView.init(height, maxHeight, size, position, force_light, + new WebViewEx.IWebView() { + @Override + public void onSizeChanged(int w, int h, int ow, int oh) { + if (h > dp60) + properties.setHeight(message.id, h); } - } - @Override - public boolean onOpenLink(String url) { - if (parentFragment == null) - return false; + @Override + public void onScaleChanged(float newScale) { + properties.setSize(message.id, newScale); + } - Uri uri = Uri.parse(url); - return ViewHolder.this.onOpenLink(uri, null, false); - } - }); - webView.setImages(show_images, inline); - webView.setOnTouchListener(touchListener); + @Override + public void onScrollChange(int scrollX, int scrollY) { + properties.setPosition(message.id, new Pair(scrollX, scrollY)); + } - tvBody.setVisibility(View.GONE); - wvBody.setVisibility(View.VISIBLE); - } else { - tvBody.setMinHeight(height); + @Override + public void onOverScrolled(int scrollX, int scrollY, int dx, int dy, boolean clampedX, boolean clampedY) { + if (clampedY && ((WebViewEx) wvBody).isZoomedY()) { + boolean flinged = false; + try { + if (!webview_legacy && rv != null) + flinged = rv.fling(dx * 10, dy * 10); + } catch (Throwable ex) { + Log.e(ex); + } + if (!flinged) + properties.scrollBy(dx, dy); + } + } - if (size != 0) - tvBody.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); + @Override + public boolean onOpenLink(String url) { + if (parentFragment == null) + return false; - tvBody.setTextColor(contrast ? textColorPrimary : colorRead); - tvBody.setTypeface(StyleHelper.getTypeface(display_font, context)); + Uri uri = Uri.parse(url); + return ViewHolder.this.onOpenLink(uri, null, false); + } + }); + webView.setImages(show_images, inline); + webView.setOnTouchListener(touchListener); - tvBody.setVisibility(View.VISIBLE); - wvBody.setVisibility(View.GONE); + tvBody.setVisibility(View.GONE); + wvBody.setVisibility(View.VISIBLE); + } else { + tvBody.setMinHeight(height); + + if (size != 0) + tvBody.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); + + tvBody.setTextColor(contrast ? textColorPrimary : colorRead); + tvBody.setTypeface(StyleHelper.getTypeface(display_font, context)); + + tvBody.setVisibility(View.VISIBLE); + wvBody.setVisibility(View.GONE); + } } final Bundle args = new Bundle(); @@ -2936,13 +2945,8 @@ public class AdapterMessage extends RecyclerView.Adapter= Build.VERSION_CODES.Q) - bindConversationActions(message, args.getParcelable("actions")); - bindExtras(message); + if (!message.isEncrypted() || message.isUnlocked()) { + if (show_full) { + ((WebViewEx) wvBody).setOnPageLoaded(new Runnable() { + @Override + public void run() { + try { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) + bindConversationActions(message, args.getParcelable("actions")); + bindExtras(message); - cowner.start(); // Show attachments - } catch (Throwable ex) { - Log.e(ex); + cowner.start(); // Show attachments + } catch (Throwable ex) { + Log.e(ex); + } } - } - }); + }); - if (result == null) - ((WebView) wvBody).loadDataWithBaseURL(null, "", "text/html", StandardCharsets.UTF_8.name(), null); - else - ((WebView) wvBody).loadDataWithBaseURL(null, (String) result, "text/html", StandardCharsets.UTF_8.name(), null); - } else { - tvBody.post(new Runnable() { - @Override - public void run() { - try { - tvBody.setText((Spanned) result); - vwRipple.setVisibility(View.VISIBLE); + if (result == null) + ((WebView) wvBody).loadDataWithBaseURL(null, "", "text/html", StandardCharsets.UTF_8.name(), null); + else + ((WebView) wvBody).loadDataWithBaseURL(null, (String) result, "text/html", StandardCharsets.UTF_8.name(), null); + } else { + tvBody.post(new Runnable() { + @Override + public void run() { + try { + tvBody.setText((Spanned) result); + vwRipple.setVisibility(View.VISIBLE); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) - bindConversationActions(message, args.getParcelable("actions")); - bindExtras(message); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) + bindConversationActions(message, args.getParcelable("actions")); + bindExtras(message); - cowner.start(); // Show attachments - } catch (Throwable ex) { - Log.e(ex); + cowner.start(); // Show attachments + } catch (Throwable ex) { + Log.e(ex); + } } - } - }); + }); + } } if (scroll) diff --git a/app/src/main/java/eu/faircode/email/EntityMessage.java b/app/src/main/java/eu/faircode/email/EntityMessage.java index 5162292ffa..8a999ec1ad 100644 --- a/app/src/main/java/eu/faircode/email/EntityMessage.java +++ b/app/src/main/java/eu/faircode/email/EntityMessage.java @@ -354,6 +354,18 @@ public class EntityMessage implements Serializable { EntityMessage.SMIME_SIGNENCRYPT.equals(ui_encrypt)); } + boolean isVerifiable(){ + return (EntityMessage.PGP_SIGNONLY.equals(encrypt) || + EntityMessage.SMIME_SIGNONLY.equals(encrypt)); + } + + boolean isUnlocked() { + return (EntityMessage.PGP_SIGNENCRYPT.equals(ui_encrypt) && + !EntityMessage.PGP_SIGNENCRYPT.equals(encrypt)) || + (EntityMessage.SMIME_SIGNENCRYPT.equals(ui_encrypt) && + !EntityMessage.SMIME_SIGNENCRYPT.equals(encrypt)); + } + String[] checkFromDomain(Context context) { return MessageHelper.equalRootDomain(context, from, smtp_from); }