diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/toolbar/ToolBarComponentsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/toolbar/ToolBarComponentsPatch.kt index 86899ff6d..73209d52f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/general/toolbar/ToolBarComponentsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/toolbar/ToolBarComponentsPatch.kt @@ -15,6 +15,7 @@ import app.revanced.patches.shared.voicesearch.VoiceSearchUtils.patchXml import app.revanced.patches.youtube.general.toolbar.fingerprints.ActionBarRingoBackgroundFingerprint import app.revanced.patches.youtube.general.toolbar.fingerprints.ActionBarRingoTextFingerprint import app.revanced.patches.youtube.general.toolbar.fingerprints.AttributeResolverFingerprint +import app.revanced.patches.youtube.general.toolbar.fingerprints.CreateButtonDrawableFingerprint import app.revanced.patches.youtube.general.toolbar.fingerprints.CreateSearchSuggestionsFingerprint import app.revanced.patches.youtube.general.toolbar.fingerprints.DrawerContentViewConstructorFingerprint import app.revanced.patches.youtube.general.toolbar.fingerprints.DrawerContentViewFingerprint @@ -31,6 +32,7 @@ import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL_CLASS_D import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ActionBarRingoBackground import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.VoiceSearch +import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.YtOutlineVideoCamera import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.YtPremiumWordMarkHeader import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.YtWordMarkHeader import app.revanced.patches.youtube.utils.settings.SettingsPatch @@ -71,6 +73,7 @@ object ToolBarComponentsPatch : BaseBytecodePatch( fingerprints = setOf( ActionBarRingoBackgroundFingerprint, AttributeResolverFingerprint, + CreateButtonDrawableFingerprint, CreateSearchSuggestionsFingerprint, DrawerContentViewConstructorFingerprint, SearchBarParentFingerprint, @@ -360,6 +363,34 @@ object ToolBarComponentsPatch : BaseBytecodePatch( // endregion + // region patch for replace create button + + CreateButtonDrawableFingerprint.resultOrThrow().mutableMethod.apply { + val index = getWideLiteralInstructionIndex(YtOutlineVideoCamera) + val register = getInstruction(index).registerA + + addInstructions( + index + 1, """ + invoke-static {v$register}, $GENERAL_CLASS_DESCRIPTOR->getCreateButtonDrawableId(I)I + move-result v$register + """ + ) + } + + ToolBarHookPatch.hook("$GENERAL_CLASS_DESCRIPTOR->replaceCreateButton") + + val settingsClass = context.findClass("Shell_SettingsActivity") + ?: throw PatchException("Shell_SettingsActivity class not found.") + + settingsClass.mutableClass.methods.find { it.name == "onCreate" }?.apply { + addInstruction( + 0, + "invoke-static {p0}, $GENERAL_CLASS_DESCRIPTOR->setShellActivityTheme(Landroid/app/Activity;)V" + ) + } ?: throw PatchException("onCreate method not found.") + + // endregion + /** * Add settings */ diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/toolbar/fingerprints/CreateButtonDrawableFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/general/toolbar/fingerprints/CreateButtonDrawableFingerprint.kt new file mode 100644 index 000000000..cc1c6d795 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/general/toolbar/fingerprints/CreateButtonDrawableFingerprint.kt @@ -0,0 +1,8 @@ +package app.revanced.patches.youtube.general.toolbar.fingerprints + +import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.YtOutlineVideoCamera +import app.revanced.util.fingerprint.LiteralValueFingerprint + +internal object CreateButtonDrawableFingerprint : LiteralValueFingerprint( + literalSupplier = { YtOutlineVideoCamera } +) \ 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 0128a9ae9..2787d2ee5 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 @@ -90,6 +90,7 @@ object SharedResourceIdPatch : ResourcePatch() { var VideoQualityBottomSheet = -1L var VoiceSearch = -1L var YouTubeControlsOverlaySubtitleButton = -1L + var YtOutlineVideoCamera = -1L var YtPremiumWordMarkHeader = -1L var YtWordMarkHeader = -1L @@ -170,6 +171,7 @@ object SharedResourceIdPatch : ResourcePatch() { VideoQualityBottomSheet = getId(LAYOUT, "video_quality_bottom_sheet_list_fragment_title") VoiceSearch = getId(ID, "voice_search") YouTubeControlsOverlaySubtitleButton = getId(LAYOUT, "youtube_controls_overlay_subtitle_button") + YtOutlineVideoCamera = getId(DRAWABLE, "yt_outline_video_camera_black_24") YtPremiumWordMarkHeader = getId(ATTR, "ytPremiumWordmarkHeader") YtWordMarkHeader = getId(ATTR, "ytWordmarkHeader") diff --git a/src/main/resources/youtube/settings/host/values/strings.xml b/src/main/resources/youtube/settings/host/values/strings.xml index dc922cfaa..12bc035b9 100644 --- a/src/main/resources/youtube/settings/host/values/strings.xml +++ b/src/main/resources/youtube/settings/host/values/strings.xml @@ -402,6 +402,13 @@ You tab > View channel > Menu > Settings." Hide voice search button Voice search button is hidden in search bar. Voice search button is shown in search bar. + Replace create button + Replaces create button with settings button. + Action type to assign to button + "Tap to open RVX Settings. +Tap and hold to open YouTube Settings." + "Tap to open YouTube Settings. +Tap and hold to open RVX Settings." diff --git a/src/main/resources/youtube/settings/xml/revanced_prefs.xml b/src/main/resources/youtube/settings/xml/revanced_prefs.xml index 90a76afdb..f28984ee8 100644 --- a/src/main/resources/youtube/settings/xml/revanced_prefs.xml +++ b/src/main/resources/youtube/settings/xml/revanced_prefs.xml @@ -139,6 +139,10 @@ SETTINGS: TOOLBAR_COMPONENTS --> +