From c8e8aaf850c9caaff78ae3a4f74a905017804aa0 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 12 Nov 2014 15:15:12 +0300 Subject: [PATCH] add amber theme --- .../java/org/fox/ttrss/ArticleFragment.java | 32 +---- .../java/org/fox/ttrss/CommonActivity.java | 7 +- .../ttrss/offline/OfflineArticleFragment.java | 114 +++++++----------- .../src/main/res/layout/article_fragment.xml | 2 +- .../main/res/layout/article_images_pager.xml | 1 + .../src/main/res/layout/feeds_row.xml | 1 + .../main/res/layout/feeds_row_selected.xml | 1 + .../src/main/res/layout/headlines_row.xml | 3 + .../res/layout/headlines_row_selected.xml | 3 + .../layout/headlines_row_selected_unread.xml | 3 + .../main/res/layout/headlines_row_unread.xml | 3 + org.fox.ttrss/src/main/res/values/arrays.xml | 4 +- org.fox.ttrss/src/main/res/values/attrs.xml | 2 + org.fox.ttrss/src/main/res/values/strings.xml | 1 + org.fox.ttrss/src/main/res/values/style.xml | 54 ++++++++- 15 files changed, 127 insertions(+), 104 deletions(-) diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/ArticleFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/ArticleFragment.java index 873935d8..398fa1ad 100644 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/ArticleFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/ArticleFragment.java @@ -123,29 +123,6 @@ public class ArticleFragment extends Fragment { } } - - /* if (!useTitleWebView) { - View scroll = view.findViewById(R.id.article_scrollview); - - if (scroll != null) { - final float scale = getResources().getDisplayMetrics().density; - - if (m_activity.isSmallScreen()) { - scroll.setPadding((int)(8 * scale + 0.5f), - (int)(5 * scale + 0.5f), - (int)(8 * scale + 0.5f), - 0); - } else { - scroll.setPadding((int)(25 * scale + 0.5f), - (int)(10 * scale + 0.5f), - (int)(25 * scale + 0.5f), - 0); - - } - - } - } */ - int articleFontSize = Integer.parseInt(m_prefs.getString("article_font_size_sp", "16")); int articleSmallFontSize = Math.max(10, Math.min(18, articleFontSize - 2)); @@ -282,9 +259,12 @@ public class ArticleFragment extends Fragment { cssOverride = "body { background : "+ backgroundHexColor+"; }"; - if (m_activity.isDarkTheme()) { - cssOverride += "body { color : #e0e0e0; }"; - } + TypedValue tvTextColor = new TypedValue(); + getActivity().getTheme().resolveAttribute(R.attr.articleTextColor, tvTextColor, true); + + String textColor = String.format("#%06X", (0xFFFFFF & tvTextColor.data)); + + cssOverride += "body { color : "+textColor+"; }"; TypedValue tvLinkColor = new TypedValue(); getActivity().getTheme().resolveAttribute(R.attr.linkColor, tvLinkColor, true); diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/CommonActivity.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/CommonActivity.java index 3f729ed3..b94e404d 100644 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/CommonActivity.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/CommonActivity.java @@ -29,6 +29,7 @@ public class CommonActivity extends ActionBarActivity { public final static String THEME_DARK = "THEME_DARK"; public final static String THEME_LIGHT = "THEME_LIGHT"; public final static String THEME_SEPIA = "THEME_SEPIA"; + public final static String THEME_AMBER = "THEME_AMBER"; public final static String THEME_DEFAULT = CommonActivity.THEME_LIGHT; public static final int EXCERPT_MAX_SIZE = 200; @@ -202,14 +203,16 @@ public class CommonActivity extends ActionBarActivity { public boolean isDarkTheme() { String theme = m_prefs.getString("theme", THEME_DEFAULT); - return theme.equals(THEME_DARK); + return theme.equals(THEME_DARK) || theme.equals(THEME_AMBER); } protected void setAppTheme(SharedPreferences prefs) { String theme = prefs.getString("theme", CommonActivity.THEME_DEFAULT); if (theme.equals(THEME_DARK)) { - setTheme(R.style.DarkTheme); + setTheme(R.style.DarkTheme); + } else if (theme.equals(THEME_AMBER)) { + setTheme(R.style.AmberTheme); } else if (theme.equals(THEME_SEPIA)) { setTheme(R.style.SepiaTheme); } else { diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineArticleFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineArticleFragment.java index 64e6c652..ace49c8b 100644 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineArticleFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineArticleFragment.java @@ -164,26 +164,6 @@ public class OfflineArticleFragment extends Fragment { fab.setVisibility(View.GONE); } } - - /* View scroll = view.findViewById(R.id.article_scrollview); - - if (scroll != null) { - final float scale = getResources().getDisplayMetrics().density; - - if (m_activity.isSmallScreen()) { - scroll.setPadding((int)(8 * scale + 0.5f), - (int)(5 * scale + 0.5f), - (int)(8 * scale + 0.5f), - 0); - } else { - scroll.setPadding((int)(25 * scale + 0.5f), - (int)(10 * scale + 0.5f), - (int)(25 * scale + 0.5f), - 0); - - } - - } */ } int articleFontSize = Integer.parseInt(m_prefs.getString("article_font_size_sp", "16")); @@ -269,43 +249,40 @@ public class OfflineArticleFragment extends Fragment { } } }); - - String content; - String cssOverride = ""; - - WebSettings ws = web.getSettings(); - ws.setSupportZoom(false); - TypedValue tv = new TypedValue(); - getActivity().getTheme().resolveAttribute(R.attr.linkColor, tv, true); - - // prevent flicker in ics - if (!m_prefs.getBoolean("webview_hardware_accel", true) || useTitleWebView) { - if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) { - web.setLayerType(View.LAYER_TYPE_SOFTWARE, null); - } - } - - String theme = m_prefs.getString("theme", CommonActivity.THEME_DEFAULT); - - if (CommonActivity.THEME_DARK.equals(theme)) { - cssOverride = "body { background : transparent; color : #e0e0e0}"; - } else { - cssOverride = "body { background : transparent; }"; - } + // prevent flicker in ics + if (!m_prefs.getBoolean("webview_hardware_accel", true) || useTitleWebView) { + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) { + web.setLayerType(View.LAYER_TYPE_SOFTWARE, null); + } + } + + String content; + String cssOverride = ""; + + WebSettings ws = web.getSettings(); + ws.setSupportZoom(false); + + TypedValue tvBackground = new TypedValue(); + getActivity().getTheme().resolveAttribute(R.attr.articleBackground, tvBackground, true); + + String backgroundHexColor = String.format("#%06X", (0xFFFFFF & tvBackground.data)); + + cssOverride = "body { background : "+ backgroundHexColor+"; }"; + + TypedValue tvTextColor = new TypedValue(); + getActivity().getTheme().resolveAttribute(R.attr.articleTextColor, tvTextColor, true); + + String textColor = String.format("#%06X", (0xFFFFFF & tvTextColor.data)); + + cssOverride += "body { color : "+textColor+"; }"; + + TypedValue tvLinkColor = new TypedValue(); + getActivity().getTheme().resolveAttribute(R.attr.linkColor, tvLinkColor, true); + + String linkHexColor = String.format("#%06X", (0xFFFFFF & tvLinkColor.data)); + cssOverride += " a:link {color: "+linkHexColor+";} a:visited { color: "+linkHexColor+";}"; - if (useTitleWebView || android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) { - web.setBackgroundColor(Color.TRANSPARENT); - } else { - // seriously? - web.setBackgroundColor(Color.argb(1, 0, 0, 0)); - } - - String hexColor = String.format("#%06X", (0xFFFFFF & tv.data)); - cssOverride += " a:link {color: "+hexColor+";} a:visited { color: "+hexColor+";}"; - - cssOverride += " table { width : 100%; }"; - String articleContent = m_cursor.getString(m_cursor.getColumnIndex("content")); Document doc = Jsoup.parse(articleContent); @@ -337,19 +314,20 @@ public class OfflineArticleFragment extends Fragment { } ws.setDefaultFontSize(articleFontSize); - - content = - "" + - "" + - "" + - "" + - "" + - "" + - "" + articleContent; + + content = + "" + + "" + + "" + + "" + + "" + + "" + + "" + articleContent; if (useTitleWebView) { content += "

 

 

 

 

