mirror of
https://github.com/revanced/revanced-integrations.git
synced 2025-01-07 10:35:49 +01:00
fix(youtube/theme): correct background color for the shorts comment box (#239)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
parent
2002bf8063
commit
9ab8a646ed
@ -1,34 +1,72 @@
|
|||||||
package app.revanced.integrations.patches;
|
package app.revanced.integrations.patches;
|
||||||
|
|
||||||
import android.util.Log;
|
import static app.revanced.integrations.utils.ReVancedUtils.getContext;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
import app.revanced.integrations.utils.ThemeHelper;
|
import app.revanced.integrations.utils.ThemeHelper;
|
||||||
|
|
||||||
public class LithoThemePatch {
|
public class LithoThemePatch {
|
||||||
// color constants used in relation with litho components
|
// color constants used in relation with litho components
|
||||||
private static final int[] WHITECONSTANTS = {
|
private static final int[] WHITE_VALUES = {
|
||||||
-1, // comments chip background
|
-1, // comments chip background
|
||||||
-394759, // music related results panel background
|
-394759, // music related results panel background
|
||||||
-83886081, // video chapters list background
|
-83886081, // video chapters list background
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final int[] DARKCONSTANTS = {
|
private static final int[] DARK_VALUES = {
|
||||||
-14145496, // explore drawer background
|
-14145496, // explore drawer background
|
||||||
-14606047, // comments chip background
|
-14606047, // comments chip background
|
||||||
-15198184, // music related results panel background
|
-15198184, // music related results panel background
|
||||||
-15790321, // comments chip background (new layout)
|
-15790321, // comments chip background (new layout)
|
||||||
-98492127 // video chapters list background
|
-98492127 // video chapters list background
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// background colors
|
||||||
|
private static int whiteColor = 0;
|
||||||
|
private static int blackColor = 0;
|
||||||
|
|
||||||
// Used by app.revanced.patches.youtube.layout.theme.patch.LithoThemePatch
|
// Used by app.revanced.patches.youtube.layout.theme.patch.LithoThemePatch
|
||||||
|
/**
|
||||||
|
* Change the color of Litho components.
|
||||||
|
* If the color of the component matches one of the values, return the background color .
|
||||||
|
*
|
||||||
|
* @param originalValue The original color value.
|
||||||
|
* @return The new or original color value
|
||||||
|
*/
|
||||||
public static int applyLithoTheme(int originalValue) {
|
public static int applyLithoTheme(int originalValue) {
|
||||||
var isDarkTheme = ThemeHelper.isDarkTheme();
|
if (ThemeHelper.isDarkTheme()) {
|
||||||
|
if (anyEquals(originalValue, DARK_VALUES)) return getBlackColor();
|
||||||
if ((isDarkTheme && anyEquals(originalValue, DARKCONSTANTS)) || (!isDarkTheme && anyEquals(originalValue, WHITECONSTANTS)))
|
} else {
|
||||||
return 0;
|
if (anyEquals(originalValue, WHITE_VALUES)) return getWhiteColor();
|
||||||
|
}
|
||||||
return originalValue;
|
return originalValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int getBlackColor() {
|
||||||
|
if (blackColor == 0) blackColor = getColor("yt_black1");
|
||||||
|
return blackColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getWhiteColor() {
|
||||||
|
if (whiteColor == 0) whiteColor = getColor("yt_white1");
|
||||||
|
return whiteColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines the color for a color resource.
|
||||||
|
*
|
||||||
|
* @param name The color resource name.
|
||||||
|
* @return The value of the color.
|
||||||
|
*/
|
||||||
|
private static int getColor(String name) {
|
||||||
|
Context context = getContext();
|
||||||
|
|
||||||
|
return context != null ? context.getColor(context.getResources()
|
||||||
|
.getIdentifier(name, "color", context.getPackageName())
|
||||||
|
) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
private static boolean anyEquals(int value, int... of) {
|
private static boolean anyEquals(int value, int... of) {
|
||||||
for (int v : of) if (value == v) return true;
|
for (int v : of) if (value == v) return true;
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user