From a7edf227d17f2dca214c277043046dd16eb521c2 Mon Sep 17 00:00:00 2001
From: inotia00 <108592928+inotia00@users.noreply.github.com>
Date: Fri, 20 Oct 2023 09:57:41 +0900
Subject: [PATCH] =?UTF-8?q?feat(YouTube/Hide=20navigation=20buttons):=20`O?=
=?UTF-8?q?pen=20library=20on=20app=20startup`=20now=20also=20works=20in?=
=?UTF-8?q?=20the=20`You`=20tab=20(`Open=20library=20on=20app=20startup`?=
=?UTF-8?q?=20=E2=86=92=20`Open=20library(You)=20on=20app=20startup`)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../NavigationButtonsPatch.kt | 27 +++++++++++++------
.../utils/resourceid/SharedResourceIdPatch.kt | 2 ++
.../youtube/settings/host/values/strings.xml | 6 ++---
3 files changed, 24 insertions(+), 11 deletions(-)
diff --git a/src/main/kotlin/app/revanced/patches/youtube/navigation/navigationbuttons/NavigationButtonsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/navigation/navigationbuttons/NavigationButtonsPatch.kt
index 66fe6410e..b20ed613b 100644
--- a/src/main/kotlin/app/revanced/patches/youtube/navigation/navigationbuttons/NavigationButtonsPatch.kt
+++ b/src/main/kotlin/app/revanced/patches/youtube/navigation/navigationbuttons/NavigationButtonsPatch.kt
@@ -13,6 +13,7 @@ import app.revanced.patches.youtube.navigation.navigationbuttons.fingerprints.Pi
import app.revanced.patches.youtube.navigation.navigationbuttons.fingerprints.PivotBarShortsButtonViewFingerprint
import app.revanced.patches.youtube.utils.fingerprints.PivotBarCreateButtonViewFingerprint
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
+import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.AvatarImageWithTextTab
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ImageOnlyTab
import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.bytecode.getWideLiteralIndex
@@ -94,17 +95,22 @@ object NavigationButtonsPatch : BytecodePatch(
}
/**
- * Create Button
+ * Create, You Button
*/
parentResult.mutableMethod.apply {
- val insertIndex = implementation!!.instructions.let {
- val scanStart = getWideLiteralIndex(ImageOnlyTab)
+ mapOf(
+ CREATE_BUTTON_HOOK to ImageOnlyTab,
+ YOU_BUTTON_HOOK to AvatarImageWithTextTab
+ ).forEach { (hook, resourceId) ->
+ val insertIndex = implementation!!.instructions.let {
+ val scanStart = getWideLiteralIndex(resourceId)
- scanStart + it.subList(scanStart, it.size - 1).indexOfFirst { instruction ->
- instruction.opcode == Opcode.INVOKE_VIRTUAL
- }
- } + 2
- injectHook(CREATE_BUTTON_HOOK, insertIndex)
+ scanStart + it.subList(scanStart, it.size - 1).indexOfFirst { instruction ->
+ instruction.opcode == Opcode.INVOKE_VIRTUAL
+ }
+ } + 2
+ injectHook(hook, insertIndex)
+ }
}
} ?: throw PivotBarCreateButtonViewFingerprint.exception
@@ -154,4 +160,9 @@ object NavigationButtonsPatch : BytecodePatch(
"invoke-static { v$REGISTER_TEMPLATE_REPLACEMENT }, $NAVIGATION" +
"->" +
"hideCreateButton(Landroid/view/View;)V"
+
+ private const val YOU_BUTTON_HOOK =
+ "invoke-static { v$REGISTER_TEMPLATE_REPLACEMENT }, $NAVIGATION" +
+ "->" +
+ "hideYouButton(Landroid/view/View;)V"
}
\ No newline at end of file
diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/resourceid/SharedResourceIdPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/resourceid/SharedResourceIdPatch.kt
index 315906a62..7614f2179 100644
--- a/src/main/kotlin/app/revanced/patches/youtube/utils/resourceid/SharedResourceIdPatch.kt
+++ b/src/main/kotlin/app/revanced/patches/youtube/utils/resourceid/SharedResourceIdPatch.kt
@@ -23,6 +23,7 @@ object SharedResourceIdPatch : ResourcePatch() {
var AppRelatedEndScreenResults: Long = -1
var AutoNavPreviewStub: Long = -1
var AutoNavToggle: Long = -1
+ var AvatarImageWithTextTab: Long = -1
var BackgroundCategory: Long = -1
var Bar: Long = -1
var BarContainerHeight: Long = -1
@@ -103,6 +104,7 @@ object SharedResourceIdPatch : ResourcePatch() {
AppRelatedEndScreenResults = find(LAYOUT, "app_related_endscreen_results")
AutoNavPreviewStub = find(ID, "autonav_preview_stub")
AutoNavToggle = find(ID, "autonav_toggle")
+ AvatarImageWithTextTab = find(LAYOUT, "avatar_image_with_text_tab")
BackgroundCategory = find(STRING, "pref_background_and_offline_category")
Bar = find(LAYOUT, "bar")
BarContainerHeight = find(DIMEN, "bar_container_height")
diff --git a/src/main/resources/youtube/settings/host/values/strings.xml b/src/main/resources/youtube/settings/host/values/strings.xml
index 25273a66e..69570d3eb 100644
--- a/src/main/resources/youtube/settings/host/values/strings.xml
+++ b/src/main/resources/youtube/settings/host/values/strings.xml
@@ -578,9 +578,9 @@ Known issue: Autoplay does not work"
Layout
Miscellaneous
Navigation
- Library is not opened at app startup
- Library is opened at app startup
- Open library on app startup
+ Library(You) is not opened at app startup
+ Library(You) is opened at app startup
+ Open library(You) on app startup
Others
Overlay button
"Tap to toggle always repeat states