Skip to content

Commit

Permalink
fix(youtube/custom-video-speed): don not implicitly depend on `old-vi…
Browse files Browse the repository at this point in the history
…deo-quality-menu` patch
  • Loading branch information
oSumAtrIX committed Jul 9, 2023
1 parent 3e78b83 commit acfda46
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package app.revanced.patches.youtube.misc.bottomsheet.hook.fingerprints

import app.revanced.patcher.extensions.or
import app.revanced.patches.youtube.video.videoqualitymenu.patch.OldVideoQualityMenuResourcePatch
import app.revanced.patches.youtube.misc.bottomsheet.hook.patch.BottomSheetHookResourcePatch
import app.revanced.util.patch.LiteralValueFingerprint
import org.jf.dexlib2.AccessFlags

object CreateBottomSheetFingerprint : LiteralValueFingerprint(
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf("L"),
returnType = "Landroid/widget/LinearLayout;",
literal = OldVideoQualityMenuResourcePatch.bottomSheetMargins
literal = BottomSheetHookResourcePatch.bottomSheetMargins
)
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import app.revanced.patches.youtube.misc.bottomsheet.hook.fingerprints.CreateBot
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction

@DependsOn([IntegrationsPatch::class])
@DependsOn([IntegrationsPatch::class, BottomSheetHookResourcePatch::class])
class BottomSheetHookPatch : BytecodePatch(
listOf(CreateBottomSheetFingerprint)
) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package app.revanced.patches.youtube.misc.bottomsheet.hook.patch

import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch

@DependsOn([ResourceMappingPatch::class])
class BottomSheetHookResourcePatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
bottomSheetMargins = ResourceMappingPatch.resourceMappings.find { it.name == "bottomSheetMargins" }?.id
?: return PatchResultError("Could not find resource")

return PatchResultSuccess()
}

internal companion object {
var bottomSheetMargins = -1L
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,10 @@ class OldVideoQualityMenuResourcePatch : ResourcePatch {
// Used for the old type of the video quality menu.
videoQualityBottomSheetListFragmentTitle = findResource("video_quality_bottom_sheet_list_fragment_title")

// Used for the new type of the video quality menu.
bottomSheetMargins = findResource("bottom_sheet_margins")

return PatchResultSuccess()
}

internal companion object {
var videoQualityBottomSheetListFragmentTitle = -1L
var bottomSheetMargins = -1L
}
}

0 comments on commit acfda46

Please sign in to comment.