fixed many colors

This commit is contained in:
gdlbo
2022-12-07 01:41:22 +03:00
parent 0feeacb533
commit 30de30cf64
9 changed files with 163 additions and 113 deletions
@@ -2,19 +2,18 @@ package ru.vtosters.lite.themes;
import android.content.res.ColorStateList;
import android.graphics.Color;
import ru.vtosters.lite.utils.ThemesUtils;
import java.util.Arrays;
import java.util.List;
import static com.vtosters.lite.R.color.*;
public class ColorReferences {
public static List<Integer> accentColors = Arrays.asList(
Color.parseColor("#3f8ae0"), // azure_300 (light accent)
Color.parseColor("#4986cc"), // azure_a400
Color.parseColor("#528bcc"), // another light accent
Color.parseColor("#71aaeb"), // vk_sky_300 (dark accent)
Color.parseColor("#74a2d6"),
Color.parseColor("#67a5eb"),
Color.parseColor("#5181b8") // header_blue
);
@@ -28,9 +27,96 @@ public class ColorReferences {
Color.parseColor("#a800244d"),
Color.parseColor("#14001c3d"),
Color.parseColor("#3d001c3d"),
Color.parseColor("#74a2d6"),
Color.parseColor("#67a5eb"),
Color.parseColor("#45678f"),
Color.parseColor("#6645678f"),
Color.parseColor("#664986cc")
);
public static List<Integer> accents = Arrays.asList(
viewer_retry_button_text_color,
azure_300,
picker_camera_button,
music_check_button_bg_pressed,
notification_color,
music_text_counter,
music_follow_button_bg_pressed,
music_blue_button_normal,
music_check_button_bg_normal,
vk_terms_link,
vk_blue_200,
accent_blue,
azure_A400,
vk_azure_A400,
blue,
blue_200,
vk_blue_300,
vk_blue_400,
blue_300,
blue_400,
cool_blue,
cornflower_blue,
cornflower_blue_two,
dot_unread,
fave_promo_btn_pressed,
header_blue,
colorAccent,
live_emoji_butt_hide,
music_action_button_blue,
name,
picker_blue,
picker_blue_pressed,
picker_tab_bg_selected,
picker_tab_text_selected,
sharing_blue_btn_normal,
sharing_blue_btn_pressed,
vk_sky_300,
vk_blue_A400,
blue_A400,
sky_300,
text_blue,
tip_background,
tw__blue_default,
tw__blue_pressed,
vkim_msg_sending_ic,
vkim_playing_drawable_rect,
vk_white_blue32,
date_picker_selector,
post_suggest_blue,
list_dialog_blue,
music_tab_bg_normal,
toolbar_blue_background,
toolbar_blue_statusBarColorBack
);
public static List<Integer> mutedAccents = Arrays.asList(
blue_200_muted,
vk_blue_200_muted,
white_blue32,
vk_white_blue32,
header_blue_opacity16,
black_blue45_alpha10,
music_check_button_bg_checked,
vk_black_blue45_alpha10,
black_blue30_alpha66,
vk_black_blue30_alpha66,
attachpicker_item_background,
black_blue24_alpha8,
music_placeholder_artist_bg,
black_blue24_alpha24,
vk_black_blue24_alpha24,
azure_100_muted,
vk_azure_100_muted,
muted_blue,
blue_600,
light_blue,
vk_blue_600,
muted_blue_opacity40,
muted_blue_old,
header_blue_opacity40
);
public static boolean isAccentedColor(ColorStateList target) {
return target != null && isAccentedColor(target.getDefaultColor());
}
@@ -48,7 +134,11 @@ public class ColorReferences {
}
public static boolean isColorRefAccented(int target) {
return ThemesUtils.isColorRefAccented(target);
return accents.contains(target);
}
public static boolean isColorRefMutedAccented(int target) {
return mutedAccents.contains(target);
}
public static boolean isCslNeedToBeThemed(ColorStateList csl) {
@@ -58,4 +148,4 @@ public class ColorReferences {
boolean isSelAccent = isAccentedColor(sel);
return ThemesCore.isCachedAccents() && (isUnselAccent || isSelAccent);
}
}
}
@@ -136,10 +136,10 @@ public class ThemesCore {
}
public static boolean hasThemedAttr(Context context, int attrID) {
try {
Log.d(TAG, "Requesting color by attr " + context.getResources().getResourceName(attrID));
} catch (Exception e) {
}
// try {
// Log.d(TAG, "Requesting color by attr " + context.getResources().getResourceName(attrID));
// } catch (Exception e) {
// }
if (isCachedAccents()) {
if (!ThemesUtils.isDarkTheme()) {
@@ -1,24 +1,14 @@
package ru.vtosters.lite.themes;
import android.content.Context;
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.graphics.drawable.*;
import android.os.Build;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import androidx.annotation.ColorRes;
import androidx.annotation.NonNull;
import com.vtosters.lite.R;
import ru.vtosters.lite.themes.utils.RecolorUtils;
import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.lite.utils.ThemesUtils;
public class ThemesHacks {
@@ -39,7 +39,7 @@ public class VTLResources extends Resources {
public VTLResources(Context context, Resources parent) {
super(parent.getAssets(), parent.getDisplayMetrics(), parent.getConfiguration());
this.context = context;
Log.d(TAG, "VTLResources: init");
// Log.d(TAG, "VTLResources: init");
}
@Override
@@ -6,10 +6,7 @@ import android.content.res.ColorStateList;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.Log;
import com.vk.core.drawable.RecoloredDrawable;
import ru.vtosters.lite.themes.ColorReferences;
import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.lite.utils.ThemesUtils;
@@ -44,6 +41,8 @@ public class RecolorUtils {
public static ColorStateList themeCSL(Context context, int color) {
if (ColorReferences.isColorRefAccented(color)) {
return ColorStateList.valueOf(ThemesUtils.getAccentColor());
} else if (ColorReferences.isColorRefMutedAccented(color)) {
return ColorStateList.valueOf(ThemesUtils.getMutedAccentColor());
}
ColorStateList csl;
@@ -43,15 +43,15 @@ public class VkUiThemer {
GradientDrawable spd = (GradientDrawable) currentTarget;
if (spd.getShape() != GradientDrawable.RECTANGLE) continue;
Log.d("TSCore", "[tsh] got a color!");
// Log.d("TSCore", "[tsh] got a color!");
ColorStateList csl = spd.getColor();
if (csl != null) {
Log.d("TSCore", "[tsh] csl2 <def: " + csl.getDefaultColor() + " = " + ThemesUtils.hex(csl.getDefaultColor()) + "> | " + csl);
}
// if (csl != null) {
// Log.d("TSCore", "[tsh] csl2 <def: " + csl.getDefaultColor() + " = " + ThemesUtils.hex(csl.getDefaultColor()) + "> | " + csl);
// }
if (ColorReferences.isAccentedColor(spd.getColor())) {
Log.d("TSCore", "[tsh] theming CSL");
// Log.d("TSCore", "[tsh] theming CSL");
spd.setTint(ThemesUtils.getAccentColor());
}
}
@@ -61,20 +61,20 @@ public class VkUiThemer {
GradientDrawable spd = (GradientDrawable) draw2;
if (spd.getShape() != GradientDrawable.RECTANGLE) return;
Log.d("TSCore", "[tsh:disabled] got a color!");
// Log.d("TSCore", "[tsh:disabled] got a color!");
ColorStateList csl = spd.getColor();
if (csl != null) {
Log.d("TSCore", "[tsh:disabled] csl2 <def: " + csl.getDefaultColor() + " = " + ThemesUtils.hex(csl.getDefaultColor()) + "> | " + csl);
}
// if (csl != null) {
// Log.d("TSCore", "[tsh:disabled] csl2 <def: " + csl.getDefaultColor() + " = " + ThemesUtils.hex(csl.getDefaultColor()) + "> | " + csl);
// }
if (ColorReferences.isAccentedColor(spd.getColor())) {
Log.d("TSCore", "[tsh:disabled] theming CSL");
// Log.d("TSCore", "[tsh:disabled] theming CSL");
spd.setTint(ThemesUtils.getAccentColor());
}
if (ColorReferences.isMutedAccentedColor(spd.getColor())) {
Log.d("TSCore", "[tsh:disabled] theming CSL");
// Log.d("TSCore", "[tsh:disabled] theming CSL");
spd.setTint(ThemesUtils.getMutedAccentColor());
}
}
@@ -1,7 +1,6 @@
package ru.vtosters.lite.utils;
import android.app.Activity;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.graphics.PorterDuff;
@@ -11,12 +10,13 @@ import android.util.Log;
import android.view.View;
import android.view.Window;
import android.webkit.WebView;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.Switch;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.Toolbar;
import androidx.appcompat.widget.SwitchCompat;
import androidx.core.graphics.ColorUtils;
import androidx.core.graphics.drawable.DrawableCompat;
import com.vk.articles.preload.WebCachePreloader;
import com.vk.core.drawable.RecoloredDrawable;
import com.vk.core.preference.Preference;
@@ -25,14 +25,11 @@ import com.vk.core.ui.themes.VKTheme;
import com.vk.core.ui.themes.VKThemeHelper;
import com.vtosters.lite.R;
import com.vtosters.lite.data.ThemeTracker;
import ru.vtosters.lite.themes.ColorReferences;
import ru.vtosters.lite.hooks.VKUIHook;
import ru.vtosters.lite.themes.ThemesHacks;
import ru.vtosters.lite.ui.wallpapers.WallpapersHooks;
import static android.view.View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
import static ru.vtosters.lite.hooks.VKUIHook.isLoaded;
import static ru.vtosters.lite.ui.wallpapers.WallpapersHooks.getWallpaper;
import static ru.vtosters.lite.utils.AndroidUtils.*;
import static ru.vtosters.lite.utils.LifecycleUtils.getCurrentActivity;
import static ru.vtosters.lite.utils.Preferences.*;
public class ThemesUtils {
@@ -63,26 +60,26 @@ public class ThemesUtils {
public static void setTheme(VKTheme theme, Activity activity) {
if (activity == null) {
activity = getCurrentActivity();
activity = LifecycleUtils.getCurrentActivity();
if (activity == null) return;
}
VKThemeHelper.theme(theme, activity, getCenterScreenCoords());
ThemeTracker.a();
isLoaded = false;
VKUIHook.isLoaded = false;
new WebView(activity).clearCache(true);
WebCachePreloader.e();
} // apply changed theme
public static void setThemeFL(VKTheme theme, Activity activity, float[] fl) {
if (activity == null) {
activity = getCurrentActivity();
activity = LifecycleUtils.getCurrentActivity();
if (activity == null) return;
}
VKThemeHelper.theme(theme, activity, fl);
ThemeTracker.a();
isLoaded = false;
VKUIHook.isLoaded = false;
new WebView(activity).clearCache(true);
WebCachePreloader.e();
}
@@ -143,7 +140,7 @@ public class ThemesUtils {
}
public static int getNeededColorNavbar() {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ? isDarkTheme() ? SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR : 0 : 0;
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ? isDarkTheme() ? View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR : 0 : 0;
}
public static int getDarkThemeRes() {
@@ -178,70 +175,32 @@ public class ThemesUtils {
return MilkshakeHelper.e();
}
public static boolean isColorRefAccented(int color) {
return color == R.color.viewer_retry_button_text_color ||
color == R.color.azure_300 ||
color == R.color.light_blue_old ||
color == R.color.picker_camera_button ||
color == R.color.music_check_button_bg_pressed ||
color == R.color.notification_color ||
color == R.color.music_text_counter ||
color == R.color.music_follow_button_bg_pressed ||
color == R.color.music_blue_button_normal ||
color == R.color.music_check_button_bg_normal ||
color == R.color.vk_terms_link ||
color == R.color.vk_blue_200_muted ||
color == R.color.vk_blue_200 ||
color == R.color.accent_blue ||
color == R.color.azure_A400 ||
color == R.color.vk_azure_A400 ||
color == R.color.blue ||
color == R.color.blue_200 ||
color == R.color.blue_200_muted ||
color == R.color.vk_blue_300 ||
color == R.color.vk_blue_400 ||
color == R.color.blue_300 ||
color == R.color.blue_400 ||
color == R.color.cool_blue ||
color == R.color.cornflower_blue ||
color == R.color.cornflower_blue_two ||
color == R.color.dot_unread ||
color == R.color.fave_promo_btn_pressed ||
color == R.color.header_blue ||
color == R.color.colorAccent ||
color == R.color.blue_gray ||
color == R.color.light_blue ||
color == R.color.light_blue_gray ||
color == R.color.live_emoji_butt_hide ||
color == R.color.music_action_button_blue ||
color == R.color.name ||
color == R.color.picker_blue ||
color == R.color.picker_blue_pressed ||
color == R.color.picker_tab_bg_selected ||
color == R.color.picker_tab_text_selected ||
color == R.color.sharing_blue_btn_normal ||
color == R.color.sharing_blue_btn_pressed ||
color == R.color.vk_sky_300 ||
color == R.color.vk_blue_A400 ||
color == R.color.blue_A400 ||
color == R.color.sky_300 ||
color == R.color.muted_blue ||
color == R.color.muted_blue_old ||
color == R.color.text_blue ||
color == R.color.tip_background ||
color == R.color.tw__blue_default ||
color == R.color.tw__blue_pressed ||
color == R.color.vkim_msg_sending_ic ||
color == R.color.vkim_playing_drawable_rect ||
color == R.color.vk_white_blue32 ||
color == R.color.date_picker_selector ||
color == R.color.post_suggest_blue ||
color == R.color.list_dialog_blue ||
color == R.color.music_tab_bg_normal ||
color == R.color.toolbar_blue_background ||
color == R.color.toolbar_blue_statusBarColorBack ||
color == R.color.white_blue32;
} // Accent colors
private static int[] p() {
int[] iArr = new int[4];
iArr[0] = getColor(isDarkTheme() ? R.color.gray_800 : R.color.white);
iArr[1] = getColor(isDarkTheme() ? R.color.switch_disabled_on_dark : R.color.switch_disabled_on_light);
iArr[2] = getColor(R.color.gray_20);
iArr[3] = getAccentColor();
return iArr;
}
private static int[][] f() {
return new int[][]{new int[]{-16842910, -16842912}, new int[]{-16842910, 16842912}, new int[]{-16842912}, new int[]{16842912}};
}
private static int[] q() {
return new int[]{VKThemeHelper.d(R.attr.loader_track_fill), getMutedAccentColor(), VKThemeHelper.d(R.attr.loader_track_fill), getMutedAccentColor()};
}
public static void setSwitch(SwitchCompat switchCompat) {
DrawableCompat.setTintList(DrawableCompat.wrap(switchCompat.getThumbDrawable()), new ColorStateList(f(), p()));
DrawableCompat.setTintList(DrawableCompat.wrap(switchCompat.getTrackDrawable()), new ColorStateList(f(), q()));
}
public static void setSwitch(Switch aSwitch) {
DrawableCompat.setTintList(DrawableCompat.wrap(aSwitch.getThumbDrawable()), new ColorStateList(f(), p()));
DrawableCompat.setTintList(DrawableCompat.wrap(aSwitch.getTrackDrawable()), new ColorStateList(f(), q()));
}
public static void setImageViewColored(ImageView view){
view.setColorFilter(ThemesUtils.getAccentColor(), PorterDuff.Mode.MULTIPLY);
@@ -300,7 +259,7 @@ public class ThemesUtils {
}
public static String getBackgroundStickers() {
if (getWallpaper() != null) {
if (WallpapersHooks.getWallpaper() != null) {
return "images_with_background";
}
return "images";