mirror of
https://github.com/ReVanced/revanced-patches.git
synced 2026-01-26 20:21:04 +00:00
Merge remote-tracking branch 'upstream/dev' into feat/patcher_instruction_filters
# Conflicts: # extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java # patches/api/patches.api # patches/src/main/kotlin/app/revanced/patches/music/layout/navigationbar/NavigationBarPatch.kt # patches/src/main/kotlin/app/revanced/patches/shared/misc/settings/SettingsPatch.kt # patches/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/SeekbarColorPatch.kt # patches/src/main/kotlin/app/revanced/patches/youtube/layout/theme/Fingerprints.kt # patches/src/main/kotlin/app/revanced/patches/youtube/layout/theme/LithoColorHookPatch.kt # patches/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemePatch.kt
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
package app.revanced.extension.shared.theme;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import app.revanced.extension.shared.Utils;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public abstract class BaseThemePatch {
|
||||
// Background colors.
|
||||
protected static final int BLACK_COLOR = Utils.getResourceColor("yt_black1");
|
||||
protected static final int WHITE_COLOR = Utils.getResourceColor("yt_white1");
|
||||
|
||||
/**
|
||||
* Check if a value matches any of the provided values.
|
||||
*
|
||||
* @param value The value to check.
|
||||
* @param of The array of values to compare against.
|
||||
* @return True if the value matches any of the provided values.
|
||||
*/
|
||||
protected static boolean anyEquals(int value, int... of) {
|
||||
for (int v : of) {
|
||||
if (value == v) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to process color values for Litho components.
|
||||
*
|
||||
* @param originalValue The original color value.
|
||||
* @param darkValues Array of dark mode color values to match.
|
||||
* @param lightValues Array of light mode color values to match.
|
||||
* @return The new or original color value.
|
||||
*/
|
||||
protected static int processColorValue(int originalValue, int[] darkValues, @Nullable int[] lightValues) {
|
||||
if (Utils.isDarkModeEnabled()) {
|
||||
if (anyEquals(originalValue, darkValues)) {
|
||||
return BLACK_COLOR;
|
||||
}
|
||||
} else if (lightValues != null && anyEquals(originalValue, lightValues)) {
|
||||
return WHITE_COLOR;
|
||||
}
|
||||
|
||||
return originalValue;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user