From f06935ddacf86cd606740dc8b6ec0c7dd54c5cce Mon Sep 17 00:00:00 2001 From: OxrxL <108184954+OxrxL@users.noreply.github.com> Date: Tue, 25 Oct 2022 09:56:39 +0200 Subject: [PATCH] fix(youtube/theme): theme litho UI components (#176) Co-authored-by: oSumAtrIX --- .../integrations/patches/LithoThemePatch.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 app/src/main/java/app/revanced/integrations/patches/LithoThemePatch.java diff --git a/app/src/main/java/app/revanced/integrations/patches/LithoThemePatch.java b/app/src/main/java/app/revanced/integrations/patches/LithoThemePatch.java new file mode 100644 index 00000000..2eb3b209 --- /dev/null +++ b/app/src/main/java/app/revanced/integrations/patches/LithoThemePatch.java @@ -0,0 +1,35 @@ +package app.revanced.integrations.patches; + +import android.util.Log; + +import app.revanced.integrations.utils.ThemeHelper; + +public class LithoThemePatch { + // color constants used in relation with litho components + private static final int[] WHITECONSTANTS = { + -1, // comments chip background + -394759, // music related results panel background + -83886081, // video chapters list background + }; + + private static final int[] DARKCONSTANTS = { + -14606047, // comments chip background + -15198184, // music related results panel background + -15790321, // comments chip background (new layout) + -98492127 // video chapters list background + }; + + // Used by app.revanced.patches.youtube.layout.theme.patch.LithoThemePatch + public static int applyLithoTheme(int originalValue) { + var isDarkTheme = ThemeHelper.isDarkTheme(); + + if ((isDarkTheme && anyEquals(originalValue, DARKCONSTANTS)) || (!isDarkTheme && anyEquals(originalValue, WHITECONSTANTS))) + return 0; + return originalValue; + } + + private static boolean anyEquals(int value, int... of) { + for (int v : of) if (value == v) return true; + return false; + } +}