diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/homebutton/patch/HomeButtonRemoverPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/homebutton/patch/HomeButtonRemoverPatch.kt new file mode 100644 index 000000000..01d52abd5 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/homebutton/patch/HomeButtonRemoverPatch.kt @@ -0,0 +1,44 @@ +package app.revanced.patches.youtube.layout.navigation.homebutton.patch + +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.annotations.DependsOn +import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.misc.lastpivottab.patch.LastPivotTabHookPatch +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch + +@Patch +@Name("hide-home-button") +@Description("Hides the home button in the navigation bar.") +@DependsOn( + [ + SettingsPatch::class, + LastPivotTabHookPatch::class + ] +) +@YouTubeCompatibility +@Version("0.0.1") +class HomeButtonRemoverPatch : BytecodePatch() { + override fun execute(context: BytecodeContext): PatchResult { + + /* + * Add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: NAVIGATION_SETTINGS", + "SETTINGS: HIDE_HOME_BUTTON" + ) + ) + + SettingsPatch.updatePatchStatus("hide-home-button") + + return PatchResultSuccess() + } +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/shortsbutton/patch/ShortsButtonRemoverPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/shortsbutton/patch/ShortsButtonRemoverPatch.kt index 61e846686..1253522a1 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/shortsbutton/patch/ShortsButtonRemoverPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/shortsbutton/patch/ShortsButtonRemoverPatch.kt @@ -1,25 +1,17 @@ package app.revanced.patches.youtube.layout.navigation.shortsbutton.patch -import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.shared.fingerprints.PivotBarCreateButtonViewFingerprint -import app.revanced.patches.youtube.layout.navigation.shortsbutton.fingerprints.PivotBarEnumFingerprint -import app.revanced.patches.youtube.layout.navigation.shortsbutton.fingerprints.PivotBarShortsButtonViewFingerprint -import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch +import app.revanced.patches.youtube.misc.lastpivottab.patch.LastPivotTabHookPatch import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.integrations.Constants.NAVIGATION -import app.revanced.util.pivotbar.InjectionUtils.REGISTER_TEMPLATE_REPLACEMENT -import app.revanced.util.pivotbar.InjectionUtils.injectHook @Patch @Name("hide-shorts-button") @@ -27,51 +19,14 @@ import app.revanced.util.pivotbar.InjectionUtils.injectHook @DependsOn( [ SettingsPatch::class, - SharedResourceIdPatch::class + LastPivotTabHookPatch::class ] ) @YouTubeCompatibility @Version("0.0.1") -class ShortsButtonRemoverPatch : BytecodePatch( - listOf(PivotBarCreateButtonViewFingerprint) -) { +class ShortsButtonRemoverPatch : BytecodePatch() { override fun execute(context: BytecodeContext): PatchResult { - /* - * Resolve fingerprints - */ - - PivotBarCreateButtonViewFingerprint.result?.let { parentResult -> - with ( - arrayOf( - PivotBarEnumFingerprint, - PivotBarShortsButtonViewFingerprint - ).onEach { - it.resolve( - context, - parentResult.mutableMethod, - parentResult.mutableClass - ) - }.map { - it.result?.scanResult?.patternScanResult ?: return it.toErrorResult() - } - ) { - val enumScanResult = this[0] - val buttonViewResult = this[1] - - val enumHookInsertIndex = enumScanResult.startIndex + 2 - val buttonHookInsertIndex = buttonViewResult.endIndex - - mapOf( - buttonHook to buttonHookInsertIndex, - enumHook to enumHookInsertIndex - ).forEach { (hook, insertIndex) -> - parentResult.mutableMethod.injectHook(hook, insertIndex) - } - } - - } ?: return PivotBarCreateButtonViewFingerprint.toErrorResult() - /* * Add settings */ @@ -86,15 +41,4 @@ class ShortsButtonRemoverPatch : BytecodePatch( return PatchResultSuccess() } - private companion object { - const val enumHook = - "sput-object v$REGISTER_TEMPLATE_REPLACEMENT, $NAVIGATION" + - "->" + - "lastPivotTab:Ljava/lang/Enum;" - - const val buttonHook = - "invoke-static { v$REGISTER_TEMPLATE_REPLACEMENT }, $NAVIGATION" + - "->" + - "hideShortsButton(Landroid/view/View;)V" - } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/subscriptionsbutton/patch/SubscriptionsButtonRemoverPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/subscriptionsbutton/patch/SubscriptionsButtonRemoverPatch.kt new file mode 100644 index 000000000..b77ab7d71 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/subscriptionsbutton/patch/SubscriptionsButtonRemoverPatch.kt @@ -0,0 +1,44 @@ +package app.revanced.patches.youtube.layout.navigation.subscriptionsbutton.patch + +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.annotations.DependsOn +import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.misc.lastpivottab.patch.LastPivotTabHookPatch +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch + +@Patch +@Name("hide-subscriptions-button") +@Description("Hides the subscriptions button in the navigation bar.") +@DependsOn( + [ + SettingsPatch::class, + LastPivotTabHookPatch::class + ] +) +@YouTubeCompatibility +@Version("0.0.1") +class SubscriptionsButtonRemoverPatch : BytecodePatch() { + override fun execute(context: BytecodeContext): PatchResult { + + /* + * Add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: NAVIGATION_SETTINGS", + "SETTINGS: HIDE_SUBSCRIPTIONS_BUTTON" + ) + ) + + SettingsPatch.updatePatchStatus("hide-subscriptions-button") + + return PatchResultSuccess() + } +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/shortsbutton/fingerprints/PivotBarEnumFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/lastpivottab/fingerprints/PivotBarEnumFingerprint.kt similarity index 82% rename from src/main/kotlin/app/revanced/patches/youtube/layout/navigation/shortsbutton/fingerprints/PivotBarEnumFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/misc/lastpivottab/fingerprints/PivotBarEnumFingerprint.kt index 7de91aeef..41783df71 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/shortsbutton/fingerprints/PivotBarEnumFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/lastpivottab/fingerprints/PivotBarEnumFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.navigation.shortsbutton.fingerprints +package app.revanced.patches.youtube.misc.lastpivottab.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.Opcode diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/shortsbutton/fingerprints/PivotBarShortsButtonViewFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/lastpivottab/fingerprints/PivotBarShortsButtonViewFingerprint.kt similarity index 79% rename from src/main/kotlin/app/revanced/patches/youtube/layout/navigation/shortsbutton/fingerprints/PivotBarShortsButtonViewFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/misc/lastpivottab/fingerprints/PivotBarShortsButtonViewFingerprint.kt index 2ce1759fd..bc38484cc 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/navigation/shortsbutton/fingerprints/PivotBarShortsButtonViewFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/lastpivottab/fingerprints/PivotBarShortsButtonViewFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.navigation.shortsbutton.fingerprints +package app.revanced.patches.youtube.misc.lastpivottab.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.Opcode diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/lastpivottab/patch/LastPivotTabHookPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/lastpivottab/patch/LastPivotTabHookPatch.kt new file mode 100644 index 000000000..eb52fcf1f --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/lastpivottab/patch/LastPivotTabHookPatch.kt @@ -0,0 +1,78 @@ +package app.revanced.patches.youtube.misc.lastpivottab.patch + +import app.revanced.extensions.toErrorResult +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.annotations.DependsOn +import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.shared.fingerprints.PivotBarCreateButtonViewFingerprint +import app.revanced.patches.youtube.misc.lastpivottab.fingerprints.PivotBarEnumFingerprint +import app.revanced.patches.youtube.misc.lastpivottab.fingerprints.PivotBarShortsButtonViewFingerprint +import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch +import app.revanced.util.integrations.Constants.NAVIGATION +import app.revanced.util.pivotbar.InjectionUtils.REGISTER_TEMPLATE_REPLACEMENT +import app.revanced.util.pivotbar.InjectionUtils.injectHook + +@Name("last-pivot-tab-hook") +@DependsOn([SharedResourceIdPatch::class]) +@YouTubeCompatibility +@Version("0.0.1") +class LastPivotTabHookPatch : BytecodePatch( + listOf(PivotBarCreateButtonViewFingerprint) +) { + override fun execute(context: BytecodeContext): PatchResult { + + /* + * Resolve fingerprints + */ + + PivotBarCreateButtonViewFingerprint.result?.let { parentResult -> + with ( + arrayOf( + PivotBarEnumFingerprint, + PivotBarShortsButtonViewFingerprint + ).onEach { + it.resolve( + context, + parentResult.mutableMethod, + parentResult.mutableClass + ) + }.map { + it.result?.scanResult?.patternScanResult ?: return it.toErrorResult() + } + ) { + val enumScanResult = this[0] + val buttonViewResult = this[1] + + val enumHookInsertIndex = enumScanResult.startIndex + 2 + val buttonHookInsertIndex = buttonViewResult.endIndex + + mapOf( + buttonHook to buttonHookInsertIndex, + enumHook to enumHookInsertIndex + ).forEach { (hook, insertIndex) -> + parentResult.mutableMethod.injectHook(hook, insertIndex) + } + } + + } ?: return PivotBarCreateButtonViewFingerprint.toErrorResult() + + return PatchResultSuccess() + } + private companion object { + const val enumHook = + "sput-object v$REGISTER_TEMPLATE_REPLACEMENT, $NAVIGATION" + + "->" + + "lastPivotTab:Ljava/lang/Enum;" + + const val buttonHook = + "invoke-static { v$REGISTER_TEMPLATE_REPLACEMENT }, $NAVIGATION" + + "->" + + "hideNavigationButton(Landroid/view/View;)V" + } +} \ No newline at end of file diff --git a/src/main/resources/youtube/settings/host/values/strings.xml b/src/main/resources/youtube/settings/host/values/strings.xml index 693581203..e17f51b45 100644 --- a/src/main/resources/youtube/settings/host/values/strings.xml +++ b/src/main/resources/youtube/settings/host/values/strings.xml @@ -279,6 +279,9 @@ Please do not report any issues you encounter while using this feature."Fullscreen panels are shown Fullscreen panels are hidden Hide fullscreen panels + Home button is shown + Home button is hidden + Hide home button Image shelves are shown Image shelves are hidden Hide image shelf diff --git a/src/main/resources/youtube/settings/values-v21/strings.xml b/src/main/resources/youtube/settings/values-v21/strings.xml index 990d90298..e4af1d4cb 100644 --- a/src/main/resources/youtube/settings/values-v21/strings.xml +++ b/src/main/resources/youtube/settings/values-v21/strings.xml @@ -43,6 +43,10 @@ @string/revanced_hide_button_thanks_summary_on @string/revanced_hide_button_thanks_title + @string/revanced_hide_shorts_player_subscriptions_button_summary_off + @string/revanced_hide_shorts_player_subscriptions_button_summary_on + @string/revanced_hide_shorts_player_subscriptions_button_title + @string/camera_speed_button_label afn / blue diff --git a/src/main/resources/youtube/settings/xml/revanced_prefs.xml b/src/main/resources/youtube/settings/xml/revanced_prefs.xml index fba07b71a..efbab6673 100644 --- a/src/main/resources/youtube/settings/xml/revanced_prefs.xml +++ b/src/main/resources/youtube/settings/xml/revanced_prefs.xml @@ -320,9 +320,15 @@ + + + + @@ -515,7 +521,9 @@ + +