diff --git a/app/src/main/java/ru/vtosters/lite/themes/ColorReferences.java b/app/src/main/java/ru/vtosters/lite/themes/ColorReferences.java index 98fd228e6..101474568 100644 --- a/app/src/main/java/ru/vtosters/lite/themes/ColorReferences.java +++ b/app/src/main/java/ru/vtosters/lite/themes/ColorReferences.java @@ -25,7 +25,8 @@ public class ColorReferences { Color.parseColor("#1a003973"), Color.parseColor("#a800244d"), Color.parseColor("#14001c3d"), - Color.parseColor("#3d001c3d") + Color.parseColor("#3d001c3d"), + Color.parseColor("#664986cc") ); public static boolean isAccentedColor(ColorStateList target) { diff --git a/app/src/main/java/ru/vtosters/lite/themes/ThemesCore.java b/app/src/main/java/ru/vtosters/lite/themes/ThemesCore.java index 711532db5..6f1f4e0b7 100644 --- a/app/src/main/java/ru/vtosters/lite/themes/ThemesCore.java +++ b/app/src/main/java/ru/vtosters/lite/themes/ThemesCore.java @@ -65,6 +65,8 @@ public class ThemesCore { } public static void setThemedColors(int accentColor) { + int mutedAccentColor = ThemesUtils.getMutedAccentColor(accentColor); + cachedAccents = true; themedColors.clear(); @@ -90,6 +92,12 @@ public class ThemesCore { themedColors.put(com.vtosters.lite.R.attr.header_tab_active_indicator, accentColor); themedColors.put(com.vtosters.lite.R.attr.header_alternate_tab_active_indicator, accentColor); + themedColors.put(com.vtosters.lite.R.attr.button_primary_background_disabled, mutedAccentColor); + themedColors.put(com.vtosters.lite.R.attr.button_secondary_foreground_disabled, mutedAccentColor); + themedColors.put(com.vtosters.lite.R.attr.button_tertiary_foreground_disabled, mutedAccentColor); + themedColors.put(com.vtosters.lite.R.attr.button_outline_border_disabled, mutedAccentColor); + themedColors.put(com.vtosters.lite.R.attr.button_muted_foreground_disabled, mutedAccentColor); + themedColors.put(com.vtosters.lite.R.attr.im_dropdown_icon_color, accentColor); themedColors.put(com.vtosters.lite.R.attr.im_dropdown_arrow_tint, accentColor); diff --git a/app/src/main/java/ru/vtosters/lite/themes/ThemesHacks.java b/app/src/main/java/ru/vtosters/lite/themes/ThemesHacks.java index 051a07881..986ee1996 100644 --- a/app/src/main/java/ru/vtosters/lite/themes/ThemesHacks.java +++ b/app/src/main/java/ru/vtosters/lite/themes/ThemesHacks.java @@ -52,9 +52,13 @@ public class ThemesHacks { public static int getHackedColor(@NonNull Context context, @ColorRes int color) { if (ThemesCore.isCachedAccents() && ColorReferences.isAccentedColor(context.getColor(color))) { - Log.d("ThemesHacks", "getHackedColor: got accent color: " + AndroidUtils.getResources().getResourceName(color)); return ThemesUtils.getAccentColor(); } + + if (ThemesCore.isCachedAccents() && ColorReferences.isMutedAccentedColor(context.getColor(color))) { + return ThemesUtils.getMutedAccentColor(); + } + if (Build.VERSION.SDK_INT > 23) { return context.getColor(color); } else return context.getResources().getColor(color); diff --git a/app/src/main/java/ru/vtosters/lite/themes/hooks/ButtonHook.java b/app/src/main/java/ru/vtosters/lite/themes/hooks/ButtonHook.java index c8150c9d8..1dec07232 100644 --- a/app/src/main/java/ru/vtosters/lite/themes/hooks/ButtonHook.java +++ b/app/src/main/java/ru/vtosters/lite/themes/hooks/ButtonHook.java @@ -12,9 +12,14 @@ public class ButtonHook implements BaseHook { public void inject(View view, int i, boolean z) { if (view instanceof Button) { var button = (Button) view; + if (button.getBackgroundTintList() != null && ColorReferences.isMutedAccentedColor(button.getBackgroundTintList())) { + button.setBackgroundTintList(ColorStateList.valueOf(ThemesUtils.getMutedAccentColor())); + } + if (button.getBackgroundTintList() != null && ColorReferences.isAccentedColor(button.getBackgroundTintList())) { button.setBackgroundTintList(ColorStateList.valueOf(ThemesUtils.getAccentColor())); } + if (TextViewHook.isPositiveButton(button) || TextViewHook.isVkUiButton(view)) { button.setBackgroundTintList(ColorStateList.valueOf(ThemesUtils.getAccentColor())); } diff --git a/app/src/main/java/ru/vtosters/lite/themes/hooks/TextViewHook.java b/app/src/main/java/ru/vtosters/lite/themes/hooks/TextViewHook.java index 42fd3c8d5..feeac0a1f 100644 --- a/app/src/main/java/ru/vtosters/lite/themes/hooks/TextViewHook.java +++ b/app/src/main/java/ru/vtosters/lite/themes/hooks/TextViewHook.java @@ -32,16 +32,28 @@ public class TextViewHook implements BaseHook { textView.setTextColor(ThemesUtils.getAccentColor()); } + if (ColorReferences.isMutedAccentedColor(textView.getCurrentTextColor())) { + textView.setTextColor(ThemesUtils.getMutedAccentColor()); + } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && textView.getCompoundDrawableTintList() != null) { if (ColorReferences.isAccentedColor(textView.getCompoundDrawableTintList())) { textView.setCompoundDrawableTintList(ColorStateList.valueOf(ThemesUtils.getAccentColor())); } + + if (ColorReferences.isMutedAccentedColor(textView.getCompoundDrawableTintList())) { + textView.setCompoundDrawableTintList(ColorStateList.valueOf(ThemesUtils.getMutedAccentColor())); + } } if (textView.getLinkTextColors() != null && ColorReferences.isAccentedColor(textView.getLinkTextColors())) { textView.setLinkTextColor(ThemesUtils.getAccentColor()); } + if (textView.getLinkTextColors() != null && ColorReferences.isMutedAccentedColor(textView.getLinkTextColors())) { + textView.setLinkTextColor(ThemesUtils.getMutedAccentColor()); + } + if (isPositiveButton(textView) || isVkUiButton(textView)) { view.setBackgroundTintList(ColorStateList.valueOf(ThemesUtils.getAccentColor())); } @@ -59,6 +71,11 @@ public class TextViewHook implements BaseHook { if (eligibleForStartTinting((TintTextView) view)) { ((TintTextView) view).setDrawableStartTint(ThemesUtils.getAccentColor()); } + + if (eligibleForStartTintingMuted((TintTextView) view)) { + ((TintTextView) view).setDrawableStartTint(ThemesUtils.getMutedAccentColor()); + } + if (eligibleForTinting(view.getId())) { ((TintTextView) view).setDrawableTint(ThemesUtils.getAccentColor()); } @@ -77,6 +94,10 @@ public class TextViewHook implements BaseHook { if (ColorReferences.isAccentedColor(check.getCheckMarkTintList())) { check.setCheckMarkTintList(ColorStateList.valueOf(ThemesUtils.getAccentColor())); } + + if (ColorReferences.isMutedAccentedColor(check.getCheckMarkTintList())) { + check.setCheckMarkTintList(ColorStateList.valueOf(ThemesUtils.getMutedAccentColor())); + } } VkUiThemer.autoThemeVkuiButtons(textView); @@ -89,6 +110,10 @@ public class TextViewHook implements BaseHook { return ColorReferences.isAccentedColor(view.getTextColors()) || view.getTextColors().getDefaultColor() == ThemesUtils.getAccentColor(); } + public static boolean eligibleForStartTintingMuted(TintTextView view) { + return ColorReferences.isMutedAccentedColor(view.getTextColors()) || view.getTextColors().getDefaultColor() == ThemesUtils.getMutedAccentColor(); + } + public static boolean eligibleForTinting(int id) { return !ThemesUtils.isDarkTheme() && (id == R.id.attach_title || id == R.id.post_retweet_name); } diff --git a/app/src/main/java/ru/vtosters/lite/themes/utils/RecolorUtils.java b/app/src/main/java/ru/vtosters/lite/themes/utils/RecolorUtils.java index ad67f793d..ef62ab878 100644 --- a/app/src/main/java/ru/vtosters/lite/themes/utils/RecolorUtils.java +++ b/app/src/main/java/ru/vtosters/lite/themes/utils/RecolorUtils.java @@ -29,8 +29,9 @@ public class RecolorUtils { } // Get res drawable via id and coloring to accent public static int recolorHexColor(int i){ - Log.d("RecolorUtils", ThemesUtils.hex(i)); - return ColorReferences.isAccentedColor(i) ? ThemesUtils.getAccentColor() : i; + var accented = ColorReferences.isAccentedColor(i); + var mutedaccented = ColorReferences.isMutedAccentedColor(i); + return (accented || mutedaccented) ? (accented ? ThemesUtils.getAccentColor() : ThemesUtils.getMutedAccentColor()) : i; } public static ColorStateList recolorCSL(ColorStateList colorStateList) { @@ -68,16 +69,21 @@ public class RecolorUtils { boolean isEnabledAccent = ColorReferences.isAccentedColor(enabled); boolean isDisabledAccent = ColorReferences.isAccentedColor(disabled); - if (isUnselAccent || isSelAccent) { + boolean isUnselMutedAccent = ColorReferences.isMutedAccentedColor(unsel); + boolean isSelMutedAccent = ColorReferences.isMutedAccentedColor(sel); + boolean isEnabledMutedAccent = ColorReferences.isMutedAccentedColor(enabled); + boolean isDisabledMutedAccent = ColorReferences.isMutedAccentedColor(disabled); + + if (isUnselAccent || isSelAccent || isUnselMutedAccent || isSelMutedAccent) { return new ColorStateList(new int[][]{ new int[]{android.R.attr.state_selected}, new int[]{-android.R.attr.state_selected} - }, new int[]{isSelAccent ? ThemesUtils.getAccentColor() : sel, isUnselAccent ? ThemesUtils.getAccentColor() : unsel}); + }, new int[]{(isSelAccent || isSelMutedAccent) ? (isSelAccent ? ThemesUtils.getAccentColor() : ThemesUtils.getMutedAccentColor()) : sel, (isUnselAccent || isUnselMutedAccent) ? (isUnselAccent ? ThemesUtils.getAccentColor() : ThemesUtils.getMutedAccentColor()) : unsel}); } - if (isDisabledAccent || isEnabledAccent) { + if (isDisabledAccent || isEnabledAccent || isEnabledMutedAccent || isDisabledMutedAccent) { return new ColorStateList(new int[][]{ new int[]{android.R.attr.state_enabled}, new int[]{-android.R.attr.state_enabled} - }, new int[]{isEnabledAccent ? ThemesUtils.getAccentColor() : enabled, isDisabledAccent ? ThemesUtils.getAccentColor() : disabled}); + }, new int[]{(isEnabledAccent || isEnabledMutedAccent) ? (isEnabledAccent ? ThemesUtils.getAccentColor() : ThemesUtils.getMutedAccentColor()) : enabled, (isDisabledAccent || isDisabledMutedAccent) ? (isDisabledAccent ? ThemesUtils.getAccentColor() : ThemesUtils.getMutedAccentColor()) : disabled}); } return csl; diff --git a/app/src/main/java/ru/vtosters/lite/themes/utils/VkUiThemer.java b/app/src/main/java/ru/vtosters/lite/themes/utils/VkUiThemer.java index d18e7f478..8b038e874 100644 --- a/app/src/main/java/ru/vtosters/lite/themes/utils/VkUiThemer.java +++ b/app/src/main/java/ru/vtosters/lite/themes/utils/VkUiThemer.java @@ -72,6 +72,11 @@ public class VkUiThemer { Log.d("TSCore", "[tsh:disabled] theming CSL"); spd.setTint(ThemesUtils.getAccentColor()); } + + if (ColorReferences.isMutedAccentedColor(spd.getColor())) { + Log.d("TSCore", "[tsh:disabled] theming CSL"); + spd.setTint(ThemesUtils.getMutedAccentColor()); + } } } catch (Exception e) { // This must go wrong, so we ignore any exceptions that may occur diff --git a/app/src/main/java/ru/vtosters/lite/utils/ThemesUtils.java b/app/src/main/java/ru/vtosters/lite/utils/ThemesUtils.java index 6a3615ae4..d2d5b4121 100644 --- a/app/src/main/java/ru/vtosters/lite/utils/ThemesUtils.java +++ b/app/src/main/java/ru/vtosters/lite/utils/ThemesUtils.java @@ -96,7 +96,11 @@ public class ThemesUtils { } // Color accent public static int getMutedAccentColor() { - return ThemesUtils.halfAlpha(ThemesUtils.getAccentColor()); + return getMutedAccentColor(getAccentColor()); + } + + public static int getMutedAccentColor(int color) { + return isDarkTheme() ? darken(color, 0.66f) : lighten(color, 0.66f); } public static void setCustomAccentColor(int newColor, boolean async) { @@ -238,10 +242,6 @@ public class ThemesUtils { color == R.color.white_blue32; } // Accent colors - public static int replaceColor(int i){ - return ColorReferences.isAccentedColor(i) ? getAccentColor() : i; - } - public static void setImageViewColored(ImageView view){ view.setColorFilter(ThemesUtils.getAccentColor(), PorterDuff.Mode.MULTIPLY); }