allow more precise font size selection for headlines & article

remove single_column layout stuff
This commit is contained in:
Andrew Dolgov 2013-11-24 01:56:01 +04:00
parent 3b3b79ade2
commit 3d23240bb0
6 changed files with 20 additions and 107 deletions

View File

@ -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>

View File

@ -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"

View File

@ -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;

View File

@ -733,21 +733,7 @@ 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);
}
}

View File

@ -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;

View File

@ -569,21 +569,7 @@ 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);
}
}