From 678a3986123c1faf700d810ea8201f092e01b703 Mon Sep 17 00:00:00 2001 From: aliveoutside <53598473+aliveoutside@users.noreply.github.com> Date: Thu, 28 Jul 2022 17:40:26 +0300 Subject: [PATCH] [accents] return themeCSL method back to ThemesUtils --- .../ru/vtosters/lite/utils/ThemesUtils.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/src/main/java/ru/vtosters/lite/utils/ThemesUtils.java b/app/src/main/java/ru/vtosters/lite/utils/ThemesUtils.java index 9cda8659e..8bb364653 100644 --- a/app/src/main/java/ru/vtosters/lite/utils/ThemesUtils.java +++ b/app/src/main/java/ru/vtosters/lite/utils/ThemesUtils.java @@ -260,6 +260,26 @@ public class ThemesUtils { } } // Recolor ColorStateList + public static ColorStateList themeCSL(ColorStateList csl){ + try { + int unsel = csl.getColorForState(new int[] {-android.R.attr.state_selected}, Color.BLACK); + int sel = csl.getColorForState(new int[] {android.R.attr.state_selected}, Color.BLACK); + + boolean isUnselAccent = isAccentedColor(unsel); + boolean isSelAccent = isAccentedColor(sel); + + if (isUnselAccent || isSelAccent) { + return new ColorStateList(new int[][] { + new int[] {android.R.attr.state_selected}, new int[] {-android.R.attr.state_selected} + }, new int[] {isSelAccent ? getAccentColor() : sel, isUnselAccent ? getAccentColor() : unsel}); + } + return csl; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + public static int darken(int color, float by) { float[] hsl = new float[3]; ColorUtils.colorToHSL(color, hsl);