mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-05 09:04:34 +02:00
feat(YouTube/Navigation bar components): add Hide navigation bar
setting
This commit is contained in:
parent
e8ad2e6b82
commit
6c060c5da6
@ -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")
|
||||
|
@ -466,9 +466,9 @@ Some components may not be hidden."</string>
|
||||
<string name="revanced_miniplayer_opacity_summary">Opacity value between 0-100, where 0 is transparent.</string>
|
||||
<string name="revanced_miniplayer_opacity_invalid_toast">Miniplayer overlay opacity must be between 0-100.</string>
|
||||
|
||||
<!-- PreferenceScreen: General, PreferenceCategory: General, PreferenceScreen: Navigation buttons -->
|
||||
<string name="revanced_preference_screen_navigation_buttons_title">Navigation buttons</string>
|
||||
<string name="revanced_preference_screen_navigation_buttons_summary">Hide or show navigation bar section components.</string>
|
||||
<!-- PreferenceScreen: General, PreferenceCategory: General, PreferenceScreen: Navigation bar -->
|
||||
<string name="revanced_preference_screen_navigation_bar_title">Navigation bar</string>
|
||||
<string name="revanced_preference_screen_navigation_bar_summary">Hide or show navigation bar section components.</string>
|
||||
|
||||
<string name="revanced_enable_narrow_navigation_buttons_title">Enable narrow navigation buttons</string>
|
||||
<string name="revanced_enable_narrow_navigation_buttons_summary_on">Spacing between navigation buttons is narrow.</string>
|
||||
@ -508,6 +508,9 @@ If this setting do not take effect, try switching to Incognito mode."</string>
|
||||
<string name="revanced_enable_translucent_navigation_bar_title">Enable translucent navigation bar</string>
|
||||
<string name="revanced_enable_translucent_navigation_bar_summary_on">Navigation bar is translucent.</string>
|
||||
<string name="revanced_enable_translucent_navigation_bar_summary_off">Navigation bar is opaque.</string>
|
||||
<string name="revanced_hide_navigation_bar_title">Hide navigation bar</string>
|
||||
<string name="revanced_hide_navigation_bar_summary_on">Navigation bar is hidden.</string>
|
||||
<string name="revanced_hide_navigation_bar_summary_off">Navigation bar is shown.</string>
|
||||
|
||||
<!-- PreferenceScreen: General, PreferenceCategory: General, PreferenceScreen: Settings menu -->
|
||||
<string name="revanced_preference_screen_settings_menu_title">Settings menu</string>
|
||||
|
@ -172,7 +172,7 @@
|
||||
</PreferenceScreen>SETTINGS: MINIPLAYER_TYPE_MODERN -->
|
||||
|
||||
<!-- SETTINGS: HIDE_NAVIGATION_COMPONENTS
|
||||
<PreferenceScreen android:title="@string/revanced_preference_screen_navigation_buttons_title" android:key="revanced_preference_screen_navigation_buttons" android:summary="@string/revanced_preference_screen_navigation_buttons_summary">
|
||||
<PreferenceScreen android:title="@string/revanced_preference_screen_navigation_bar_title" android:key="revanced_preference_screen_navigation_bar" android:summary="@string/revanced_preference_screen_navigation_bar_summary">
|
||||
<SwitchPreference android:title="@string/revanced_enable_narrow_navigation_buttons_title" android:key="revanced_enable_narrow_navigation_buttons" android:summaryOn="@string/revanced_enable_narrow_navigation_buttons_summary_on" android:summaryOff="@string/revanced_enable_narrow_navigation_buttons_summary_off" />
|
||||
<SwitchPreference android:title="@string/revanced_hide_navigation_create_button_title" android:key="revanced_hide_navigation_create_button" android:summaryOn="@string/revanced_hide_navigation_create_button_summary_on" android:summaryOff="@string/revanced_hide_navigation_create_button_summary_off" />
|
||||
<SwitchPreference android:title="@string/revanced_hide_navigation_home_button_title" android:key="revanced_hide_navigation_home_button" android:summaryOn="@string/revanced_hide_navigation_home_button_summary_on" android:summaryOff="@string/revanced_hide_navigation_home_button_summary_off" />
|
||||
@ -181,13 +181,15 @@
|
||||
<SwitchPreference android:title="@string/revanced_hide_navigation_shorts_button_title" android:key="revanced_hide_navigation_shorts_button" android:summaryOn="@string/revanced_hide_navigation_shorts_button_summary_on" android:summaryOff="@string/revanced_hide_navigation_shorts_button_summary_off" />
|
||||
<SwitchPreference android:title="@string/revanced_hide_navigation_subscriptions_button_title" android:key="revanced_hide_navigation_subscriptions_button" android:summaryOn="@string/revanced_hide_navigation_subscriptions_button_summary_on" android:summaryOff="@string/revanced_hide_navigation_subscriptions_button_summary_off" />
|
||||
<SwitchPreference android:title="@string/revanced_hide_navigation_label_title" android:key="revanced_hide_navigation_label" android:summaryOn="@string/revanced_hide_navigation_label_summary_on" android:summaryOff="@string/revanced_hide_navigation_label_summary_off" />
|
||||
<SwitchPreference android:title="@string/revanced_switch_create_with_notifications_button_title" android:key="revanced_switch_create_with_notifications_button" android:summaryOn="@string/revanced_switch_create_with_notifications_button_summary_on" android:summaryOff="@string/revanced_switch_create_with_notifications_button_summary_off" />SETTINGS: HIDE_NAVIGATION_COMPONENTS -->
|
||||
<SwitchPreference android:title="@string/revanced_switch_create_with_notifications_button_title" android:key="revanced_switch_create_with_notifications_button" android:summaryOn="@string/revanced_switch_create_with_notifications_button_summary_on" android:summaryOff="@string/revanced_switch_create_with_notifications_button_summary_off" />
|
||||
|
||||
<PreferenceCategory android:title="@string/revanced_preference_category_experimental_flag" android:layout="@layout/revanced_settings_preferences_category"/>SETTINGS: HIDE_NAVIGATION_COMPONENTS -->
|
||||
|
||||
<!-- SETTINGS: TRANSLUCENT_NAVIGATION_BAR
|
||||
<PreferenceCategory android:title="@string/revanced_preference_category_experimental_flag" android:layout="@layout/revanced_settings_preferences_category"/>
|
||||
<SwitchPreference android:title="@string/revanced_enable_translucent_navigation_bar_title" android:key="revanced_enable_translucent_navigation_bar" android:summaryOn="@string/revanced_enable_translucent_navigation_bar_summary_on" android:summaryOff="@string/revanced_enable_translucent_navigation_bar_summary_off" />SETTINGS: TRANSLUCENT_NAVIGATION_BAR -->
|
||||
|
||||
<!-- SETTINGS: HIDE_NAVIGATION_COMPONENTS
|
||||
<!-- SETTINGS: HIDE_NAVIGATION_COMPONENTS
|
||||
<SwitchPreference android:title="@string/revanced_hide_navigation_bar_title" android:key="revanced_hide_navigation_bar" android:summaryOn="@string/revanced_hide_navigation_bar_summary_on" android:summaryOff="@string/revanced_hide_navigation_bar_summary_off" />
|
||||
</PreferenceScreen>SETTINGS: HIDE_NAVIGATION_COMPONENTS -->
|
||||
|
||||
<!-- SETTINGS: HIDE_LAYOUT_COMPONENTS
|
||||
|
Loading…
x
Reference in New Issue
Block a user