From 35f486dc86e0e2a3d1463e2c80bc36ef2870bda5 Mon Sep 17 00:00:00 2001 From: aliveoutside <53598473+aliveoutside@users.noreply.github.com> Date: Thu, 28 Jul 2022 17:08:07 +0300 Subject: [PATCH] [accents] add some dirty hacks --- .../ru/vtosters/lite/themes/ThemesHacks.java | 45 +++++++++++++++++++ .../lite/themes/hooks/TextViewHook.java | 3 ++ 2 files changed, 48 insertions(+) create mode 100644 app/src/main/java/ru/vtosters/lite/themes/ThemesHacks.java diff --git a/app/src/main/java/ru/vtosters/lite/themes/ThemesHacks.java b/app/src/main/java/ru/vtosters/lite/themes/ThemesHacks.java new file mode 100644 index 000000000..3fc84ff50 --- /dev/null +++ b/app/src/main/java/ru/vtosters/lite/themes/ThemesHacks.java @@ -0,0 +1,45 @@ +package ru.vtosters.lite.themes; + +import android.graphics.drawable.BitmapDrawable; +import android.graphics.drawable.ColorDrawable; +import android.graphics.drawable.Drawable; +import android.graphics.drawable.DrawableContainer; +import android.graphics.drawable.InsetDrawable; +import android.graphics.drawable.LayerDrawable; +import android.graphics.drawable.StateListDrawable; +import android.view.View; +import android.widget.TextView; + +import com.vtosters.lite.R; + +import ru.vtosters.lite.utils.Themes; + +public class ThemesHacks { + // Фиксит селектор (все/свои/архив) в профиле + public static void fixProfileSelector(View view) { + if (!Themes.isMilkshake()) return; + var id = view.getId(); + + if (id == R.id.profile_wall_owner_posts || id == R.id.profile_wall_all_posts || id == R.id.profile_wall_archived_posts) { + StateListDrawable states = (StateListDrawable) ((LayerDrawable) view.getBackground()).getDrawable(0); + LayerDrawable selected = (LayerDrawable) ((DrawableContainer.DrawableContainerState) states.getConstantState()).getChildren()[0]; + ((ColorDrawable) selected.getDrawable(0)).setColor(Themes.getAccentColor()); + } + } + + public static void fixThemedFeed(TextView textView, int i) { + if (i != R.layout.themed_feed_tab_2) { + return; + } + textView.setTextColor(Themes.themeCSL(textView.getTextColors())); + ((InsetDrawable) ((DrawableContainer.DrawableContainerState) ((StateListDrawable) textView.getBackground()).getConstantState()).getChildren()[0]).getDrawable().setTint(Themes.lighten(Themes.getAccentColor(), 0.15f)); + } + + public static void fixDropdown(Drawable drawable) { + if (!Themes.isDarkTheme() && Themes.isMilkshake() && ThemesCore.isCachedAccents()) { + StateListDrawable stateListDrawable = (StateListDrawable) drawable; + ((BitmapDrawable) ((DrawableContainer.DrawableContainerState) stateListDrawable.getConstantState()).getChildren()[0]).setTint(Themes.getAccentColor()); + ((BitmapDrawable) ((DrawableContainer.DrawableContainerState) stateListDrawable.getConstantState()).getChildren()[1]).setTint(Themes.halfAlpha(Themes.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 c976f9e5d..e9878063e 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 @@ -10,6 +10,7 @@ import androidx.appcompat.widget.AppCompatCheckedTextView; import com.vk.core.view.TintTextView; import com.vtosters.lite.R; +import ru.vtosters.lite.themes.ThemesHacks; import ru.vtosters.lite.themes.utils.VkUiThemer; import ru.vtosters.lite.utils.Themes; @@ -52,6 +53,8 @@ public class TextViewHook implements BaseHook { } VkUiThemer.autoThemeVkuiButtons(textView); + ThemesHacks.fixProfileSelector(textView); + ThemesHacks.fixThemedFeed(textView, i); } }