diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/pivotbar/switchbutton/fingerprints/AutoMotiveFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/pivotbar/switchbutton/fingerprints/AutoMotiveFingerprint.kt new file mode 100644 index 000000000..f35a6adce --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/pivotbar/switchbutton/fingerprints/AutoMotiveFingerprint.kt @@ -0,0 +1,14 @@ +package app.revanced.patches.youtube.layout.general.pivotbar.switchbutton.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.Opcode + +object AutoMotiveFingerprint : MethodFingerprint( + opcodes = listOf( + Opcode.GOTO, + Opcode.INVOKE_STATIC, + Opcode.MOVE_RESULT, + Opcode.IF_EQZ + ), + strings = listOf("Android Automotive") +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/pivotbar/switchbutton/patch/SwitchCreateButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/pivotbar/switchbutton/patch/SwitchCreateButtonPatch.kt new file mode 100644 index 000000000..f60757d86 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/pivotbar/switchbutton/patch/SwitchCreateButtonPatch.kt @@ -0,0 +1,60 @@ +package app.revanced.patches.youtube.layout.general.pivotbar.switchbutton.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.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.patch.annotations.DependsOn +import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.layout.general.pivotbar.switchbutton.fingerprints.AutoMotiveFingerprint +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +import app.revanced.util.integrations.Constants.GENERAL_LAYOUT +import org.jf.dexlib2.iface.instruction.OneRegisterInstruction + +@Patch +@Name("switch-create-notification") +@Description("Switching the create button and notification button.") +@DependsOn([SettingsPatch::class]) +@YouTubeCompatibility +@Version("0.0.1") +class SwitchCreateButtonPatch : BytecodePatch( + listOf(AutoMotiveFingerprint) +) { + override fun execute(context: BytecodeContext): PatchResult { + + AutoMotiveFingerprint.result?.let { + with (it.mutableMethod) { + val insertIndex = it.scanResult.patternScanResult!!.endIndex + val register = (instruction(insertIndex) as OneRegisterInstruction).registerA + + addInstructions( + insertIndex, """ + invoke-static {v$register}, $GENERAL_LAYOUT->switchCreateNotification(Z)Z + move-result v$register + """ + ) + } + } ?: return AutoMotiveFingerprint.toErrorResult() + + /* + * Add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: GENERAL_LAYOUT_SETTINGS", + "SETTINGS: SWITCH_CREATE_NOTIFICATION" + ) + ) + + SettingsPatch.updatePatchStatus("switch-create-notification") + + 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 d67380fe7..0bb28509b 100644 --- a/src/main/resources/youtube/settings/host/values/strings.xml +++ b/src/main/resources/youtube/settings/host/values/strings.xml @@ -489,6 +489,8 @@ In the app settings, the YouTube version may be marked as v17.28.35" If you enable this setting, the following features are available: - Community Posts - Hide Mix playlist" + "If you enable this setting, the following features are not available: +- Ambient mode" "Tricks the dpi to change some layouts to tablet layouts. If you enable this setting, the following features are not available: @@ -527,6 +529,9 @@ Since these setting is quite outdated, it may not be valid" Swipe overlay text size The amount of milliseconds the overlay is visible Swipe overlay timeout + Create button and notification button not switching + Create button and notification button are switched + Switching the create button and notification button Tool used Video ads are shown Video ads are hidden diff --git a/src/main/resources/youtube/settings/xml/revanced_prefs.xml b/src/main/resources/youtube/settings/xml/revanced_prefs.xml index 9e794c2b3..fa9ecc591 100644 --- a/src/main/resources/youtube/settings/xml/revanced_prefs.xml +++ b/src/main/resources/youtube/settings/xml/revanced_prefs.xml @@ -145,6 +145,10 @@ + + @@ -395,6 +399,7 @@ +