[accents] add some dirty hacks

This commit is contained in:
aliveoutside
2022-07-28 17:08:07 +03:00
parent 252d761b9e
commit 35f486dc86
2 changed files with 48 additions and 0 deletions
@@ -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()));
}
}
}
@@ -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);
}
}