Fiw webview not displaying item content when using api 29

This commit is contained in:
Shinokuni 2019-11-24 15:54:39 +01:00
parent 0897126117
commit 2f5a140988
1 changed files with 12 additions and 1 deletions

View File

@ -3,9 +3,12 @@ package com.readrops.app.utils;
import android.annotation.SuppressLint;
import android.content.Context;
import android.util.AttributeSet;
import android.util.Base64;
import android.webkit.WebSettings;
import android.webkit.WebView;
import androidx.annotation.Nullable;
import com.readrops.app.R;
import com.readrops.app.database.pojo.ItemWithFeed;
@ -27,7 +30,14 @@ public class ReadropsWebView extends WebView {
public void setItem(ItemWithFeed itemWithFeed) {
this.itemWithFeed = itemWithFeed;
loadData(getText(), "text/html; charset=utf-8", "UTF-8");
String text = getText();
String base64Content = null;
if (text != null)
base64Content = Base64.encodeToString(text.getBytes(), Base64.NO_PADDING);
loadData(base64Content, "text/html; charset=utf-8", "base64");
}
@SuppressLint("SetJavaScriptEnabled")
@ -44,6 +54,7 @@ public class ReadropsWebView extends WebView {
setBackgroundColor(getResources().getColor(R.color.colorBackground));
}
@Nullable
private String getText() {
if (itemWithFeed.getItem().getText() != null) {
Document document = Jsoup.parse(Parser.unescapeEntities(itemWithFeed.getItem().getText(), false), itemWithFeed.getWebsiteUrl());