diff options
author | Andrew Dolgov <[email protected]> | 2013-11-24 01:56:01 +0400 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2013-11-24 01:56:01 +0400 |
commit | 3d23240bb0c10c0393dcf286a1d52f69bc0a24cc (patch) | |
tree | 99e252915cb93089953ef220ef0e47652164a56a | |
parent | 3b3b79ade20b6b5e808faa262e868a04c6dd985d (diff) |
allow more precise font size selection for headlines & article
remove single_column layout stuff
-rw-r--r-- | res/values/arrays.xml | 10 | ||||
-rw-r--r-- | res/xml/preferences.xml | 19 | ||||
-rw-r--r-- | src/org/fox/ttrss/ArticleFragment.java | 34 | ||||
-rw-r--r-- | src/org/fox/ttrss/HeadlinesFragment.java | 16 | ||||
-rw-r--r-- | src/org/fox/ttrss/offline/OfflineArticleFragment.java | 32 | ||||
-rw-r--r-- | src/org/fox/ttrss/offline/OfflineHeadlinesFragment.java | 16 |
6 files changed, 20 insertions, 107 deletions
diff --git a/res/values/arrays.xml b/res/values/arrays.xml index 63e90184..b26a97a5 100644 --- a/res/values/arrays.xml +++ b/res/values/arrays.xml @@ -11,16 +11,6 @@ <item>THEME_LIGHT</item> <item>THEME_SEPIA</item> </string-array> - <string-array name="pref_font_size_names"> - <item>@string/font_size_small</item> - <item>@string/font_size_medium</item> - <item>@string/font_size_large</item> - </string-array> - <string-array name="pref_font_size_values" translatable="false"> - <item>0</item> - <item>1</item> - <item>2</item> - </string-array> <string-array name="pref_view_mode_names"> <item>@string/category_browse_headlines</item> <item>@string/category_browse_articles</item> diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml index ec74841a..addf8852 100644 --- a/res/xml/preferences.xml +++ b/res/xml/preferences.xml @@ -103,21 +103,18 @@ android:summary="@string/pref_headlines_mark_read_scroll_long"
android:title="@string/pref_headlines_mark_read_scroll" />
- <ListPreference
- android:defaultValue="0"
- android:entries="@array/pref_font_size_names"
- android:entryValues="@array/pref_font_size_values"
- android:key="headlines_font_size"
+ <EditTextPreference
+ android:defaultValue="13"
+ android:key="headlines_font_size_sp"
+ android:inputType="number"
android:title="@string/pref_headline_font_size" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/reading" >
- <ListPreference
- android:defaultValue="0"
- android:entries="@array/pref_font_size_names"
- android:entryValues="@array/pref_font_size_values"
- android:key="font_size"
+ <EditTextPreference
+ android:defaultValue="16"
+ android:key="article_font_size_sp"
+ android:inputType="number"
android:title="@string/pref_font_size" />
-
<CheckBoxPreference
android:defaultValue="true"
android:key="justify_article_text"
diff --git a/src/org/fox/ttrss/ArticleFragment.java b/src/org/fox/ttrss/ArticleFragment.java index fb0e2aa8..d7791d83 100644 --- a/src/org/fox/ttrss/ArticleFragment.java +++ b/src/org/fox/ttrss/ArticleFragment.java @@ -1,6 +1,5 @@ package org.fox.ttrss; -import java.lang.reflect.Method; import java.net.MalformedURLException; import java.net.URI; import java.net.URL; @@ -25,20 +24,16 @@ import android.os.Bundle; import android.preference.PreferenceManager; import android.support.v4.app.Fragment; import android.text.Html; -import android.util.Log; import android.util.TypedValue; import android.view.ContextMenu; import android.view.ContextMenu.ContextMenuInfo; -import android.view.GestureDetector; import android.view.KeyEvent; import android.view.LayoutInflater; -import android.view.MotionEvent; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.webkit.WebChromeClient; import android.webkit.WebSettings; -import android.webkit.WebSettings.LayoutAlgorithm; import android.webkit.WebView; import android.webkit.WebView.HitTestResult; import android.widget.TextView; @@ -219,13 +214,7 @@ public class ArticleFragment extends Fragment { String cssOverride = ""; WebSettings ws = web.getSettings(); - ws.setSupportZoom(true); - ws.setBuiltInZoomControls(true); - - if (!m_activity.isCompatMode()) - ws.setDisplayZoomControls(false); - - web.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN); + ws.setSupportZoom(false); TypedValue tv = new TypedValue(); getActivity().getTheme().resolveAttribute(R.attr.linkColor, tv, true); @@ -270,30 +259,17 @@ public class ArticleFragment extends Fragment { cssOverride += "body { text-align : justify; } "; } - switch (Integer.parseInt(m_prefs.getString("font_size", "0"))) { - case 0: - ws.setDefaultFontSize(13); - break; - case 1: - ws.setDefaultFontSize(16); - break; - case 2: - ws.setDefaultFontSize(18); - break; - } - - if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) { - cssOverride += "img { max-width : 99%; }"; - } + ws.setDefaultFontSize(Integer.parseInt(m_prefs.getString("article_font_size_sp", "16"))); content = "<html>" + "<head>" + "<meta content=\"text/html; charset=utf-8\" http-equiv=\"content-type\">" + + "<meta name=\"viewport\" content=\"width=device-width, user-scalable=no\" />" + "<style type=\"text/css\">" + - "body { padding : 0px; margin : 0px; }" + + "body { padding : 0px; margin : 0px; line-height : 120%; }" + + "img { max-width : 100%; width : auto; height : auto; }" + cssOverride + - "body { line-height : 120%; }" + "</style>" + "</head>" + "<body>" + articleContent; diff --git a/src/org/fox/ttrss/HeadlinesFragment.java b/src/org/fox/ttrss/HeadlinesFragment.java index a8baa915..13429ec0 100644 --- a/src/org/fox/ttrss/HeadlinesFragment.java +++ b/src/org/fox/ttrss/HeadlinesFragment.java @@ -732,22 +732,8 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, if (excerpt.length() > CommonActivity.EXCERPT_MAX_SIZE) excerpt = excerpt.substring(0, CommonActivity.EXCERPT_MAX_SIZE) + "..."; - - int fontSize = -1; - - switch (Integer.parseInt(m_prefs.getString("headlines_font_size", "0"))) { - case 0: - fontSize = 13; - break; - case 1: - fontSize = 16; - break; - case 2: - fontSize = 18; - break; - } - te.setTextSize(TypedValue.COMPLEX_UNIT_SP, fontSize); + te.setTextSize(TypedValue.COMPLEX_UNIT_SP, Integer.parseInt(m_prefs.getString("headlines_font_size_sp", "13"))); te.setText(excerpt); } } diff --git a/src/org/fox/ttrss/offline/OfflineArticleFragment.java b/src/org/fox/ttrss/offline/OfflineArticleFragment.java index de50d42c..a1033aec 100644 --- a/src/org/fox/ttrss/offline/OfflineArticleFragment.java +++ b/src/org/fox/ttrss/offline/OfflineArticleFragment.java @@ -29,17 +29,14 @@ import android.util.Log; import android.util.TypedValue; import android.view.ContextMenu; import android.view.ContextMenu.ContextMenuInfo; -import android.view.GestureDetector; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.MenuItem; -import android.view.MotionEvent; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.webkit.WebChromeClient; import android.webkit.WebSettings; -import android.webkit.WebSettings.LayoutAlgorithm; import android.webkit.WebView; import android.webkit.WebView.HitTestResult; import android.widget.TextView; @@ -220,13 +217,7 @@ public class OfflineArticleFragment extends Fragment { String cssOverride = ""; WebSettings ws = web.getSettings(); - ws.setSupportZoom(true); - ws.setBuiltInZoomControls(true); - - if (!m_activity.isCompatMode()) - ws.setDisplayZoomControls(false); - - web.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN); + ws.setSupportZoom(false); TypedValue tv = new TypedValue(); getActivity().getTheme().resolveAttribute(R.attr.linkColor, tv, true); @@ -290,30 +281,17 @@ public class OfflineArticleFragment extends Fragment { cssOverride += "body { text-align : justify; } "; } - switch (Integer.parseInt(m_prefs.getString("font_size", "0"))) { - case 0: - ws.setDefaultFontSize(13); - break; - case 1: - ws.setDefaultFontSize(16); - break; - case 2: - ws.setDefaultFontSize(18); - break; - } - - if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) { - cssOverride += "img { max-width : 99%; }"; - } + ws.setDefaultFontSize(Integer.parseInt(m_prefs.getString("article_font_size_sp", "16"))); content = "<html>" + "<head>" + "<meta content=\"text/html; charset=utf-8\" http-equiv=\"content-type\">" + + "<meta name=\"viewport\" content=\"width=device-width, user-scalable=no\" />" + "<style type=\"text/css\">" + - "body { padding : 0px; margin : 0px; }" + + "body { padding : 0px; margin : 0px; line-height : 120%; }" + cssOverride + - "body { line-height : 120%; }" + + "img { max-width : 100%; width : auto; height : auto; }" + "</style>" + "</head>" + "<body>" + articleContent; diff --git a/src/org/fox/ttrss/offline/OfflineHeadlinesFragment.java b/src/org/fox/ttrss/offline/OfflineHeadlinesFragment.java index 72892081..b4383319 100644 --- a/src/org/fox/ttrss/offline/OfflineHeadlinesFragment.java +++ b/src/org/fox/ttrss/offline/OfflineHeadlinesFragment.java @@ -568,22 +568,8 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis if (excerpt.length() > CommonActivity.EXCERPT_MAX_SIZE) excerpt = excerpt.substring(0, CommonActivity.EXCERPT_MAX_SIZE) + "..."; - - int fontSize = -1; - - switch (Integer.parseInt(m_prefs.getString("headlines_font_size", "0"))) { - case 0: - fontSize = 13; - break; - case 1: - fontSize = 16; - break; - case 2: - fontSize = 18; - break; - } - te.setTextSize(TypedValue.COMPLEX_UNIT_SP, fontSize); + te.setTextSize(TypedValue.COMPLEX_UNIT_SP, Integer.parseInt(m_prefs.getString("headlines_font_size_sp", "13"))); te.setText(excerpt); } } |