mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-13 13:47:42 +02:00
fix(music/litho-filter): don't include all Litho patches, when not included
This commit is contained in:
@ -34,6 +34,12 @@ class MusicAdsPatch : AbstractAdsPatch(
|
|||||||
|
|
||||||
SettingsPatch.addMusicPreference(CategoryType.ADS, "revanced_hide_music_ads", "true")
|
SettingsPatch.addMusicPreference(CategoryType.ADS, "revanced_hide_music_ads", "true")
|
||||||
|
|
||||||
|
LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR)
|
||||||
|
|
||||||
return PatchResultSuccess()
|
return PatchResultSuccess()
|
||||||
}
|
}
|
||||||
|
private companion object {
|
||||||
|
private const val FILTER_CLASS_DESCRIPTOR =
|
||||||
|
"$MUSIC_ADS_PATH/AdsFilter;"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ import app.revanced.patches.music.utils.annotations.MusicCompatibility
|
|||||||
import app.revanced.patches.music.utils.litho.patch.LithoFilterPatch
|
import app.revanced.patches.music.utils.litho.patch.LithoFilterPatch
|
||||||
import app.revanced.patches.music.utils.settings.resource.patch.SettingsPatch
|
import app.revanced.patches.music.utils.settings.resource.patch.SettingsPatch
|
||||||
import app.revanced.util.enum.CategoryType
|
import app.revanced.util.enum.CategoryType
|
||||||
|
import app.revanced.util.integrations.Constants.MUSIC_ADS_PATH
|
||||||
|
|
||||||
@Patch
|
@Patch
|
||||||
@Name("hide-button-shelf")
|
@Name("hide-button-shelf")
|
||||||
@ -34,6 +35,12 @@ class HideButtonShelfPatch : BytecodePatch() {
|
|||||||
"false"
|
"false"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR)
|
||||||
|
|
||||||
return PatchResultSuccess()
|
return PatchResultSuccess()
|
||||||
}
|
}
|
||||||
|
private companion object {
|
||||||
|
private const val FILTER_CLASS_DESCRIPTOR =
|
||||||
|
"$MUSIC_ADS_PATH/ButtonShelfFilter;"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ import app.revanced.patches.music.utils.annotations.MusicCompatibility
|
|||||||
import app.revanced.patches.music.utils.litho.patch.LithoFilterPatch
|
import app.revanced.patches.music.utils.litho.patch.LithoFilterPatch
|
||||||
import app.revanced.patches.music.utils.settings.resource.patch.SettingsPatch
|
import app.revanced.patches.music.utils.settings.resource.patch.SettingsPatch
|
||||||
import app.revanced.util.enum.CategoryType
|
import app.revanced.util.enum.CategoryType
|
||||||
|
import app.revanced.util.integrations.Constants.MUSIC_ADS_PATH
|
||||||
|
|
||||||
@Patch
|
@Patch
|
||||||
@Name("hide-carousel-shelf")
|
@Name("hide-carousel-shelf")
|
||||||
@ -34,6 +35,12 @@ class HideCarouselShelfPatch : BytecodePatch() {
|
|||||||
"false"
|
"false"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR)
|
||||||
|
|
||||||
return PatchResultSuccess()
|
return PatchResultSuccess()
|
||||||
}
|
}
|
||||||
|
private companion object {
|
||||||
|
private const val FILTER_CLASS_DESCRIPTOR =
|
||||||
|
"$MUSIC_ADS_PATH/CarouselShelfFilter;"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
|||||||
|
|
||||||
@Patch
|
@Patch
|
||||||
@Name("enable-color-match-player")
|
@Name("enable-color-match-player")
|
||||||
@Description("Matches the fullscreen player color with the minimized one.")
|
@Description("Matches the color of the mini player and the fullscreen player.")
|
||||||
@DependsOn([SettingsPatch::class])
|
@DependsOn([SettingsPatch::class])
|
||||||
@MusicCompatibility
|
@MusicCompatibility
|
||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
|
@ -13,6 +13,7 @@ import app.revanced.patches.music.utils.annotations.MusicCompatibility
|
|||||||
import app.revanced.patches.music.utils.litho.patch.LithoFilterPatch
|
import app.revanced.patches.music.utils.litho.patch.LithoFilterPatch
|
||||||
import app.revanced.patches.music.utils.settings.resource.patch.SettingsPatch
|
import app.revanced.patches.music.utils.settings.resource.patch.SettingsPatch
|
||||||
import app.revanced.util.enum.CategoryType
|
import app.revanced.util.enum.CategoryType
|
||||||
|
import app.revanced.util.integrations.Constants.MUSIC_ADS_PATH
|
||||||
|
|
||||||
@Patch
|
@Patch
|
||||||
@Name("hide-playlist-card")
|
@Name("hide-playlist-card")
|
||||||
@ -34,6 +35,12 @@ class HidePlaylistCardPatch : BytecodePatch() {
|
|||||||
"false"
|
"false"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR)
|
||||||
|
|
||||||
return PatchResultSuccess()
|
return PatchResultSuccess()
|
||||||
}
|
}
|
||||||
|
private companion object {
|
||||||
|
private const val FILTER_CLASS_DESCRIPTOR =
|
||||||
|
"$MUSIC_ADS_PATH/PlaylistCardFilter;"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
package app.revanced.patches.music.utils.litho.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.extensions.or
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
import org.jf.dexlib2.AccessFlags
|
||||||
|
|
||||||
|
object LithoFilterFingerprint : MethodFingerprint(
|
||||||
|
returnType = "V",
|
||||||
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC or AccessFlags.CONSTRUCTOR,
|
||||||
|
customFingerprint = { methodDef, _ ->
|
||||||
|
methodDef.definingClass == "Lapp/revanced/music/patches/ads/LithoFilterPatch;"
|
||||||
|
}
|
||||||
|
)
|
@ -1,23 +1,57 @@
|
|||||||
package app.revanced.patches.music.utils.litho.patch
|
package app.revanced.patches.music.utils.litho.patch
|
||||||
|
|
||||||
|
import app.revanced.extensions.toErrorResult
|
||||||
import app.revanced.patcher.annotation.Version
|
import app.revanced.patcher.annotation.Version
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||||
|
import app.revanced.patcher.extensions.InstructionExtensions.removeInstructions
|
||||||
|
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||||
import app.revanced.patcher.patch.BytecodePatch
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
import app.revanced.patcher.patch.PatchResult
|
import app.revanced.patcher.patch.PatchResult
|
||||||
import app.revanced.patcher.patch.PatchResultSuccess
|
import app.revanced.patcher.patch.PatchResultSuccess
|
||||||
import app.revanced.patcher.patch.annotations.DependsOn
|
import app.revanced.patcher.patch.annotations.DependsOn
|
||||||
import app.revanced.patches.music.utils.annotations.MusicCompatibility
|
import app.revanced.patches.music.utils.annotations.MusicCompatibility
|
||||||
|
import app.revanced.patches.music.utils.litho.fingerprints.LithoFilterFingerprint
|
||||||
import app.revanced.patches.shared.patch.litho.ComponentParserPatch
|
import app.revanced.patches.shared.patch.litho.ComponentParserPatch
|
||||||
import app.revanced.patches.shared.patch.litho.ComponentParserPatch.Companion.identifierHook
|
import app.revanced.patches.shared.patch.litho.ComponentParserPatch.Companion.identifierHook
|
||||||
import app.revanced.util.integrations.Constants.MUSIC_ADS_PATH
|
import app.revanced.util.integrations.Constants.MUSIC_ADS_PATH
|
||||||
|
import java.io.Closeable
|
||||||
|
|
||||||
@DependsOn([ComponentParserPatch::class])
|
@DependsOn([ComponentParserPatch::class])
|
||||||
@MusicCompatibility
|
@MusicCompatibility
|
||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
class LithoFilterPatch : BytecodePatch() {
|
class LithoFilterPatch : BytecodePatch(
|
||||||
|
listOf(LithoFilterFingerprint)
|
||||||
|
), Closeable {
|
||||||
override fun execute(context: BytecodeContext): PatchResult {
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
identifierHook("$MUSIC_ADS_PATH/LithoFilterPatch;->filter")
|
identifierHook("$MUSIC_ADS_PATH/LithoFilterPatch;->filter")
|
||||||
|
|
||||||
|
LithoFilterFingerprint.result?.mutableMethod?.apply {
|
||||||
|
removeInstructions(2, 4) // Remove dummy filter.
|
||||||
|
|
||||||
|
addFilter = { classDescriptor ->
|
||||||
|
addInstructions(
|
||||||
|
2,
|
||||||
|
"""
|
||||||
|
new-instance v1, $classDescriptor
|
||||||
|
invoke-direct {v1}, $classDescriptor-><init>()V
|
||||||
|
const/4 v2, ${filterCount++}
|
||||||
|
aput-object v1, v0, v2
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} ?: return LithoFilterFingerprint.toErrorResult()
|
||||||
|
|
||||||
return PatchResultSuccess()
|
return PatchResultSuccess()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun close() = LithoFilterFingerprint.result!!
|
||||||
|
.mutableMethod.replaceInstruction(0, "const/4 v0, $filterCount")
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
internal lateinit var addFilter: (String) -> Unit
|
||||||
|
private set
|
||||||
|
|
||||||
|
private var filterCount = 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user