adjust other relevant element sizes in headline and article views based

on user setting
This commit is contained in:
Andrew Dolgov 2014-01-25 13:17:27 +04:00
parent 53e9a7d9f3
commit 86daa8ee53
5 changed files with 52 additions and 12 deletions

View File

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

View File

@ -94,8 +94,11 @@ public class ArticleFragment extends Fragment {
if (m_article != null) {
TextView title = (TextView)view.findViewById(R.id.title);
int articleFontSize = Integer.parseInt(m_prefs.getString("article_font_size_sp", "16"));
int articleSmallFontSize = Math.max(10, Math.min(18, articleFontSize - 2));
TextView title = (TextView)view.findViewById(R.id.title);
if (title != null) {
String titleStr;
@ -104,8 +107,8 @@ public class ArticleFragment extends Fragment {
titleStr = m_article.title.substring(0, 200) + "...";
else
titleStr = m_article.title;
title.setTextSize(TypedValue.COMPLEX_UNIT_SP, Math.min(21, articleFontSize + 3));
title.setText(Html.fromHtml(titleStr));
//title.setPaintFlags(title.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
title.setOnClickListener(new OnClickListener() {
@ -131,6 +134,8 @@ public class ArticleFragment extends Fragment {
if (comments != null) {
if (m_activity.getApiLevel() >= 4 && m_article.comments_count > 0) {
comments.setTextSize(TypedValue.COMPLEX_UNIT_SP, articleSmallFontSize);
String commentsTitle = getString(R.string.article_comments, m_article.comments_count);
comments.setText(commentsTitle);
//comments.setPaintFlags(title.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
@ -161,6 +166,7 @@ public class ArticleFragment extends Fragment {
if (note != null) {
if (m_article.note != null && !"".equals(m_article.note)) {
note.setTextSize(TypedValue.COMPLEX_UNIT_SP, articleSmallFontSize);
note.setText(m_article.note);
} else {
note.setVisibility(View.GONE);
@ -259,7 +265,7 @@ public class ArticleFragment extends Fragment {
cssOverride += "body { text-align : justify; } ";
}
ws.setDefaultFontSize(Integer.parseInt(m_prefs.getString("article_font_size_sp", "16")));
ws.setDefaultFontSize(articleFontSize);
content =
"<html>" +
@ -329,6 +335,8 @@ public class ArticleFragment extends Fragment {
TextView dv = (TextView)view.findViewById(R.id.date);
if (dv != null) {
dv.setTextSize(TypedValue.COMPLEX_UNIT_SP, articleSmallFontSize);
Date d = new Date(m_article.updated * 1000L);
DateFormat df = new SimpleDateFormat("MMM dd, HH:mm");
dv.setText(df.format(d));
@ -339,6 +347,8 @@ public class ArticleFragment extends Fragment {
boolean hasAuthor = false;
if (author != null) {
author.setTextSize(TypedValue.COMPLEX_UNIT_SP, articleSmallFontSize);
if (m_article.author != null && m_article.author.length() > 0) {
author.setText(getString(R.string.author_formatted, m_article.author));
} else {
@ -350,6 +360,8 @@ public class ArticleFragment extends Fragment {
TextView tagv = (TextView)view.findViewById(R.id.tags);
if (tagv != null) {
tagv.setTextSize(TypedValue.COMPLEX_UNIT_SP, articleSmallFontSize);
if (m_article.feed_title != null) {
String fTitle = m_article.feed_title;

View File

@ -658,6 +658,9 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
final Article article = items.get(position);
int headlineFontSize = Integer.parseInt(m_prefs.getString("headlines_font_size_sp", "13"));
int headlineSmallFontSize = Math.max(10, Math.min(18, headlineFontSize - 2));
if (v == null) {
int layoutId = R.layout.headlines_row;
@ -686,19 +689,21 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
TextView tt = (TextView)v.findViewById(R.id.title);
if (tt != null) {
tt.setTextSize(TypedValue.COMPLEX_UNIT_SP, Math.min(21, headlineFontSize + 3));
tt.setText(Html.fromHtml(article.title));
adjustTitleTextView(article.score, tt, position);
}
TextView ft = (TextView)v.findViewById(R.id.feed_title);
if (ft != null) {
if (ft != null) {
if (article.feed_title != null && (m_feed.is_cat || m_feed.id < 0)) {
/* if (article.feed_title.length() > 20)
ft.setText(article.feed_title.substring(0, 20) + "...");
else */
ft.setTextSize(TypedValue.COMPLEX_UNIT_SP, headlineSmallFontSize);
ft.setText(article.feed_title);
} else {
@ -754,7 +759,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
if (excerpt.length() > CommonActivity.EXCERPT_MAX_SIZE)
excerpt = excerpt.substring(0, CommonActivity.EXCERPT_MAX_SIZE) + "...";
te.setTextSize(TypedValue.COMPLEX_UNIT_SP, Integer.parseInt(m_prefs.getString("headlines_font_size_sp", "13")));
te.setTextSize(TypedValue.COMPLEX_UNIT_SP, headlineFontSize);
te.setText(excerpt);
}
}
@ -763,12 +768,15 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
TextView author = (TextView)v.findViewById(R.id.author);
if (author != null)
if (author != null) {
author.setTextSize(TypedValue.COMPLEX_UNIT_SP, headlineSmallFontSize);
if (articleAuthor.length() > 0) {
author.setText(getString(R.string.author_formatted, articleAuthor));
} else {
author.setText("");
}
}
/* ImageView separator = (ImageView)v.findViewById(R.id.headlines_separator);
@ -779,6 +787,8 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
TextView dv = (TextView) v.findViewById(R.id.date);
if (dv != null) {
dv.setTextSize(TypedValue.COMPLEX_UNIT_SP, headlineSmallFontSize);
Date d = new Date((long)article.updated * 1000);
DateFormat df = new SimpleDateFormat("MMM dd, HH:mm");
df.setTimeZone(TimeZone.getDefault());

View File

@ -131,6 +131,8 @@ public class OfflineArticleFragment extends Fragment {
m_cursor.moveToFirst();
if (m_cursor.isFirst()) {
int articleFontSize = Integer.parseInt(m_prefs.getString("article_font_size_sp", "16"));
int articleSmallFontSize = Math.max(10, Math.min(18, articleFontSize - 2));
TextView title = (TextView)view.findViewById(R.id.title);
@ -145,6 +147,7 @@ public class OfflineArticleFragment extends Fragment {
else
titleStr = m_cursor.getString(m_cursor.getColumnIndex("title"));
title.setTextSize(TypedValue.COMPLEX_UNIT_SP, Math.min(21, articleFontSize + 3));
title.setText(titleStr);
//title.setPaintFlags(title.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
title.setOnClickListener(new OnClickListener() {
@ -281,7 +284,7 @@ public class OfflineArticleFragment extends Fragment {
cssOverride += "body { text-align : justify; } ";
}
ws.setDefaultFontSize(Integer.parseInt(m_prefs.getString("article_font_size_sp", "16")));
ws.setDefaultFontSize(articleFontSize);
content =
"<html>" +
@ -323,6 +326,8 @@ public class OfflineArticleFragment extends Fragment {
TextView dv = (TextView)view.findViewById(R.id.date);
if (dv != null) {
dv.setTextSize(TypedValue.COMPLEX_UNIT_SP, articleSmallFontSize);
Date d = new Date(m_cursor.getInt(m_cursor.getColumnIndex("updated")) * 1000L);
DateFormat df = new SimpleDateFormat("MMM dd, HH:mm");
dv.setText(df.format(d));
@ -333,6 +338,8 @@ public class OfflineArticleFragment extends Fragment {
boolean hasAuthor = false;
if (author != null) {
author.setTextSize(TypedValue.COMPLEX_UNIT_SP, articleSmallFontSize);
int authorIndex = m_cursor.getColumnIndex("author");
if (authorIndex >= 0)
author.setText(m_cursor.getString(authorIndex));
@ -345,6 +352,8 @@ public class OfflineArticleFragment extends Fragment {
TextView tagv = (TextView)view.findViewById(R.id.tags);
if (tagv != null) {
tagv.setTextSize(TypedValue.COMPLEX_UNIT_SP, articleSmallFontSize);
int feedTitleIndex = m_cursor.getColumnIndex("feed_title");
if (feedTitleIndex != -1 /* && m_isCat */) {

View File

@ -462,6 +462,9 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
Cursor article = (Cursor)getItem(position);
final int articleId = article.getInt(0);
int headlineFontSize = Integer.parseInt(m_prefs.getString("headlines_font_size_sp", "13"));
int headlineSmallFontSize = Math.max(10, Math.min(18, headlineFontSize - 2));
if (v == null) {
int layoutId = R.layout.headlines_row;
@ -490,6 +493,7 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
TextView tt = (TextView)v.findViewById(R.id.title);
if (tt != null) {
tt.setTextSize(TypedValue.COMPLEX_UNIT_SP, Math.min(21, headlineFontSize + 3));
tt.setText(Html.fromHtml(article.getString(article.getColumnIndex("title"))));
int scoreIndex = article.getColumnIndex("score");
@ -508,6 +512,7 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
feedTitle = feedTitle.substring(0, 20) + "...";
if (feedTitle.length() > 0) {
ft.setTextSize(TypedValue.COMPLEX_UNIT_SP, headlineSmallFontSize);
ft.setText(feedTitle);
} else {
ft.setVisibility(View.GONE);
@ -569,7 +574,7 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
if (excerpt.length() > CommonActivity.EXCERPT_MAX_SIZE)
excerpt = excerpt.substring(0, CommonActivity.EXCERPT_MAX_SIZE) + "...";
te.setTextSize(TypedValue.COMPLEX_UNIT_SP, Integer.parseInt(m_prefs.getString("headlines_font_size_sp", "13")));
te.setTextSize(TypedValue.COMPLEX_UNIT_SP, headlineFontSize);
te.setText(excerpt);
}
}
@ -581,7 +586,9 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
if (authorIndex >= 0) {
String author = article.getString(authorIndex);
if (author != null && author.length() > 0)
ta.setTextSize(TypedValue.COMPLEX_UNIT_SP, headlineSmallFontSize);
if (author != null && author.length() > 0)
ta.setText(getString(R.string.author_formatted, author));
else
ta.setText("");
@ -597,6 +604,8 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
TextView dv = (TextView) v.findViewById(R.id.date);
if (dv != null) {
dv.setTextSize(TypedValue.COMPLEX_UNIT_SP, headlineSmallFontSize);
Date d = new Date((long)article.getInt(article.getColumnIndex("updated")) * 1000);
DateFormat df = new SimpleDateFormat("MMM dd, HH:mm");
df.setTimeZone(TimeZone.getDefault());