From 9ab8426aee0ae142d0343d172917c6def470cb51 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Reimar=20D=C3=B6ffinger?= Date: Sat, 11 Feb 2017 19:02:41 +0100 Subject: [PATCH] Apply font size also in WebView. --- .../android/dictionary/HtmlDisplayActivity.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/com/hughes/android/dictionary/HtmlDisplayActivity.java b/src/com/hughes/android/dictionary/HtmlDisplayActivity.java index c4460f0..e96b351 100644 --- a/src/com/hughes/android/dictionary/HtmlDisplayActivity.java +++ b/src/com/hughes/android/dictionary/HtmlDisplayActivity.java @@ -16,7 +16,9 @@ package com.hughes.android.dictionary; import android.content.Context; import android.content.Intent; +import android.content.SharedPreferences; import android.os.Bundle; +import android.preference.PreferenceManager; import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBarActivity; import android.util.Base64; @@ -90,6 +92,15 @@ public final class HtmlDisplayActivity extends ActionBarActivity { html = getIntent().getStringExtra(HTML); } final MyWebView webView = (MyWebView) findViewById(R.id.webView); + final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); + final String fontSize = prefs.getString(getString(R.string.fontSizeKey), "14"); + int fontSizeSp; + try { + fontSizeSp = Integer.parseInt(fontSize.trim()); + } catch (NumberFormatException e) { + fontSizeSp = 14; + } + webView.getSettings().setDefaultFontSize(fontSizeSp); try { // No way to get pure UTF-8 data into WebView html = Base64.encodeToString(html.getBytes("UTF-8"), Base64.DEFAULT); -- 2.43.0