diff --git a/app/src/main/java/com/readrops/app/utils/ReadropsWebView.java b/app/src/main/java/com/readrops/app/utils/ReadropsWebView.java index 719d715c..18b6b690 100644 --- a/app/src/main/java/com/readrops/app/utils/ReadropsWebView.java +++ b/app/src/main/java/com/readrops/app/utils/ReadropsWebView.java @@ -44,11 +44,11 @@ public class ReadropsWebView extends WebView { if (itemWithFeed.getItem().getText() != null) { Document document = Jsoup.parse(itemWithFeed.getItem().getText()); - document.head().append(""); - document.head().append(""); + return getContext().getString(R.string.webview_html_template, String.valueOf(width), + Utils.getCssColor(itemWithFeed.getBgColor() != 0 ? itemWithFeed.getBgColor() : + (itemWithFeed.getColor() != 0 ? itemWithFeed.getColor() : getResources().getColor(R.color.colorPrimary))), + document.body().html()); - return document.toString(); } else return null; diff --git a/app/src/main/java/com/readrops/app/utils/Utils.java b/app/src/main/java/com/readrops/app/utils/Utils.java index 50606623..b28ff57c 100644 --- a/app/src/main/java/com/readrops/app/utils/Utils.java +++ b/app/src/main/java/com/readrops/app/utils/Utils.java @@ -5,13 +5,16 @@ import android.app.Application; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; +import android.graphics.Color; import android.os.Handler; import android.os.Looper; +import android.support.annotation.ColorInt; import android.util.DisplayMetrics; import android.widget.Toast; import java.io.IOException; import java.io.InputStream; +import java.util.Locale; import okhttp3.OkHttpClient; import okhttp3.Request; @@ -64,4 +67,12 @@ public final class Utils { return minutes; } + public static String getCssColor(@ColorInt int color) { + return String.format(Locale.US, "rgba(%d,%d,%d,%.2f)", + Color.red(color), + Color.green(color), + Color.blue(color), + Color.alpha(color) / 255.0); + } + } diff --git a/app/src/main/res/values/html.xml b/app/src/main/res/values/html.xml new file mode 100644 index 00000000..6246e625 --- /dev/null +++ b/app/src/main/res/values/html.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + %3$s + +]]> + \ No newline at end of file