mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-06 01:24:35 +02:00
feat(YouTube/NavigationBar hook): contains navigation bar index
This commit is contained in:
parent
a9b24ae626
commit
1b271e45d7
@ -8,7 +8,9 @@ import app.revanced.patcher.patch.BytecodePatch
|
|||||||
import app.revanced.patcher.patch.PatchException
|
import app.revanced.patcher.patch.PatchException
|
||||||
import app.revanced.patcher.patch.annotation.Patch
|
import app.revanced.patcher.patch.annotation.Patch
|
||||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||||
|
import app.revanced.patches.shared.litho.LithoFilterPatch
|
||||||
import app.revanced.patches.youtube.utils.fingerprints.InitializeButtonsFingerprint
|
import app.revanced.patches.youtube.utils.fingerprints.InitializeButtonsFingerprint
|
||||||
|
import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH
|
||||||
import app.revanced.patches.youtube.utils.integrations.Constants.SHARED_PATH
|
import app.revanced.patches.youtube.utils.integrations.Constants.SHARED_PATH
|
||||||
import app.revanced.patches.youtube.utils.navigation.fingerprints.NavigationEnumFingerprint
|
import app.revanced.patches.youtube.utils.navigation.fingerprints.NavigationEnumFingerprint
|
||||||
import app.revanced.patches.youtube.utils.navigation.fingerprints.PivotBarButtonsCreateDrawableViewFingerprint
|
import app.revanced.patches.youtube.utils.navigation.fingerprints.PivotBarButtonsCreateDrawableViewFingerprint
|
||||||
@ -29,6 +31,7 @@ import com.android.tools.smali.dexlib2.util.MethodUtil
|
|||||||
@Patch(
|
@Patch(
|
||||||
description = "Hooks the active navigation or search bar.",
|
description = "Hooks the active navigation or search bar.",
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
LithoFilterPatch::class,
|
||||||
PlayerTypeHookPatch::class,
|
PlayerTypeHookPatch::class,
|
||||||
SharedResourceIdPatch::class
|
SharedResourceIdPatch::class
|
||||||
],
|
],
|
||||||
@ -43,11 +46,12 @@ object NavigationBarHookPatch : BytecodePatch(
|
|||||||
PivotBarConstructorFingerprint
|
PivotBarConstructorFingerprint
|
||||||
),
|
),
|
||||||
) {
|
) {
|
||||||
internal const val INTEGRATIONS_CLASS_DESCRIPTOR =
|
private const val INTEGRATIONS_CLASS_DESCRIPTOR =
|
||||||
"$SHARED_PATH/NavigationBar;"
|
"$SHARED_PATH/NavigationBar;"
|
||||||
|
|
||||||
private const val INTEGRATIONS_NAVIGATION_BUTTON_DESCRIPTOR =
|
private const val INTEGRATIONS_NAVIGATION_BUTTON_DESCRIPTOR =
|
||||||
"$SHARED_PATH/NavigationBar\$NavigationButton;"
|
"$SHARED_PATH/NavigationBar\$NavigationButton;"
|
||||||
|
private const val FILTER_CLASS_DESCRIPTOR =
|
||||||
|
"$COMPONENTS_PATH/NavigationButtonIndexFilter;"
|
||||||
|
|
||||||
private lateinit var navigationTabCreatedCallback: MutableMethod
|
private lateinit var navigationTabCreatedCallback: MutableMethod
|
||||||
|
|
||||||
@ -101,11 +105,16 @@ object NavigationBarHookPatch : BytecodePatch(
|
|||||||
val instruction = getInstruction<FiveRegisterInstruction>(index)
|
val instruction = getInstruction<FiveRegisterInstruction>(index)
|
||||||
val viewRegister = instruction.registerC
|
val viewRegister = instruction.registerC
|
||||||
val isSelectedRegister = instruction.registerD
|
val isSelectedRegister = instruction.registerD
|
||||||
|
val freeRegister = implementation!!.registerCount - parameters.size - 2
|
||||||
|
|
||||||
addInstruction(
|
addInstruction(
|
||||||
index + 1,
|
index + 1,
|
||||||
"invoke-static { v$viewRegister, v$isSelectedRegister }, " +
|
"invoke-static { v$viewRegister, v$freeRegister, v$isSelectedRegister }, " +
|
||||||
"$INTEGRATIONS_CLASS_DESCRIPTOR->navigationTabSelected(Landroid/view/View;Z)V",
|
"$INTEGRATIONS_CLASS_DESCRIPTOR->navigationTabSelected(Landroid/view/View;IZ)V",
|
||||||
|
)
|
||||||
|
addInstruction(
|
||||||
|
0,
|
||||||
|
"move/16 v$freeRegister, p1"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -113,6 +122,8 @@ object NavigationBarHookPatch : BytecodePatch(
|
|||||||
navigationTabCreatedCallback = context.findClass(INTEGRATIONS_CLASS_DESCRIPTOR)?.mutableClass?.methods?.first { method ->
|
navigationTabCreatedCallback = context.findClass(INTEGRATIONS_CLASS_DESCRIPTOR)?.mutableClass?.methods?.first { method ->
|
||||||
method.name == "navigationTabCreatedCallback"
|
method.name == "navigationTabCreatedCallback"
|
||||||
} ?: throw PatchException("Could not find navigationTabCreatedCallback method")
|
} ?: throw PatchException("Could not find navigationTabCreatedCallback method")
|
||||||
|
|
||||||
|
LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR)
|
||||||
}
|
}
|
||||||
|
|
||||||
val hookNavigationButtonCreated: (String) -> Unit by lazy {
|
val hookNavigationButtonCreated: (String) -> Unit by lazy {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user