mirror of
https://github.com/revanced/revanced-patches.git
synced 2025-06-12 05:07:45 +02:00
fix(Spotify): Remove ads sections from home (#4722)
Co-authored-by: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com>
This commit is contained in:
@ -4,6 +4,7 @@ import static java.lang.Boolean.FALSE;
|
||||
import static java.lang.Boolean.TRUE;
|
||||
|
||||
import com.spotify.remoteconfig.internal.AccountAttribute;
|
||||
import com.spotify.home.evopage.homeapi.proto.Section;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -69,8 +70,13 @@ public final class UnlockPremiumPatch {
|
||||
new OverrideAttribute("tablet-free", FALSE, false)
|
||||
);
|
||||
|
||||
private static final List<Integer> REMOVED_HOME_SECTIONS = List.of(
|
||||
Section.VIDEO_BRAND_AD_FIELD_NUMBER,
|
||||
Section.IMAGE_BRAND_AD_FIELD_NUMBER
|
||||
);
|
||||
|
||||
/**
|
||||
* Injection point.
|
||||
* Override attributes injection point.
|
||||
*/
|
||||
public static void overrideAttribute(Map<String, AccountAttribute> attributes) {
|
||||
try {
|
||||
@ -78,7 +84,7 @@ public final class UnlockPremiumPatch {
|
||||
var attribute = attributes.get(override.key);
|
||||
if (attribute == null) {
|
||||
if (override.isExpected) {
|
||||
Logger.printException(() -> "''" + override.key + "' expected but not found");
|
||||
Logger.printException(() -> "'" + override.key + "' expected but not found");
|
||||
}
|
||||
} else {
|
||||
attribute.value_ = override.overrideValue;
|
||||
@ -88,4 +94,15 @@ public final class UnlockPremiumPatch {
|
||||
Logger.printException(() -> "overrideAttribute failure", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove ads sections from home injection point.
|
||||
*/
|
||||
public static void removeHomeSections(List<Section> sections) {
|
||||
try {
|
||||
sections.removeIf(section -> REMOVED_HOME_SECTIONS.contains(section.featureTypeCase_));
|
||||
} catch (Exception ex) {
|
||||
Logger.printException(() -> "Remove home sections failure", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,7 @@
|
||||
package com.spotify.home.evopage.homeapi.proto;
|
||||
|
||||
public final class Section {
|
||||
public static final int VIDEO_BRAND_AD_FIELD_NUMBER = 20;
|
||||
public static final int IMAGE_BRAND_AD_FIELD_NUMBER = 21;
|
||||
public int featureTypeCase_;
|
||||
}
|
Reference in New Issue
Block a user