mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-09 11:04:36 +02:00
feat(youtube/enable-old-quality-layout): match with the official Revanced
This commit is contained in:
parent
4d2fd8ff06
commit
ee5fc11958
@ -67,7 +67,7 @@ class OldQualityLayoutPatch : BytecodePatch(
|
||||
|
||||
addInstruction(
|
||||
insertIndex,
|
||||
"invoke-static { v$insertRegister }, $FLYOUT_PANEL->enableOldQualityMenu(Landroid/widget/LinearLayout;)V"
|
||||
"invoke-static { v$insertRegister }, $FLYOUT_PANEL->onFlyoutMenuCreate(Landroid/widget/LinearLayout;)V"
|
||||
)
|
||||
}
|
||||
} ?: return NewFlyoutPanelBuilderFingerprint.toErrorResult()
|
||||
|
@ -4,9 +4,9 @@ import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
|
||||
object FlyoutPanelPatchFingerprint : MethodFingerprint(
|
||||
object CustomPlaybackSpeedIntegrationsFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PRIVATE or AccessFlags.STATIC,
|
||||
parameters = emptyList(),
|
||||
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("/FlyoutPanelPatch;") && methodDef.name == "openOldPlaybackRateBottomSheetFragment" }
|
||||
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("/CustomPlaybackSpeedPatch;") && methodDef.name == "showOldPlaybackSpeedMenu" }
|
||||
)
|
@ -3,21 +3,22 @@ package app.revanced.patches.youtube.flyoutpanel.oldspeedlayout.patch
|
||||
import app.revanced.extensions.toErrorResult
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableField.Companion.toMutable
|
||||
import app.revanced.patches.youtube.flyoutpanel.oldspeedlayout.fingerprints.FlyoutPanelPatchFingerprint
|
||||
import app.revanced.patches.youtube.flyoutpanel.oldspeedlayout.fingerprints.CustomPlaybackSpeedIntegrationsFingerprint
|
||||
import app.revanced.patches.youtube.flyoutpanel.oldspeedlayout.fingerprints.PlaybackRateBottomSheetBuilderFingerprint
|
||||
import app.revanced.patches.youtube.flyoutpanel.oldspeedlayout.fingerprints.PlaybackRateBottomSheetClassFingerprint
|
||||
import app.revanced.patches.youtube.utils.fingerprints.NewFlyoutPanelBuilderFingerprint
|
||||
import app.revanced.patches.youtube.utils.litho.patch.LithoFilterPatch
|
||||
import app.revanced.util.integrations.Constants.FLYOUT_PANEL
|
||||
import app.revanced.util.integrations.Constants.PATCHES_PATH
|
||||
import app.revanced.util.integrations.Constants.VIDEO_PATH
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import com.android.tools.smali.dexlib2.immutable.ImmutableField
|
||||
@ -25,7 +26,7 @@ import com.android.tools.smali.dexlib2.immutable.ImmutableField
|
||||
@DependsOn([LithoFilterPatch::class])
|
||||
class OldSpeedLayoutPatch : BytecodePatch(
|
||||
listOf(
|
||||
FlyoutPanelPatchFingerprint,
|
||||
CustomPlaybackSpeedIntegrationsFingerprint,
|
||||
NewFlyoutPanelBuilderFingerprint,
|
||||
PlaybackRateBottomSheetClassFingerprint,
|
||||
PlaybackRateBottomSheetBuilderFingerprint
|
||||
@ -47,7 +48,7 @@ class OldSpeedLayoutPatch : BytecodePatch(
|
||||
* Create a static field in the patch
|
||||
* Add a call the Playback Speed Bottom Sheet Fragment method
|
||||
*/
|
||||
FlyoutPanelPatchFingerprint.result?.let {
|
||||
CustomPlaybackSpeedIntegrationsFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
// Create a static field 'playbackRateBottomSheetClass' in FlyoutPanelPatch.
|
||||
it.mutableClass.staticFields.add(
|
||||
@ -62,18 +63,20 @@ class OldSpeedLayoutPatch : BytecodePatch(
|
||||
).toMutable()
|
||||
)
|
||||
|
||||
// Add a call the Playback Speed Bottom Sheet Fragment method
|
||||
replaceInstruction(
|
||||
3,
|
||||
"invoke-virtual {v0}, $PLAYBACK_RATE_BOTTOM_SHEET_CLASS->$PLAYBACK_RATE_BOTTOM_SHEET_BUILDER_METHOD()V"
|
||||
)
|
||||
removeInstruction(1)
|
||||
removeInstruction(0)
|
||||
|
||||
replaceInstruction(
|
||||
0,
|
||||
"sget-object v0, $FLYOUT_PANEL->playbackRateBottomSheetClass:$PLAYBACK_RATE_BOTTOM_SHEET_CLASS"
|
||||
addInstructionsWithLabels(
|
||||
0, """
|
||||
sget-object v0, $INTEGRATIONS_CLASS_DESCRIPTOR->playbackRateBottomSheetClass:$PLAYBACK_RATE_BOTTOM_SHEET_CLASS
|
||||
if-nez v0, :not_null
|
||||
return-void
|
||||
:not_null
|
||||
invoke-virtual {v0}, $PLAYBACK_RATE_BOTTOM_SHEET_CLASS->$PLAYBACK_RATE_BOTTOM_SHEET_BUILDER_METHOD()V
|
||||
"""
|
||||
)
|
||||
}
|
||||
} ?: return FlyoutPanelPatchFingerprint.toErrorResult()
|
||||
} ?: return CustomPlaybackSpeedIntegrationsFingerprint.toErrorResult()
|
||||
|
||||
/**
|
||||
* Input 'playbackRateBottomSheetClass' in FlyoutPanelPatch.
|
||||
@ -82,7 +85,7 @@ class OldSpeedLayoutPatch : BytecodePatch(
|
||||
it.mutableMethod.apply {
|
||||
addInstruction(
|
||||
0,
|
||||
"sput-object p0, $FLYOUT_PANEL->playbackRateBottomSheetClass:$PLAYBACK_RATE_BOTTOM_SHEET_CLASS"
|
||||
"sput-object p0, $INTEGRATIONS_CLASS_DESCRIPTOR->playbackRateBottomSheetClass:$PLAYBACK_RATE_BOTTOM_SHEET_CLASS"
|
||||
)
|
||||
}
|
||||
} ?: return PlaybackRateBottomSheetClassFingerprint.toErrorResult()
|
||||
@ -97,7 +100,7 @@ class OldSpeedLayoutPatch : BytecodePatch(
|
||||
|
||||
addInstruction(
|
||||
insertIndex,
|
||||
"invoke-static { v$insertRegister }, $FLYOUT_PANEL->enableOldPlaybackRateMenu(Landroid/widget/LinearLayout;)V"
|
||||
"invoke-static { v$insertRegister }, $INTEGRATIONS_CLASS_DESCRIPTOR->onFlyoutMenuCreate(Landroid/widget/LinearLayout;)V"
|
||||
)
|
||||
}
|
||||
} ?: return NewFlyoutPanelBuilderFingerprint.toErrorResult()
|
||||
@ -108,6 +111,9 @@ class OldSpeedLayoutPatch : BytecodePatch(
|
||||
}
|
||||
|
||||
private companion object {
|
||||
private const val INTEGRATIONS_CLASS_DESCRIPTOR =
|
||||
"$VIDEO_PATH/CustomPlaybackSpeedPatch;"
|
||||
|
||||
lateinit var PLAYBACK_RATE_BOTTOM_SHEET_CLASS: String
|
||||
lateinit var PLAYBACK_RATE_BOTTOM_SHEET_BUILDER_METHOD: String
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user