[accents] resolve merge issues

This commit is contained in:
aliveoutside
2022-07-28 17:40:54 +03:00
parent 678a398612
commit 74f10e6ab2
16 changed files with 62 additions and 67 deletions
@@ -7,7 +7,8 @@ import androidx.annotation.IdRes;
import java.util.HashMap;
import ru.vtosters.lite.utils.Themes;
import ru.vtosters.lite.utils.ThemesUtils;
public class ThemesCore {
// log tag
@@ -61,8 +62,8 @@ public class ThemesCore {
themedColors.put(com.vtosters.lite.R.attr.action_sheet_action_foreground, accentColor);
// messages
wallDarkColor = Themes.darken(accentColor, 0.25f);
wallLightColor = Themes.lighten(accentColor, 0.25f);
wallDarkColor = ThemesUtils.darken(accentColor, 0.25f);
wallLightColor = ThemesUtils.lighten(accentColor, 0.25f);
//themedColors.put(com.vtosters.lite.R.attr.im_ic_send_msg, accentColor);
themedColors.put(com.vtosters.lite.R.attr.im_bubble_wallpaper_outgoing, accentColor);
@@ -73,11 +74,11 @@ public class ThemesCore {
@SuppressWarnings("ConstantConditions")
public static int getThemedAttr(Context context, @IdRes int attr) {
if (attr == com.vtosters.lite.R.attr.im_bubble_wallpaper_outgoing || attr == com.vtosters.lite.R.attr.im_bubble_outgoing) {
return (!Themes.isDarkTheme()) ? wallLightColor : wallDarkColor;
return (!ThemesUtils.isDarkTheme()) ? wallLightColor : wallDarkColor;
}
if (attr == com.vtosters.lite.R.attr.im_bubble_outgoing_highlighted) {
return (!Themes.isDarkTheme()) ? Themes.lighten(wallLightColor, 0.2f) : Themes.darken(wallDarkColor, 0.2f);
return (!ThemesUtils.isDarkTheme()) ? ThemesUtils.lighten(wallLightColor, 0.2f) : ThemesUtils.darken(wallDarkColor, 0.2f);
}
return themedColors.get(attr);
@@ -12,18 +12,18 @@ import android.widget.TextView;
import com.vtosters.lite.R;
import ru.vtosters.lite.utils.Themes;
import ru.vtosters.lite.utils.ThemesUtils;
public class ThemesHacks {
// Фиксит селектор (все/свои/архив) в профиле
public static void fixProfileSelector(View view) {
if (!Themes.isMilkshake()) return;
if (!ThemesUtils.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());
((ColorDrawable) selected.getDrawable(0)).setColor(ThemesUtils.getAccentColor());
}
}
@@ -31,15 +31,15 @@ public class ThemesHacks {
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));
textView.setTextColor(ThemesUtils.themeCSL(textView.getTextColors()));
((InsetDrawable) ((DrawableContainer.DrawableContainerState) ((StateListDrawable) textView.getBackground()).getConstantState()).getChildren()[0]).getDrawable().setTint(ThemesUtils.lighten(ThemesUtils.getAccentColor(), 0.15f));
}
public static void fixDropdown(Drawable drawable) {
if (!Themes.isDarkTheme() && Themes.isMilkshake() && ThemesCore.isCachedAccents()) {
if (!ThemesUtils.isDarkTheme() && ThemesUtils.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()));
((BitmapDrawable) ((DrawableContainer.DrawableContainerState) stateListDrawable.getConstantState()).getChildren()[0]).setTint(ThemesUtils.getAccentColor());
((BitmapDrawable) ((DrawableContainer.DrawableContainerState) stateListDrawable.getConstantState()).getChildren()[1]).setTint(ThemesUtils.halfAlpha(ThemesUtils.getAccentColor()));
}
}
}
@@ -14,7 +14,7 @@ import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import ru.vtosters.lite.utils.Themes;
import ru.vtosters.lite.utils.ThemesUtils;
public class VTLResources extends Resources {
private static final String TAG = "VTLResources";
@@ -57,7 +57,7 @@ public class VTLResources extends Resources {
if (type == TypedValue.TYPE_ATTRIBUTE && isAttrThemeable(cnt)) {
data[i*6] = TypedValue.TYPE_INT_COLOR_RGB8;
data[(i*6)+1] = Themes.getAccentColor();
data[(i*6)+1] = ThemesUtils.getAccentColor();
data[(i*6)+2] = 0; // clear reference content
}
}
@@ -79,7 +79,7 @@ public class VTLResources extends Resources {
}
private static boolean isAttrThemeable(int attrID) {
return !Themes.isDarkTheme() && attrID == com.vtosters.lite.R.attr.button_primary_background;
return !ThemesUtils.isDarkTheme() && attrID == com.vtosters.lite.R.attr.button_primary_background;
}
private static int[] getArrayData(TypedArray arr) {
@@ -4,18 +4,18 @@ import android.content.res.ColorStateList;
import android.view.View;
import android.widget.Button;
import ru.vtosters.lite.utils.Themes;
import ru.vtosters.lite.utils.ThemesUtils;
public class ButtonHook implements BaseHook {
@Override
public void inject(View view, int i, boolean z) {
if (view instanceof Button) {
var button = (Button) view;
if (button.getBackgroundTintList() != null && Themes.isAccentedColor(button.getBackgroundTintList())) {
button.setBackgroundTintList(ColorStateList.valueOf(Themes.getAccentColor()));
if (button.getBackgroundTintList() != null && ThemesUtils.isAccentedColor(button.getBackgroundTintList())) {
button.setBackgroundTintList(ColorStateList.valueOf(ThemesUtils.getAccentColor()));
}
if (TextViewHook.isPositiveButton(button) || TextViewHook.isVkUiButton(view)) {
button.setBackgroundTintList(ColorStateList.valueOf(Themes.getAccentColor()));
button.setBackgroundTintList(ColorStateList.valueOf(ThemesUtils.getAccentColor()));
}
}
}
@@ -1,12 +1,11 @@
package ru.vtosters.lite.themes.hooks;
import android.content.res.ColorStateList;
import android.view.View;
import android.widget.ImageView;
import androidx.appcompat.widget.AppCompatImageView;
import ru.vtosters.lite.utils.Themes;
import ru.vtosters.lite.utils.ThemesUtils;
public class ImageViewHook implements BaseHook {
@Override
@@ -14,14 +13,14 @@ public class ImageViewHook implements BaseHook {
if (view instanceof AppCompatImageView) {
var imageView = (AppCompatImageView) view;
if (imageView.getImageTintList() != null) {
imageView.setImageTintList(Themes.themeCSL(imageView.getImageTintList()));
imageView.setImageTintList(ThemesUtils.themeCSL(imageView.getImageTintList()));
}
}
if (view instanceof ImageView) {
var imageView = (ImageView) view;
if (imageView.getImageTintList() != null) {
imageView.setImageTintList(Themes.themeCSL(imageView.getImageTintList()));
imageView.setImageTintList(ThemesUtils.themeCSL(imageView.getImageTintList()));
}
}
}
@@ -5,15 +5,16 @@ import android.view.View;
import com.vk.core.view.VKTabLayout;
import ru.vtosters.lite.utils.Themes;
import ru.vtosters.lite.utils.ThemesUtils;
public class TabLayoutHook implements BaseHook {
@Override
public void inject(View view, int i, boolean z) {
if (view instanceof VKTabLayout) {
var tabLayout = (VKTabLayout) view;
tabLayout.setSelectedTabIndicatorColor(Themes.getAccentColor());
tabLayout.setTabRippleColor(ColorStateList.valueOf(Themes.getAccentColor()));
tabLayout.setSelectedTabIndicatorColor(ThemesUtils.getAccentColor());
tabLayout.setTabRippleColor(ColorStateList.valueOf(ThemesUtils.getAccentColor()));
}
}
}
@@ -12,7 +12,7 @@ import com.vtosters.lite.R;
import ru.vtosters.lite.themes.ThemesHacks;
import ru.vtosters.lite.themes.utils.VkUiThemer;
import ru.vtosters.lite.utils.Themes;
import ru.vtosters.lite.utils.ThemesUtils;
public class TextViewHook implements BaseHook {
@@ -24,31 +24,31 @@ public class TextViewHook implements BaseHook {
if (view instanceof TextView) {
var textView = (TextView) view;
if (Themes.isAccentedColor(textView.getCurrentTextColor())) {
textView.setTextColor(Themes.getAccentColor());
if (ThemesUtils.isAccentedColor(textView.getCurrentTextColor())) {
textView.setTextColor(ThemesUtils.getAccentColor());
}
if (textView.getLinkTextColors() != null && Themes.isAccentedColor(textView.getLinkTextColors())) {
textView.setLinkTextColor(Themes.getAccentColor());
if (textView.getLinkTextColors() != null && ThemesUtils.isAccentedColor(textView.getLinkTextColors())) {
textView.setLinkTextColor(ThemesUtils.getAccentColor());
}
if (isPositiveButton(textView) || isVkUiButton(textView)) {
view.setBackgroundTintList(ColorStateList.valueOf(Themes.getAccentColor()));
view.setBackgroundTintList(ColorStateList.valueOf(ThemesUtils.getAccentColor()));
}
if (view instanceof TintTextView) {
if (eligibleForStartTinting(view.getId())) {
((TintTextView) view).setDrawableStartTint(Themes.getAccentColor());
((TintTextView) view).setDrawableStartTint(ThemesUtils.getAccentColor());
} else if (eligibleForTinting(view.getId())) {
((TintTextView) view).setDrawableTint(Themes.getAccentColor());
((TintTextView) view).setDrawableTint(ThemesUtils.getAccentColor());
}
}
if (view instanceof AppCompatCheckedTextView) {
var check = (AppCompatCheckedTextView) view;
if (Themes.isAccentedColor(check.getCheckMarkTintList())) {
check.setCheckMarkTintList(ColorStateList.valueOf(Themes.getAccentColor()));
if (ThemesUtils.isAccentedColor(check.getCheckMarkTintList())) {
check.setCheckMarkTintList(ColorStateList.valueOf(ThemesUtils.getAccentColor()));
}
}
@@ -59,19 +59,19 @@ public class TextViewHook implements BaseHook {
}
public static boolean eligibleForStartTinting(int id) {
return !Themes.isDarkTheme() && id == com.vtosters.lite.R.id.post_retweet_name;
return !ThemesUtils.isDarkTheme() && id == com.vtosters.lite.R.id.post_retweet_name;
}
public static boolean eligibleForTinting(int id) {
return !Themes.isDarkTheme() && (id == com.vtosters.lite.R.id.attach_title);
return !ThemesUtils.isDarkTheme() && (id == com.vtosters.lite.R.id.attach_title);
}
public static boolean isPositiveButton(View view) {
return !Themes.isDarkTheme() && (view.getId() == R.id.positive || view.getId() == R.id.positive_button);
return !ThemesUtils.isDarkTheme() && (view.getId() == R.id.positive || view.getId() == R.id.positive_button);
}
public static boolean isVkUiButton(View view) {
return !Themes.isDarkTheme() && (
return !ThemesUtils.isDarkTheme() && (
view.getId() == R.id.empty_button
);
}
@@ -1,11 +1,8 @@
package ru.vtosters.lite.themes.hooks;
import android.content.res.ColorStateList;
import android.view.View;
import android.widget.Toolbar;
import ru.vtosters.lite.utils.Themes;
public class ToolbarHook implements BaseHook {
@Override
public void inject(View view, int i, boolean z) {
@@ -4,7 +4,7 @@ import android.view.View;
import com.vk.imageloader.view.VKImageView;
import ru.vtosters.lite.utils.Themes;
import ru.vtosters.lite.utils.ThemesUtils;
public class VKImageViewHook implements BaseHook {
@Override
@@ -12,7 +12,7 @@ public class VKImageViewHook implements BaseHook {
if (view instanceof VKImageView) {
var imageView = (VKImageView) view;
if (imageView.getImageTintList() != null) {
imageView.setImageTintList(Themes.themeCSL(imageView.getImageTintList()));
imageView.setImageTintList(ThemesUtils.themeCSL(imageView.getImageTintList()));
}
}
}
@@ -2,17 +2,14 @@ package ru.vtosters.lite.themes.hooks;
import android.view.View;
import com.vtosters.lite.ui.widget.WaveformView;
import ru.vtosters.lite.utils.Themes;
public class WaveformViewHook implements BaseHook {
@Override
public void inject(View view, int i, boolean z) {
if (view instanceof WaveformView) {
var waveformView = (WaveformView) view;
//waveformView.set(Themes.getAccentColor());
//waveformView.set(ThemesUtils.getAccentColor());
}
}
}
@@ -12,12 +12,12 @@ import android.widget.TextView;
import com.vk.core.ui.themes.VKTheme;
import ru.vtosters.lite.utils.Themes;
import ru.vtosters.lite.utils.ThemesUtils;
public class VkUiThemer {
public static void autoThemeVkuiButtons(TextView view) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) return;
if (Themes.isDarkTheme())
if (ThemesUtils.isDarkTheme())
return; // no need to theme b/w buttons, well it should skip, but I do it for extra performance
try {
@@ -48,12 +48,12 @@ public class VkUiThemer {
ColorStateList csl = spd.getColor();
if (csl != null) {
Log.d("TSCore", "[tsh] csl2 <def: " + csl.getDefaultColor() + " = " + Themes.hex(csl.getDefaultColor()) + "> | " + csl);
Log.d("TSCore", "[tsh] csl2 <def: " + csl.getDefaultColor() + " = " + ThemesUtils.hex(csl.getDefaultColor()) + "> | " + csl);
}
if (Themes.isAccentedColor(spd.getColor())) {
if (ThemesUtils.isAccentedColor(spd.getColor())) {
Log.d("TSCore", "[tsh] theming CSL");
spd.setTint(Themes.getAccentColor());
spd.setTint(ThemesUtils.getAccentColor());
}
}
@@ -66,12 +66,12 @@ public class VkUiThemer {
ColorStateList csl = spd.getColor();
if (csl != null) {
Log.d("TSCore", "[tsh:disabled] csl2 <def: " + csl.getDefaultColor() + " = " + Themes.hex(csl.getDefaultColor()) + "> | " + csl);
Log.d("TSCore", "[tsh:disabled] csl2 <def: " + csl.getDefaultColor() + " = " + ThemesUtils.hex(csl.getDefaultColor()) + "> | " + csl);
}
if (Themes.isAccentedColor(spd.getColor())) {
if (ThemesUtils.isAccentedColor(spd.getColor())) {
Log.d("TSCore", "[tsh:disabled] theming CSL");
spd.setTint(Themes.getAccentColor());
spd.setTint(ThemesUtils.getAccentColor());
}
}
} catch (Exception e) {
@@ -81,10 +81,10 @@ public class VkUiThemer {
}
public static void fixDropdown(Drawable drawable) {
if (Themes.getCurrentTheme() == VKTheme.VKAPP_MILK_LIGHT) {
if (ThemesUtils.getCurrentTheme() == VKTheme.VKAPP_MILK_LIGHT) {
var stateListDrawable = (StateListDrawable) drawable;
((DrawableContainer.DrawableContainerState) stateListDrawable.getConstantState()).getChildren()[0].setTint(Themes.getAccentColor());
((DrawableContainer.DrawableContainerState) stateListDrawable.getConstantState()).getChildren()[1].setTint(Themes.halfAlpha(Themes.getAccentColor()));
((DrawableContainer.DrawableContainerState) stateListDrawable.getConstantState()).getChildren()[0].setTint(ThemesUtils.getAccentColor());
((DrawableContainer.DrawableContainerState) stateListDrawable.getConstantState()).getChildren()[1].setTint(ThemesUtils.halfAlpha(ThemesUtils.getAccentColor()));
}
}
}