feat(YouTube - Hide Shorts components): Add patch option to hide Shorts from app launcher widget Beta (#3707)

This commit is contained in:
LisoUseInAIKyrios 2024-09-28 17:02:42 -04:00 committed by GitHub
parent b794236294
commit 838f1834a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 24 additions and 7 deletions

View File

@ -81,7 +81,14 @@ object HideShortsComponentsPatch : BytecodePatch(
key = "hideShortsAppShortcut",
default = false,
title = "Hide Shorts app shortcut",
description = "Permanently hides the shortcut to open Shorts from long pressing the app icon in your launcher."
description = "Permanently hides the shortcut to open Shorts when long pressing the app icon in your launcher."
)
internal val hideShortsWidget by booleanPatchOption(
key = "hideShortsWidget",
default = false,
title = "Hide Shorts widget",
description = "Permanently hides the launcher widget Shorts button."
)
override fun execute(context: BytecodeContext) {

View File

@ -7,6 +7,7 @@ import app.revanced.patches.all.misc.resources.AddResourcesPatch
import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
import app.revanced.patches.youtube.layout.hide.shorts.HideShortsComponentsPatch.hideShortsAppShortcut
import app.revanced.patches.youtube.layout.hide.shorts.HideShortsComponentsPatch.hideShortsWidget
import app.revanced.patches.youtube.misc.settings.SettingsPatch
import app.revanced.util.findElementByAttributeValueOrThrow
import org.w3c.dom.Element
@ -57,9 +58,7 @@ object HideShortsComponentsResourcePatch : ResourcePatch() {
if (hideShortsAppShortcut == true) {
context.xmlEditor["res/xml/main_shortcuts.xml"].use { editor ->
val shortcuts = editor.file.getElementsByTagName("shortcuts").item(0) as Element
val shortsItem =
shortcuts.getElementsByTagName("shortcut").findElementByAttributeValueOrThrow(
val shortsItem = editor.file.childNodes.findElementByAttributeValueOrThrow(
"android:shortcutId",
"shorts-shortcut"
)
@ -68,6 +67,17 @@ object HideShortsComponentsResourcePatch : ResourcePatch() {
}
}
if (hideShortsWidget == true) {
context.xmlEditor["res/layout/appwidget_two_rows.xml"].use { editor ->
val shortsItem = editor.file.childNodes.findElementByAttributeValueOrThrow(
"android:id",
"@id/button_shorts_container"
)
shortsItem.parentNode.removeChild(shortsItem)
}
}
reelPlayerRightCellButtonHeight = ResourceMappingPatch[
"dimen",
"reel_player_right_cell_button_height",