Skip to content

Commit

Permalink
fix(youtube/old-quality-layout): does not work on tablet devices
Browse files Browse the repository at this point in the history
Fix the following issues
- 'Custom playback speed' patch does not work on tablet devices
- 'Old quality layout' patch does not work on tablet devices
- when user opens the sharing panel, the custom playback speed panel opens ReVanced/revanced-patches#2824
  • Loading branch information
inotia00 committed Sep 5, 2023
1 parent 94a36ed commit 16c34b7
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.youtube.flyoutpanel.oldqualitylayout.fingerprints.QualityMenuViewInflateFingerprint
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.fingerprints.NewFlyoutPanelBuilderFingerprint
import app.revanced.patches.youtube.utils.fingerprints.RecyclerViewTreeObserverFingerprint
import app.revanced.patches.youtube.utils.litho.patch.LithoFilterPatch
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
Expand All @@ -32,7 +32,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@YouTubeCompatibility
class OldQualityLayoutPatch : BytecodePatch(
listOf(
NewFlyoutPanelBuilderFingerprint,
RecyclerViewTreeObserverFingerprint,
QualityMenuViewInflateFingerprint
)
) {
Expand All @@ -56,17 +56,17 @@ class OldQualityLayoutPatch : BytecodePatch(
/**
* New method
*/
NewFlyoutPanelBuilderFingerprint.result?.let {
RecyclerViewTreeObserverFingerprint.result?.let {
it.mutableMethod.apply {
val insertIndex = implementation!!.instructions.size - 1
val insertRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
val insertIndex = it.scanResult.patternScanResult!!.startIndex + 2
val recyclerViewRegister = 2

addInstruction(
insertIndex,
"invoke-static { v$insertRegister }, $FLYOUT_PANEL->onFlyoutMenuCreate(Landroid/widget/LinearLayout;)V"
"invoke-static/range { p$recyclerViewRegister .. p$recyclerViewRegister }, $FLYOUT_PANEL->onFlyoutMenuCreate(Landroid/support/v7/widget/RecyclerView;)V"
)
}
} ?: throw NewFlyoutPanelBuilderFingerprint.exception
} ?: throw RecyclerViewTreeObserverFingerprint.exception

LithoFilterPatch.addFilter("$PATCHES_PATH/ads/VideoQualityMenuFilter;")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import app.revanced.extensions.exception
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.removeInstruction
import app.revanced.patcher.extensions.or
import app.revanced.patcher.patch.BytecodePatch
Expand All @@ -13,21 +12,20 @@ import app.revanced.patcher.util.proxy.mutableTypes.MutableField.Companion.toMut
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.fingerprints.RecyclerViewTreeObserverFingerprint
import app.revanced.patches.youtube.utils.litho.patch.LithoFilterPatch
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

@DependsOn([LithoFilterPatch::class])
class OldSpeedLayoutPatch : BytecodePatch(
listOf(
CustomPlaybackSpeedIntegrationsFingerprint,
NewFlyoutPanelBuilderFingerprint,
PlaybackRateBottomSheetClassFingerprint,
PlaybackRateBottomSheetBuilderFingerprint
PlaybackRateBottomSheetBuilderFingerprint,
RecyclerViewTreeObserverFingerprint
)
) {
override fun execute(context: BytecodeContext) {
Expand Down Expand Up @@ -91,17 +89,17 @@ class OldSpeedLayoutPatch : BytecodePatch(
/**
* New method
*/
NewFlyoutPanelBuilderFingerprint.result?.let {
RecyclerViewTreeObserverFingerprint.result?.let {
it.mutableMethod.apply {
val insertIndex = implementation!!.instructions.size - 1
val insertRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
val insertIndex = it.scanResult.patternScanResult!!.startIndex + 2
val recyclerViewRegister = 2

addInstruction(
insertIndex,
"invoke-static { v$insertRegister }, $INTEGRATIONS_CLASS_DESCRIPTOR->onFlyoutMenuCreate(Landroid/widget/LinearLayout;)V"
"invoke-static/range { p$recyclerViewRegister .. p$recyclerViewRegister }, $INTEGRATIONS_CLASS_DESCRIPTOR->onFlyoutMenuCreate(Landroid/support/v7/widget/RecyclerView;)V"
)
}
} ?: throw NewFlyoutPanelBuilderFingerprint.exception
} ?: throw RecyclerViewTreeObserverFingerprint.exception

LithoFilterPatch.addFilter("$PATCHES_PATH/ads/PlaybackSpeedMenuFilter;")

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package app.revanced.patches.youtube.utils.fingerprints

import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode

object RecyclerViewTreeObserverFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
opcodes = listOf(
Opcode.IGET_BOOLEAN,
Opcode.IF_NEZ,
Opcode.INVOKE_VIRTUAL_RANGE,
Opcode.MOVE_RESULT_OBJECT
),
strings = listOf("LithoRVSLCBinder")
)
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class SharedResourceIdPatch : ResourcePatch {
var Bar: Long = -1
var BarContainerHeight: Long = -1
var BottomPanelOverlayText: Long = -1
var BottomSheetMargins: Long = -1
var BottomUiContainerStub: Long = -1
var ChannelListSubMenu: Long = -1
var CompactLink: Long = -1
Expand Down Expand Up @@ -103,7 +102,6 @@ class SharedResourceIdPatch : ResourcePatch {
Bar = find(LAYOUT, "bar")
BarContainerHeight = find(DIMEN, "bar_container_height")
BottomPanelOverlayText = find(ID, "bottom_panel_overlay_text")
BottomSheetMargins = find(DIMEN, "bottom_sheet_margins")
BottomUiContainerStub = find(ID, "bottom_ui_container_stub")
ChannelListSubMenu = find(LAYOUT, "channel_list_sub_menu")
CompactLink = find(LAYOUT, "compact_link")
Expand Down

0 comments on commit 16c34b7

Please sign in to comment.