mirror of
https://github.com/revanced/revanced-integrations.git
synced 2025-05-09 10:54:26 +02:00
28 lines
787 B
Java
28 lines
787 B
Java
package app.revanced.integrations.utils;
|
|
|
|
import android.app.Activity;
|
|
|
|
public class ThemeHelper {
|
|
private static int themeValue;
|
|
|
|
public static void setTheme(Object value) {
|
|
final int newOrdinalValue = ((Enum) value).ordinal();
|
|
if (themeValue != newOrdinalValue) {
|
|
themeValue = newOrdinalValue;
|
|
LogHelper.printDebug(() -> "Theme value: " + newOrdinalValue);
|
|
}
|
|
}
|
|
|
|
public static boolean isDarkTheme() {
|
|
return themeValue == 1;
|
|
}
|
|
|
|
public static void setActivityTheme(Activity activity) {
|
|
final var theme = isDarkTheme()
|
|
? "Theme.YouTube.Settings.Dark"
|
|
: "Theme.YouTube.Settings";
|
|
activity.setTheme(ReVancedUtils.getResourceIdentifier(theme, "style"));
|
|
}
|
|
|
|
}
|