diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 0b919ea8..b95b7361 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="235" + android:versionName="1.38" > + + 200) @@ -108,7 +122,6 @@ public class ArticleFragment extends Fragment { 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() { diff --git a/src/org/fox/ttrss/HeadlinesFragment.java b/src/org/fox/ttrss/HeadlinesFragment.java index 231a66d6..c6380b94 100644 --- a/src/org/fox/ttrss/HeadlinesFragment.java +++ b/src/org/fox/ttrss/HeadlinesFragment.java @@ -11,6 +11,7 @@ import org.fox.ttrss.types.Article; import org.fox.ttrss.types.ArticleList; import org.fox.ttrss.types.Feed; import org.fox.ttrss.util.HeadlinesRequest; +import org.fox.ttrss.util.TypefaceCache; import org.jsoup.Jsoup; import uk.co.senab.actionbarpulltorefresh.library.PullToRefreshAttacher.OnRefreshListener; @@ -21,6 +22,7 @@ import android.content.Intent; import android.content.SharedPreferences; import android.content.res.Resources.Theme; import android.graphics.Paint; +import android.graphics.Typeface; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.net.Uri; @@ -688,9 +690,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)); + if (tt != null) { tt.setText(Html.fromHtml(article.title)); + + if (m_prefs.getBoolean("enable_condensed_fonts", false)) { + Typeface tf = TypefaceCache.get(m_activity, "sans-serif-condensed", article.unread ? Typeface.BOLD : Typeface.NORMAL); + + if (tf != null && !tf.equals(tt.getTypeface())) { + tt.setTypeface(tf); + } + + tt.setTextSize(TypedValue.COMPLEX_UNIT_SP, Math.min(21, headlineFontSize + 5)); + } else { + tt.setTextSize(TypedValue.COMPLEX_UNIT_SP, Math.min(21, headlineFontSize + 3)); + } + adjustTitleTextView(article.score, tt, position); } diff --git a/src/org/fox/ttrss/PreferencesActivity.java b/src/org/fox/ttrss/PreferencesActivity.java index 6b9599da..f42154a7 100644 --- a/src/org/fox/ttrss/PreferencesActivity.java +++ b/src/org/fox/ttrss/PreferencesActivity.java @@ -14,7 +14,11 @@ public class PreferencesActivity extends PreferenceActivity { if (compatMode) { findPreference("dim_status_bar").setEnabled(false); - findPreference("webview_hardware_accel").setEnabled(false); + findPreference("webview_hardware_accel").setEnabled(false); + } + + if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) { + findPreference("enable_condensed_fonts").setEnabled(false); } } diff --git a/src/org/fox/ttrss/offline/OfflineArticleFragment.java b/src/org/fox/ttrss/offline/OfflineArticleFragment.java index 668e9575..59838ea7 100644 --- a/src/org/fox/ttrss/offline/OfflineArticleFragment.java +++ b/src/org/fox/ttrss/offline/OfflineArticleFragment.java @@ -9,6 +9,7 @@ import java.util.Date; import org.fox.ttrss.R; import org.fox.ttrss.util.ImageCacheService; +import org.fox.ttrss.util.TypefaceCache; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; @@ -20,6 +21,7 @@ import android.content.Intent; import android.content.SharedPreferences; import android.database.Cursor; import android.graphics.Color; +import android.graphics.Typeface; import android.net.Uri; import android.os.Bundle; import android.preference.PreferenceManager; @@ -140,14 +142,25 @@ public class OfflineArticleFragment extends Fragment { if (title != null) { + if (m_prefs.getBoolean("enable_condensed_fonts", false)) { + Typeface tf = TypefaceCache.get(m_activity, "sans-serif-condensed", Typeface.NORMAL); + + if (tf != null && !tf.equals(title.getTypeface())) { + title.setTypeface(tf); + } + + title.setTextSize(TypedValue.COMPLEX_UNIT_SP, Math.min(21, articleFontSize + 5)); + } else { + title.setTextSize(TypedValue.COMPLEX_UNIT_SP, Math.min(21, articleFontSize + 3)); + } + String titleStr; if (m_cursor.getString(m_cursor.getColumnIndex("title")).length() > 200) titleStr = m_cursor.getString(m_cursor.getColumnIndex("title")).substring(0, 200) + "..."; 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() { diff --git a/src/org/fox/ttrss/offline/OfflineHeadlinesFragment.java b/src/org/fox/ttrss/offline/OfflineHeadlinesFragment.java index a780c43c..f9e6056e 100644 --- a/src/org/fox/ttrss/offline/OfflineHeadlinesFragment.java +++ b/src/org/fox/ttrss/offline/OfflineHeadlinesFragment.java @@ -8,6 +8,7 @@ import java.util.TimeZone; import org.fox.ttrss.CommonActivity; import org.fox.ttrss.GlobalState; import org.fox.ttrss.R; +import org.fox.ttrss.util.TypefaceCache; import org.jsoup.Jsoup; import android.app.Activity; @@ -17,6 +18,7 @@ import android.content.res.Resources.Theme; import android.database.Cursor; import android.database.sqlite.SQLiteStatement; import android.graphics.Paint; +import android.graphics.Typeface; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.os.Bundle; @@ -493,9 +495,21 @@ 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")))); + if (m_prefs.getBoolean("enable_condensed_fonts", false)) { + Typeface tf = TypefaceCache.get(m_activity, "sans-serif-condensed", article.getInt(article.getColumnIndex("unread")) == 1 ? Typeface.BOLD : Typeface.NORMAL); + + if (tf != null && !tf.equals(tt.getTypeface())) { + tt.setTypeface(tf); + } + + tt.setTextSize(TypedValue.COMPLEX_UNIT_SP, Math.min(21, headlineFontSize + 5)); + } else { + tt.setTextSize(TypedValue.COMPLEX_UNIT_SP, Math.min(21, headlineFontSize + 3)); + } + int scoreIndex = article.getColumnIndex("score"); if (scoreIndex >= 0) adjustTitleTextView(article.getInt(scoreIndex), tt, position); diff --git a/src/org/fox/ttrss/util/TypefaceCache.java b/src/org/fox/ttrss/util/TypefaceCache.java new file mode 100644 index 00000000..150d3d83 --- /dev/null +++ b/src/org/fox/ttrss/util/TypefaceCache.java @@ -0,0 +1,29 @@ +package org.fox.ttrss.util; + +import java.util.Hashtable; + +import android.content.Context; +import android.graphics.Typeface; +import android.util.Log; + +public class TypefaceCache { + private static final String TAG = "TypefaceCache"; + private static final Hashtable cache = new Hashtable(); + + public static Typeface get(Context c, String typefaceName, int style) { + synchronized (cache) { + String key = typefaceName + ":" + style; + + if (!cache.containsKey(key)) { + try { + Typeface t = Typeface.create(typefaceName, style); + cache.put(key, t); + } catch (Exception e) { + Log.e(TAG, "Could not get typeface '" + typefaceName + "' because " + e.getMessage()); + return null; + } + } + return cache.get(key); + } + } +} \ No newline at end of file