updated color hooks
This commit is contained in:
@@ -2,6 +2,7 @@ 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;
|
||||
@@ -25,14 +26,7 @@ public class ColorReferences {
|
||||
}
|
||||
|
||||
public static boolean isColorRefAccented(int target) {
|
||||
return target == com.vtosters.lite.R.color.accent_blue || // accent_blue
|
||||
target == com.vtosters.lite.R.color.blue_gray || // light_blue_gray
|
||||
target == com.vtosters.lite.R.color.azure_300 ||
|
||||
target == com.vtosters.lite.R.color.light_blue_old || // light_blue
|
||||
target == com.vtosters.lite.R.color.blue_200 || // blue_200
|
||||
target == com.vtosters.lite.R.color.vk_blue_400 || // blue_200
|
||||
target == com.vtosters.lite.R.color.header_blue ||
|
||||
target == com.vtosters.lite.R.color.blue_200_muted; // blue_200_muted
|
||||
return ThemesUtils.isColorRefAccented(target);
|
||||
}
|
||||
|
||||
public static boolean isCslNeedToBeThemed(ColorStateList csl) {
|
||||
|
||||
@@ -124,36 +124,10 @@ public class ThemesUtils {
|
||||
return getColorFromAttr(R.attr.header_text);
|
||||
} // Header/Toolbar color text
|
||||
|
||||
public static int getAmoledTheme() {
|
||||
return getIdentifier("BaseAmoledStyle", "style");
|
||||
} // Get Amoled theme id
|
||||
|
||||
public static int picFix() {
|
||||
return getIdentifier("ActionBarThemeFix", "style");
|
||||
} // Fix tabbar color in photo viewer
|
||||
|
||||
public static int getAmoledImTheme() {
|
||||
return getIdentifier("VkIm.Theme.VkApp.Amoled", "style");
|
||||
} // Get Amoled theme id for messages
|
||||
|
||||
public static int getAmoledMeTheme() {
|
||||
return getIdentifier("VkIm.Theme.VkMe.Amoled", "style");
|
||||
} // Get Amoled theme id for messages with rounded msg
|
||||
|
||||
public static int getAttrId(String attr) {
|
||||
return getIdentifier(attr, "attr");
|
||||
}
|
||||
|
||||
public static void setBarTheme(View getview) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
getview.setSystemUiVisibility(getNeededColorNavbar() | getNeededColorStatusbar());
|
||||
}
|
||||
} // Set white/dark statusbar/navbar icons
|
||||
|
||||
public static int getNeededColorStatusbar() {
|
||||
return !isDarkTheme() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S ? 8192 : 0;
|
||||
}
|
||||
|
||||
public static int getNeededColorNavbar() {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ? isDarkTheme() ? SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR : 0 : 0;
|
||||
}
|
||||
@@ -191,21 +165,74 @@ public class ThemesUtils {
|
||||
}
|
||||
|
||||
public static boolean isColorRefAccented(int color) {
|
||||
for (int accent : new int[]{R.color.accent_blue, R.color.azure_A400, R.color.blue, R.color.blue_200, R.color.blue_200_muted, R.color.blue_300, R.color.blue_400, R.color.cool_blue, R.color.cornflower_blue, R.color.cornflower_blue_two, R.color.dot_unread, R.color.fave_promo_btn_pressed, R.color.header_blue, R.color.vkim_ripple_dark, R.color.colorAccent, R.color.light_blue, R.color.light_blue_gray, R.color.live_emoji_butt_hide, R.color.music_action_button_blue, R.color.name, R.color.picker_blue, R.color.picker_blue_pressed, R.color.picker_tab_bg_selected, R.color.picker_tab_text_selected, R.color.sharing_blue_btn_normal, R.color.sharing_blue_btn_pressed, R.color.sky_300, R.color.text_blue, R.color.tip_background, R.color.tw__blue_default, R.color.tw__blue_pressed, R.color.vkim_msg_sending_ic, R.color.vkim_playing_drawable_rect, R.color.white_blue32}) {
|
||||
if (color == accent) return true;
|
||||
}
|
||||
return false;
|
||||
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
|
||||
|
||||
public static int replaceColor(int i){
|
||||
return ColorReferences.isAccentedColor(i) ? getAccentColor() : i;
|
||||
}
|
||||
|
||||
public static void themeMonetToolbar(ImageButton imageButton, Toolbar toolbar) {
|
||||
imageButton.setImageTintList(ColorStateList.valueOf(getHeaderText()));
|
||||
toolbar.setElevation(0.0f);
|
||||
}
|
||||
|
||||
public static void setImageViewColored(ImageView view){
|
||||
view.setColorFilter(ThemesUtils.getAccentColor(), PorterDuff.Mode.MULTIPLY);
|
||||
}
|
||||
@@ -223,17 +250,6 @@ public class ThemesUtils {
|
||||
view.getBackground().setColorFilter(ThemesUtils.getAccentColor(), PorterDuff.Mode.SRC_OVER);
|
||||
}
|
||||
|
||||
public static Drawable recolorVKIconMenu(Drawable drawable) {
|
||||
int accent = getHeaderText();
|
||||
|
||||
if (drawable == null) return null;
|
||||
|
||||
if (isAndroidMonet() || isDarkTheme()) accent = getAccentColor();
|
||||
|
||||
return new RecoloredDrawable(drawable, accent);
|
||||
} // Recolor vk icon to accent color
|
||||
|
||||
|
||||
public static int darken(int color, float by) {
|
||||
float[] hsl = new float[3];
|
||||
ColorUtils.colorToHSL(color, hsl);
|
||||
@@ -260,9 +276,8 @@ public class ThemesUtils {
|
||||
return ColorUtils.setAlphaComponent(src, 169);
|
||||
}
|
||||
|
||||
|
||||
public static int getColor(Context context, int i) {
|
||||
if (isColorRefAccented(i) && isAndroidMonet()) {
|
||||
if (isColorRefAccented(i)) {
|
||||
return getAccentColor();
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
@@ -272,8 +287,8 @@ public class ThemesUtils {
|
||||
}
|
||||
} // Android Support color injector + accent color checker
|
||||
|
||||
public static int getColor2(int i) {
|
||||
if (isColorRefAccented(i) && isAndroidMonet()) {
|
||||
public static int getColor(int i) {
|
||||
if (isColorRefAccented(i)) {
|
||||
return getAccentColor();
|
||||
}
|
||||
return getResources().getColor(i);
|
||||
|
||||
@@ -5723,7 +5723,7 @@
|
||||
sget v5, Landroidx/appcompat/R$color;->abc_input_method_navigation_guard:I
|
||||
|
||||
.line 19
|
||||
invoke-virtual {v4, v5}, Landroid/content/res/Resources;->getColor(I)I
|
||||
invoke-static {v5}, Lru/vtosters/lite/utils/ThemesUtils;->getColor(I)I
|
||||
|
||||
move-result v4
|
||||
|
||||
|
||||
@@ -79,9 +79,7 @@
|
||||
.end annotation
|
||||
|
||||
.line 1
|
||||
iget-object v0, p0, Landroidx/appcompat/widget/ResourcesWrapper;->mResources:Landroid/content/res/Resources;
|
||||
|
||||
invoke-virtual {v0, p1}, Landroid/content/res/Resources;->getColor(I)I
|
||||
invoke-static {p1}, Lru/vtosters/lite/utils/ThemesUtils;->getColor(I)I
|
||||
|
||||
move-result p1
|
||||
|
||||
|
||||
@@ -235,7 +235,7 @@
|
||||
|
||||
sget v1, Landroidx/cardview/R$color;->cardview_light_background:I
|
||||
|
||||
invoke-virtual {p3, v1}, Landroid/content/res/Resources;->getColor(I)I
|
||||
invoke-static {v1}, Lru/vtosters/lite/utils/ThemesUtils;->getColor(I)I
|
||||
|
||||
move-result p3
|
||||
|
||||
@@ -249,7 +249,7 @@
|
||||
|
||||
sget v1, Landroidx/cardview/R$color;->cardview_dark_background:I
|
||||
|
||||
invoke-virtual {p3, v1}, Landroid/content/res/Resources;->getColor(I)I
|
||||
invoke-static {v1}, Lru/vtosters/lite/utils/ThemesUtils;->getColor(I)I
|
||||
|
||||
move-result p3
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@
|
||||
.line 5
|
||||
sget v1, Landroidx/cardview/R$color;->cardview_shadow_start_color:I
|
||||
|
||||
invoke-virtual {p1, v1}, Landroid/content/res/Resources;->getColor(I)I
|
||||
invoke-static {v1}, Lru/vtosters/lite/utils/ThemesUtils;->getColor(I)I
|
||||
|
||||
move-result v1
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
.line 6
|
||||
sget v1, Landroidx/cardview/R$color;->cardview_shadow_end_color:I
|
||||
|
||||
invoke-virtual {p1, v1}, Landroid/content/res/Resources;->getColor(I)I
|
||||
invoke-static {v1}, Lru/vtosters/lite/utils/ThemesUtils;->getColor(I)I
|
||||
|
||||
move-result v1
|
||||
|
||||
|
||||
@@ -48,23 +48,7 @@
|
||||
}
|
||||
.end annotation
|
||||
|
||||
.line 1
|
||||
sget v0, Landroid/os/Build$VERSION;->SDK_INT:I
|
||||
|
||||
const/16 v1, 0x17
|
||||
|
||||
if-lt v0, v1, :cond_0
|
||||
|
||||
.line 2
|
||||
invoke-virtual {p0, p1, p2}, Landroid/content/res/Resources;->getColor(ILandroid/content/res/Resources$Theme;)I
|
||||
|
||||
move-result p0
|
||||
|
||||
return p0
|
||||
|
||||
.line 3
|
||||
:cond_0
|
||||
invoke-virtual {p0, p1}, Landroid/content/res/Resources;->getColor(I)I
|
||||
invoke-static {p1}, Lru/vtosters/lite/utils/ThemesUtils;->getColor(I)I
|
||||
|
||||
move-result p0
|
||||
|
||||
|
||||
@@ -203,9 +203,7 @@
|
||||
iput v0, p0, Lcom/fourmob/datetimepicker/date/SimpleMonthView;->e:I
|
||||
|
||||
.line 20
|
||||
sget v0, Lcom/fourmob/datetimepicker/a;->blue:I
|
||||
|
||||
invoke-virtual {p1, v0}, Landroid/content/res/Resources;->getColor(I)I
|
||||
invoke-static {}, Lru/vtosters/lite/utils/ThemesUtils;->getAccentColor()I
|
||||
|
||||
move-result v0
|
||||
|
||||
|
||||
@@ -33,9 +33,7 @@
|
||||
move-result-object p2
|
||||
|
||||
.line 4
|
||||
sget v0, Lcom/fourmob/datetimepicker/a;->blue:I
|
||||
|
||||
invoke-virtual {p2, v0}, Landroid/content/res/Resources;->getColor(I)I
|
||||
invoke-static {}, Lru/vtosters/lite/utils/ThemesUtils;->getAccentColor()I
|
||||
|
||||
move-result p2
|
||||
|
||||
|
||||
@@ -204,9 +204,7 @@
|
||||
iput v0, p0, Lcom/fourmob/datetimepicker/time/AmPmCirclesView;->c:I
|
||||
|
||||
.line 6
|
||||
sget v0, Lcom/fourmob/datetimepicker/a;->blue:I
|
||||
|
||||
invoke-virtual {p1, v0}, Landroid/content/res/Resources;->getColor(I)I
|
||||
invoke-static {}, Lru/vtosters/lite/utils/ThemesUtils;->getAccentColor()I
|
||||
|
||||
move-result v0
|
||||
|
||||
|
||||
@@ -496,9 +496,7 @@
|
||||
move-result-object p1
|
||||
|
||||
.line 4
|
||||
sget v0, Lcom/fourmob/datetimepicker/a;->blue:I
|
||||
|
||||
invoke-virtual {p1, v0}, Landroid/content/res/Resources;->getColor(I)I
|
||||
invoke-static {}, Lru/vtosters/lite/utils/ThemesUtils;->getAccentColor()I
|
||||
|
||||
move-result v0
|
||||
|
||||
|
||||
@@ -2820,9 +2820,7 @@
|
||||
iput-object v2, p0, Lcom/fourmob/datetimepicker/time/RadialTimePickerDialog;->V:Ljava/lang/String;
|
||||
|
||||
.line 10
|
||||
sget v2, Lcom/fourmob/datetimepicker/a;->blue:I
|
||||
|
||||
invoke-virtual {v1, v2}, Landroid/content/res/Resources;->getColor(I)I
|
||||
invoke-static {}, Lru/vtosters/lite/utils/ThemesUtils;->getAccentColor()I
|
||||
|
||||
move-result v2
|
||||
|
||||
|
||||
@@ -3494,14 +3494,14 @@
|
||||
|
||||
const v1, 0x7f060018
|
||||
|
||||
invoke-static {v1}, Lru/vtosters/lite/utils/ThemesUtils;->getColor2(I)I
|
||||
invoke-static {v1}, Lru/vtosters/lite/utils/ThemesUtils;->getColor(I)I
|
||||
|
||||
move-result v2
|
||||
|
||||
const v3, 0x7f060105
|
||||
|
||||
.line 20
|
||||
invoke-static {v3}, Lru/vtosters/lite/utils/ThemesUtils;->getColor2(I)I
|
||||
invoke-static {v3}, Lru/vtosters/lite/utils/ThemesUtils;->getColor(I)I
|
||||
|
||||
move-result v4
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
|
||||
sget v1, Lb/h/z/c;->light_blue:I
|
||||
|
||||
invoke-static {v1}, Lru/vtosters/lite/utils/ThemesUtils;->getColor2(I)I
|
||||
invoke-static {v1}, Lru/vtosters/lite/utils/ThemesUtils;->getColor(I)I
|
||||
|
||||
move-result v0
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
.line 2
|
||||
sget v0, Lcom/vk/mentions/p;->light_blue:I
|
||||
|
||||
invoke-static {v0}, Lru/vtosters/lite/utils/ThemesUtils;->getColor2(I)I
|
||||
invoke-static {v0}, Lru/vtosters/lite/utils/ThemesUtils;->getColor(I)I
|
||||
|
||||
move-result p1
|
||||
|
||||
|
||||
@@ -410,7 +410,7 @@
|
||||
|
||||
move-result-object p3
|
||||
|
||||
invoke-virtual {p3, v2}, Landroid/content/res/Resources;->getColor(I)I
|
||||
invoke-static {v2}, Lru/vtosters/lite/utils/ThemesUtils;->getColor(I)I
|
||||
|
||||
move-result p3
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
|
||||
const v0, 0x7f0600f7
|
||||
|
||||
invoke-static {v0}, Lru/vtosters/lite/utils/ThemesUtils;->getColor2(I)I
|
||||
invoke-static {v0}, Lru/vtosters/lite/utils/ThemesUtils;->getColor(I)I
|
||||
|
||||
move-result p3
|
||||
|
||||
|
||||
Reference in New Issue
Block a user