diff options
author | Andrew Dolgov <[email protected]> | 2014-11-12 15:15:12 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2014-11-12 16:20:18 +0400 |
commit | c8e8aaf850c9caaff78ae3a4f74a905017804aa0 (patch) | |
tree | f5dedd116ee055dfd3d6f2cdaa1fd514f79467f5 /org.fox.ttrss/src/main/java | |
parent | 9ad5384b385a26bee4932865c74b2c7a924d71bd (diff) |
add amber theme
Diffstat (limited to 'org.fox.ttrss/src/main/java')
3 files changed, 58 insertions, 97 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; }"; - } - 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%; }"; - + // 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+";}"; + 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 = - "<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; line-height : 130%; }" + - cssOverride + - "img { max-width : 100%; width : auto; height : auto; }" + - "</style>" + - "</head>" + - "<body>" + articleContent; + + 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; line-height : 130%; }" + + "img { max-width : 100%; width : auto; height : auto; }" + + " table { width : 100%; }" + + cssOverride + + "</style>" + + "</head>" + + "<body>" + articleContent; if (useTitleWebView) { content += "<p> </p><p> </p><p> </p><p> </p>"; |