diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/snackbar/bytecode/fingerprints/HideSnackbarFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/snackbar/bytecode/fingerprints/HideSnackbarFingerprint.kt new file mode 100644 index 000000000..899198fc6 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/snackbar/bytecode/fingerprints/HideSnackbarFingerprint.kt @@ -0,0 +1,12 @@ +package app.revanced.patches.youtube.layout.general.snackbar.bytecode.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.AccessFlags + +object HideSnackbarFingerprint : MethodFingerprint( + returnType = "V", + access = AccessFlags.PUBLIC or AccessFlags.FINAL, + parameters = listOf("L", "L"), + customFingerprint = { it.definingClass == "Lcom/google/android/apps/youtube/app/common/ui/bottomui/BottomUiContainer;" } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/snackbar/bytecode/patch/HideSnackbarBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/snackbar/bytecode/patch/HideSnackbarBytecodePatch.kt new file mode 100644 index 000000000..c54dbdb7c --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/snackbar/bytecode/patch/HideSnackbarBytecodePatch.kt @@ -0,0 +1,40 @@ +package app.revanced.patches.youtube.layout.general.snackbar.bytecode.patch + +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.instruction +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.util.smali.ExternalLabel +import app.revanced.patches.youtube.layout.general.snackbar.bytecode.fingerprints.HideSnackbarFingerprint +import app.revanced.shared.annotation.YouTubeCompatibility +import app.revanced.shared.extensions.toErrorResult +import app.revanced.shared.util.integrations.Constants.GENERAL_LAYOUT + +@Name("hide-snackbar-bytecode-patch") +@YouTubeCompatibility +@Version("0.0.1") +class HideSnackbarBytecodePatch : BytecodePatch( + listOf( + HideSnackbarFingerprint + ) +) { + override fun execute(context: BytecodeContext): PatchResult { + + HideSnackbarFingerprint.result?.mutableMethod?.let { + it.addInstructions( + 0, """ + invoke-static {}, $GENERAL_LAYOUT->hideSnackbar()Z + move-result v0 + if-eqz v0, :default + return-void + """, listOf(ExternalLabel("default", it.instruction(0))) + ) + } ?: return HideSnackbarFingerprint.toErrorResult() + + return PatchResultSuccess() + } +} diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/snackbar/resource/patch/HideSnackbarPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/snackbar/resource/patch/HideSnackbarPatch.kt new file mode 100644 index 000000000..def46a495 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/snackbar/resource/patch/HideSnackbarPatch.kt @@ -0,0 +1,49 @@ +package app.revanced.patches.youtube.layout.general.snackbar.resource.patch + +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.ResourceContext +import app.revanced.patcher.patch.annotations.DependsOn +import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.ResourcePatch +import app.revanced.patches.youtube.layout.general.snackbar.bytecode.patch.HideSnackbarBytecodePatch +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +import app.revanced.shared.annotation.YouTubeCompatibility +import app.revanced.shared.util.resources.ResourceHelper + +@Patch +@Name("hide-snackbar") +@Description("Hides the snackbar action popup.") +@DependsOn( + [ + HideSnackbarBytecodePatch::class, + SettingsPatch::class + ] +) +@YouTubeCompatibility +@Version("0.0.1") +class HideSnackbarPatch : ResourcePatch { + override fun execute(context: ResourceContext): PatchResult { + + /* + add settings + */ + ResourceHelper.addSettings2( + context, + "PREFERENCE_CATEGORY: REVANCED_SETTINGS", + "PREFERENCE: LAYOUT_SETTINGS", + "PREFERENCE_HEADER: GENERAL", + "SETTINGS: HIDE_SNACKBAR" + ) + + ResourceHelper.patchSuccess( + context, + "hide-snackbar" + ) + + return PatchResultSuccess() + } +} \ 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 54e05453c..a6bae2fc4 100644 --- a/src/main/resources/youtube/settings/host/values/strings.xml +++ b/src/main/resources/youtube/settings/host/values/strings.xml @@ -402,6 +402,9 @@ Is it ready to submit?" Shorts shelves are shown Shorts shelves are hidden Hide shorts shelf + Snackbar is shown + Snackbar is hidden + Hide snackbar Shorts player is shown at app startup Shorts player is hidden at app startup Hide shorts player at app startup diff --git a/src/main/resources/youtube/settings/xml/revanced_prefs.xml b/src/main/resources/youtube/settings/xml/revanced_prefs.xml index 740aecd02..5ec131dc8 100644 --- a/src/main/resources/youtube/settings/xml/revanced_prefs.xml +++ b/src/main/resources/youtube/settings/xml/revanced_prefs.xml @@ -139,6 +139,9 @@ + + @@ -364,6 +367,7 @@ +