improved theme

This commit is contained in:
Mariotaku Lee 2015-05-01 11:04:08 +08:00
parent f789020ff9
commit 320fa8e28f
2 changed files with 5 additions and 6 deletions

View File

@ -1287,12 +1287,11 @@ public class ThemeUtils implements Constants {
} }
public static Context getActionBarThemedContext(Context base, int themeId, int accentColor) { public static Context getActionBarThemedContext(Context base, int themeId, int accentColor) {
if (isDarkTheme(themeId)) return base;
final int actionBarThemeId; final int actionBarThemeId;
if (TwidereColorUtils.getYIQLuminance(accentColor) > ACCENT_COLOR_THRESHOLD) { if (isDarkTheme(themeId) || TwidereColorUtils.getYIQLuminance(accentColor) <= ACCENT_COLOR_THRESHOLD) {
actionBarThemeId = R.style.Theme_Twidere_Light;
} else {
actionBarThemeId = R.style.Theme_Twidere_Dark; actionBarThemeId = R.style.Theme_Twidere_Dark;
} else {
actionBarThemeId = R.style.Theme_Twidere_Light;
} }
final Resources.Theme baseTheme = base.getTheme(); final Resources.Theme baseTheme = base.getTheme();
final Resources.Theme actionBarTheme = base.getResources().newTheme(); final Resources.Theme actionBarTheme = base.getResources().newTheme();

View File

@ -165,7 +165,7 @@ public class ThemedLayoutInflaterFactory implements LayoutInflaterFactory {
} }
} }
if (view instanceof IThemeAccentView) { if (view instanceof IThemeAccentView) {
if (isAccentOptimal) { if (isAccentOptimal || !isColorTint) {
((IThemeAccentView) view).setAccentTintColor(ColorStateList.valueOf(accentColor)); ((IThemeAccentView) view).setAccentTintColor(ColorStateList.valueOf(accentColor));
} else { } else {
final int defaultAccentColor = ThemeUtils.getColorFromAttribute(view.getContext(), final int defaultAccentColor = ThemeUtils.getColorFromAttribute(view.getContext(),
@ -187,7 +187,7 @@ public class ThemedLayoutInflaterFactory implements LayoutInflaterFactory {
((TwidereToolbar) view).setItemColor(itemColor); ((TwidereToolbar) view).setItemColor(itemColor);
} else if (view instanceof EditText) { } else if (view instanceof EditText) {
if (isAccentOptimal || !isColorTint) { if (isAccentOptimal || !isColorTint) {
ViewCompat.setBackgroundTintList(view, ColorStateList.valueOf(accentColor)); ViewCompat.setBackgroundTintList(view, ColorStateList.valueOf(backgroundTintColor));
} }
} else if (view instanceof ProgressBar) { } else if (view instanceof ProgressBar) {
if (isAccentOptimal) { if (isAccentOptimal) {