diff --git a/app/src/main/java/ru/vtosters/lite/themes/Recolor.java b/app/src/main/java/ru/vtosters/lite/themes/Recolor.java index 17227eed1..13f18b259 100644 --- a/app/src/main/java/ru/vtosters/lite/themes/Recolor.java +++ b/app/src/main/java/ru/vtosters/lite/themes/Recolor.java @@ -36,8 +36,6 @@ public class Recolor { recolors.add(new TintTextViewRecolor()); recolors.add(new ToolbarRecolor()); recolors.add(new ViewRecolor()); - - // attrs.add(new AccentAttrs()); } public static void recolorViewOrViewGroup(View target, SparseArray satts) { diff --git a/app/src/main/java/ru/vtosters/lite/themes/VTLResources.java b/app/src/main/java/ru/vtosters/lite/themes/VTLResources.java index a756d0436..fbbfd12fd 100644 --- a/app/src/main/java/ru/vtosters/lite/themes/VTLResources.java +++ b/app/src/main/java/ru/vtosters/lite/themes/VTLResources.java @@ -51,23 +51,23 @@ public class VTLResources { var data = getData(target); for (int i = 0; i < attrs.length; i++) { //var attr = attrs[i]; - var index = STYLE_NUM_ENTRIES * i; - var type = data[index]; - var replacement = data[index + 0x1]; + var off = STYLE_NUM_ENTRIES * i; + var type = data[off]; + var replacement = -1; if (type == TypedValue.TYPE_ATTRIBUTE) { - replacement = theme.getColor(data[index + 0x1]); - if (replacement == -1) continue; + replacement = theme.getColor(data[off + 0x1]); } else if (type == TypedValue.TYPE_INT_COLOR_ARGB8 || type == TypedValue.TYPE_INT_COLOR_RGB8) { - replacement = forcedAttrs.get(data[index + 0x1], -1); - if (replacement == -1) continue; + replacement = forcedAttrs.get(data[off + 0x1], -1); + if (replacement == -1 + && ThemesUtils.accentColors.contains(Integer.toHexString(data[off + 0x1]).toLowerCase())) + replacement = ThemesUtils.getAccentColor(); } - else - continue; + if (replacement == -1) continue; try { - data[index] = TypedValue.TYPE_INT_COLOR_RGB8; // type - data[index + 0x1] = replacement; // data - data[index + 0x2] = 0x0; // asset cookie - data[index + 0x3] = 0x0; // resource id + data[off] = TypedValue.TYPE_INT_COLOR_RGB8; // type + data[off + 0x1] = replacement; // data + data[off + 0x2] = 0x0; // asset cookie + data[off + 0x3] = 0x0; // resource id } catch (Throwable ignored) { } } diff --git a/app/src/main/java/ru/vtosters/lite/themes/modifiers/ImageViewRecolor.java b/app/src/main/java/ru/vtosters/lite/themes/modifiers/ImageViewRecolor.java index 0faaa40e4..df141a340 100644 --- a/app/src/main/java/ru/vtosters/lite/themes/modifiers/ImageViewRecolor.java +++ b/app/src/main/java/ru/vtosters/lite/themes/modifiers/ImageViewRecolor.java @@ -1,6 +1,7 @@ package ru.vtosters.lite.themes.modifiers; import android.content.res.ColorStateList; +import android.util.Log; import android.view.View; import android.widget.ImageView; @@ -20,6 +21,7 @@ public class ImageViewRecolor implements IModifier { switch (attr) { case tint: case androidTint: + Log.d("ImageViewRecolor", "setColor"); iv.setImageTintList(ColorStateList.valueOf(color)); break; } diff --git a/app/src/main/java/ru/vtosters/lite/themes/modifiers/ToolbarRecolor.java b/app/src/main/java/ru/vtosters/lite/themes/modifiers/ToolbarRecolor.java index dc88d2bfa..5436f6de5 100644 --- a/app/src/main/java/ru/vtosters/lite/themes/modifiers/ToolbarRecolor.java +++ b/app/src/main/java/ru/vtosters/lite/themes/modifiers/ToolbarRecolor.java @@ -10,7 +10,6 @@ public class ToolbarRecolor implements IModifier { public static final int subtitleTextColor = R.attr.subtitleTextColor; public static final int titleTextColor = R.attr.titleTextColor; public static final int textColorPrimary = android.R.attr.textColorPrimary; - public static final int background = android.R.attr.background; @Override public boolean isModifiable(View target) { diff --git a/app/src/main/java/ru/vtosters/lite/themes/proxy/ProxyResources.java b/app/src/main/java/ru/vtosters/lite/themes/proxy/ProxyResources.java index 8cb0e076e..43afadfdf 100644 --- a/app/src/main/java/ru/vtosters/lite/themes/proxy/ProxyResources.java +++ b/app/src/main/java/ru/vtosters/lite/themes/proxy/ProxyResources.java @@ -2,12 +2,18 @@ package ru.vtosters.lite.themes.proxy; import android.content.res.ColorStateList; import android.content.res.Resources; +import android.graphics.Color; +import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.util.Log; +import android.util.Xml; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import org.xmlpull.v1.XmlPullParserException; + +import java.io.IOException; import java.lang.reflect.Field; import java.util.HashMap; @@ -38,12 +44,16 @@ public class ProxyResources extends Resources { @NonNull @Override public ColorStateList getColorStateList(int id, @Nullable Resources.Theme theme) throws Resources.NotFoundException { - return mOriginalResource.getColorStateList(id, theme); + Log.d("getColorStateList", getResourceEntryName(id)); + return ColorStateList.valueOf(Color.RED);//mOriginalResource.getColorStateList(id, theme); } @Nullable @Override public Drawable getDrawableForDensity(int id, int density, @Nullable Resources.Theme theme) { + if (ThemesUtils.isCustomThemeApplied()) { + + } return mOriginalResource.getDrawableForDensity(id, density, theme); }