feat(youtube/theme): change seekbar color via preference

This commit is contained in:
oSumAtrIX 2023-05-02 05:30:12 +02:00
parent 2ee18fce69
commit 1185ceedf7
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4
3 changed files with 34 additions and 14 deletions

View File

@ -1,9 +1,9 @@
package app.revanced.integrations.patches;
package app.revanced.integrations.patches.theme;
import app.revanced.integrations.utils.ReVancedUtils;
import app.revanced.integrations.utils.ThemeHelper;
public class LithoThemePatch {
public class ThemeLithoComponentsPatch {
// color constants used in relation with litho components
private static final int[] WHITE_VALUES = {
-1, // comments chip background
@ -31,7 +31,7 @@ public class LithoThemePatch {
* @param originalValue The original color value.
* @return The new or original color value
*/
public static int applyLithoTheme(int originalValue) {
public static int getValue(int originalValue) {
if (ThemeHelper.isDarkTheme()) {
if (anyEquals(originalValue, DARK_VALUES)) return getBlackColor();
} else {

View File

@ -0,0 +1,23 @@
package app.revanced.integrations.patches.theme;
import android.graphics.Color;
import app.revanced.integrations.settings.SettingsEnum;
import app.revanced.integrations.utils.ReVancedUtils;
public final class ThemePatch {
public static final int DEFAULT_SEEKBAR_COLOR = 0xffff0000;
private static void resetSeekbarColor() {
ReVancedUtils.showToastShort("Invalid seekbar color value. Using default value.");
SettingsEnum.SEEKBAR_COLOR.saveValue(Integer.toHexString(DEFAULT_SEEKBAR_COLOR));
}
public static int getSeekbarColorValue() {
try {
return Color.parseColor(SettingsEnum.SEEKBAR_COLOR.getString());
} catch (IllegalArgumentException exception) {
resetSeekbarColor();
return DEFAULT_SEEKBAR_COLOR;
}
}
}

View File

@ -1,21 +1,17 @@
package app.revanced.integrations.settings;
import static java.lang.Boolean.FALSE;
import static java.lang.Boolean.TRUE;
import static app.revanced.integrations.settings.SettingsEnum.ReturnType.BOOLEAN;
import static app.revanced.integrations.settings.SettingsEnum.ReturnType.FLOAT;
import static app.revanced.integrations.settings.SettingsEnum.ReturnType.INTEGER;
import static app.revanced.integrations.settings.SettingsEnum.ReturnType.LONG;
import static app.revanced.integrations.settings.SettingsEnum.ReturnType.STRING;
import static app.revanced.integrations.settings.SharedPrefCategory.RETURN_YOUTUBE_DISLIKE;
import static app.revanced.integrations.settings.SharedPrefCategory.SPONSOR_BLOCK;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import app.revanced.integrations.utils.StringRef;
import app.revanced.integrations.patches.theme.ThemePatch;
import java.util.Objects;
import app.revanced.integrations.utils.StringRef;
import static app.revanced.integrations.settings.SettingsEnum.ReturnType.*;
import static app.revanced.integrations.settings.SharedPrefCategory.RETURN_YOUTUBE_DISLIKE;
import static app.revanced.integrations.settings.SharedPrefCategory.SPONSOR_BLOCK;
import static java.lang.Boolean.FALSE;
import static java.lang.Boolean.TRUE;
public enum SettingsEnum {
//Download Settings
@ -107,6 +103,7 @@ public enum SettingsEnum {
SPOOF_APP_VERSION_TARGET("revanced_spoof_app_version_target", STRING, "17.30.35", true, parents(SPOOF_APP_VERSION)),
USE_TABLET_MINIPLAYER("revanced_tablet_miniplayer", BOOLEAN, FALSE, true),
WIDE_SEARCHBAR("revanced_wide_searchbar", BOOLEAN, FALSE, true),
SEEKBAR_COLOR("revanced_seekbar_color", STRING, Integer.toHexString(ThemePatch.DEFAULT_SEEKBAR_COLOR), true),
// Misc. Settings
SIGNATURE_SPOOFING("revanced_spoof_signature_verification", BOOLEAN, TRUE, "revanced_spoof_signature_verification_user_dialog_message"),