From deb1d41c95fd09744273913a5af8c91fbe378f4b Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Sun, 3 Nov 2024 18:54:33 -0400 Subject: [PATCH] fix(YouTube - SponsorBlock): Show correct segment behavior in settings UI after importing --- .../youtube/sponsorblock/objects/SegmentCategory.java | 2 +- .../objects/SegmentCategoryListPreference.java | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/extensions/shared/src/main/java/app/revanced/extension/youtube/sponsorblock/objects/SegmentCategory.java b/extensions/shared/src/main/java/app/revanced/extension/youtube/sponsorblock/objects/SegmentCategory.java index 7518b2cc34..5be3755aed 100644 --- a/extensions/shared/src/main/java/app/revanced/extension/youtube/sponsorblock/objects/SegmentCategory.java +++ b/extensions/shared/src/main/java/app/revanced/extension/youtube/sponsorblock/objects/SegmentCategory.java @@ -136,7 +136,7 @@ public static void loadAllCategoriesFromSettings() { @NonNull public final String keyValue; @NonNull - private final StringSetting behaviorSetting; + public final StringSetting behaviorSetting; @NonNull private final StringSetting colorSetting; diff --git a/extensions/shared/src/main/java/app/revanced/extension/youtube/sponsorblock/objects/SegmentCategoryListPreference.java b/extensions/shared/src/main/java/app/revanced/extension/youtube/sponsorblock/objects/SegmentCategoryListPreference.java index a0410f0989..ec83d91228 100644 --- a/extensions/shared/src/main/java/app/revanced/extension/youtube/sponsorblock/objects/SegmentCategoryListPreference.java +++ b/extensions/shared/src/main/java/app/revanced/extension/youtube/sponsorblock/objects/SegmentCategoryListPreference.java @@ -31,14 +31,18 @@ public SegmentCategoryListPreference(Context context, SegmentCategory category) super(context); final boolean isHighlightCategory = category == SegmentCategory.HIGHLIGHT; this.category = Objects.requireNonNull(category); - setKey(category.keyValue); - setDefaultValue(category.behaviour.reVancedKeyValue); + + // Edit: Using preferences to sync together multiple pieces + // of code together is messy and should be rethought. + setKey(category.behaviorSetting.key); + setDefaultValue(category.behaviorSetting.defaultValue); setEntries(isHighlightCategory ? CategoryBehaviour.getBehaviorDescriptionsWithoutSkipOnce() : CategoryBehaviour.getBehaviorDescriptions()); setEntryValues(isHighlightCategory ? CategoryBehaviour.getBehaviorKeyValuesWithoutSkipOnce() : CategoryBehaviour.getBehaviorKeyValues()); + setSummary(category.description.toString()); updateTitle(); }