fix 3
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
package ru.vtosters.lite.themes;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
import android.util.SparseArray;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -21,12 +21,14 @@ import ru.vtosters.lite.themes.modifiers.TextViewRecolor;
|
||||
import ru.vtosters.lite.themes.modifiers.TintTextViewRecolor;
|
||||
import ru.vtosters.lite.themes.modifiers.ToolbarRecolor;
|
||||
import ru.vtosters.lite.themes.modifiers.ViewRecolor;
|
||||
import ru.vtosters.lite.utils.ThemesUtils;
|
||||
|
||||
public class Recolor {
|
||||
|
||||
private static final List<IModifier> recolors = new ArrayList<>();
|
||||
|
||||
static {
|
||||
com.vtosters.lite.R.id
|
||||
recolors.add(new FloatingActionButtonRecolor());
|
||||
recolors.add(new ImageViewRecolor());
|
||||
recolors.add(new ProgressBarRecolor());
|
||||
@@ -50,6 +52,8 @@ public class Recolor {
|
||||
}
|
||||
|
||||
private static void recolorView(View target, ViewModel viewModel) {
|
||||
if (target instanceof Toolbar && target.getId() == com.vtosters.lite.R.id.toolbar)
|
||||
((Toolbar) target).setBackgroundColor(Color.RED);
|
||||
for (var recolor : recolors) {
|
||||
if (!recolor.isModifiable(target)) continue;
|
||||
for (var attr : viewModel.attrs) {
|
||||
@@ -65,15 +69,8 @@ public class Recolor {
|
||||
return original;
|
||||
}
|
||||
|
||||
public static void recolorImageView(ImageView target) {
|
||||
|
||||
}
|
||||
|
||||
public static void recolorRipple(View target) {
|
||||
|
||||
}
|
||||
|
||||
public static void recolorActivity(Activity activity) {
|
||||
|
||||
public static void recolorToolbar(Toolbar toolbar) {
|
||||
if (ThemesUtils.isCustomThemeApplied())
|
||||
toolbar.setBackgroundColor(ThemesUtils.getHeaderBackground());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,21 +110,31 @@ public class VTLResources {
|
||||
}
|
||||
|
||||
public static int getColor(Resources res, int colorId) {
|
||||
return res.getColor(colorId);
|
||||
return VTLColors.getColor(colorId);//res.getColor(colorId);
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
public static int getColor(Resources res, int colorId, Resources.Theme theme) {
|
||||
return res.getColor(colorId, theme);
|
||||
return VTLColors.getColor(colorId);
|
||||
}
|
||||
|
||||
@SuppressLint("UseCompatLoadingForColorStateLists")
|
||||
public static ColorStateList getColorStateList(Resources res, int colorId) {
|
||||
if (ThemesUtils.isCustomThemeApplied()) {
|
||||
int color = VTLColors.getColor(colorId);
|
||||
if (color != -1)
|
||||
return ColorStateList.valueOf(color);
|
||||
}
|
||||
return res.getColorStateList(colorId);
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
public static ColorStateList getColorStateList(Resources res, int colorId, Resources.Theme theme) {
|
||||
if (ThemesUtils.isCustomThemeApplied()) {
|
||||
int color = VTLColors.getColor(colorId);
|
||||
if (color != -1)
|
||||
return ColorStateList.valueOf(color);
|
||||
}
|
||||
return res.getColorStateList(colorId, theme);
|
||||
}
|
||||
//endregion
|
||||
|
||||
@@ -10,6 +10,7 @@ public class ToolbarRecolor implements IModifier<View> {
|
||||
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) {
|
||||
@@ -26,6 +27,8 @@ public class ToolbarRecolor implements IModifier<View> {
|
||||
case titleTextColor:
|
||||
t.setTitleTextColor(color);
|
||||
break;
|
||||
case background:
|
||||
t.setBackgroundColor(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.content.res.Resources;
|
||||
import android.content.res.XmlResourceParser;
|
||||
import android.graphics.Color;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
import android.util.SparseArray;
|
||||
import android.util.Xml;
|
||||
@@ -43,16 +44,11 @@ public class ProxyLayoutInflater extends LayoutInflater {
|
||||
|
||||
@Override
|
||||
public View inflate(int resource, @Nullable ViewGroup root, boolean attachToRoot) {
|
||||
var isCustomTheme = ThemesUtils.isCustomThemeApplied();
|
||||
if (isCustomTheme) parseLayout(resource);
|
||||
var target = super.inflate(resource, root, attachToRoot);
|
||||
if (isCustomTheme) Recolor.recolorViewOrViewGroup(target, layouts.get(resource));
|
||||
return target;
|
||||
}
|
||||
|
||||
public View createView(AttributeSet attrs, String name, String prefix)
|
||||
throws ClassNotFoundException {
|
||||
var target = super.createView(name, prefix, attrs);
|
||||
// if (ThemesUtils.isCustomThemeApplied()) {
|
||||
// parseLayout(resource);
|
||||
// Recolor.recolorViewOrViewGroup(target, layouts.get(resource));
|
||||
// }
|
||||
return target;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,13 +3,17 @@ 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.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
import android.util.Xml;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.annotation.XmlRes;
|
||||
|
||||
import com.vtosters.lite.R;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
@@ -41,18 +45,22 @@ public class ProxyResources extends Resources {
|
||||
return mOriginalResource.getColor(id, theme);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||
@NonNull
|
||||
@Override
|
||||
public ColorStateList getColorStateList(int id, @Nullable Resources.Theme theme) throws Resources.NotFoundException {
|
||||
Log.d("getColorStateList", getResourceEntryName(id));
|
||||
return ColorStateList.valueOf(Color.RED);//mOriginalResource.getColorStateList(id, theme);
|
||||
public ColorStateList getColorStateList(@XmlRes int id, @Nullable Resources.Theme theme)
|
||||
throws Resources.NotFoundException {
|
||||
var target = mOriginalResource.getColorStateList(id, theme);
|
||||
if (ThemesUtils.isCustomThemeApplied() && ThemesUtils.isAccentedColor(target)) {
|
||||
return ColorStateList.valueOf(ThemesUtils.getAccentColor());
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Drawable getDrawableForDensity(int id, int density, @Nullable Resources.Theme theme) {
|
||||
if (ThemesUtils.isCustomThemeApplied()) {
|
||||
|
||||
}
|
||||
return mOriginalResource.getDrawableForDensity(id, density, theme);
|
||||
}
|
||||
@@ -84,7 +92,6 @@ public class ProxyResources extends Resources {
|
||||
field = resourceFieldsMap.get(clz);
|
||||
}
|
||||
if (field == null) return;
|
||||
Log.d("ProxyResources", String.format("Found class: %s (%s)", clz.getName(), field));
|
||||
field.setAccessible(true);
|
||||
ReflectionUtils.unfinalField(field);
|
||||
var original = (Resources) field.get(target);
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
|
||||
import com.vk.navigation.Navigator;
|
||||
import com.vtosters.lite.VKActivity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -242,7 +242,7 @@
|
||||
|
||||
.line 7
|
||||
:cond_1
|
||||
invoke-virtual {p0, p4, p2, v1}, Lru/vtosters/lite/themes/proxy/ProxyLayoutInflater;->createView(Landroid/util/AttributeSet;Ljava/lang/String;Ljava/lang/String;)Landroid/view/View;
|
||||
invoke-virtual {p0, p2, v1, p4}, Landroid/view/LayoutInflater;->createView(Ljava/lang/String;Ljava/lang/String;Landroid/util/AttributeSet;)Landroid/view/View;
|
||||
|
||||
move-result-object p1
|
||||
:try_end_0
|
||||
@@ -309,7 +309,7 @@
|
||||
|
||||
.line 2
|
||||
:try_start_0
|
||||
invoke-virtual {p0, p2, p1, v3}, Lru/vtosters/lite/themes/proxy/ProxyLayoutInflater;->createView(Landroid/util/AttributeSet;Ljava/lang/String;Ljava/lang/String;)Landroid/view/View;
|
||||
invoke-virtual {p0, p1, v3, p2}, Landroid/view/LayoutInflater;->createView(Ljava/lang/String;Ljava/lang/String;Landroid/util/AttributeSet;)Landroid/view/View;
|
||||
|
||||
move-result-object v3
|
||||
:try_end_0
|
||||
|
||||
@@ -1043,7 +1043,7 @@
|
||||
.line 15
|
||||
sget v5, Lb/h/z/b;->text_primary:I
|
||||
|
||||
invoke-static {v5}, Lcom/vk/core/ui/themes/VKThemeHelper;->d(I)I
|
||||
invoke-static {v5}, Lru/vtosters/lite/themes/VTLColors;->getColor(I)I
|
||||
|
||||
move-result v5
|
||||
|
||||
@@ -1638,7 +1638,7 @@
|
||||
.line 47
|
||||
sget v3, Lb/h/z/b;->activity_indicator_tint:I
|
||||
|
||||
invoke-static {v3}, Lcom/vk/core/ui/themes/VKThemeHelper;->d(I)I
|
||||
invoke-static {v3}, Lru/vtosters/lite/themes/VTLColors;->getColor(I)I
|
||||
|
||||
move-result v3
|
||||
|
||||
@@ -1674,7 +1674,7 @@
|
||||
.line 43
|
||||
sget v1, Lb/h/z/b;->accent:I
|
||||
|
||||
invoke-static {v1}, Lcom/vk/core/ui/themes/VKThemeHelper;->d(I)I
|
||||
invoke-static {v1}, Lru/vtosters/lite/themes/VTLColors;->getColor(I)I
|
||||
|
||||
move-result v1
|
||||
|
||||
@@ -1687,7 +1687,7 @@
|
||||
.line 44
|
||||
sget v0, Lb/h/z/b;->modal_card_background:I
|
||||
|
||||
invoke-static {v0}, Lcom/vk/core/ui/themes/VKThemeHelper;->d(I)I
|
||||
invoke-static {v0}, Lru/vtosters/lite/themes/VTLColors;->getColor(I)I
|
||||
|
||||
move-result v0
|
||||
|
||||
|
||||
@@ -394,7 +394,7 @@
|
||||
|
||||
move-result-object p0
|
||||
|
||||
invoke-static {p1}, Lcom/vk/core/ui/themes/VKThemeHelper;->d(I)I
|
||||
invoke-static {p1}, Lru/vtosters/lite/themes/VTLColors;->getColor(I)I
|
||||
|
||||
move-result p1
|
||||
|
||||
@@ -738,7 +738,7 @@
|
||||
|
||||
move-result-object p0
|
||||
|
||||
invoke-static {p2}, Lcom/vk/core/ui/themes/VKThemeHelper;->d(I)I
|
||||
invoke-static {p2}, Lru/vtosters/lite/themes/VTLColors;->getColor(I)I
|
||||
|
||||
move-result p1
|
||||
|
||||
@@ -813,7 +813,7 @@
|
||||
.end param
|
||||
|
||||
.line 11
|
||||
invoke-static {p1}, Lcom/vk/core/ui/themes/VKThemeHelper;->d(I)I
|
||||
invoke-static {p1}, Lru/vtosters/lite/themes/VTLColors;->getColor(I)I
|
||||
|
||||
move-result v0
|
||||
|
||||
@@ -856,7 +856,7 @@
|
||||
.line 23
|
||||
new-instance v0, Lcom/vk/core/drawable/RecoloredDrawable;
|
||||
|
||||
invoke-static {p2}, Lcom/vk/core/ui/themes/VKThemeHelper;->d(I)I
|
||||
invoke-static {p2}, Lru/vtosters/lite/themes/VTLColors;->getColor(I)I
|
||||
|
||||
move-result v1
|
||||
|
||||
@@ -1016,7 +1016,7 @@
|
||||
.line 71
|
||||
sget p0, Lb/h/z/b;->background_page:I
|
||||
|
||||
invoke-static {p0}, Lcom/vk/core/ui/themes/VKThemeHelper;->d(I)I
|
||||
invoke-static {p0}, Lru/vtosters/lite/themes/VTLColors;->getColor(I)I
|
||||
|
||||
move-result p0
|
||||
|
||||
@@ -1089,7 +1089,7 @@
|
||||
.line 62
|
||||
sget p1, Lb/h/z/b;->background_page:I
|
||||
|
||||
invoke-static {p1}, Lcom/vk/core/ui/themes/VKThemeHelper;->d(I)I
|
||||
invoke-static {p1}, Lru/vtosters/lite/themes/VTLColors;->getColor(I)I
|
||||
|
||||
move-result p1
|
||||
|
||||
@@ -1164,7 +1164,7 @@
|
||||
.line 83
|
||||
sget v1, Lb/h/z/b;->selection_off_icon:I
|
||||
|
||||
invoke-static {v1}, Lcom/vk/core/ui/themes/VKThemeHelper;->d(I)I
|
||||
invoke-static {v1}, Lru/vtosters/lite/themes/VTLColors;->getColor(I)I
|
||||
|
||||
move-result v1
|
||||
|
||||
@@ -1181,7 +1181,7 @@
|
||||
.line 84
|
||||
sget v1, Lb/h/z/b;->accent:I
|
||||
|
||||
invoke-static {v1}, Lcom/vk/core/ui/themes/VKThemeHelper;->d(I)I
|
||||
invoke-static {v1}, Lru/vtosters/lite/themes/VTLColors;->getColor(I)I
|
||||
|
||||
move-result v1
|
||||
|
||||
@@ -1196,7 +1196,7 @@
|
||||
.line 85
|
||||
sget v1, Lb/h/z/b;->selection_off_icon:I
|
||||
|
||||
invoke-static {v1}, Lcom/vk/core/ui/themes/VKThemeHelper;->d(I)I
|
||||
invoke-static {v1}, Lru/vtosters/lite/themes/VTLColors;->getColor(I)I
|
||||
|
||||
move-result v1
|
||||
|
||||
@@ -1207,7 +1207,7 @@
|
||||
.line 86
|
||||
sget v1, Lb/h/z/b;->accent:I
|
||||
|
||||
invoke-static {v1}, Lcom/vk/core/ui/themes/VKThemeHelper;->d(I)I
|
||||
invoke-static {v1}, Lru/vtosters/lite/themes/VTLColors;->getColor(I)I
|
||||
|
||||
move-result v1
|
||||
|
||||
@@ -1254,7 +1254,7 @@
|
||||
.line 20
|
||||
new-instance v0, Lcom/vk/core/drawable/RecoloredDrawable;
|
||||
|
||||
invoke-static {p2}, Lcom/vk/core/ui/themes/VKThemeHelper;->d(I)I
|
||||
invoke-static {p2}, Lru/vtosters/lite/themes/VTLColors;->getColor(I)I
|
||||
|
||||
move-result v1
|
||||
|
||||
@@ -1282,7 +1282,7 @@
|
||||
.end param
|
||||
|
||||
.line 25
|
||||
invoke-static {p1}, Lcom/vk/core/ui/themes/VKThemeHelper;->d(I)I
|
||||
invoke-static {p1}, Lru/vtosters/lite/themes/VTLColors;->getColor(I)I
|
||||
|
||||
move-result v0
|
||||
|
||||
@@ -1310,7 +1310,7 @@
|
||||
.line 17
|
||||
new-instance v0, Lcom/vk/core/drawable/RecoloredDrawable;
|
||||
|
||||
invoke-static {p2}, Lcom/vk/core/ui/themes/VKThemeHelper;->d(I)I
|
||||
invoke-static {p2}, Lru/vtosters/lite/themes/VTLColors;->getColor(I)I
|
||||
|
||||
move-result v1
|
||||
|
||||
@@ -1435,7 +1435,7 @@
|
||||
.end param
|
||||
|
||||
.line 13
|
||||
invoke-static {p1}, Lcom/vk/core/ui/themes/VKThemeHelper;->d(I)I
|
||||
invoke-static {p1}, Lru/vtosters/lite/themes/VTLColors;->getColor(I)I
|
||||
|
||||
move-result v0
|
||||
|
||||
@@ -1461,7 +1461,7 @@
|
||||
.end param
|
||||
|
||||
.line 15
|
||||
invoke-static {p1}, Lcom/vk/core/ui/themes/VKThemeHelper;->d(I)I
|
||||
invoke-static {p1}, Lru/vtosters/lite/themes/VTLColors;->getColor(I)I
|
||||
|
||||
move-result v0
|
||||
|
||||
@@ -1621,7 +1621,7 @@
|
||||
.end param
|
||||
|
||||
.line 15
|
||||
invoke-static {p0}, Lcom/vk/core/ui/themes/VKThemeHelper;->d(I)I
|
||||
invoke-static {p0}, Lru/vtosters/lite/themes/VTLColors;->getColor(I)I
|
||||
|
||||
move-result p0
|
||||
|
||||
@@ -2032,7 +2032,7 @@
|
||||
|
||||
move-result-object v0
|
||||
|
||||
invoke-static {v0, p0}, Lru/vtosters/lite/themes/VTLColors;->getColor(Landroid/content/Context;I)I
|
||||
invoke-static {v0, p0}, Lcom/vk/core/util/ContextExtKt;->h(Landroid/content/Context;I)I
|
||||
|
||||
move-result p0
|
||||
|
||||
@@ -2191,7 +2191,7 @@
|
||||
.line 5
|
||||
sget v0, Lb/h/z/b;->header_background:I
|
||||
|
||||
invoke-static {v0}, Lcom/vk/core/ui/themes/VKThemeHelper;->d(I)I
|
||||
invoke-static {v0}, Lru/vtosters/lite/themes/VTLColors;->getColor(I)I
|
||||
|
||||
move-result v0
|
||||
|
||||
@@ -2380,7 +2380,7 @@
|
||||
.line 1
|
||||
sget v0, Lb/h/z/b;->background_page:I
|
||||
|
||||
invoke-static {v0}, Lcom/vk/core/ui/themes/VKThemeHelper;->d(I)I
|
||||
invoke-static {v0}, Lru/vtosters/lite/themes/VTLColors;->getColor(I)I
|
||||
|
||||
move-result v0
|
||||
|
||||
@@ -2570,7 +2570,7 @@
|
||||
.line 4
|
||||
sget v2, Lb/h/z/b;->accent:I
|
||||
|
||||
invoke-static {v2}, Lcom/vk/core/ui/themes/VKThemeHelper;->d(I)I
|
||||
invoke-static {v2}, Lru/vtosters/lite/themes/VTLColors;->getColor(I)I
|
||||
|
||||
move-result v2
|
||||
|
||||
@@ -2589,7 +2589,7 @@
|
||||
.line 1
|
||||
sget v1, Lb/h/z/b;->loader_track_fill:I
|
||||
|
||||
invoke-static {v1}, Lcom/vk/core/ui/themes/VKThemeHelper;->d(I)I
|
||||
invoke-static {v1}, Lru/vtosters/lite/themes/VTLColors;->getColor(I)I
|
||||
|
||||
move-result v1
|
||||
|
||||
@@ -2606,7 +2606,7 @@
|
||||
.line 2
|
||||
sget v1, Lb/h/z/b;->accent:I
|
||||
|
||||
invoke-static {v1}, Lcom/vk/core/ui/themes/VKThemeHelper;->d(I)I
|
||||
invoke-static {v1}, Lru/vtosters/lite/themes/VTLColors;->getColor(I)I
|
||||
|
||||
move-result v1
|
||||
|
||||
@@ -2623,7 +2623,7 @@
|
||||
.line 3
|
||||
sget v1, Lb/h/z/b;->loader_track_fill:I
|
||||
|
||||
invoke-static {v1}, Lcom/vk/core/ui/themes/VKThemeHelper;->d(I)I
|
||||
invoke-static {v1}, Lru/vtosters/lite/themes/VTLColors;->getColor(I)I
|
||||
|
||||
move-result v1
|
||||
|
||||
@@ -2634,7 +2634,7 @@
|
||||
.line 4
|
||||
sget v1, Lb/h/z/b;->accent:I
|
||||
|
||||
invoke-static {v1}, Lcom/vk/core/ui/themes/VKThemeHelper;->d(I)I
|
||||
invoke-static {v1}, Lru/vtosters/lite/themes/VTLColors;->getColor(I)I
|
||||
|
||||
move-result v1
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
.method public static final a(Landroidx/appcompat/widget/Toolbar;)V
|
||||
.locals 4
|
||||
|
||||
invoke-static {p0}, Lru/vtosters/lite/themes/Recolor;->recolorToolbar(Landroidx/appcompat/widget/Toolbar;)V
|
||||
|
||||
.line 1
|
||||
sget v0, Lb/h/z/b;->toolbar_title_textColor:I
|
||||
|
||||
|
||||
@@ -368,6 +368,8 @@
|
||||
|
||||
check-cast p2, Landroidx/appcompat/widget/Toolbar;
|
||||
|
||||
invoke-static {p2}, Lru/vtosters/lite/themes/Recolor;->recolorToolbar(Landroidx/appcompat/widget/Toolbar;)V
|
||||
|
||||
const v1, 0x7f120fae
|
||||
|
||||
.line 3
|
||||
|
||||
Reference in New Issue
Block a user