support different article text sizes

This commit is contained in:
Andrew Dolgov 2012-02-25 14:05:37 +03:00
parent 9b637ba139
commit feefd1fd9a
9 changed files with 84 additions and 17 deletions

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.fox.ttrss" package="org.fox.ttrss"
android:versionCode="63" android:versionCode="64"
android:versionName="0.5.0" > android:versionName="0.5.1" >
<uses-sdk android:minSdkVersion="7" /> <uses-sdk android:minSdkVersion="7" />

View File

@ -48,6 +48,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_above="@+id/linearLayout3" android:layout_above="@+id/linearLayout3"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:textSize="15sp"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:layout_weight="1" android:layout_weight="1"
android:text="There are many variations of passages of Lorem Ipsum available" /> android:text="There are many variations of passages of Lorem Ipsum available" />

View File

@ -1,12 +1,21 @@
<resources>
<string-array name="pref_theme_names">
<item>@string/theme_dark</item>
<item>@string/theme_light</item>
</string-array>
<string-array name="pref_theme_values">
<item>THEME_DARK</item>
<item>THEME_LIGHT</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">
<item>0</item>
<item>1</item>
<item>2</item>
</string-array>
<resources> </resources>
<string-array name="pref_theme_names">
<item>@string/theme_dark</item>
<item>@string/theme_light</item>
</string-array>
<string-array name="pref_theme_values">
<item>THEME_DARK</item>
<item>THEME_LIGHT</item>
</string-array>
</resources>

View File

@ -118,4 +118,8 @@
<string name="search">Search</string> <string name="search">Search</string>
<string name="cancel">Cancel</string> <string name="cancel">Cancel</string>
<string name="attachments">Attachments:</string> <string name="attachments">Attachments:</string>
<string name="font_size_small">Small</string>
<string name="font_size_medium">Medium</string>
<string name="font_size_large">Large</string>
<string name="pref_font_size">Article text size</string>
</resources> </resources>

View File

@ -19,10 +19,10 @@
<EditTextPreference <EditTextPreference
android:hint="@string/default_url" android:hint="@string/default_url"
android:inputType="textUri"
android:key="ttrss_url" android:key="ttrss_url"
android:singleLine="true" android:singleLine="true"
android:summary="@string/ttrss_url_summary" android:summary="@string/ttrss_url_summary"
android:inputType="textUri"
android:title="@string/ttrss_url" > android:title="@string/ttrss_url" >
</EditTextPreference> </EditTextPreference>
@ -59,6 +59,13 @@
android:summary="@string/pref_theme_long" android:summary="@string/pref_theme_long"
android:title="@string/pref_theme" /> android:title="@string/pref_theme" />
<ListPreference
android:defaultValue="0"
android:entries="@array/pref_font_size_names"
android:entryValues="@array/pref_font_size_values"
android:key="font_size"
android:title="@string/pref_font_size" />
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="false" android:defaultValue="false"
android:key="sort_feeds_by_unread" android:key="sort_feeds_by_unread"

View File

@ -138,6 +138,18 @@ public class ArticleFragment extends Fragment {
articleContent = doc.toString(); articleContent = doc.toString();
} }
switch (Integer.parseInt(m_prefs.getString("font_size", "0"))) {
case 0:
cssOverride += "body { text-align : justify; font-size : 14px; } ";
break;
case 1:
cssOverride += "body { text-align : justify; font-size : 18px; } ";
break;
case 2:
cssOverride += "body { text-align : justify; font-size : 21px; } ";
break;
}
content = content =
"<html>" + "<html>" +
"<head>" + "<head>" +
@ -147,7 +159,6 @@ public class ArticleFragment extends Fragment {
cssOverride + cssOverride +
"div.attachments { font-size : 70%; margin-top : 1em; }" + "div.attachments { font-size : 70%; margin-top : 1em; }" +
"img { max-width : 98%; height : auto; }" + "img { max-width : 98%; height : auto; }" +
"body { text-align : justify; }" +
"</style>" + "</style>" +
"</head>" + "</head>" +
"<body>" + articleContent; "<body>" + articleContent;

View File

@ -469,11 +469,24 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
} }
articleContent += attachments.replaceAll(", $", ""); articleContent += attachments.replaceAll(", $", "");
articleContent += "</div>"; articleContent += "</div>";
} }
//content.setText(Html.fromHtml(article.content, new URLImageGetter(content, getActivity()), null)); //content.setText(Html.fromHtml(article.content, new URLImageGetter(content, getActivity()), null));
content.setText(Html.fromHtml(articleContent, m_dummyGetter, null)); content.setText(Html.fromHtml(articleContent, m_dummyGetter, null));
switch (Integer.parseInt(m_prefs.getString("font_size", "0"))) {
case 0:
content.setTextSize(15F);
break;
case 1:
content.setTextSize(18F);
break;
case 2:
content.setTextSize(21F);
break;
}
} else { } else {
content.setVisibility(View.GONE); content.setVisibility(View.GONE);
} }

View File

@ -151,6 +151,18 @@ public class OfflineArticleFragment extends Fragment {
articleContent = doc.toString(); articleContent = doc.toString();
} }
switch (Integer.parseInt(m_prefs.getString("font_size", "0"))) {
case 0:
cssOverride += "body { text-align : justify; font-size : 14px; } ";
break;
case 1:
cssOverride += "body { text-align : justify; font-size : 18px; } ";
break;
case 2:
cssOverride += "body { text-align : justify; font-size : 21px; } ";
break;
}
content = content =
"<html>" + "<html>" +
"<head>" + "<head>" +
@ -159,7 +171,6 @@ public class OfflineArticleFragment extends Fragment {
"<style type=\"text/css\">" + "<style type=\"text/css\">" +
cssOverride + cssOverride +
"img { max-width : 98%; height : auto; }" + "img { max-width : 98%; height : auto; }" +
"body { text-align : justify; }" +
"</style>" + "</style>" +
"</head>" + "</head>" +
"<body>" + articleContent + "</body></html>"; "<body>" + articleContent + "</body></html>";

View File

@ -357,6 +357,17 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
content.setText(Html.fromHtml(article.getString(article.getColumnIndex("content")), m_dummyGetter, null)); content.setText(Html.fromHtml(article.getString(article.getColumnIndex("content")), m_dummyGetter, null));
switch (Integer.parseInt(m_prefs.getString("font_size", "0"))) {
case 0:
content.setTextSize(15F);
break;
case 1:
content.setTextSize(18F);
break;
case 2:
content.setTextSize(21F);
break;
}
} else { } else {
content.setVisibility(View.GONE); content.setVisibility(View.GONE);
} }