mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 05:07:41 +02:00
feat(YouTube/Navigation bar components): add Hide navigation bar
setting
This commit is contained in:
@ -12,6 +12,7 @@ import app.revanced.patches.youtube.general.navigation.fingerprints.TranslucentN
|
||||
import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL_CLASS_DESCRIPTOR
|
||||
import app.revanced.patches.youtube.utils.navigation.NavigationBarHookPatch
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.util.getReference
|
||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||
@ -30,6 +31,7 @@ object NavigationBarComponentsPatch : BaseBytecodePatch(
|
||||
description = "Adds options to hide or change components related to the navigation bar.",
|
||||
dependencies = setOf(
|
||||
SettingsPatch::class,
|
||||
SharedResourceIdPatch::class,
|
||||
NavigationBarHookPatch::class
|
||||
),
|
||||
compatiblePackages = COMPATIBLE_PACKAGE,
|
||||
@ -84,6 +86,12 @@ object NavigationBarComponentsPatch : BaseBytecodePatch(
|
||||
|
||||
// endregion
|
||||
|
||||
// region patch for hide navigation bar
|
||||
|
||||
NavigationBarHookPatch.addBottomBarContainerHook("$GENERAL_CLASS_DESCRIPTOR->hideNavigationBar(Landroid/view/View;)V")
|
||||
|
||||
// endregion
|
||||
|
||||
// region patch for hide navigation buttons
|
||||
|
||||
AutoMotiveFingerprint.resultOrThrow().let {
|
||||
|
@ -321,7 +321,7 @@ object VisualPreferencesIconsPatch : BaseResourcePatch(
|
||||
"revanced_preference_screen_hook_buttons",
|
||||
"revanced_preference_screen_import_export",
|
||||
"revanced_preference_screen_miniplayer",
|
||||
"revanced_preference_screen_navigation_buttons",
|
||||
"revanced_preference_screen_navigation_bar",
|
||||
"revanced_preference_screen_patch_information",
|
||||
"revanced_preference_screen_player_buttons",
|
||||
"revanced_preference_screen_player_flyout_menu",
|
||||
@ -418,7 +418,7 @@ object VisualPreferencesIconsPatch : BaseResourcePatch(
|
||||
"revanced_hide_shorts_comments_button" -> "revanced_hide_quick_actions_comment_button_icon"
|
||||
"revanced_hide_shorts_dislike_button" -> "revanced_preference_screen_ryd_icon"
|
||||
"revanced_hide_shorts_like_button" -> "revanced_hide_quick_actions_like_button_icon"
|
||||
"revanced_hide_shorts_navigation_bar" -> "revanced_preference_screen_navigation_buttons_icon"
|
||||
"revanced_hide_shorts_navigation_bar" -> "revanced_preference_screen_navigation_bar_icon"
|
||||
"revanced_hide_shorts_shelf_home_related_videos" -> "revanced_hide_navigation_home_button_icon"
|
||||
"revanced_hide_shorts_shelf_subscriptions" -> "revanced_hide_navigation_subscriptions_button_icon"
|
||||
"revanced_hide_shorts_toolbar" -> "revanced_preference_screen_toolbar_icon"
|
||||
|
@ -8,8 +8,8 @@ import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patches.youtube.shorts.components.fingerprints.BottomNavigationBarFingerprint
|
||||
import app.revanced.patches.youtube.shorts.components.fingerprints.RenderBottomNavigationBarFingerprint
|
||||
import app.revanced.patches.youtube.shorts.components.fingerprints.SetPivotBarFingerprint
|
||||
import app.revanced.patches.youtube.utils.fingerprints.InitializeButtonsFingerprint
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.SHORTS_CLASS_DESCRIPTOR
|
||||
import app.revanced.patches.youtube.utils.navigation.fingerprints.InitializeButtonsFingerprint
|
||||
import app.revanced.util.getReference
|
||||
import app.revanced.util.getWalkerMethod
|
||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||
|
@ -8,9 +8,10 @@ import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchException
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||
import app.revanced.patches.youtube.utils.fingerprints.InitializeButtonsFingerprint
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.SHARED_PATH
|
||||
import app.revanced.patches.youtube.utils.mainactivity.MainActivityResolvePatch
|
||||
import app.revanced.patches.youtube.utils.navigation.fingerprints.InitializeBottomBarContainerFingerprint
|
||||
import app.revanced.patches.youtube.utils.navigation.fingerprints.InitializeButtonsFingerprint
|
||||
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.PivotBarButtonsCreateResourceViewFingerprint
|
||||
@ -39,6 +40,7 @@ import com.android.tools.smali.dexlib2.util.MethodUtil
|
||||
@Suppress("unused")
|
||||
object NavigationBarHookPatch : BytecodePatch(
|
||||
setOf(
|
||||
InitializeBottomBarContainerFingerprint,
|
||||
NavigationEnumFingerprint,
|
||||
PivotBarButtonsCreateDrawableViewFingerprint,
|
||||
PivotBarButtonsCreateResourceViewFingerprint,
|
||||
@ -53,6 +55,10 @@ object NavigationBarHookPatch : BytecodePatch(
|
||||
|
||||
private lateinit var navigationTabCreatedCallback: MutableMethod
|
||||
|
||||
private lateinit var bottomBarContainerMethod: MutableMethod
|
||||
private var bottomBarContainerIndex = 0
|
||||
private var bottomBarContainerRegister = 0
|
||||
|
||||
override fun execute(context: BytecodeContext) {
|
||||
fun MutableMethod.addHook(hook: Hook, insertPredicate: Instruction.() -> Boolean) {
|
||||
val filtered = getInstructions().filter(insertPredicate)
|
||||
@ -124,6 +130,14 @@ object NavigationBarHookPatch : BytecodePatch(
|
||||
INTEGRATIONS_CLASS_DESCRIPTOR,
|
||||
"onBackPressed"
|
||||
)
|
||||
|
||||
InitializeBottomBarContainerFingerprint.resultOrThrow().mutableMethod.apply {
|
||||
bottomBarContainerMethod = this
|
||||
bottomBarContainerIndex =
|
||||
InitializeBottomBarContainerFingerprint.indexOfLayoutChangeListenerInstruction(this)
|
||||
bottomBarContainerRegister =
|
||||
getInstruction<FiveRegisterInstruction>(bottomBarContainerIndex).registerC
|
||||
}
|
||||
}
|
||||
|
||||
val hookNavigationButtonCreated: (String) -> Unit by lazy {
|
||||
@ -138,6 +152,12 @@ object NavigationBarHookPatch : BytecodePatch(
|
||||
}
|
||||
}
|
||||
|
||||
fun addBottomBarContainerHook(descriptor: String) =
|
||||
bottomBarContainerMethod.addInstruction(
|
||||
bottomBarContainerIndex,
|
||||
"invoke-static { v$bottomBarContainerRegister }, $descriptor"
|
||||
)
|
||||
|
||||
private enum class Hook(val methodName: String, val parameters: String) {
|
||||
SET_LAST_APP_NAVIGATION_ENUM("setLastAppNavigationEnum", "Ljava/lang/Enum;"),
|
||||
NAVIGATION_TAB_LOADED("navigationTabLoaded", "Landroid/view/View;"),
|
||||
|
@ -0,0 +1,29 @@
|
||||
package app.revanced.patches.youtube.utils.navigation.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
import app.revanced.patches.youtube.utils.navigation.fingerprints.InitializeBottomBarContainerFingerprint.indexOfLayoutChangeListenerInstruction
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.BottomBarContainer
|
||||
import app.revanced.util.containsWideLiteralInstructionValue
|
||||
import app.revanced.util.getReference
|
||||
import app.revanced.util.indexOfFirstInstruction
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.Method
|
||||
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||
|
||||
internal object InitializeBottomBarContainerFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
customFingerprint = { methodDef, classDef ->
|
||||
AccessFlags.SYNTHETIC.isSet(classDef.accessFlags) &&
|
||||
methodDef.containsWideLiteralInstructionValue(BottomBarContainer) &&
|
||||
indexOfLayoutChangeListenerInstruction(methodDef) >= 0
|
||||
},
|
||||
) {
|
||||
fun indexOfLayoutChangeListenerInstruction(methodDef: Method) =
|
||||
methodDef.indexOfFirstInstruction {
|
||||
opcode == Opcode.INVOKE_VIRTUAL &&
|
||||
getReference<MethodReference>()?.toString() == "Landroid/view/View;->addOnLayoutChangeListener(Landroid/view/View${'$'}OnLayoutChangeListener;)V"
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package app.revanced.patches.youtube.utils.fingerprints
|
||||
package app.revanced.patches.youtube.utils.navigation.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ImageOnlyTab
|
@ -31,6 +31,7 @@ object SharedResourceIdPatch : ResourcePatch() {
|
||||
var BadgeLabel = -1L
|
||||
var Bar = -1L
|
||||
var BarContainerHeight = -1L
|
||||
var BottomBarContainer = -1L
|
||||
var BottomSheetFooterText = -1L
|
||||
var BottomSheetRecyclerView = -1L
|
||||
var BottomUiContainerStub = -1L
|
||||
@ -136,6 +137,7 @@ object SharedResourceIdPatch : ResourcePatch() {
|
||||
BadgeLabel = getId(ID, "badge_label")
|
||||
Bar = getId(LAYOUT, "bar")
|
||||
BarContainerHeight = getId(DIMEN, "bar_container_height")
|
||||
BottomBarContainer = getId(ID, "bottom_bar_container")
|
||||
BottomSheetFooterText = getId(ID, "bottom_sheet_footer_text")
|
||||
BottomSheetRecyclerView = getId(LAYOUT, "bottom_sheet_recycler_view")
|
||||
BottomUiContainerStub = getId(ID, "bottom_ui_container_stub")
|
||||
|
Reference in New Issue
Block a user