mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-13 13:47:42 +02:00
feat(YouTube/Description components): add Always expand panel
and Disable description interaction
settings
This commit is contained in:
@ -9,13 +9,12 @@ import app.revanced.patcher.patch.PatchException
|
||||
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.youtube.flyoutpanel.recyclerview.BottomSheetRecyclerViewPatch
|
||||
import app.revanced.patches.youtube.utils.fingerprints.QualityMenuViewInflateFingerprint
|
||||
import app.revanced.patches.youtube.utils.fingerprints.RecyclerViewTreeObserverFingerprint
|
||||
import app.revanced.patches.youtube.utils.fingerprints.VideoQualitySetterFingerprint
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.FLYOUT_PANEL
|
||||
import app.revanced.patches.youtube.utils.litho.LithoFilterPatch
|
||||
import app.revanced.patches.youtube.utils.recyclerview.BottomSheetRecyclerViewPatch
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.util.exception
|
||||
@ -69,7 +68,6 @@ import com.android.tools.smali.dexlib2.iface.reference.FieldReference
|
||||
@Suppress("unused")
|
||||
object OldQualityLayoutPatch : BytecodePatch(
|
||||
setOf(
|
||||
RecyclerViewTreeObserverFingerprint,
|
||||
QualityMenuViewInflateFingerprint,
|
||||
VideoQualitySetterFingerprint
|
||||
)
|
||||
@ -117,17 +115,7 @@ object OldQualityLayoutPatch : BytecodePatch(
|
||||
/**
|
||||
* New method
|
||||
*/
|
||||
RecyclerViewTreeObserverFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val insertIndex = it.scanResult.patternScanResult!!.startIndex
|
||||
val recyclerViewRegister = 2
|
||||
|
||||
addInstruction(
|
||||
insertIndex,
|
||||
"invoke-static/range { p$recyclerViewRegister .. p$recyclerViewRegister }, $FLYOUT_PANEL->onFlyoutMenuCreate(Landroid/support/v7/widget/RecyclerView;)V"
|
||||
)
|
||||
}
|
||||
} ?: throw RecyclerViewTreeObserverFingerprint.exception
|
||||
BottomSheetRecyclerViewPatch.injectCall("$FLYOUT_PANEL->onFlyoutMenuCreate(Landroid/support/v7/widget/RecyclerView;)V")
|
||||
|
||||
LithoFilterPatch.addFilter("$COMPONENTS_PATH/VideoQualityMenuFilter;")
|
||||
|
||||
|
@ -11,11 +11,10 @@ import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableField.Companion.toMutable
|
||||
import app.revanced.patches.youtube.flyoutpanel.oldspeedlayout.fingerprints.CustomPlaybackSpeedIntegrationsFingerprint
|
||||
import app.revanced.patches.youtube.flyoutpanel.oldspeedlayout.fingerprints.PlaybackRateBottomSheetClassFingerprint
|
||||
import app.revanced.patches.youtube.flyoutpanel.recyclerview.BottomSheetRecyclerViewPatch
|
||||
import app.revanced.patches.youtube.utils.fingerprints.RecyclerViewTreeObserverFingerprint
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.VIDEO_PATH
|
||||
import app.revanced.patches.youtube.utils.litho.LithoFilterPatch
|
||||
import app.revanced.patches.youtube.utils.recyclerview.BottomSheetRecyclerViewPatch
|
||||
import app.revanced.util.exception
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.immutable.ImmutableField
|
||||
@ -30,8 +29,7 @@ import com.android.tools.smali.dexlib2.immutable.ImmutableField
|
||||
object OldSpeedLayoutPatch : BytecodePatch(
|
||||
setOf(
|
||||
CustomPlaybackSpeedIntegrationsFingerprint,
|
||||
PlaybackRateBottomSheetClassFingerprint,
|
||||
RecyclerViewTreeObserverFingerprint
|
||||
PlaybackRateBottomSheetClassFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
@ -91,17 +89,7 @@ object OldSpeedLayoutPatch : BytecodePatch(
|
||||
/**
|
||||
* New method
|
||||
*/
|
||||
RecyclerViewTreeObserverFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val insertIndex = it.scanResult.patternScanResult!!.startIndex
|
||||
val recyclerViewRegister = 2
|
||||
|
||||
addInstruction(
|
||||
insertIndex,
|
||||
"invoke-static/range { p$recyclerViewRegister .. p$recyclerViewRegister }, $INTEGRATIONS_CLASS_DESCRIPTOR->onFlyoutMenuCreate(Landroid/support/v7/widget/RecyclerView;)V"
|
||||
)
|
||||
}
|
||||
} ?: throw RecyclerViewTreeObserverFingerprint.exception
|
||||
BottomSheetRecyclerViewPatch.injectCall("$INTEGRATIONS_CLASS_DESCRIPTOR->onFlyoutMenuCreate(Landroid/support/v7/widget/RecyclerView;)V")
|
||||
|
||||
LithoFilterPatch.addFilter("$COMPONENTS_PATH/PlaybackSpeedMenuFilter;")
|
||||
|
||||
|
@ -1,17 +1,26 @@
|
||||
package app.revanced.patches.youtube.general.descriptions
|
||||
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patches.youtube.general.descriptions.fingerprints.TextViewComponentFingerprint
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL
|
||||
import app.revanced.patches.youtube.utils.litho.LithoFilterPatch
|
||||
import app.revanced.patches.youtube.utils.recyclerview.BottomSheetRecyclerViewPatch
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.util.exception
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceName
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||
|
||||
@Patch(
|
||||
name = "Hide description components",
|
||||
description = "Adds an option to hide description components.",
|
||||
name = "Description components",
|
||||
description = "Adds an option to hide or disable description components.",
|
||||
dependencies = [
|
||||
BottomSheetRecyclerViewPatch::class,
|
||||
LithoFilterPatch::class,
|
||||
SettingsPatch::class
|
||||
],
|
||||
@ -46,8 +55,37 @@ import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
]
|
||||
)
|
||||
@Suppress("unused")
|
||||
object DescriptionComponentsPatch : BytecodePatch(emptySet()) {
|
||||
object DescriptionComponentsPatch : BytecodePatch(
|
||||
setOf(TextViewComponentFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
if (SettingsPatch.upward1902) {
|
||||
TextViewComponentFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val insertIndex = getTargetIndexWithMethodReferenceName("setTextIsSelectable")
|
||||
val insertInstruction = getInstruction<FiveRegisterInstruction>(insertIndex)
|
||||
|
||||
replaceInstruction(
|
||||
insertIndex,
|
||||
"invoke-static {v${insertInstruction.registerC}, v${insertInstruction.registerD}}, " +
|
||||
"$GENERAL->disableDescriptionInteraction(Landroid/widget/TextView;Z)V"
|
||||
)
|
||||
}
|
||||
} ?: throw TextViewComponentFingerprint.exception
|
||||
|
||||
BottomSheetRecyclerViewPatch.injectCall("$GENERAL->onDescriptionPanelCreate(Landroid/support/v7/widget/RecyclerView;)V")
|
||||
|
||||
/**
|
||||
* Add settings
|
||||
*/
|
||||
SettingsPatch.addPreference(
|
||||
arrayOf(
|
||||
"SETTINGS: DESCRIPTION_PANEL_INTERACTION"
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
LithoFilterPatch.addFilter("$COMPONENTS_PATH/DescriptionsFilter;")
|
||||
|
||||
/**
|
||||
@ -56,11 +94,11 @@ object DescriptionComponentsPatch : BytecodePatch(emptySet()) {
|
||||
SettingsPatch.addPreference(
|
||||
arrayOf(
|
||||
"PREFERENCE: GENERAL_SETTINGS",
|
||||
"SETTINGS: HIDE_DESCRIPTION_COMPONENTS"
|
||||
"SETTINGS: DESCRIPTION_COMPONENTS"
|
||||
)
|
||||
)
|
||||
|
||||
SettingsPatch.updatePatchStatus("Hide description components")
|
||||
SettingsPatch.updatePatchStatus("Description components")
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,14 @@
|
||||
package app.revanced.patches.youtube.general.descriptions.fingerprints
|
||||
|
||||
import app.revanced.util.fingerprint.MethodReferenceNameFingerprint
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
/**
|
||||
* This fingerprint is compatible with YouTube v18.35.xx~
|
||||
* Nonetheless, the patch works in YouTube v19.02.xx~
|
||||
*/
|
||||
object TextViewComponentFingerprint : MethodReferenceNameFingerprint(
|
||||
returnType = "V",
|
||||
opcodes = listOf(Opcode.CMPL_FLOAT),
|
||||
reference = { "setBreakStrategy" }
|
||||
)
|
@ -1,17 +1,24 @@
|
||||
package app.revanced.patches.youtube.flyoutpanel.recyclerview
|
||||
package app.revanced.patches.youtube.utils.recyclerview
|
||||
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprintResult
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patches.youtube.flyoutpanel.recyclerview.fingerprints.BottomSheetRecyclerViewBuilderFingerprint
|
||||
import app.revanced.patches.youtube.utils.recyclerview.fingerprints.BottomSheetRecyclerViewBuilderFingerprint
|
||||
import app.revanced.patches.youtube.utils.recyclerview.fingerprints.RecyclerViewTreeObserverFingerprint
|
||||
import app.revanced.util.exception
|
||||
import app.revanced.util.getWideLiteralInstructionIndex
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
object BottomSheetRecyclerViewPatch : BytecodePatch(
|
||||
setOf(BottomSheetRecyclerViewBuilderFingerprint)
|
||||
setOf(
|
||||
BottomSheetRecyclerViewBuilderFingerprint,
|
||||
RecyclerViewTreeObserverFingerprint
|
||||
)
|
||||
) {
|
||||
private lateinit var recyclerViewTreeObserverResult: MethodFingerprintResult
|
||||
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
/**
|
||||
@ -32,5 +39,23 @@ object BottomSheetRecyclerViewPatch : BytecodePatch(
|
||||
}
|
||||
} ?: throw BottomSheetRecyclerViewBuilderFingerprint.exception
|
||||
|
||||
recyclerViewTreeObserverResult = RecyclerViewTreeObserverFingerprint.result
|
||||
?: throw RecyclerViewTreeObserverFingerprint.exception
|
||||
|
||||
}
|
||||
|
||||
fun injectCall(descriptor: String) {
|
||||
recyclerViewTreeObserverResult.let {
|
||||
it.mutableMethod.apply {
|
||||
val insertIndex = it.scanResult.patternScanResult!!.startIndex
|
||||
val recyclerViewRegister = 2
|
||||
|
||||
addInstruction(
|
||||
insertIndex,
|
||||
"invoke-static/range { p$recyclerViewRegister .. p$recyclerViewRegister }, $descriptor"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package app.revanced.patches.youtube.flyoutpanel.recyclerview.fingerprints
|
||||
package app.revanced.patches.youtube.utils.recyclerview.fingerprints
|
||||
|
||||
import app.revanced.util.fingerprint.LiteralValueFingerprint
|
||||
|
@ -1,4 +1,4 @@
|
||||
package app.revanced.patches.youtube.utils.fingerprints
|
||||
package app.revanced.patches.youtube.utils.recyclerview.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
@ -64,6 +64,17 @@ import java.util.jar.Manifest
|
||||
object SettingsPatch : AbstractSettingsResourcePatch(
|
||||
"youtube/settings"
|
||||
), Closeable {
|
||||
|
||||
private val THREAD_COUNT = Runtime.getRuntime().availableProcessors()
|
||||
private val threadPoolExecutor = Executors.newFixedThreadPool(THREAD_COUNT)
|
||||
|
||||
internal lateinit var contexts: ResourceContext
|
||||
internal var upward1831: Boolean = false
|
||||
internal var upward1834: Boolean = false
|
||||
internal var upward1839: Boolean = false
|
||||
internal var upward1849: Boolean = false
|
||||
internal var upward1902: Boolean = false
|
||||
|
||||
override fun execute(context: ResourceContext) {
|
||||
super.execute(context)
|
||||
contexts = context
|
||||
@ -92,9 +103,10 @@ object SettingsPatch : AbstractSettingsResourcePatch(
|
||||
val playServicesVersion = node.textContent.toInt()
|
||||
|
||||
upward1831 = 233200000 <= playServicesVersion
|
||||
upward1834 = 233502000 <= playServicesVersion
|
||||
upward1839 = 234002000 <= playServicesVersion
|
||||
upward1849 = 235002000 <= playServicesVersion
|
||||
upward1834 = 233500000 <= playServicesVersion
|
||||
upward1839 = 234000000 <= playServicesVersion
|
||||
upward1849 = 235000000 <= playServicesVersion
|
||||
upward1902 = 240204000 < playServicesVersion
|
||||
|
||||
break
|
||||
}
|
||||
@ -155,15 +167,6 @@ object SettingsPatch : AbstractSettingsResourcePatch(
|
||||
|
||||
}
|
||||
|
||||
private val THREAD_COUNT = Runtime.getRuntime().availableProcessors()
|
||||
private val threadPoolExecutor = Executors.newFixedThreadPool(THREAD_COUNT)
|
||||
|
||||
internal lateinit var contexts: ResourceContext
|
||||
internal var upward1831: Boolean = false
|
||||
internal var upward1834: Boolean = false
|
||||
internal var upward1839: Boolean = false
|
||||
internal var upward1849: Boolean = false
|
||||
|
||||
internal fun addPreference(settingArray: Array<String>) {
|
||||
contexts.addPreference(settingArray)
|
||||
}
|
||||
|
Reference in New Issue
Block a user