add amber theme

This commit is contained in:
Andrew Dolgov 2014-11-12 15:15:12 +03:00
parent 9ad5384b38
commit c8e8aaf850
15 changed files with 127 additions and 104 deletions

View File

@ -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 articleFontSize = Integer.parseInt(m_prefs.getString("article_font_size_sp", "16"));
int articleSmallFontSize = Math.max(10, Math.min(18, articleFontSize - 2)); int articleSmallFontSize = Math.max(10, Math.min(18, articleFontSize - 2));
@ -282,9 +259,12 @@ public class ArticleFragment extends Fragment {
cssOverride = "body { background : "+ backgroundHexColor+"; }"; cssOverride = "body { background : "+ backgroundHexColor+"; }";
if (m_activity.isDarkTheme()) { TypedValue tvTextColor = new TypedValue();
cssOverride += "body { color : #e0e0e0; }"; getActivity().getTheme().resolveAttribute(R.attr.articleTextColor, tvTextColor, true);
}
String textColor = String.format("#%06X", (0xFFFFFF & tvTextColor.data));
cssOverride += "body { color : "+textColor+"; }";
TypedValue tvLinkColor = new TypedValue(); TypedValue tvLinkColor = new TypedValue();
getActivity().getTheme().resolveAttribute(R.attr.linkColor, tvLinkColor, true); getActivity().getTheme().resolveAttribute(R.attr.linkColor, tvLinkColor, true);

View File

@ -29,6 +29,7 @@ public class CommonActivity extends ActionBarActivity {
public final static String THEME_DARK = "THEME_DARK"; public final static String THEME_DARK = "THEME_DARK";
public final static String THEME_LIGHT = "THEME_LIGHT"; public final static String THEME_LIGHT = "THEME_LIGHT";
public final static String THEME_SEPIA = "THEME_SEPIA"; 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 final static String THEME_DEFAULT = CommonActivity.THEME_LIGHT;
public static final int EXCERPT_MAX_SIZE = 200; public static final int EXCERPT_MAX_SIZE = 200;
@ -202,14 +203,16 @@ public class CommonActivity extends ActionBarActivity {
public boolean isDarkTheme() { public boolean isDarkTheme() {
String theme = m_prefs.getString("theme", THEME_DEFAULT); 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) { protected void setAppTheme(SharedPreferences prefs) {
String theme = prefs.getString("theme", CommonActivity.THEME_DEFAULT); String theme = prefs.getString("theme", CommonActivity.THEME_DEFAULT);
if (theme.equals(THEME_DARK)) { 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)) { } else if (theme.equals(THEME_SEPIA)) {
setTheme(R.style.SepiaTheme); setTheme(R.style.SepiaTheme);
} else { } else {

View File

@ -164,26 +164,6 @@ public class OfflineArticleFragment extends Fragment {
fab.setVisibility(View.GONE); 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")); int articleFontSize = Integer.parseInt(m_prefs.getString("article_font_size_sp", "16"));
@ -270,41 +250,38 @@ public class OfflineArticleFragment extends Fragment {
} }
}); });
String content; // prevent flicker in ics
String cssOverride = ""; 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);
}
}
WebSettings ws = web.getSettings(); String content;
ws.setSupportZoom(false); String cssOverride = "";
TypedValue tv = new TypedValue(); WebSettings ws = web.getSettings();
getActivity().getTheme().resolveAttribute(R.attr.linkColor, tv, true); ws.setSupportZoom(false);
// prevent flicker in ics TypedValue tvBackground = new TypedValue();
if (!m_prefs.getBoolean("webview_hardware_accel", true) || useTitleWebView) { getActivity().getTheme().resolveAttribute(R.attr.articleBackground, tvBackground, true);
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); String backgroundHexColor = String.format("#%06X", (0xFFFFFF & tvBackground.data));
if (CommonActivity.THEME_DARK.equals(theme)) { cssOverride = "body { background : "+ backgroundHexColor+"; }";
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) { TypedValue tvTextColor = new TypedValue();
web.setBackgroundColor(Color.TRANSPARENT); getActivity().getTheme().resolveAttribute(R.attr.articleTextColor, tvTextColor, true);
} else {
// seriously?
web.setBackgroundColor(Color.argb(1, 0, 0, 0));
}
String hexColor = String.format("#%06X", (0xFFFFFF & tv.data)); String textColor = String.format("#%06X", (0xFFFFFF & tvTextColor.data));
cssOverride += " a:link {color: "+hexColor+";} a:visited { color: "+hexColor+";}";
cssOverride += " table { width : 100%; }"; 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")); String articleContent = m_cursor.getString(m_cursor.getColumnIndex("content"));
Document doc = Jsoup.parse(articleContent); Document doc = Jsoup.parse(articleContent);
@ -338,18 +315,19 @@ public class OfflineArticleFragment extends Fragment {
ws.setDefaultFontSize(articleFontSize); ws.setDefaultFontSize(articleFontSize);
content = content =
"<html>" + "<html>" +
"<head>" + "<head>" +
"<meta content=\"text/html; charset=utf-8\" http-equiv=\"content-type\">" + "<meta content=\"text/html; charset=utf-8\" http-equiv=\"content-type\">" +
"<meta name=\"viewport\" content=\"width=device-width, user-scalable=no\" />" + "<meta name=\"viewport\" content=\"width=device-width, user-scalable=no\" />" +
"<style type=\"text/css\">" + "<style type=\"text/css\">" +
"body { padding : 0px; margin : 0px; line-height : 130%; }" + "body { padding : 0px; margin : 0px; line-height : 130%; }" +
cssOverride + "img { max-width : 100%; width : auto; height : auto; }" +
"img { max-width : 100%; width : auto; height : auto; }" + " table { width : 100%; }" +
"</style>" + cssOverride +
"</head>" + "</style>" +
"<body>" + articleContent; "</head>" +
"<body>" + articleContent;
if (useTitleWebView) { if (useTitleWebView) {
content += "<p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p>"; content += "<p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p>";

View File

@ -2,6 +2,7 @@
android:id="@+id/article_images" android:id="@+id/article_images"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:fitsSystemWindows="true" android:fitsSystemWindows="true"
android:background="?smallScreenBackground"
android:layout_height="fill_parent"> android:layout_height="fill_parent">
/* /*
android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingLeft="@dimen/activity_horizontal_margin"

View File

@ -13,6 +13,7 @@
android:orientation="horizontal"> android:orientation="horizontal">
<ImageView <ImageView
android:tint="?iconTintColor"
android:id="@+id/icon" android:id="@+id/icon"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_width="16dp" android:layout_width="16dp"

View File

@ -14,6 +14,7 @@
android:orientation="horizontal"> android:orientation="horizontal">
<ImageView <ImageView
android:tint="?iconTintColor"
android:id="@+id/icon" android:id="@+id/icon"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_width="16dp" android:layout_width="16dp"

View File

@ -153,6 +153,7 @@
android:textStyle="italic" /> android:textStyle="italic" />
<ImageView <ImageView
android:tint="?iconTintColor"
android:id="@+id/marked" android:id="@+id/marked"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="16dp" android:layout_height="16dp"
@ -163,6 +164,7 @@
android:src="@drawable/ic_star_empty" /> android:src="@drawable/ic_star_empty" />
<ImageView <ImageView
android:tint="?iconTintColor"
android:id="@+id/published" android:id="@+id/published"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="16dp" android:layout_height="16dp"
@ -173,6 +175,7 @@
android:src="@drawable/ic_unpublished" /> android:src="@drawable/ic_unpublished" />
<ImageView <ImageView
android:tint="?iconTintColor"
android:id="@+id/article_menu_button" android:id="@+id/article_menu_button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="16dp" android:layout_height="16dp"

View File

@ -154,6 +154,7 @@
android:textStyle="italic" /> android:textStyle="italic" />
<ImageView <ImageView
android:tint="?iconTintColor"
android:id="@+id/marked" android:id="@+id/marked"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="16dp" android:layout_height="16dp"
@ -164,6 +165,7 @@
android:src="@drawable/ic_star_empty" /> android:src="@drawable/ic_star_empty" />
<ImageView <ImageView
android:tint="?iconTintColor"
android:id="@+id/published" android:id="@+id/published"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="16dp" android:layout_height="16dp"
@ -174,6 +176,7 @@
android:src="@drawable/ic_unpublished" /> android:src="@drawable/ic_unpublished" />
<ImageView <ImageView
android:tint="?iconTintColor"
android:id="@+id/article_menu_button" android:id="@+id/article_menu_button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="16dp" android:layout_height="16dp"

View File

@ -155,6 +155,7 @@
android:textStyle="italic" /> android:textStyle="italic" />
<ImageView <ImageView
android:tint="?iconTintColor"
android:id="@+id/marked" android:id="@+id/marked"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="16dp" android:layout_height="16dp"
@ -165,6 +166,7 @@
android:src="@drawable/ic_star_empty" /> android:src="@drawable/ic_star_empty" />
<ImageView <ImageView
android:tint="?iconTintColor"
android:id="@+id/published" android:id="@+id/published"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="16dp" android:layout_height="16dp"
@ -175,6 +177,7 @@
android:src="@drawable/ic_unpublished" /> android:src="@drawable/ic_unpublished" />
<ImageView <ImageView
android:tint="?iconTintColor"
android:id="@+id/article_menu_button" android:id="@+id/article_menu_button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="16dp" android:layout_height="16dp"

View File

@ -154,6 +154,7 @@
android:textStyle="italic" /> android:textStyle="italic" />
<ImageView <ImageView
android:tint="?iconTintColor"
android:id="@+id/marked" android:id="@+id/marked"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="16dp" android:layout_height="16dp"
@ -164,6 +165,7 @@
android:src="@drawable/ic_star_empty" /> android:src="@drawable/ic_star_empty" />
<ImageView <ImageView
android:tint="?iconTintColor"
android:id="@+id/published" android:id="@+id/published"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="16dp" android:layout_height="16dp"
@ -174,6 +176,7 @@
android:src="@drawable/ic_unpublished" /> android:src="@drawable/ic_unpublished" />
<ImageView <ImageView
android:tint="?iconTintColor"
android:id="@+id/article_menu_button" android:id="@+id/article_menu_button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="16dp" android:layout_height="16dp"

View File

@ -3,11 +3,13 @@
<item>@string/theme_light</item> <item>@string/theme_light</item>
<item>@string/theme_dark</item> <item>@string/theme_dark</item>
<item>@string/theme_sepia</item> <item>@string/theme_sepia</item>
<item>@string/theme_amber</item>
</string-array> </string-array>
<string-array name="pref_theme_values" translatable="false"> <string-array name="pref_theme_values" translatable="false">
<item>THEME_LIGHT</item> <item>THEME_LIGHT</item>
<item>THEME_DARK</item> <item>THEME_DARK</item>
<item>THEME_SEPIA</item> <item>THEME_SEPIA</item>
<item>THEME_AMBER</item>
</string-array> </string-array>
<string-array name="pref_view_mode_names"> <string-array name="pref_view_mode_names">
<item>@string/category_browse_headlines</item> <item>@string/category_browse_headlines</item>

View File

@ -29,4 +29,6 @@
<attr name="parentBtnBackground" format="reference|color" /> <attr name="parentBtnBackground" format="reference|color" />
<attr name="articleHeader" format="reference|color" /> <attr name="articleHeader" format="reference|color" />
<attr name="articleHeaderTextColor" format="reference|color" /> <attr name="articleHeaderTextColor" format="reference|color" />
<attr name="articleTextColor" format="reference|color" />
<attr name="iconTintColor" format="reference|color" />
</resources> </resources>

View File

@ -159,6 +159,7 @@
<string name="trial_expired">Trial expired</string> <string name="trial_expired">Trial expired</string>
<string name="trial_expired_message">To continue using Tiny Tiny RSS please unlock the full version by purchasing the key.</string> <string name="trial_expired_message">To continue using Tiny Tiny RSS please unlock the full version by purchasing the key.</string>
<string name="theme_sepia">Sepia</string> <string name="theme_sepia">Sepia</string>
<string name="theme_amber">Amber</string>
<string name="trial_thanks">Full version, thank you for support!</string> <string name="trial_thanks">Full version, thank you for support!</string>
<string name="prefs_fullscreen_mode">Fullscreen mode</string> <string name="prefs_fullscreen_mode">Fullscreen mode</string>
<string name="reading">Reading</string> <string name="reading">Reading</string>

View File

@ -30,7 +30,9 @@
<item name="parentBtnBackground">#dddddd</item> <item name="parentBtnBackground">#dddddd</item>
<item name="articleHeader">?colorPrimaryDark</item> <item name="articleHeader">?colorPrimaryDark</item>
<item name="articleHeaderTextColor">@android:color/white</item> <item name="articleHeaderTextColor">@android:color/white</item>
<item name="articleTextColor">@android:color/black</item>
<item name="floatingActionButtonStyle">@style/FabTheme</item> <item name="floatingActionButtonStyle">@style/FabTheme</item>
<item name="iconTintColor">@android:color/transparent</item>
<item name="colorPrimary">#6482af</item> <item name="colorPrimary">#6482af</item>
<item name="colorPrimaryDark">#526A8E</item> <item name="colorPrimaryDark">#526A8E</item>
@ -50,6 +52,44 @@
<item name="colorAccent">#E5B0A0</item> <item name="colorAccent">#E5B0A0</item>
</style> </style>
<style name="AmberTheme" parent="DarkTheme">
<item name="articleHeader">@android:color/black</item>
<item name="articleNoteTextColor">?linkColor</item>
<item name="articleNoteBackground">#543800</item>
<item name="headlineNormalBackground">@android:color/black</item>
<item name="smallScreenBackground">@android:color/black</item>
<item name="feedlistBackground">?colorPrimaryDark</item>
<item name="headlinesBackground">@android:color/black</item>
<item name="headlinesBackgroundSolid">@android:color/black</item>
<item name="articleBackground">@android:color/black</item>
<item name="articleHeaderTextColor">?linkColor</item>
<item name="articleTextColor">?colorPrimary</item>
<item name="linkColor">?colorAccent</item>
<item name="feedlistTextColor">?linkColor</item>
<item name="unreadCounterColor">?colorPrimaryDark</item>
<item name="headlineUnreadTextColor">?linkColor</item>
<item name="headlineSelectedTextColor">?linkColor</item>
<item name="headlineExcerptTextColor">?articleTextColor</item>
<item name="headlineSecondaryTextColor">?colorPrimary</item>
<item name="headlineSelectedExcerptTextColor">?linkColor</item>
<item name="headlineTextColor">@android:color/secondary_text_dark</item>
<item name="headlineSelectedSecondaryTextColor">?colorPrimary</item>
<item name="headlineUnreadBackground">@android:color/black</item>
<item name="headlineSelectedBackground">#635200</item>
<item name="iconTintColor">?linkColor</item>
<item name="colorPrimary">#B78300</item>
<item name="colorPrimaryDark">#A87300</item>
<item name="colorAccent">#FFBF00</item>
</style>
<style name="DarkTheme" parent="Theme.AppCompat"> <style name="DarkTheme" parent="Theme.AppCompat">
<item name="statusBarHintColor">?colorPrimary</item> <item name="statusBarHintColor">?colorPrimary</item>
<item name="unreadCounterColor">#909090</item> <item name="unreadCounterColor">#909090</item>
@ -60,6 +100,11 @@
<item name="headlineExcerptTextColor">@android:color/secondary_text_dark</item> <item name="headlineExcerptTextColor">@android:color/secondary_text_dark</item>
<item name="headlineSecondaryTextColor">#909090</item> <item name="headlineSecondaryTextColor">#909090</item>
<item name="headlineTitleHighScoreUnreadTextColor">#00FF00</item> <item name="headlineTitleHighScoreUnreadTextColor">#00FF00</item>
<item name="headlineSelectedExcerptTextColor">@android:color/secondary_text_dark</item>
<item name="headlineTextColor">@android:color/secondary_text_dark</item>
<item name="headlineSelectedSecondaryTextColor">#a0a0a0</item>
<item name="headlineSelectedBackground">?colorPrimary</item>
<item name="headlineUnreadBackground">#383c42</item>
<item name="linkColor">?colorPrimary</item> <item name="linkColor">?colorPrimary</item>
<item name="loadingBackground">@android:color/black</item> <item name="loadingBackground">@android:color/black</item>
<item name="articleNoteTextColor">@android:color/secondary_text_dark</item> <item name="articleNoteTextColor">@android:color/secondary_text_dark</item>
@ -71,16 +116,13 @@
<item name="headlinesBackground">@drawable/shadow_headlines_gray</item> <item name="headlinesBackground">@drawable/shadow_headlines_gray</item>
<item name="headlinesBackgroundSolid">@color/feeds_dark_gray</item> <item name="headlinesBackgroundSolid">@color/feeds_dark_gray</item>
<item name="articleBackground">@color/feeds_dark_gray</item> <item name="articleBackground">@color/feeds_dark_gray</item>
<item name="headlineSelectedBackground">?colorPrimary</item> <item name="feedsSelectedBackground">?colorPrimaryDark</item>
<item name="headlineUnreadBackground">#383c42</item>
<item name="feedsSelectedBackground">#445877</item>
<item name="feedlistSelectedTextColor">@android:color/primary_text_dark</item> <item name="feedlistSelectedTextColor">@android:color/primary_text_dark</item>
<item name="headlineSelectedExcerptTextColor">@android:color/secondary_text_dark</item>
<item name="headlineTextColor">@android:color/secondary_text_dark</item>
<item name="headlineSelectedSecondaryTextColor">#a0a0a0</item>
<item name="articleHeader">?colorPrimaryDark</item> <item name="articleHeader">?colorPrimaryDark</item>
<item name="articleHeaderTextColor">@android:color/white</item> <item name="articleHeaderTextColor">@android:color/white</item>
<item name="floatingActionButtonStyle">@style/FabTheme</item> <item name="floatingActionButtonStyle">@style/FabTheme</item>
<item name="articleTextColor">#e0e0e0</item>
<item name="iconTintColor">@android:color/transparent</item>
<item name="colorPrimary">#51698E</item> <item name="colorPrimary">#51698E</item>
<item name="colorPrimaryDark">#445877</item> <item name="colorPrimaryDark">#445877</item>