"; diff --git a/org.fox.ttrss/src/main/res/layout/article_fragment.xml b/org.fox.ttrss/src/main/res/layout/article_fragment.xml index 45d41f72..27051f12 100644 --- a/org.fox.ttrss/src/main/res/layout/article_fragment.xml +++ b/org.fox.ttrss/src/main/res/layout/article_fragment.xml @@ -86,7 +86,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" - android:background="?articleNoteBackground" + android:background="?articleNoteBackground" android:textColor="?articleNoteTextColor" android:textSize="13sp" android:padding="8dp" diff --git a/org.fox.ttrss/src/main/res/layout/article_images_pager.xml b/org.fox.ttrss/src/main/res/layout/article_images_pager.xml index 92bd9518..2755a6ae 100644 --- a/org.fox.ttrss/src/main/res/layout/article_images_pager.xml +++ b/org.fox.ttrss/src/main/res/layout/article_images_pager.xml @@ -2,6 +2,7 @@ android:id="@+id/article_images" android:layout_width="fill_parent" android:fitsSystemWindows="true" + android:background="?smallScreenBackground" android:layout_height="fill_parent"> /* android:paddingLeft="@dimen/activity_horizontal_margin" diff --git a/org.fox.ttrss/src/main/res/layout/feeds_row.xml b/org.fox.ttrss/src/main/res/layout/feeds_row.xml index 362dffa9..19959c51 100644 --- a/org.fox.ttrss/src/main/res/layout/feeds_row.xml +++ b/org.fox.ttrss/src/main/res/layout/feeds_row.xml @@ -13,6 +13,7 @@ android:orientation="horizontal"> @string/theme_light @string/theme_dark - @string/theme_sepia + @string/theme_sepia + @string/theme_amber THEME_LIGHT THEME_DARK THEME_SEPIA + THEME_AMBER @string/category_browse_headlines diff --git a/org.fox.ttrss/src/main/res/values/attrs.xml b/org.fox.ttrss/src/main/res/values/attrs.xml index f08f757e..fcf4ee30 100644 --- a/org.fox.ttrss/src/main/res/values/attrs.xml +++ b/org.fox.ttrss/src/main/res/values/attrs.xml @@ -29,4 +29,6 @@ + + \ No newline at end of file diff --git a/org.fox.ttrss/src/main/res/values/strings.xml b/org.fox.ttrss/src/main/res/values/strings.xml index 77f3c3fc..356df730 100644 --- a/org.fox.ttrss/src/main/res/values/strings.xml +++ b/org.fox.ttrss/src/main/res/values/strings.xml @@ -159,6 +159,7 @@ Trial expired To continue using Tiny Tiny RSS please unlock the full version by purchasing the key. Sepia + Amber Full version, thank you for support! Fullscreen mode Reading diff --git a/org.fox.ttrss/src/main/res/values/style.xml b/org.fox.ttrss/src/main/res/values/style.xml index 41e913e1..aadc0dec 100644 --- a/org.fox.ttrss/src/main/res/values/style.xml +++ b/org.fox.ttrss/src/main/res/values/style.xml @@ -30,7 +30,9 @@ #dddddd ?colorPrimaryDark @android:color/white + @android:color/black @style/FabTheme + @android:color/transparent #6482af #526A8E @@ -50,6 +52,44 @@ #E5B0A0 + +