From 320fa8e28fefd5c2f4fd6438185115deb395cc7d Mon Sep 17 00:00:00 2001 From: Mariotaku Lee Date: Fri, 1 May 2015 11:04:08 +0800 Subject: [PATCH] improved theme --- .../main/java/org/mariotaku/twidere/util/ThemeUtils.java | 7 +++---- .../twidere/util/ThemedLayoutInflaterFactory.java | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/twidere/src/main/java/org/mariotaku/twidere/util/ThemeUtils.java b/twidere/src/main/java/org/mariotaku/twidere/util/ThemeUtils.java index c7a548dc4..7405fedab 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/util/ThemeUtils.java +++ b/twidere/src/main/java/org/mariotaku/twidere/util/ThemeUtils.java @@ -1287,12 +1287,11 @@ public class ThemeUtils implements Constants { } public static Context getActionBarThemedContext(Context base, int themeId, int accentColor) { - if (isDarkTheme(themeId)) return base; final int actionBarThemeId; - if (TwidereColorUtils.getYIQLuminance(accentColor) > ACCENT_COLOR_THRESHOLD) { - actionBarThemeId = R.style.Theme_Twidere_Light; - } else { + if (isDarkTheme(themeId) || TwidereColorUtils.getYIQLuminance(accentColor) <= ACCENT_COLOR_THRESHOLD) { actionBarThemeId = R.style.Theme_Twidere_Dark; + } else { + actionBarThemeId = R.style.Theme_Twidere_Light; } final Resources.Theme baseTheme = base.getTheme(); final Resources.Theme actionBarTheme = base.getResources().newTheme(); diff --git a/twidere/src/main/java/org/mariotaku/twidere/util/ThemedLayoutInflaterFactory.java b/twidere/src/main/java/org/mariotaku/twidere/util/ThemedLayoutInflaterFactory.java index c3480aed1..cb0eeb8ad 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/util/ThemedLayoutInflaterFactory.java +++ b/twidere/src/main/java/org/mariotaku/twidere/util/ThemedLayoutInflaterFactory.java @@ -165,7 +165,7 @@ public class ThemedLayoutInflaterFactory implements LayoutInflaterFactory { } } if (view instanceof IThemeAccentView) { - if (isAccentOptimal) { + if (isAccentOptimal || !isColorTint) { ((IThemeAccentView) view).setAccentTintColor(ColorStateList.valueOf(accentColor)); } else { final int defaultAccentColor = ThemeUtils.getColorFromAttribute(view.getContext(), @@ -187,7 +187,7 @@ public class ThemedLayoutInflaterFactory implements LayoutInflaterFactory { ((TwidereToolbar) view).setItemColor(itemColor); } else if (view instanceof EditText) { if (isAccentOptimal || !isColorTint) { - ViewCompat.setBackgroundTintList(view, ColorStateList.valueOf(accentColor)); + ViewCompat.setBackgroundTintList(view, ColorStateList.valueOf(backgroundTintColor)); } } else if (view instanceof ProgressBar) { if (isAccentOptimal) {