diff --git a/src/main/kotlin/app/revanced/extensions/Extensions.kt b/src/main/kotlin/app/revanced/extensions/Extensions.kt index dc294e383..dcc7999a4 100644 --- a/src/main/kotlin/app/revanced/extensions/Extensions.kt +++ b/src/main/kotlin/app/revanced/extensions/Extensions.kt @@ -93,9 +93,9 @@ internal fun String.startsWithAny(vararg prefixes: String): Boolean { } internal fun toResult(errorIndex: Int): PatchResult { - if (errorIndex == -1) - return PatchResultSuccess() + return if (errorIndex == -1) + PatchResultSuccess() else - return PatchResultError("Instruction not found: $errorIndex") + PatchResultError("Instruction not found: $errorIndex") } diff --git a/src/main/kotlin/app/revanced/patches/music/layout/branding/icon/patch/CustomBrandingMusicPatch_Blue.kt b/src/main/kotlin/app/revanced/patches/music/layout/branding/icon/patch/CustomBrandingMusicIconBluePatch.kt similarity index 71% rename from src/main/kotlin/app/revanced/patches/music/layout/branding/icon/patch/CustomBrandingMusicPatch_Blue.kt rename to src/main/kotlin/app/revanced/patches/music/layout/branding/icon/patch/CustomBrandingMusicIconBluePatch.kt index 40398d25f..59b380a3c 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/branding/icon/patch/CustomBrandingMusicPatch_Blue.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/branding/icon/patch/CustomBrandingMusicIconBluePatch.kt @@ -7,18 +7,19 @@ import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.* import app.revanced.patcher.patch.annotations.Patch import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility -import app.revanced.util.resources.IconHelper +import app.revanced.util.resources.IconHelper.customIconMusic +import app.revanced.util.resources.IconHelper.customIconMusicAdditional @Patch @Name("custom-branding-music-afn-blue") @Description("Changes the YouTube Music launcher icon (Afn / Blue).") @YouTubeMusicCompatibility @Version("0.0.1") -class CustomBrandingMusicPatch_Blue : ResourcePatch { +class CustomBrandingMusicIconBluePatch : ResourcePatch { override fun execute(context: ResourceContext): PatchResult { - IconHelper.customIconMusic(context, "blue") - IconHelper.customIconMusicAdditional(context, "blue") + context.customIconMusic("blue") + context.customIconMusicAdditional("blue") return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/music/layout/branding/icon/patch/CustomBrandingMusicPatch_Red.kt b/src/main/kotlin/app/revanced/patches/music/layout/branding/icon/patch/CustomBrandingMusicIconRedPatch.kt similarity index 71% rename from src/main/kotlin/app/revanced/patches/music/layout/branding/icon/patch/CustomBrandingMusicPatch_Red.kt rename to src/main/kotlin/app/revanced/patches/music/layout/branding/icon/patch/CustomBrandingMusicIconRedPatch.kt index 968c799e6..521d03088 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/branding/icon/patch/CustomBrandingMusicPatch_Red.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/branding/icon/patch/CustomBrandingMusicIconRedPatch.kt @@ -7,18 +7,19 @@ import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.* import app.revanced.patcher.patch.annotations.Patch import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility -import app.revanced.util.resources.IconHelper +import app.revanced.util.resources.IconHelper.customIconMusic +import app.revanced.util.resources.IconHelper.customIconMusicAdditional @Patch @Name("custom-branding-music-afn-red") @Description("Changes the YouTube Music launcher icon (Afn / Red).") @YouTubeMusicCompatibility @Version("0.0.1") -class CustomBrandingMusicPatch_Red : ResourcePatch { +class CustomBrandingMusicIconRedPatch : ResourcePatch { override fun execute(context: ResourceContext): PatchResult { - IconHelper.customIconMusic(context, "red") - IconHelper.customIconMusicAdditional(context, "red") + context.customIconMusic("red") + context.customIconMusicAdditional("red") return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/music/layout/branding/icon/patch/CustomBrandingMusicPatch_Revancify.kt b/src/main/kotlin/app/revanced/patches/music/layout/branding/icon/patch/CustomBrandingMusicIconRevancifyPatch.kt similarity index 80% rename from src/main/kotlin/app/revanced/patches/music/layout/branding/icon/patch/CustomBrandingMusicPatch_Revancify.kt rename to src/main/kotlin/app/revanced/patches/music/layout/branding/icon/patch/CustomBrandingMusicIconRevancifyPatch.kt index a4869e5c5..8f9c3c8b4 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/branding/icon/patch/CustomBrandingMusicPatch_Revancify.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/branding/icon/patch/CustomBrandingMusicIconRevancifyPatch.kt @@ -7,17 +7,17 @@ import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.* import app.revanced.patcher.patch.annotations.Patch import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility -import app.revanced.util.resources.IconHelper +import app.revanced.util.resources.IconHelper.customIconMusic @Patch(false) @Name("custom-branding-music-revancify") @Description("Changes the YouTube Music launcher icon to your choice (Revancify).") @YouTubeMusicCompatibility @Version("0.0.1") -class CustomBrandingMusicPatch_Revancify : ResourcePatch { +class CustomBrandingMusicIconRevancifyPatch : ResourcePatch { override fun execute(context: ResourceContext): PatchResult { - IconHelper.customIconMusic(context, "revancify") + context.customIconMusic("revancify") return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/music/misc/microg/bytecode/patch/MusicMicroGBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/music/misc/microg/bytecode/patch/MusicMicroGBytecodePatch.kt index a32e25716..e9986cf98 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/microg/bytecode/patch/MusicMicroGBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/microg/bytecode/patch/MusicMicroGBytecodePatch.kt @@ -48,8 +48,8 @@ class MusicMicroGBytecodePatch : BytecodePatch( // - "com.google.android.gms.phenotype.UPDATE", // - "com.google.android.gms.phenotype", override fun execute(context: BytecodeContext): PatchResult { - val YouTubePackageName = PatchOptions.YouTube_PackageName - val MusicPackageName = PatchOptions.Music_PackageName + val packageNameYouTube = PatchOptions.YouTubePackageName!! + val packageNameMusic = PatchOptions.MusicPackageName!! // apply common microG patch MicroGBytecodeHelper.patchBytecode( @@ -57,13 +57,13 @@ class MusicMicroGBytecodePatch : BytecodePatch( arrayOf( MicroGBytecodeHelper.packageNameTransform( YOUTUBE_PACKAGE_NAME, - "$YouTubePackageName" + packageNameYouTube ) ), MicroGBytecodeHelper.PrimeMethodTransformationData( PrimeFingerprint, MUSIC_PACKAGE_NAME, - "$MusicPackageName" + packageNameMusic ), listOf( ServiceCheckFingerprint, diff --git a/src/main/kotlin/app/revanced/patches/music/misc/microg/resource/patch/MusicMicroGResourcePatch.kt b/src/main/kotlin/app/revanced/patches/music/misc/microg/resource/patch/MusicMicroGResourcePatch.kt index 478bd0772..8eff0fb9d 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/microg/resource/patch/MusicMicroGResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/microg/resource/patch/MusicMicroGResourcePatch.kt @@ -13,8 +13,8 @@ import app.revanced.patches.music.misc.microg.shared.Constants.SPOOFED_PACKAGE_N import app.revanced.patches.music.misc.microg.shared.Constants.SPOOFED_PACKAGE_SIGNATURE import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.patches.shared.patch.options.PatchOptions -import app.revanced.util.microg.MicroGManifestHelper -import app.revanced.util.microg.MicroGResourceHelper +import app.revanced.util.microg.MicroGManifestHelper.addSpoofingMetadata +import app.revanced.util.microg.MicroGResourceHelper.patchManifest @Name("music-microg-resource-patch") @Description("Resource patch to allow YouTube Music ReVanced to run without root and under a different package name.") @@ -27,18 +27,16 @@ import app.revanced.util.microg.MicroGResourceHelper @Version("0.0.2") class MusicMicroGResourcePatch : ResourcePatch { override fun execute(context: ResourceContext): PatchResult { - val MusicPackageName = PatchOptions.Music_PackageName + val packageNameMusic = PatchOptions.MusicPackageName!! // update manifest - MicroGResourceHelper.patchManifest( - context, + context.patchManifest( MUSIC_PACKAGE_NAME, - "$MusicPackageName" + packageNameMusic ) // add metadata to the manifest - MicroGManifestHelper.addSpoofingMetadata( - context, + context.addSpoofingMetadata( SPOOFED_PACKAGE_NAME, SPOOFED_PACKAGE_SIGNATURE ) diff --git a/src/main/kotlin/app/revanced/patches/music/misc/translations/patch/MusicTranslationsPatch.kt b/src/main/kotlin/app/revanced/patches/music/misc/translations/patch/MusicTranslationsPatch.kt index f0182fe6c..cef024b3a 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/translations/patch/MusicTranslationsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/translations/patch/MusicTranslationsPatch.kt @@ -11,18 +11,18 @@ import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patches.music.misc.settings.patch.MusicSettingsPatch import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility -import app.revanced.util.resources.ResourceHelper +import app.revanced.util.resources.ResourceHelper.addTranslations @Patch @Name("translations-music") -@Description("Add Crowdin Translations for YouTube Music") +@Description("Add Crowdin translations for YouTube Music.") @DependsOn([MusicSettingsPatch::class]) @YouTubeMusicCompatibility @Version("0.0.1") class MusicTranslationsPatch : ResourcePatch { override fun execute(context: ResourceContext): PatchResult { - ResourceHelper.addTranslations(context, "music", LANGUAGE_LIST) + context.addTranslations("music", LANGUAGE_LIST) return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/shared/patch/options/PatchOptions.kt b/src/main/kotlin/app/revanced/patches/shared/patch/options/PatchOptions.kt index f9d804e68..9d0858224 100644 --- a/src/main/kotlin/app/revanced/patches/shared/patch/options/PatchOptions.kt +++ b/src/main/kotlin/app/revanced/patches/shared/patch/options/PatchOptions.kt @@ -27,39 +27,36 @@ class PatchOptions : ResourcePatch { /* * Custom Branding Name */ - internal var YouTube_AppName: String? by option( + internal var YouTubeAppName: String? by option( PatchOption.StringOption( - key = "YouTube_AppName", + key = "YouTubeAppName", default = "ReVanced Extended", title = "Application Name of YouTube", - description = "The name of the YouTube it will show on your home screen.", - required = true + description = "The name of the YouTube it will show on your home screen." ) ) /* * Custom Package Name (YouTube) */ - internal var YouTube_PackageName: String? by option( + internal var YouTubePackageName: String? by option( PatchOption.StringOption( - key = "YouTube_PackageName", + key = "YouTubePackageName", default = "app.rvx.android.youtube", title = "Package Name of YouTube", - description = "The package name of the YouTube. (NON-ROOT user only)", - required = true + description = "The package name of the YouTube. (NON-ROOT user only)" ) ) /* * Custom Package Name (YouTube Music) */ - internal var Music_PackageName: String? by option( + internal var MusicPackageName: String? by option( PatchOption.StringOption( - key = "Music_PackageName", + key = "MusicPackageName", default = "app.rvx.android.apps.youtube.music", title = "Package Name of YouTube Music", - description = "The package name of the YouTube Music. (NON-ROOT user only)", - required = true + description = "The package name of the YouTube Music. (NON-ROOT user only)" ) ) @@ -68,24 +65,22 @@ class PatchOptions : ResourcePatch { */ internal var CustomSpeedArrays: String? by option( PatchOption.StringOption( - key = "Custom_Speed_Arrays", + key = "CustomSpeedArrays", default = "0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0, 2.25, 2.5, 3.0, 5.0", title = "Custom Speed Values", - description = "A list of custom video speeds. Be sure to separate them with commas (,).", - required = true + description = "A list of custom video speeds. Be sure to separate them with commas (,)." ) ) /* * Overlay Buttons Icon */ - internal var Overlay_Buttons_Icon: String? by option( + internal var OverlayButtonsIcon: String? by option( PatchOption.StringOption( - key = "Overlay_Buttons_Icon", + key = "OverlayButtonsIcon", default = "new", title = "Overlay button icon selection", - description = "Choose an overlay buttons icon (old/new)", - required = true + description = "Choose an overlay buttons icon: old/new" ) ) @@ -97,8 +92,7 @@ class PatchOptions : ResourcePatch { key = "darkThemeBackgroundColor", default = "@android:color/black", title = "Background color for the dark theme", - description = "The background color of the dark theme. Can be a hex color or a resource reference.", - required = true + description = "The background color of the dark theme. Can be a hex color or a resource reference." ) ) diff --git a/src/main/kotlin/app/revanced/patches/shared/patch/settings/AbstractSettingsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/shared/patch/settings/AbstractSettingsResourcePatch.kt index 1c392b57d..5e74bbec1 100644 --- a/src/main/kotlin/app/revanced/patches/shared/patch/settings/AbstractSettingsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/patch/settings/AbstractSettingsResourcePatch.kt @@ -40,7 +40,6 @@ abstract class AbstractSettingsResourcePatch( /* initialize ReVanced Settings */ if (isYouTube == true) { context.copyResources(sourceDirectory, ResourceUtils.ResourceGroup("xml", "revanced_prefs.xml")) - ResourceHelper.initReVancedSettings(context) } return PatchResultSuccess() diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/doublebacktoclose/fingerprint/OnBackPressedFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/ads/doublebacktoclose/fingerprint/OnBackPressedFingerprint.kt similarity index 83% rename from src/main/kotlin/app/revanced/patches/youtube/misc/doublebacktoclose/fingerprint/OnBackPressedFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/ads/doublebacktoclose/fingerprint/OnBackPressedFingerprint.kt index 6b2b7e4e4..576bcbc01 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/doublebacktoclose/fingerprint/OnBackPressedFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ads/doublebacktoclose/fingerprint/OnBackPressedFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.doublebacktoclose.fingerprint +package app.revanced.patches.youtube.ads.doublebacktoclose.fingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.Opcode diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/doublebacktoclose/fingerprint/ScrollPositionFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/ads/doublebacktoclose/fingerprint/ScrollPositionFingerprint.kt similarity index 87% rename from src/main/kotlin/app/revanced/patches/youtube/misc/doublebacktoclose/fingerprint/ScrollPositionFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/ads/doublebacktoclose/fingerprint/ScrollPositionFingerprint.kt index 6a02800f5..3f19acd84 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/doublebacktoclose/fingerprint/ScrollPositionFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ads/doublebacktoclose/fingerprint/ScrollPositionFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.doublebacktoclose.fingerprint +package app.revanced.patches.youtube.ads.doublebacktoclose.fingerprint import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/doublebacktoclose/fingerprint/ScrollTopFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/ads/doublebacktoclose/fingerprint/ScrollTopFingerprint.kt similarity index 87% rename from src/main/kotlin/app/revanced/patches/youtube/misc/doublebacktoclose/fingerprint/ScrollTopFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/ads/doublebacktoclose/fingerprint/ScrollTopFingerprint.kt index 4af17a7c5..8abb9c2eb 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/doublebacktoclose/fingerprint/ScrollTopFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ads/doublebacktoclose/fingerprint/ScrollTopFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.doublebacktoclose.fingerprint +package app.revanced.patches.youtube.ads.doublebacktoclose.fingerprint import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/doublebacktoclose/fingerprint/ScrollTopParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/ads/doublebacktoclose/fingerprint/ScrollTopParentFingerprint.kt similarity index 90% rename from src/main/kotlin/app/revanced/patches/youtube/misc/doublebacktoclose/fingerprint/ScrollTopParentFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/ads/doublebacktoclose/fingerprint/ScrollTopParentFingerprint.kt index faafb6de2..08e3d7d90 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/doublebacktoclose/fingerprint/ScrollTopParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ads/doublebacktoclose/fingerprint/ScrollTopParentFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.doublebacktoclose.fingerprint +package app.revanced.patches.youtube.ads.doublebacktoclose.fingerprint import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/doublebacktoclose/patch/DoubleBackToClosePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/ads/doublebacktoclose/patch/DoubleBackToClosePatch.kt similarity index 93% rename from src/main/kotlin/app/revanced/patches/youtube/misc/doublebacktoclose/patch/DoubleBackToClosePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/ads/doublebacktoclose/patch/DoubleBackToClosePatch.kt index 727cad384..01ce6e816 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/doublebacktoclose/patch/DoubleBackToClosePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ads/doublebacktoclose/patch/DoubleBackToClosePatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.doublebacktoclose.patch +package app.revanced.patches.youtube.ads.doublebacktoclose.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Name @@ -13,8 +13,8 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.shared.patch.gestures.PredictiveBackGesturePatch -import app.revanced.patches.youtube.misc.doublebacktoclose.fingerprint.* +import app.revanced.patches.youtube.ads.gestures.PredictiveBackGesturePatch +import app.revanced.patches.youtube.ads.doublebacktoclose.fingerprint.* import app.revanced.util.integrations.Constants.UTILS_PATH @Name("double-back-to-close") diff --git a/src/main/kotlin/app/revanced/patches/youtube/ads/general/bytecode/patch/GeneralAdsBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/ads/general/bytecode/patch/GeneralAdsBytecodePatch.kt index ac09993dc..dac9378f0 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ads/general/bytecode/patch/GeneralAdsBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ads/general/bytecode/patch/GeneralAdsBytecodePatch.kt @@ -17,7 +17,7 @@ import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.shared.patch.mapping.ResourceMappingPatch import app.revanced.patches.youtube.ads.general.bytecode.fingerprints.ComponentContextParserFingerprint import app.revanced.patches.youtube.ads.general.bytecode.fingerprints.EmptyComponentBuilderFingerprint -import app.revanced.util.bytecode.BytecodeHelper +import app.revanced.util.bytecode.BytecodeHelper.updatePatchStatus import app.revanced.util.integrations.Constants.ADS_PATH import org.jf.dexlib2.Opcode import org.jf.dexlib2.builder.instruction.BuilderInstruction21s @@ -79,7 +79,7 @@ class GeneralAdsBytecodePatch : BytecodePatch( } } ?: return ComponentContextParserFingerprint.toErrorResult() - BytecodeHelper.patchStatus(context, "GeneralAds") + context.updatePatchStatus("GeneralAds") return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/youtube/ads/general/resource/patch/GeneralAdsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/ads/general/resource/patch/GeneralAdsPatch.kt index 80f344c06..31a620fb1 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ads/general/resource/patch/GeneralAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ads/general/resource/patch/GeneralAdsPatch.kt @@ -14,9 +14,8 @@ import app.revanced.patcher.patch.annotations.Patch import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.youtube.ads.general.bytecode.patch.GeneralAdsBytecodePatch import app.revanced.patches.youtube.ads.general.bytecode.patch.GeneralAdsSecondaryBytecodePatch -import app.revanced.patches.youtube.misc.litho.filter.patch.LithoFilterPatch +import app.revanced.patches.youtube.misc.litho.patch.LithoFilterPatch import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper import org.w3c.dom.Element @Patch @@ -88,33 +87,22 @@ class GeneralAdsPatch : ResourcePatch { /* add settings */ - ResourceHelper.addSettings( - context, - "PREFERENCE_CATEGORY: REVANCED_SETTINGS", - "PREFERENCE: ADS_SETTINGS", - "SETTINGS: HIDE_GENERAL_ADS" + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: ADS_SETTINGS", + "SETTINGS: HIDE_GENERAL_ADS", + + "PREFERENCE: LAYOUT_SETTINGS", + "PREFERENCE_HEADER: GENERAL", + "SETTINGS: HIDE_GENERAL_LAYOUT_ADS", + + "PREFERENCE: LAYOUT_SETTINGS", + "PREFERENCE_HEADER: PLAYER", + "SETTINGS: HIDE_VIEW_PRODUCT" + ) ) - ResourceHelper.addSettings2( - context, - "PREFERENCE_CATEGORY: REVANCED_SETTINGS", - "PREFERENCE: LAYOUT_SETTINGS", - "PREFERENCE_HEADER: GENERAL", - "SETTINGS: HIDE_GENERAL_LAYOUT_ADS" - ) - - ResourceHelper.addSettings2( - context, - "PREFERENCE_CATEGORY: REVANCED_SETTINGS", - "PREFERENCE: LAYOUT_SETTINGS", - "PREFERENCE_HEADER: PLAYER", - "SETTINGS: HIDE_VIEW_PRODUCT" - ) - - ResourceHelper.patchSuccess( - context, - "hide-general-ads" - ) + SettingsPatch.updatePatchStatus("hide-general-ads") return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/shared/patch/gestures/PredictiveBackGesturePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/ads/gestures/PredictiveBackGesturePatch.kt similarity index 95% rename from src/main/kotlin/app/revanced/patches/shared/patch/gestures/PredictiveBackGesturePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/ads/gestures/PredictiveBackGesturePatch.kt index 0f67fe4fb..4a8d11809 100644 --- a/src/main/kotlin/app/revanced/patches/shared/patch/gestures/PredictiveBackGesturePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ads/gestures/PredictiveBackGesturePatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.patch.gestures +package app.revanced.patches.youtube.ads.gestures import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/swiperefresh/fingerprint/SwipeRefreshLayoutFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/ads/swiperefresh/fingerprint/SwipeRefreshLayoutFingerprint.kt similarity index 89% rename from src/main/kotlin/app/revanced/patches/youtube/misc/swiperefresh/fingerprint/SwipeRefreshLayoutFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/ads/swiperefresh/fingerprint/SwipeRefreshLayoutFingerprint.kt index cdf53c691..3a280d005 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/swiperefresh/fingerprint/SwipeRefreshLayoutFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ads/swiperefresh/fingerprint/SwipeRefreshLayoutFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.swiperefresh.fingerprint +package app.revanced.patches.youtube.ads.swiperefresh.fingerprint import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/swiperefresh/patch/SwipeRefreshPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/ads/swiperefresh/patch/SwipeRefreshPatch.kt similarity index 89% rename from src/main/kotlin/app/revanced/patches/youtube/misc/swiperefresh/patch/SwipeRefreshPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/ads/swiperefresh/patch/SwipeRefreshPatch.kt index 4c3789024..0733ca8fb 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/swiperefresh/patch/SwipeRefreshPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ads/swiperefresh/patch/SwipeRefreshPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.swiperefresh.patch +package app.revanced.patches.youtube.ads.swiperefresh.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name @@ -9,7 +9,7 @@ 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.patches.youtube.misc.swiperefresh.fingerprint.SwipeRefreshLayoutFingerprint +import app.revanced.patches.youtube.ads.swiperefresh.fingerprint.SwipeRefreshLayoutFingerprint import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.extensions.toErrorResult import org.jf.dexlib2.iface.instruction.OneRegisterInstruction diff --git a/src/main/kotlin/app/revanced/patches/youtube/ads/video/bytecode/patch/VideoAdsBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/ads/video/patch/VideoAdsPatch.kt similarity index 55% rename from src/main/kotlin/app/revanced/patches/youtube/ads/video/bytecode/patch/VideoAdsBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/ads/video/patch/VideoAdsPatch.kt index 0845b2dd0..ba8aa839c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ads/video/bytecode/patch/VideoAdsBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ads/video/patch/VideoAdsPatch.kt @@ -1,5 +1,6 @@ -package app.revanced.patches.youtube.ads.video.bytecode.patch +package app.revanced.patches.youtube.ads.video.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 @@ -7,26 +8,44 @@ 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.patch.videoads.GeneralVideoAdsPatch -import app.revanced.util.bytecode.BytecodeHelper +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +import app.revanced.util.bytecode.BytecodeHelper.updatePatchStatus import app.revanced.util.integrations.Constants.ADS_PATH +@Patch +@Name("hide-video-ads") +@Description("Removes ads in the video player.") @DependsOn( [ - GeneralVideoAdsPatch::class + GeneralVideoAdsPatch::class, + SettingsPatch::class ] ) -@Name("hide-video-ads-bytecode-patch") @YouTubeCompatibility @Version("0.0.1") -class VideoAdsBytecodePatch : BytecodePatch() { +class VideoAdsPatch : BytecodePatch() { override fun execute(context: BytecodeContext): PatchResult { GeneralVideoAdsPatch.injectLegacyAds(INTEGRATIONS_CLASS_DESCRIPTOR) GeneralVideoAdsPatch.injectMainstreamAds(INTEGRATIONS_CLASS_DESCRIPTOR) - BytecodeHelper.patchStatus(context, "VideoAds") + context.updatePatchStatus("VideoAds") + + /* + add settings + */ + + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: ADS_SETTINGS", + "SETTINGS: HIDE_VIDEO_ADS" + ) + ) + + SettingsPatch.updatePatchStatus("hide-video-ads") return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/youtube/ads/video/resource/patch/VideoAdsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/ads/video/resource/patch/VideoAdsPatch.kt deleted file mode 100644 index 2b2f08f86..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/ads/video/resource/patch/VideoAdsPatch.kt +++ /dev/null @@ -1,48 +0,0 @@ -package app.revanced.patches.youtube.ads.video.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.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -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.ads.video.bytecode.patch.VideoAdsBytecodePatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper - -@Patch -@Name("hide-video-ads") -@Description("Removes ads in the video player.") -@DependsOn( - [ - VideoAdsBytecodePatch::class, - SettingsPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class VideoAdsPatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - /* - add settings - */ - ResourceHelper.addSettings( - context, - "PREFERENCE_CATEGORY: REVANCED_SETTINGS", - "PREFERENCE: ADS_SETTINGS", - "SETTINGS: HIDE_VIDEO_ADS" - ) - - ResourceHelper.patchSuccess( - context, - "hide-video-ads" - ) - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/button/overlaybuttons/resource/patch/OverlayButtonsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/button/overlaybuttons/resource/patch/OverlayButtonsPatch.kt index ed045eea9..f166ee0ef 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/button/overlaybuttons/resource/patch/OverlayButtonsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/button/overlaybuttons/resource/patch/OverlayButtonsPatch.kt @@ -15,7 +15,6 @@ import app.revanced.patches.youtube.button.autorepeat.patch.AutoRepeatPatch import app.revanced.patches.youtube.button.overlaybuttons.bytecode.patch.OverlayButtonsBytecodePatch import app.revanced.patches.youtube.button.whitelist.patch.WhitelistPatch import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper import app.revanced.util.resources.ResourceUtils import app.revanced.util.resources.ResourceUtils.copyResources import app.revanced.util.resources.ResourceUtils.copyXmlNode @@ -37,7 +36,14 @@ import app.revanced.util.resources.ResourceUtils.copyXmlNode class OverlayButtonsResourcePatch : ResourcePatch { override fun execute(context: ResourceContext): PatchResult { - val icon = PatchOptions.Overlay_Buttons_Icon + val icon = PatchOptions.OverlayButtonsIcon!! + + /* + * Copy arrays + */ + + context.copyXmlNode("youtube/overlaybuttons/host", "values/arrays.xml", "resources") + /* * Copy resources @@ -105,17 +111,14 @@ class OverlayButtonsResourcePatch : ResourcePatch { /* add settings */ - ResourceHelper.addSettings( - context, - "PREFERENCE_CATEGORY: REVANCED_EXTENDED_SETTINGS", - "PREFERENCE: OVERLAY_BUTTONS", - "SETTINGS: OVERLAY_BUTTONS" + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: OVERLAY_BUTTONS", + "SETTINGS: OVERLAY_BUTTONS" + ) ) - ResourceHelper.patchSuccess( - context, - "overlay-buttons" - ) + SettingsPatch.updatePatchStatus("overlay-buttons") return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/youtube/extended/forcevp9/resource/patch/ForceVP9CodecPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/extended/forcevp9/resource/patch/ForceVP9CodecPatch.kt deleted file mode 100644 index 9aeb4d6f6..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/extended/forcevp9/resource/patch/ForceVP9CodecPatch.kt +++ /dev/null @@ -1,49 +0,0 @@ -package app.revanced.patches.youtube.extended.forcevp9.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.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -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.extended.forcevp9.bytecode.patch.ForceVP9CodecBytecodePatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper - -@Patch -@Name("force-vp9-codec") -@Description("Forces the VP9 codec for videos.") -@DependsOn( - [ - ForceVP9CodecBytecodePatch::class, - SettingsPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class ForceVP9CodecPatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - /* - add settings - */ - ResourceHelper.addSettings2( - context, - "PREFERENCE_CATEGORY: REVANCED_EXTENDED_SETTINGS", - "PREFERENCE: EXTENDED_SETTINGS", - "SETTINGS: EXPERIMENTAL_FLAGS", - "SETTINGS: ENABLE_VP9_CODEC" - ) - - ResourceHelper.patchSuccess( - context, - "force-vp9-codec" - ) - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/extended/layoutswitch/resource/patch/LayoutSwitchPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/extended/layoutswitch/resource/patch/LayoutSwitchPatch.kt deleted file mode 100644 index adfeec4c2..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/extended/layoutswitch/resource/patch/LayoutSwitchPatch.kt +++ /dev/null @@ -1,49 +0,0 @@ -package app.revanced.patches.youtube.extended.layoutswitch.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.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -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.extended.layoutswitch.bytecode.patch.LayoutSwitchBytecodePatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper - -@Patch -@Name("layout-switch") -@Description("Tricks the dpi to use some tablet/phone layouts.") -@DependsOn( - [ - LayoutSwitchBytecodePatch::class, - SettingsPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class LayoutSwitchPatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - /* - add settings - */ - ResourceHelper.addSettings2( - context, - "PREFERENCE_CATEGORY: REVANCED_EXTENDED_SETTINGS", - "PREFERENCE: EXTENDED_SETTINGS", - "SETTINGS: EXPERIMENTAL_FLAGS", - "SETTINGS: LAYOUT_SWITCH" - ) - - ResourceHelper.patchSuccess( - context, - "layout-switch" - ) - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/extended/oldlayout/resource/patch/OldLayoutPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/extended/oldlayout/resource/patch/OldLayoutPatch.kt deleted file mode 100644 index b692b39c2..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/extended/oldlayout/resource/patch/OldLayoutPatch.kt +++ /dev/null @@ -1,49 +0,0 @@ -package app.revanced.patches.youtube.extended.oldlayout.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.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -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.extended.oldlayout.bytecode.patch.OldLayoutBytecodePatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper - -@Patch -@Name("enable-old-layout") -@Description("Spoof the YouTube client version to use the old layout.") -@DependsOn( - [ - OldLayoutBytecodePatch::class, - SettingsPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class OldLayoutPatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - /* - add settings - */ - ResourceHelper.addSettings2( - context, - "PREFERENCE_CATEGORY: REVANCED_EXTENDED_SETTINGS", - "PREFERENCE: EXTENDED_SETTINGS", - "SETTINGS: EXPERIMENTAL_FLAGS", - "SETTINGS: ENABLE_OLD_LAYOUT" - ) - - ResourceHelper.patchSuccess( - context, - "enable-old-layout" - ) - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttomplayer/buttoncontainer/patch/ButtonContainerPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttomplayer/buttoncontainer/patch/ButtonContainerPatch.kt index d27ffc8ef..923c807f5 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttomplayer/buttoncontainer/patch/ButtonContainerPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttomplayer/buttoncontainer/patch/ButtonContainerPatch.kt @@ -10,9 +10,8 @@ import app.revanced.patcher.patch.ResourcePatch 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.litho.filter.patch.LithoFilterPatch +import app.revanced.patches.youtube.misc.litho.patch.LithoFilterPatch import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper @Patch @Name("hide-button-container") @@ -31,18 +30,15 @@ class ButtonContainerPatch : ResourcePatch { /* add settings */ - ResourceHelper.addSettings2( - context, - "PREFERENCE_CATEGORY: REVANCED_SETTINGS", - "PREFERENCE: LAYOUT_SETTINGS", - "PREFERENCE_HEADER: BOTTOM_PLAYER", - "SETTINGS: BUTTON_CONTAINER" + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: LAYOUT_SETTINGS", + "PREFERENCE_HEADER: BOTTOM_PLAYER", + "SETTINGS: BUTTON_CONTAINER" + ) ) - ResourceHelper.patchSuccess( - context, - "hide-button-container" - ) + SettingsPatch.updatePatchStatus("hide-button-container") return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttomplayer/comment/patch/CommentComponentPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttomplayer/comment/patch/CommentComponentPatch.kt index e12e054da..1460f85c6 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttomplayer/comment/patch/CommentComponentPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttomplayer/comment/patch/CommentComponentPatch.kt @@ -12,7 +12,6 @@ import app.revanced.patcher.patch.annotations.Patch import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.youtube.ads.general.bytecode.patch.GeneralAdsBytecodePatch import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper @Patch @Name("hide-comment-component") @@ -31,18 +30,15 @@ class CommentComponentPatch : ResourcePatch { /* add settings */ - ResourceHelper.addSettings2( - context, - "PREFERENCE_CATEGORY: REVANCED_SETTINGS", - "PREFERENCE: LAYOUT_SETTINGS", - "PREFERENCE_HEADER: BOTTOM_PLAYER", - "SETTINGS: COMMENT_COMPONENT" + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: LAYOUT_SETTINGS", + "PREFERENCE_HEADER: BOTTOM_PLAYER", + "SETTINGS: COMMENT_COMPONENT" + ) ) - ResourceHelper.patchSuccess( - context, - "hide-comment-component" - ) + SettingsPatch.updatePatchStatus("hide-comment-component") return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/branding/icon/patch/CustomBrandingPatch_Blue.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/etc/branding/icon/patch/CustomBrandingIconBluePatch.kt similarity index 70% rename from src/main/kotlin/app/revanced/patches/youtube/misc/branding/icon/patch/CustomBrandingPatch_Blue.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/etc/branding/icon/patch/CustomBrandingIconBluePatch.kt index c8fb96290..df9629183 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/branding/icon/patch/CustomBrandingPatch_Blue.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/etc/branding/icon/patch/CustomBrandingIconBluePatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.branding.icon.patch +package app.revanced.patches.youtube.layout.etc.branding.icon.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name @@ -11,8 +11,8 @@ 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.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.IconHelper -import app.revanced.util.resources.ResourceHelper +import app.revanced.util.resources.IconHelper.customIcon +import app.revanced.util.resources.ResourceHelper.updatePatchStatusIcon @Patch(false) @Name("custom-branding-icon-afn-blue") @@ -20,18 +20,11 @@ import app.revanced.util.resources.ResourceHelper @DependsOn([SettingsPatch::class]) @YouTubeCompatibility @Version("0.0.1") -class CustomBrandingPatch_Blue : ResourcePatch { +class CustomBrandingIconBluePatch : ResourcePatch { override fun execute(context: ResourceContext): PatchResult { - IconHelper.customIcon( - context, - "blue" - ) - - ResourceHelper.iconPatchSuccess( - context, - "blue" - ) + context.customIcon("blue") + context.updatePatchStatusIcon("blue") return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/branding/icon/patch/CustomBrandingPatch_Red.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/etc/branding/icon/patch/CustomBrandingIconRedPatch.kt similarity index 70% rename from src/main/kotlin/app/revanced/patches/youtube/misc/branding/icon/patch/CustomBrandingPatch_Red.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/etc/branding/icon/patch/CustomBrandingIconRedPatch.kt index fb0e68a6d..7521a4818 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/branding/icon/patch/CustomBrandingPatch_Red.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/etc/branding/icon/patch/CustomBrandingIconRedPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.branding.icon.patch +package app.revanced.patches.youtube.layout.etc.branding.icon.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name @@ -11,8 +11,8 @@ 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.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.IconHelper -import app.revanced.util.resources.ResourceHelper +import app.revanced.util.resources.IconHelper.customIcon +import app.revanced.util.resources.ResourceHelper.updatePatchStatusIcon @Patch @Name("custom-branding-icon-afn-red") @@ -20,18 +20,11 @@ import app.revanced.util.resources.ResourceHelper @DependsOn([SettingsPatch::class]) @YouTubeCompatibility @Version("0.0.1") -class CustomBrandingPatch_Red : ResourcePatch { +class CustomBrandingIconRedPatch : ResourcePatch { override fun execute(context: ResourceContext): PatchResult { - IconHelper.customIcon( - context, - "red" - ) - - ResourceHelper.iconPatchSuccess( - context, - "red" - ) + context.customIcon("red") + context.updatePatchStatusIcon("red") return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/branding/icon/patch/CustomBrandingPatch_Revancify.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/etc/branding/icon/patch/CustomBrandingIconRevancifyPatch.kt similarity index 69% rename from src/main/kotlin/app/revanced/patches/youtube/misc/branding/icon/patch/CustomBrandingPatch_Revancify.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/etc/branding/icon/patch/CustomBrandingIconRevancifyPatch.kt index 1be94811f..be6b927bc 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/branding/icon/patch/CustomBrandingPatch_Revancify.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/etc/branding/icon/patch/CustomBrandingIconRevancifyPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.branding.icon.patch +package app.revanced.patches.youtube.layout.etc.branding.icon.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name @@ -11,8 +11,8 @@ 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.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.IconHelper -import app.revanced.util.resources.ResourceHelper +import app.revanced.util.resources.IconHelper.customIcon +import app.revanced.util.resources.ResourceHelper.updatePatchStatusIcon @Patch(false) @Name("custom-branding-icon-revancify") @@ -20,18 +20,11 @@ import app.revanced.util.resources.ResourceHelper @DependsOn([SettingsPatch::class]) @YouTubeCompatibility @Version("0.0.1") -class CustomBrandingPatch_Revancify : ResourcePatch { +class CustomBrandingIconRevancifyPatch : ResourcePatch { override fun execute(context: ResourceContext): PatchResult { - IconHelper.customIcon( - context, - "revancify" - ) - - ResourceHelper.iconPatchSuccess( - context, - "revancify" - ) + context.customIcon("revancify") + context.updatePatchStatusIcon("revancify") return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/branding/name/patch/CustomBrandingNamePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/etc/branding/name/patch/CustomBrandingNamePatch.kt similarity index 88% rename from src/main/kotlin/app/revanced/patches/youtube/misc/branding/name/patch/CustomBrandingNamePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/etc/branding/name/patch/CustomBrandingNamePatch.kt index 5c68ced34..cc1e09662 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/branding/name/patch/CustomBrandingNamePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/etc/branding/name/patch/CustomBrandingNamePatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.branding.name.patch +package app.revanced.patches.youtube.layout.etc.branding.name.patch import app.revanced.extensions.startsWithAny import app.revanced.patcher.annotation.Description @@ -13,7 +13,7 @@ import app.revanced.patcher.patch.annotations.Patch import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.shared.patch.options.PatchOptions import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper +import app.revanced.util.resources.ResourceHelper.updatePatchStatusLabel import org.w3c.dom.Element @Patch @@ -32,7 +32,7 @@ class CustomBrandingNamePatch : ResourcePatch { // App name val resourceFileNames = arrayOf("strings.xml") - val appName = PatchOptions.YouTube_AppName + val appName = PatchOptions.YouTubeAppName context.forEach { if (!it.name.startsWithAny(*resourceFileNames)) return@forEach @@ -54,10 +54,7 @@ class CustomBrandingNamePatch : ResourcePatch { } } - ResourceHelper.labelPatchSuccess( - context, - "$appName" - ) + context.updatePatchStatusLabel("$appName") return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/forceheader/patch/PremiumHeadingPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/etc/forceheader/patch/PremiumHeadingPatch.kt similarity index 80% rename from src/main/kotlin/app/revanced/patches/youtube/misc/forceheader/patch/PremiumHeadingPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/etc/forceheader/patch/PremiumHeadingPatch.kt index 805cd164c..6ddff8040 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/forceheader/patch/PremiumHeadingPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/etc/forceheader/patch/PremiumHeadingPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.forceheader.patch +package app.revanced.patches.youtube.layout.etc.forceheader.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name @@ -12,7 +12,6 @@ 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.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper import java.nio.file.Files import java.nio.file.StandardCopyOption import kotlin.io.path.exists @@ -51,18 +50,15 @@ class PremiumHeadingPatch : ResourcePatch { prefs.writeText( prefs.readText() .replace( - "", - "" + "HEADER_SWITCH", + "FORCE_PREMIUM_HEADER" ).replace( "header-switch", "force-premium-heading" ) ) - ResourceHelper.patchSuccess( - context, - "force-premium-heading" - ) + SettingsPatch.updatePatchStatus("force-premium-heading") return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/materialyou/patch/MaterialYouPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/etc/materialyou/patch/MaterialYouPatch.kt similarity index 84% rename from src/main/kotlin/app/revanced/patches/youtube/misc/materialyou/patch/MaterialYouPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/etc/materialyou/patch/MaterialYouPatch.kt index e841340a2..3a9d384ef 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/materialyou/patch/MaterialYouPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/etc/materialyou/patch/MaterialYouPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.materialyou.patch +package app.revanced.patches.youtube.layout.etc.materialyou.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name @@ -10,9 +10,10 @@ import app.revanced.patcher.patch.ResourcePatch 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.etc.theme.bytecode.patch.GeneralThemePatch +import app.revanced.patches.youtube.layout.etc.theme.bytecode.patch.GeneralThemePatch.Companion.isMonetPatchIncluded import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.patches.youtube.misc.theme.bytecode.patch.GeneralThemePatch -import app.revanced.util.resources.ResourceHelper +import app.revanced.util.resources.ResourceHelper.updatePatchStatusTheme import app.revanced.util.resources.ResourceUtils.copyXmlNode import java.nio.file.Files import java.nio.file.StandardCopyOption @@ -68,12 +69,9 @@ class MaterialYouPatch : ResourcePatch { /* add settings */ + context.updatePatchStatusTheme("materialyou") - ResourceHelper.themePatchSuccess( - context, - "default", - "materialyou" - ) + isMonetPatchIncluded = true return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/optimize/patch/OptimizeResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/etc/optimize/patch/OptimizeResourcePatch.kt similarity index 82% rename from src/main/kotlin/app/revanced/patches/youtube/misc/optimize/patch/OptimizeResourcePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/etc/optimize/patch/OptimizeResourcePatch.kt index d369d301d..1b86597a8 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/optimize/patch/OptimizeResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/etc/optimize/patch/OptimizeResourcePatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.optimize.patch +package app.revanced.patches.youtube.layout.etc.optimize.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name @@ -11,7 +11,6 @@ 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.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper @Patch @Name("optimize-resource") @@ -27,10 +26,7 @@ import app.revanced.util.resources.ResourceHelper class OptimizeResourcePatch : ResourcePatch { override fun execute(context: ResourceContext): PatchResult { - ResourceHelper.patchSuccess( - context, - "optimize-resource" - ) + SettingsPatch.updatePatchStatus("optimize-resource") return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/optimize/patch/RedundantResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/etc/optimize/patch/RedundantResourcePatch.kt similarity index 99% rename from src/main/kotlin/app/revanced/patches/youtube/misc/optimize/patch/RedundantResourcePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/etc/optimize/patch/RedundantResourcePatch.kt index d85846bea..4357010b9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/optimize/patch/RedundantResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/etc/optimize/patch/RedundantResourcePatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.optimize.patch +package app.revanced.patches.youtube.layout.etc.optimize.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/pipnotification/bytecode/fingerprints/PrimaryPiPFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/etc/pipnotification/fingerprints/PrimaryPiPFingerprint.kt similarity index 88% rename from src/main/kotlin/app/revanced/patches/youtube/misc/pipnotification/bytecode/fingerprints/PrimaryPiPFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/etc/pipnotification/fingerprints/PrimaryPiPFingerprint.kt index 5270ad7cf..35f7c6eae 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/pipnotification/bytecode/fingerprints/PrimaryPiPFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/etc/pipnotification/fingerprints/PrimaryPiPFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.pipnotification.bytecode.fingerprints +package app.revanced.patches.youtube.layout.etc.pipnotification.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/pipnotification/bytecode/fingerprints/SecondaryPiPFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/etc/pipnotification/fingerprints/SecondaryPiPFingerprint.kt similarity index 87% rename from src/main/kotlin/app/revanced/patches/youtube/misc/pipnotification/bytecode/fingerprints/SecondaryPiPFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/etc/pipnotification/fingerprints/SecondaryPiPFingerprint.kt index 07bb53a78..36ae0de0f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/pipnotification/bytecode/fingerprints/SecondaryPiPFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/etc/pipnotification/fingerprints/SecondaryPiPFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.pipnotification.bytecode.fingerprints +package app.revanced.patches.youtube.layout.etc.pipnotification.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/pipnotification/bytecode/patch/PiPNotificationBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/etc/pipnotification/patch/PiPNotificationPatch.kt similarity index 59% rename from src/main/kotlin/app/revanced/patches/youtube/misc/pipnotification/bytecode/patch/PiPNotificationBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/etc/pipnotification/patch/PiPNotificationPatch.kt index 4a0cf15ae..1a1c23dc4 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/pipnotification/bytecode/patch/PiPNotificationBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/etc/pipnotification/patch/PiPNotificationPatch.kt @@ -1,6 +1,7 @@ -package app.revanced.patches.youtube.misc.pipnotification.bytecode.patch +package app.revanced.patches.youtube.layout.etc.pipnotification.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 @@ -8,13 +9,19 @@ import app.revanced.patcher.extensions.addInstruction 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.pipnotification.bytecode.fingerprints.* +import app.revanced.patches.youtube.layout.etc.pipnotification.fingerprints.* +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -@Name("hide-pip-notification-bytecode-patch") +@Patch +@Name("hide-pip-notification") +@Description("Disable pip notification when you first launch pip mode.") +@DependsOn([SettingsPatch::class]) @YouTubeCompatibility @Version("0.0.1") -class PiPNotificationBytecodePatch : BytecodePatch( +class PiPNotificationPatch : BytecodePatch( listOf( PrimaryPiPFingerprint, SecondaryPiPFingerprint @@ -32,6 +39,11 @@ class PiPNotificationBytecodePatch : BytecodePatch( it.mutableMethod.addInstruction(index, "return-void") } + /* + add settings + */ + SettingsPatch.updatePatchStatus("hide-pip-notification") + return PatchResultSuccess() } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/theme/bytecode/fingerprints/LithoThemeFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/etc/theme/bytecode/fingerprints/LithoThemeFingerprint.kt similarity index 87% rename from src/main/kotlin/app/revanced/patches/youtube/misc/theme/bytecode/fingerprints/LithoThemeFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/etc/theme/bytecode/fingerprints/LithoThemeFingerprint.kt index 7fd71fe87..d31904706 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/theme/bytecode/fingerprints/LithoThemeFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/etc/theme/bytecode/fingerprints/LithoThemeFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.theme.bytecode.fingerprints +package app.revanced.patches.youtube.layout.etc.theme.bytecode.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/theme/bytecode/patch/GeneralThemePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/etc/theme/bytecode/patch/GeneralThemePatch.kt similarity index 81% rename from src/main/kotlin/app/revanced/patches/youtube/misc/theme/bytecode/patch/GeneralThemePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/etc/theme/bytecode/patch/GeneralThemePatch.kt index fafcbd5ea..5489222b2 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/theme/bytecode/patch/GeneralThemePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/etc/theme/bytecode/patch/GeneralThemePatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.theme.bytecode.patch +package app.revanced.patches.youtube.layout.etc.theme.bytecode.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Name @@ -10,8 +10,8 @@ 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.youtube.misc.theme.bytecode.fingerprints.LithoThemeFingerprint -import app.revanced.patches.youtube.misc.theme.resource.patch.GeneralThemeResourcePatch +import app.revanced.patches.youtube.layout.etc.theme.bytecode.fingerprints.LithoThemeFingerprint +import app.revanced.patches.youtube.layout.etc.theme.resource.patch.GeneralThemeResourcePatch import app.revanced.util.integrations.Constants.UTILS_PATH import org.jf.dexlib2.iface.instruction.formats.Instruction35c @@ -42,4 +42,7 @@ class GeneralThemePatch : BytecodePatch( return PatchResultSuccess() } + internal companion object { + var isMonetPatchIncluded: Boolean = false + } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/theme/resource/patch/GeneralThemeResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/etc/theme/resource/patch/GeneralThemeResourcePatch.kt similarity index 98% rename from src/main/kotlin/app/revanced/patches/youtube/misc/theme/resource/patch/GeneralThemeResourcePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/etc/theme/resource/patch/GeneralThemeResourcePatch.kt index d856bd609..3582623b5 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/theme/resource/patch/GeneralThemeResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/etc/theme/resource/patch/GeneralThemeResourcePatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.theme.resource.patch +package app.revanced.patches.youtube.layout.etc.theme.resource.patch import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/theme/resource/patch/ThemePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/etc/theme/resource/patch/ThemePatch.kt similarity index 70% rename from src/main/kotlin/app/revanced/patches/youtube/misc/theme/resource/patch/ThemePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/etc/theme/resource/patch/ThemePatch.kt index 8d7fc801a..30539a6d3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/theme/resource/patch/ThemePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/etc/theme/resource/patch/ThemePatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.theme.resource.patch +package app.revanced.patches.youtube.layout.etc.theme.resource.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name @@ -11,9 +11,10 @@ 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.patch.options.PatchOptions +import app.revanced.patches.youtube.layout.etc.theme.bytecode.patch.GeneralThemePatch +import app.revanced.patches.youtube.layout.etc.theme.bytecode.patch.GeneralThemePatch.Companion.isMonetPatchIncluded import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.patches.youtube.misc.theme.bytecode.patch.GeneralThemePatch -import app.revanced.util.resources.ResourceHelper +import app.revanced.util.resources.ResourceHelper.updatePatchStatusTheme import org.w3c.dom.Element @Patch @@ -31,31 +32,19 @@ import org.w3c.dom.Element class ThemePatch : ResourcePatch { override fun execute(context: ResourceContext): PatchResult { - arrayOf("values", "values-v31").forEach { valuesPath -> - setTheme(context, valuesPath) + arrayOf("values", "values-v31").forEach { + context.setTheme(it) } - ResourceHelper.themePatchSuccess( - context, - "default", - "amoled" - ) + val currentTheme = if (isMonetPatchIncluded) "mix" else "amoled" - ResourceHelper.themePatchSuccess( - context, - "materialyou", - "mix" - ) + context.updatePatchStatusTheme(currentTheme) return PatchResultSuccess() } - companion object { - - fun setTheme( - context: ResourceContext, - valuesPath: String - ) { - context.xmlEditor["res/$valuesPath/colors.xml"].use { editor -> + private companion object { + private fun ResourceContext.setTheme(valuesPath: String) { + this.xmlEditor["res/$valuesPath/colors.xml"].use { editor -> val resourcesNode = editor.file.getElementsByTagName("resources").item(0) as Element for (i in 0 until resourcesNode.childNodes.length) { @@ -63,7 +52,7 @@ class ThemePatch : ResourcePatch { node.textContent = when (node.getAttribute("name")) { "yt_black0", "yt_black1", "yt_black1_opacity95", "yt_black1_opacity98", "yt_black2", "yt_black3", - "yt_black4", "yt_status_bar_background_dark", "material_grey_850" -> PatchOptions.darkThemeBackgroundColor + "yt_black4", "yt_status_bar_background_dark", "material_grey_850" -> PatchOptions.darkThemeBackgroundColor!! else -> continue } diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/tooltip/bytecode/fingerprints/TooltipContentViewFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/etc/tooltip/fingerprints/TooltipContentViewFingerprint.kt similarity index 91% rename from src/main/kotlin/app/revanced/patches/youtube/misc/tooltip/bytecode/fingerprints/TooltipContentViewFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/etc/tooltip/fingerprints/TooltipContentViewFingerprint.kt index b7763e575..65587c238 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/tooltip/bytecode/fingerprints/TooltipContentViewFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/etc/tooltip/fingerprints/TooltipContentViewFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.tooltip.bytecode.fingerprints +package app.revanced.patches.youtube.layout.etc.tooltip.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/tooltip/bytecode/patch/TooltipContentViewBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/etc/tooltip/patch/TooltipContentViewPatch.kt similarity index 61% rename from src/main/kotlin/app/revanced/patches/youtube/misc/tooltip/bytecode/patch/TooltipContentViewBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/etc/tooltip/patch/TooltipContentViewPatch.kt index 860e09147..3876388bb 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/tooltip/bytecode/patch/TooltipContentViewBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/etc/tooltip/patch/TooltipContentViewPatch.kt @@ -1,6 +1,7 @@ -package app.revanced.patches.youtube.misc.tooltip.bytecode.patch +package app.revanced.patches.youtube.layout.etc.tooltip.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 @@ -9,12 +10,21 @@ 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.etc.tooltip.fingerprints.TooltipContentViewFingerprint import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourcdIdPatch -import app.revanced.patches.youtube.misc.tooltip.bytecode.fingerprints.TooltipContentViewFingerprint +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -@Name("hide-tooltip-content-bytecode-patch") -@DependsOn([SharedResourcdIdPatch::class]) +@Patch +@Name("hide-tooltip-content") +@Description("Hides the tooltip box that appears on first install.") +@DependsOn( + [ + SettingsPatch::class, + SharedResourcdIdPatch::class + ] +) @YouTubeCompatibility @Version("0.0.1") class TooltipContentViewBytecodePatch : BytecodePatch( @@ -29,6 +39,11 @@ class TooltipContentViewBytecodePatch : BytecodePatch( "return-void" ) ?: return TooltipContentViewFingerprint.toErrorResult() + /* + add settings + */ + SettingsPatch.updatePatchStatus("hide-tooltip-content") + return PatchResultSuccess() } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/flyoutpanel/flyoutpanel/patch/FlyoutPanelPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/flyoutpanel/flyoutpanel/patch/FlyoutPanelPatch.kt index e5fc7e368..5cb27b671 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/flyoutpanel/flyoutpanel/patch/FlyoutPanelPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/flyoutpanel/flyoutpanel/patch/FlyoutPanelPatch.kt @@ -10,9 +10,8 @@ import app.revanced.patcher.patch.ResourcePatch 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.litho.filter.patch.LithoFilterPatch +import app.revanced.patches.youtube.misc.litho.patch.LithoFilterPatch import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper @Patch @Name("hide-flyout-panel") @@ -31,18 +30,15 @@ class FlyoutPanelPatch : ResourcePatch { /* add settings */ - ResourceHelper.addSettings2( - context, - "PREFERENCE_CATEGORY: REVANCED_SETTINGS", - "PREFERENCE: LAYOUT_SETTINGS", - "PREFERENCE_HEADER: FLYOUT_PANEL", - "SETTINGS: FLYOUT_PANEL_COMPONENT" + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: LAYOUT_SETTINGS", + "PREFERENCE_HEADER: FLYOUT_PANEL", + "SETTINGS: FLYOUT_PANEL_COMPONENT" + ) ) - ResourceHelper.patchSuccess( - context, - "hide-flyout-panel" - ) + SettingsPatch.updatePatchStatus("hide-flyout-panel") return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/flyoutpanel/oldqualitylayout/bytecode/fingerprints/QualityMenuViewInflateFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/flyoutpanel/oldqualitylayout/fingerprints/QualityMenuViewInflateFingerprint.kt similarity index 95% rename from src/main/kotlin/app/revanced/patches/youtube/layout/flyoutpanel/oldqualitylayout/bytecode/fingerprints/QualityMenuViewInflateFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/flyoutpanel/oldqualitylayout/fingerprints/QualityMenuViewInflateFingerprint.kt index bfd6753b8..2e80337a8 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/flyoutpanel/oldqualitylayout/bytecode/fingerprints/QualityMenuViewInflateFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/flyoutpanel/oldqualitylayout/fingerprints/QualityMenuViewInflateFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.flyoutpanel.oldqualitylayout.bytecode.fingerprints +package app.revanced.patches.youtube.layout.flyoutpanel.oldqualitylayout.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourcdIdPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/flyoutpanel/oldqualitylayout/bytecode/patch/OldQualityLayoutBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/flyoutpanel/oldqualitylayout/patch/OldQualityLayoutPatch.kt similarity index 64% rename from src/main/kotlin/app/revanced/patches/youtube/layout/flyoutpanel/oldqualitylayout/bytecode/patch/OldQualityLayoutBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/flyoutpanel/oldqualitylayout/patch/OldQualityLayoutPatch.kt index 0c9137b29..f0c44aa62 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/flyoutpanel/oldqualitylayout/bytecode/patch/OldQualityLayoutBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/flyoutpanel/oldqualitylayout/patch/OldQualityLayoutPatch.kt @@ -1,6 +1,7 @@ -package app.revanced.patches.youtube.layout.flyoutpanel.oldqualitylayout.bytecode.patch +package app.revanced.patches.youtube.layout.flyoutpanel.oldqualitylayout.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 @@ -8,15 +9,21 @@ import app.revanced.patcher.extensions.addInstructions 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.flyoutpanel.oldqualitylayout.bytecode.fingerprints.QualityMenuViewInflateFingerprint +import app.revanced.patches.youtube.layout.flyoutpanel.oldqualitylayout.fingerprints.QualityMenuViewInflateFingerprint +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.FLYOUTPANEL_LAYOUT import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction -@Name("enable-old-quality-layout-bytecode-patch") +@Patch +@Name("enable-old-quality-layout") +@Description("Enables the original quality flyout menu.") +@DependsOn([SettingsPatch::class]) @YouTubeCompatibility @Version("0.0.1") -class OldQualityLayoutBytecodePatch : BytecodePatch( +class OldQualityLayoutPatch : BytecodePatch( listOf(QualityMenuViewInflateFingerprint) ) { override fun execute(context: BytecodeContext): PatchResult { @@ -33,6 +40,19 @@ class OldQualityLayoutBytecodePatch : BytecodePatch( } } ?: return QualityMenuViewInflateFingerprint.toErrorResult() + /* + add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: LAYOUT_SETTINGS", + "PREFERENCE_HEADER: FLYOUT_PANEL", + "SETTINGS: ENABLE_OLD_QUALITY_LAYOUT" + ) + ) + + SettingsPatch.updatePatchStatus("enable-old-quality-layout") + return PatchResultSuccess() } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/flyoutpanel/oldqualitylayout/resource/patch/OldQualityLayoutPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/flyoutpanel/oldqualitylayout/resource/patch/OldQualityLayoutPatch.kt deleted file mode 100644 index 36c4e7ce6..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/flyoutpanel/oldqualitylayout/resource/patch/OldQualityLayoutPatch.kt +++ /dev/null @@ -1,49 +0,0 @@ -package app.revanced.patches.youtube.layout.flyoutpanel.oldqualitylayout.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.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -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.flyoutpanel.oldqualitylayout.bytecode.patch.OldQualityLayoutBytecodePatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper - -@Patch -@Name("enable-old-quality-layout") -@Description("Enables the original quality flyout menu.") -@DependsOn( - [ - OldQualityLayoutBytecodePatch::class, - SettingsPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class OldQualityLayoutPatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - /* - add settings - */ - ResourceHelper.addSettings2( - context, - "PREFERENCE_CATEGORY: REVANCED_SETTINGS", - "PREFERENCE: LAYOUT_SETTINGS", - "PREFERENCE_HEADER: FLYOUT_PANEL", - "SETTINGS: ENABLE_OLD_QUALITY_LAYOUT" - ) - - ResourceHelper.patchSuccess( - context, - "enable-old-quality-layout" - ) - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/endscreenoverlay/bytecode/patch/HideEndscreenOverlayBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/endscreenoverlay/patch/HideEndscreenOverlayPatch.kt similarity index 73% rename from src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/endscreenoverlay/bytecode/patch/HideEndscreenOverlayBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/endscreenoverlay/patch/HideEndscreenOverlayPatch.kt index 7cc33651f..ec379a77b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/endscreenoverlay/bytecode/patch/HideEndscreenOverlayBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/endscreenoverlay/patch/HideEndscreenOverlayPatch.kt @@ -1,7 +1,7 @@ -package app.revanced.patches.youtube.layout.fullscreen.endscreenoverlay.bytecode.patch +package app.revanced.patches.youtube.layout.fullscreen.endscreenoverlay.patch import app.revanced.extensions.findMutableMethodOf -import app.revanced.extensions.toResult +import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext @@ -9,19 +9,30 @@ 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.PatchResultError +import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn +import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.shared.patch.mapping.ResourceMappingPatch +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.FULLSCREEN_LAYOUT import org.jf.dexlib2.Opcode import org.jf.dexlib2.iface.instruction.formats.Instruction31i -@Name("hide-endscreen-overlay-bytecode-patch") -@DependsOn([ResourceMappingPatch::class]) +@Patch +@Name("hide-endscreen-overlay") +@Description("Hide endscreen overlay on swipe controls.") +@DependsOn( + [ + ResourceMappingPatch::class, + SettingsPatch::class + ] +) @YouTubeCompatibility @Version("0.0.1") -class HideEndscreenOverlayBytecodePatch : BytecodePatch() { +class HideEndscreenOverlayPatch : BytecodePatch() { // list of resource names to get the id of private val resourceIds = arrayOf( "app_related_endscreen_results" @@ -65,6 +76,25 @@ class HideEndscreenOverlayBytecodePatch : BytecodePatch() { } } } - return toResult(patchSuccessArray.indexOf(false)) + + val errorIndex: Int = patchSuccessArray.indexOf(false) + + if (errorIndex == -1) { + /* + add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: LAYOUT_SETTINGS", + "PREFERENCE_HEADER: FULLSCREEN", + "SETTINGS: HIDE_ENDSCREEN_OVERLAY" + ) + ) + + SettingsPatch.updatePatchStatus("hide-endscreen-overlay") + + return PatchResultSuccess() + } else + return PatchResultError("Instruction not found: $errorIndex") } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/endscreenoverlay/resource/patch/HideEndscreenOverlayPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/endscreenoverlay/resource/patch/HideEndscreenOverlayPatch.kt deleted file mode 100644 index c9c3fb6c7..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/endscreenoverlay/resource/patch/HideEndscreenOverlayPatch.kt +++ /dev/null @@ -1,48 +0,0 @@ -package app.revanced.patches.youtube.layout.fullscreen.endscreenoverlay.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.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -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.fullscreen.endscreenoverlay.bytecode.patch.HideEndscreenOverlayBytecodePatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper - -@Patch -@Name("hide-endscreen-overlay") -@Description("Hide endscreen overlay on swipe controls.") -@DependsOn( - [ - HideEndscreenOverlayBytecodePatch::class, - SettingsPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class HideFilmStripPatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - /* - add settings - */ - ResourceHelper.addSettings2( - context, - "PREFERENCE_CATEGORY: REVANCED_SETTINGS", - "PREFERENCE: LAYOUT_SETTINGS", - "PREFERENCE_HEADER: FULLSCREEN", - "SETTINGS: HIDE_ENDSCREEN_OVERLAY" - ) - - ResourceHelper.patchSuccess( - context, - "hide-endscreen-overlay" - ) - return PatchResultSuccess() - } -} diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/flimstripoverlay/bytecode/fingerprints/ScrubbingLabelFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/flimstripoverlay/fingerprints/ScrubbingLabelFingerprint.kt similarity index 95% rename from src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/flimstripoverlay/bytecode/fingerprints/ScrubbingLabelFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/flimstripoverlay/fingerprints/ScrubbingLabelFingerprint.kt index d555aa00c..35192c158 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/flimstripoverlay/bytecode/fingerprints/ScrubbingLabelFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/flimstripoverlay/fingerprints/ScrubbingLabelFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.fullscreen.flimstripoverlay.bytecode.fingerprints +package app.revanced.patches.youtube.layout.fullscreen.flimstripoverlay.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourcdIdPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/flimstripoverlay/bytecode/patch/HideFilmstripOverlayBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/flimstripoverlay/patch/HideFilmstripOverlayPatch.kt similarity index 73% rename from src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/flimstripoverlay/bytecode/patch/HideFilmstripOverlayBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/flimstripoverlay/patch/HideFilmstripOverlayPatch.kt index fd944f896..bb17bc4cb 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/flimstripoverlay/bytecode/patch/HideFilmstripOverlayBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/flimstripoverlay/patch/HideFilmstripOverlayPatch.kt @@ -1,6 +1,7 @@ -package app.revanced.patches.youtube.layout.fullscreen.flimstripoverlay.bytecode.patch +package app.revanced.patches.youtube.layout.fullscreen.flimstripoverlay.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 @@ -10,18 +11,24 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError 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.fullscreen.flimstripoverlay.bytecode.fingerprints.ScrubbingLabelFingerprint +import app.revanced.patches.youtube.layout.fullscreen.flimstripoverlay.fingerprints.ScrubbingLabelFingerprint +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.FULLSCREEN_LAYOUT import org.jf.dexlib2.Opcode import org.jf.dexlib2.iface.instruction.ReferenceInstruction import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction import org.jf.dexlib2.iface.reference.FieldReference -@Name("hide-filmstrip-overlay-bytecode-patch") +@Patch +@Name("hide-filmstrip-overlay") +@Description("Hide flimstrip overlay on swipe controls.") +@DependsOn([SettingsPatch::class]) @YouTubeCompatibility @Version("0.0.1") -class HideFilmstripOverlayBytecodePatch : BytecodePatch( +class HideFilmstripOverlayPatch : BytecodePatch( listOf( ScrubbingLabelFingerprint ) @@ -49,6 +56,19 @@ class HideFilmstripOverlayBytecodePatch : BytecodePatch( it.removeInstruction(index) + /* + add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: LAYOUT_SETTINGS", + "PREFERENCE_HEADER: FULLSCREEN", + "SETTINGS: HIDE_FILMSTRIP_OVERLAY" + ) + ) + + SettingsPatch.updatePatchStatus("hide-filmstrip-overlay") + return PatchResultSuccess() } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/flimstripoverlay/resource/patch/HideFilmstripOverlayPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/flimstripoverlay/resource/patch/HideFilmstripOverlayPatch.kt deleted file mode 100644 index 736fda328..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/flimstripoverlay/resource/patch/HideFilmstripOverlayPatch.kt +++ /dev/null @@ -1,49 +0,0 @@ -package app.revanced.patches.youtube.layout.fullscreen.flimstripoverlay.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.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -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.fullscreen.flimstripoverlay.bytecode.patch.HideFilmstripOverlayBytecodePatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper - -@Patch -@Name("hide-filmstrip-overlay") -@Description("Hide flimstrip overlay on swipe controls.") -@DependsOn( - [ - HideFilmstripOverlayBytecodePatch::class, - SettingsPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class HideFilmstripOverlayPatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - /* - add settings - */ - ResourceHelper.addSettings2( - context, - "PREFERENCE_CATEGORY: REVANCED_SETTINGS", - "PREFERENCE: LAYOUT_SETTINGS", - "PREFERENCE_HEADER: FULLSCREEN", - "SETTINGS: HIDE_FILMSTRIP_OVERLAY" - ) - - ResourceHelper.patchSuccess( - context, - "hide-filmstrip-overlay" - ) - - return PatchResultSuccess() - } -} diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/fullscreenpanels/bytecode/fingerprints/FullscreenViewAdderFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/fullscreenpanels/fingerprints/FullscreenViewAdderFingerprint.kt similarity index 94% rename from src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/fullscreenpanels/bytecode/fingerprints/FullscreenViewAdderFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/fullscreenpanels/fingerprints/FullscreenViewAdderFingerprint.kt index b85e77666..3ff7790b9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/fullscreenpanels/bytecode/fingerprints/FullscreenViewAdderFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/fullscreenpanels/fingerprints/FullscreenViewAdderFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.fullscreen.fullscreenpanels.bytecode.fingerprints +package app.revanced.patches.youtube.layout.fullscreen.fullscreenpanels.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/fullscreen/fullscreenpanels/bytecode/patch/FullscreenButtonContainerBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/fullscreenpanels/patch/HideFullscreenButtonContainerPatch.kt similarity index 94% rename from src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/fullscreenpanels/bytecode/patch/FullscreenButtonContainerBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/fullscreenpanels/patch/HideFullscreenButtonContainerPatch.kt index 22d12daf0..d2d11fc0c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/fullscreenpanels/bytecode/patch/FullscreenButtonContainerBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/fullscreenpanels/patch/HideFullscreenButtonContainerPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.fullscreen.fullscreenpanels.bytecode.patch +package app.revanced.patches.youtube.layout.fullscreen.fullscreenpanels.patch import app.revanced.extensions.findMutableMethodOf import app.revanced.extensions.injectHideCall @@ -15,11 +15,11 @@ import org.jf.dexlib2.Opcode import org.jf.dexlib2.iface.instruction.formats.Instruction21c import org.jf.dexlib2.iface.instruction.formats.Instruction31i -@Name("hide-fullscreen-buttoncontainer-bytecode-patch") +@Name("hide-fullscreen-buttoncontainer") @DependsOn([ResourceMappingPatch::class]) @YouTubeCompatibility @Version("0.0.1") -class FullscreenButtonContainerBytecodePatch : BytecodePatch() { +class HideFullscreenButtonContainerPatch : BytecodePatch() { private val resourceIds = arrayOf( "quick_actions_element_container" ).map { name -> diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/fullscreenpanels/bytecode/patch/HideFullscreenPanelsBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/fullscreenpanels/patch/HideFullscreenPanelsPatch.kt similarity index 75% rename from src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/fullscreenpanels/bytecode/patch/HideFullscreenPanelsBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/fullscreenpanels/patch/HideFullscreenPanelsPatch.kt index 6369bf921..15db3355b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/fullscreenpanels/bytecode/patch/HideFullscreenPanelsBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/fullscreenpanels/patch/HideFullscreenPanelsPatch.kt @@ -1,6 +1,7 @@ -package app.revanced.patches.youtube.layout.fullscreen.fullscreenpanels.bytecode.patch +package app.revanced.patches.youtube.layout.fullscreen.fullscreenpanels.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 @@ -10,19 +11,30 @@ import app.revanced.patcher.extensions.removeInstruction 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.patcher.util.smali.ExternalLabel import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.shared.fingerprints.LayoutConstructorFingerprint -import app.revanced.patches.youtube.layout.fullscreen.fullscreenpanels.bytecode.fingerprints.FullscreenViewAdderFingerprint +import app.revanced.patches.youtube.layout.fullscreen.fullscreenpanels.fingerprints.FullscreenViewAdderFingerprint +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.FULLSCREEN_LAYOUT import org.jf.dexlib2.Opcode import org.jf.dexlib2.builder.instruction.BuilderInstruction35c import org.jf.dexlib2.iface.instruction.formats.Instruction35c -@Name("hide-fullscreen-panels-bytecode-patch") +@Patch +@Name("hide-fullscreen-panels") +@Description("Hides video description and comments panel in fullscreen view.") +@DependsOn( + [ + HideFullscreenButtonContainerPatch::class, + SettingsPatch::class + ] +) @YouTubeCompatibility @Version("0.0.1") -class HideFullscreenPanelsBytecodePatch : BytecodePatch( +class HideFullscreenPanelsPatch : BytecodePatch( listOf( FullscreenViewAdderFingerprint, LayoutConstructorFingerprint @@ -45,6 +57,19 @@ class HideFullscreenPanelsBytecodePatch : BytecodePatch( } } ?: return FullscreenViewAdderFingerprint.toErrorResult() + /* + add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: LAYOUT_SETTINGS", + "PREFERENCE_HEADER: FULLSCREEN", + "SETTINGS: HIDE_FULLSCREEN_PANELS" + ) + ) + + SettingsPatch.updatePatchStatus("hide-fullscreen-panels") + LayoutConstructorFingerprint.result?.mutableMethod?.let { method -> val invokeIndex = method.implementation!!.instructions.indexOfFirst { it.opcode.ordinal == Opcode.INVOKE_VIRTUAL.ordinal && diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/fullscreenpanels/resource/patch/HideFullscreenPanelsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/fullscreenpanels/resource/patch/HideFullscreenPanelsPatch.kt deleted file mode 100644 index 777a62cd2..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/fullscreenpanels/resource/patch/HideFullscreenPanelsPatch.kt +++ /dev/null @@ -1,51 +0,0 @@ -package app.revanced.patches.youtube.layout.fullscreen.fullscreenpanels.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.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -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.fullscreen.fullscreenpanels.bytecode.patch.FullscreenButtonContainerBytecodePatch -import app.revanced.patches.youtube.layout.fullscreen.fullscreenpanels.bytecode.patch.HideFullscreenPanelsBytecodePatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper - -@Patch -@Name("hide-fullscreen-panels") -@Description("Hides video description and comments panel in fullscreen view.") -@DependsOn( - [ - FullscreenButtonContainerBytecodePatch::class, - HideFullscreenPanelsBytecodePatch::class, - SettingsPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class HideFullscreenPanelsPatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - /* - add settings - */ - ResourceHelper.addSettings2( - context, - "PREFERENCE_CATEGORY: REVANCED_SETTINGS", - "PREFERENCE: LAYOUT_SETTINGS", - "PREFERENCE_HEADER: FULLSCREEN", - "SETTINGS: HIDE_FULLSCREEN_PANELS" - ) - - ResourceHelper.patchSuccess( - context, - "hide-fullscreen-panels" - ) - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/bytecode/fingerprints/MarkerHapticsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/fingerprints/MarkerHapticsFingerprint.kt similarity index 90% rename from src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/bytecode/fingerprints/MarkerHapticsFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/fingerprints/MarkerHapticsFingerprint.kt index 1305b4a8b..d140c2452 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/bytecode/fingerprints/MarkerHapticsFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/fingerprints/MarkerHapticsFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.fullscreen.hapticfeedback.bytecode.fingerprints +package app.revanced.patches.youtube.layout.fullscreen.hapticfeedback.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/bytecode/fingerprints/ScrubbingHapticsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/fingerprints/ScrubbingHapticsFingerprint.kt similarity index 90% rename from src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/bytecode/fingerprints/ScrubbingHapticsFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/fingerprints/ScrubbingHapticsFingerprint.kt index 52b62ce1c..c78605e12 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/bytecode/fingerprints/ScrubbingHapticsFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/fingerprints/ScrubbingHapticsFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.fullscreen.hapticfeedback.bytecode.fingerprints +package app.revanced.patches.youtube.layout.fullscreen.hapticfeedback.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/bytecode/fingerprints/SeekHapticsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/fingerprints/SeekHapticsFingerprint.kt similarity index 93% rename from src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/bytecode/fingerprints/SeekHapticsFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/fingerprints/SeekHapticsFingerprint.kt index 4dd2bc3bd..814b4b3c6 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/bytecode/fingerprints/SeekHapticsFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/fingerprints/SeekHapticsFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.fullscreen.hapticfeedback.bytecode.fingerprints +package app.revanced.patches.youtube.layout.fullscreen.hapticfeedback.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/fullscreen/hapticfeedback/bytecode/fingerprints/ZoomHapticsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/fingerprints/ZoomHapticsFingerprint.kt similarity index 90% rename from src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/bytecode/fingerprints/ZoomHapticsFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/fingerprints/ZoomHapticsFingerprint.kt index 295789ed5..6ac8fb782 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/bytecode/fingerprints/ZoomHapticsFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/fingerprints/ZoomHapticsFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.fullscreen.hapticfeedback.bytecode.fingerprints +package app.revanced.patches.youtube.layout.fullscreen.hapticfeedback.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/bytecode/patch/HapticFeedBackBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/patch/HapticFeedBackPatch.kt similarity index 82% rename from src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/bytecode/patch/HapticFeedBackBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/patch/HapticFeedBackPatch.kt index 4110646c4..970b93fed 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/bytecode/patch/HapticFeedBackBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/patch/HapticFeedBackPatch.kt @@ -1,6 +1,7 @@ -package app.revanced.patches.youtube.layout.fullscreen.hapticfeedback.bytecode.patch +package app.revanced.patches.youtube.layout.fullscreen.hapticfeedback.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 @@ -11,16 +12,22 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult 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.patcher.util.smali.ExternalLabel import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.layout.fullscreen.hapticfeedback.bytecode.fingerprints.* +import app.revanced.patches.youtube.layout.fullscreen.hapticfeedback.fingerprints.* +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.FULLSCREEN_LAYOUT import org.jf.dexlib2.iface.instruction.OneRegisterInstruction -@Name("disable-haptic-feedback-bytecode-patch") +@Patch +@Name("disable-haptic-feedback") +@Description("Disable haptic feedback when swiping.") +@DependsOn([SettingsPatch::class]) @YouTubeCompatibility @Version("0.0.1") -class HapticFeedBackBytecodePatch : BytecodePatch( +class HapticFeedBackPatch : BytecodePatch( listOf( MarkerHapticsFingerprint, SeekHapticsFingerprint, @@ -44,6 +51,19 @@ class HapticFeedBackBytecodePatch : BytecodePatch( } ?: return fingerprint.toErrorResult() } + /* + add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: LAYOUT_SETTINGS", + "PREFERENCE_HEADER: FULLSCREEN", + "SETTINGS: DISABLE_HAPTIC_FEEDBACK" + ) + ) + + SettingsPatch.updatePatchStatus("disable-haptic-feedback") + return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/resource/patch/HapticFeedBackPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/resource/patch/HapticFeedBackPatch.kt deleted file mode 100644 index 13e7fbc50..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreen/hapticfeedback/resource/patch/HapticFeedBackPatch.kt +++ /dev/null @@ -1,49 +0,0 @@ -package app.revanced.patches.youtube.layout.fullscreen.hapticfeedback.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.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -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.fullscreen.hapticfeedback.bytecode.patch.HapticFeedBackBytecodePatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper - -@Patch -@Name("disable-haptic-feedback") -@Description("Disable haptic feedback when swiping.") -@DependsOn( - [ - HapticFeedBackBytecodePatch::class, - SettingsPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class HapticFeedBackPatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - /* - add settings - */ - ResourceHelper.addSettings2( - context, - "PREFERENCE_CATEGORY: REVANCED_SETTINGS", - "PREFERENCE: LAYOUT_SETTINGS", - "PREFERENCE_HEADER: FULLSCREEN", - "SETTINGS: DISABLE_HAPTIC_FEEDBACK" - ) - - ResourceHelper.patchSuccess( - context, - "disable-haptic-feedback" - ) - - return PatchResultSuccess() - } -} diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/autocaptions/bytecode/fingerprints/StartVideoInformerFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/autocaptions/fingerprints/StartVideoInformerFingerprint.kt similarity index 95% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/autocaptions/bytecode/fingerprints/StartVideoInformerFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/general/autocaptions/fingerprints/StartVideoInformerFingerprint.kt index 4c621e6fa..31312a9fa 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/autocaptions/bytecode/fingerprints/StartVideoInformerFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/autocaptions/fingerprints/StartVideoInformerFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.autocaptions.bytecode.fingerprints +package app.revanced.patches.youtube.layout.general.autocaptions.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/autocaptions/bytecode/fingerprints/SubtitleTrackFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/autocaptions/fingerprints/SubtitleTrackFingerprint.kt similarity index 96% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/autocaptions/bytecode/fingerprints/SubtitleTrackFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/general/autocaptions/fingerprints/SubtitleTrackFingerprint.kt index a64c4b610..775f53945 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/autocaptions/bytecode/fingerprints/SubtitleTrackFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/autocaptions/fingerprints/SubtitleTrackFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.autocaptions.bytecode.fingerprints +package app.revanced.patches.youtube.layout.general.autocaptions.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/autocaptions/bytecode/patch/AutoCaptionsBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/autocaptions/patch/AutoCaptionsPatch.kt similarity index 74% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/autocaptions/bytecode/patch/AutoCaptionsBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/general/autocaptions/patch/AutoCaptionsPatch.kt index 9d3cc95f8..dd3a433ab 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/autocaptions/bytecode/patch/AutoCaptionsBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/autocaptions/patch/AutoCaptionsPatch.kt @@ -1,6 +1,7 @@ -package app.revanced.patches.youtube.layout.general.autocaptions.bytecode.patch +package app.revanced.patches.youtube.layout.general.autocaptions.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 @@ -10,16 +11,23 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint 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.patcher.util.smali.ExternalLabel import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.shared.fingerprints.SubtitleButtonControllerFingerprint -import app.revanced.patches.youtube.layout.general.autocaptions.bytecode.fingerprints.* +import app.revanced.patches.youtube.layout.general.autocaptions.fingerprints.StartVideoInformerFingerprint +import app.revanced.patches.youtube.layout.general.autocaptions.fingerprints.SubtitleTrackFingerprint +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.GENERAL_LAYOUT -@Name("hide-auto-captions-bytecode-patch") +@Patch +@Name("hide-auto-captions") +@Description("Hide captions from being automatically enabled.") +@DependsOn([SettingsPatch::class]) @YouTubeCompatibility @Version("0.0.1") -class AutoCaptionsBytecodePatch : BytecodePatch( +class AutoCaptionsPatch : BytecodePatch( listOf( StartVideoInformerFingerprint, SubtitleButtonControllerFingerprint, @@ -56,6 +64,19 @@ class AutoCaptionsBytecodePatch : BytecodePatch( ) } ?: return SubtitleTrackFingerprint.toErrorResult() + /* + add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: LAYOUT_SETTINGS", + "PREFERENCE_HEADER: GENERAL", + "SETTINGS: HIDE_AUTO_CAPTIONS" + ) + ) + + SettingsPatch.updatePatchStatus("hide-auto-captions") + return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/autocaptions/resource/patch/AutoCaptionsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/autocaptions/resource/patch/AutoCaptionsPatch.kt deleted file mode 100644 index e125eb2d2..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/autocaptions/resource/patch/AutoCaptionsPatch.kt +++ /dev/null @@ -1,49 +0,0 @@ -package app.revanced.patches.youtube.layout.general.autocaptions.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.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -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.autocaptions.bytecode.patch.AutoCaptionsBytecodePatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper - -@Patch -@Name("hide-auto-captions") -@Description("Hide captions from being automatically enabled.") -@DependsOn( - [ - AutoCaptionsBytecodePatch::class, - SettingsPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class AutoCaptionsPatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - /* - add settings - */ - ResourceHelper.addSettings2( - context, - "PREFERENCE_CATEGORY: REVANCED_SETTINGS", - "PREFERENCE: LAYOUT_SETTINGS", - "PREFERENCE_HEADER: GENERAL", - "SETTINGS: HIDE_AUTO_CAPTIONS" - ) - - ResourceHelper.patchSuccess( - context, - "hide-auto-captions" - ) - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/autopopuppanels/bytecode/fingerprints/EngagementPanelControllerFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/autopopuppanels/fingerprints/EngagementPanelControllerFingerprint.kt similarity index 95% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/autopopuppanels/bytecode/fingerprints/EngagementPanelControllerFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/general/autopopuppanels/fingerprints/EngagementPanelControllerFingerprint.kt index 12c6e8ff3..ddfabebd1 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/autopopuppanels/bytecode/fingerprints/EngagementPanelControllerFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/autopopuppanels/fingerprints/EngagementPanelControllerFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.autopopuppanels.bytecode.fingerprints +package app.revanced.patches.youtube.layout.general.autopopuppanels.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/autopopuppanels/bytecode/patch/PlayerPopupPanelsBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/autopopuppanels/patch/PlayerPopupPanelsPatch.kt similarity index 64% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/autopopuppanels/bytecode/patch/PlayerPopupPanelsBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/general/autopopuppanels/patch/PlayerPopupPanelsPatch.kt index 3dc60bcea..c13dd813e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/autopopuppanels/bytecode/patch/PlayerPopupPanelsBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/autopopuppanels/patch/PlayerPopupPanelsPatch.kt @@ -1,6 +1,7 @@ -package app.revanced.patches.youtube.layout.general.autopopuppanels.bytecode.patch +package app.revanced.patches.youtube.layout.general.autopopuppanels.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 @@ -9,15 +10,21 @@ 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.patcher.util.smali.ExternalLabel import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.layout.general.autopopuppanels.bytecode.fingerprints.EngagementPanelControllerFingerprint +import app.revanced.patches.youtube.layout.general.autopopuppanels.fingerprints.EngagementPanelControllerFingerprint +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.GENERAL_LAYOUT -@Name("hide-auto-player-popup-panels-bytecode-patch") +@Patch +@Name("hide-auto-player-popup-panels") +@Description("Hide automatic popup panels (playlist or live chat) on video player.") +@DependsOn([SettingsPatch::class]) @YouTubeCompatibility @Version("0.0.1") -class PlayerPopupPanelsBytecodePatch : BytecodePatch( +class PlayerPopupPanelsPatch : BytecodePatch( listOf( EngagementPanelControllerFingerprint ) @@ -37,6 +44,19 @@ class PlayerPopupPanelsBytecodePatch : BytecodePatch( ) } ?: return EngagementPanelControllerFingerprint.toErrorResult() + /* + add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: LAYOUT_SETTINGS", + "PREFERENCE_HEADER: GENERAL", + "SETTINGS: HIDE_AUTO_PLAYER_POPUP_PANELS" + ) + ) + + SettingsPatch.updatePatchStatus("hide-auto-player-popup-panels") + return PatchResultSuccess() } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/autopopuppanels/resource/patch/PlayerPopupPanelsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/autopopuppanels/resource/patch/PlayerPopupPanelsPatch.kt deleted file mode 100644 index 9d44bd046..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/autopopuppanels/resource/patch/PlayerPopupPanelsPatch.kt +++ /dev/null @@ -1,49 +0,0 @@ -package app.revanced.patches.youtube.layout.general.autopopuppanels.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.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -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.autopopuppanels.bytecode.patch.PlayerPopupPanelsBytecodePatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper - -@Patch -@Name("hide-auto-player-popup-panels") -@Description("Hide automatic popup panels (playlist or live chat) on video player.") -@DependsOn( - [ - PlayerPopupPanelsBytecodePatch::class, - SettingsPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class PlayerPopupPanelsPatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - /* - add settings - */ - ResourceHelper.addSettings2( - context, - "PREFERENCE_CATEGORY: REVANCED_SETTINGS", - "PREFERENCE: LAYOUT_SETTINGS", - "PREFERENCE_HEADER: GENERAL", - "SETTINGS: HIDE_AUTO_PLAYER_POPUP_PANELS" - ) - - ResourceHelper.patchSuccess( - context, - "hide-auto-player-popup-panels" - ) - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/crowdfundingbox/bytecode/patch/CrowdfundingBoxBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/crowdfundingbox/patch/CrowdfundingBoxPatch.kt similarity index 69% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/crowdfundingbox/bytecode/patch/CrowdfundingBoxBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/general/crowdfundingbox/patch/CrowdfundingBoxPatch.kt index 7e90cd1ee..94ceb35e7 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/crowdfundingbox/bytecode/patch/CrowdfundingBoxBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/crowdfundingbox/patch/CrowdfundingBoxPatch.kt @@ -1,25 +1,36 @@ -package app.revanced.patches.youtube.layout.general.crowdfundingbox.bytecode.patch +package app.revanced.patches.youtube.layout.general.crowdfundingbox.patch import app.revanced.extensions.findMutableMethodOf import app.revanced.extensions.injectHideCall -import app.revanced.extensions.toResult +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.PatchResultError +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.patch.mapping.ResourceMappingPatch +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch import org.jf.dexlib2.Opcode import org.jf.dexlib2.iface.instruction.formats.Instruction22c import org.jf.dexlib2.iface.instruction.formats.Instruction31i -@Name("hide-crowdfunding-box-bytecode-patch") -@DependsOn([ResourceMappingPatch::class]) +@Patch +@Name("hide-crowdfunding-box") +@Description("Hides the crowdfunding box between the player and video description.") +@DependsOn( + [ + ResourceMappingPatch::class, + SettingsPatch::class + ] +) @YouTubeCompatibility @Version("0.0.1") -class CrowdfundingBoxBytecodePatch : BytecodePatch() { +class CrowdfundingBoxPatch : BytecodePatch() { // list of resource names to get the id of private val resourceIds = arrayOf( @@ -56,6 +67,25 @@ class CrowdfundingBoxBytecodePatch : BytecodePatch() { } } } - return toResult(patchSuccessArray.indexOf(false)) + + val errorIndex: Int = patchSuccessArray.indexOf(false) + + if (errorIndex == -1) { + /* + add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: LAYOUT_SETTINGS", + "PREFERENCE_HEADER: GENERAL", + "SETTINGS: HIDE_CROWDFUNDING_BOX" + ) + ) + + SettingsPatch.updatePatchStatus("hide-crowdfunding-box") + + return PatchResultSuccess() + } else + return PatchResultError("Instruction not found: $errorIndex") } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/crowdfundingbox/resource/patch/CrowdfundingBoxPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/crowdfundingbox/resource/patch/CrowdfundingBoxPatch.kt deleted file mode 100644 index 82b3db2c4..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/crowdfundingbox/resource/patch/CrowdfundingBoxPatch.kt +++ /dev/null @@ -1,49 +0,0 @@ -package app.revanced.patches.youtube.layout.general.crowdfundingbox.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.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -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.crowdfundingbox.bytecode.patch.CrowdfundingBoxBytecodePatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper - -@Patch -@Name("hide-crowdfunding-box") -@Description("Hides the crowdfunding box between the player and video description.") -@DependsOn( - [ - CrowdfundingBoxBytecodePatch::class, - SettingsPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class CrowdfundingBoxPatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - /* - add settings - */ - ResourceHelper.addSettings2( - context, - "PREFERENCE_CATEGORY: REVANCED_SETTINGS", - "PREFERENCE: LAYOUT_SETTINGS", - "PREFERENCE_HEADER: GENERAL", - "SETTINGS: HIDE_CROWDFUNDING_BOX" - ) - - ResourceHelper.patchSuccess( - context, - "hide-crowdfunding-box" - ) - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/headerswitch/bytecode/patch/HeaderSwitchBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/headerswitch/patch/HeaderSwitchPatch.kt similarity index 70% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/headerswitch/bytecode/patch/HeaderSwitchBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/general/headerswitch/patch/HeaderSwitchPatch.kt index 45169972e..5200738bd 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/headerswitch/bytecode/patch/HeaderSwitchBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/headerswitch/patch/HeaderSwitchPatch.kt @@ -1,24 +1,35 @@ -package app.revanced.patches.youtube.layout.general.headerswitch.bytecode.patch +package app.revanced.patches.youtube.layout.general.headerswitch.patch import app.revanced.extensions.findMutableMethodOf -import app.revanced.extensions.toResult +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.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultError +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.patch.mapping.ResourceMappingPatch +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch import org.jf.dexlib2.Opcode import org.jf.dexlib2.iface.instruction.formats.Instruction31i -@DependsOn([ResourceMappingPatch::class]) -@Name("header-switch-bytecode-patch") +@Patch +@Name("header-switch") +@Description("Add switch to change header.") +@DependsOn( + [ + ResourceMappingPatch::class, + SettingsPatch::class + ] +) @YouTubeCompatibility @Version("0.0.1") -class HeaderSwitchBytecodePatch : BytecodePatch() { +class HeaderSwitchPatch : BytecodePatch() { // list of resource names to get the id of private val resourceIds = arrayOf( @@ -60,6 +71,25 @@ class HeaderSwitchBytecodePatch : BytecodePatch() { } } } - return toResult(patchSuccessArray.indexOf(false)) + + val errorIndex: Int = patchSuccessArray.indexOf(false) + + if (errorIndex == -1) { + /* + add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: LAYOUT_SETTINGS", + "PREFERENCE_HEADER: GENERAL", + "SETTINGS: HEADER_SWITCH" + ) + ) + + SettingsPatch.updatePatchStatus("header-switch") + + return PatchResultSuccess() + } else + return PatchResultError("Instruction not found: $errorIndex") } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/headerswitch/resource/patch/HeaderSwitchPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/headerswitch/resource/patch/HeaderSwitchPatch.kt deleted file mode 100644 index 0ede9c3d1..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/headerswitch/resource/patch/HeaderSwitchPatch.kt +++ /dev/null @@ -1,49 +0,0 @@ -package app.revanced.patches.youtube.layout.general.headerswitch.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.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -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.headerswitch.bytecode.patch.HeaderSwitchBytecodePatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper - -@Patch -@Name("header-switch") -@Description("Add switch to change header.") -@DependsOn( - [ - HeaderSwitchBytecodePatch::class, - SettingsPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class HeaderSwitchPatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - /* - add settings - */ - ResourceHelper.addSettings2( - context, - "PREFERENCE_CATEGORY: REVANCED_SETTINGS", - "PREFERENCE: LAYOUT_SETTINGS", - "PREFERENCE_HEADER: GENERAL", - "SETTINGS: HEADER_SWITCH" - ) - - ResourceHelper.patchSuccess( - context, - "header-switch" - ) - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/mixplaylists/bytecode/fingerprints/CreateMixPlaylistFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/mixplaylists/fingerprints/CreateMixPlaylistFingerprint.kt similarity index 97% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/mixplaylists/bytecode/fingerprints/CreateMixPlaylistFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/general/mixplaylists/fingerprints/CreateMixPlaylistFingerprint.kt index e5b09a7b3..0f88d2176 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/mixplaylists/bytecode/fingerprints/CreateMixPlaylistFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/mixplaylists/fingerprints/CreateMixPlaylistFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.mixplaylists.bytecode.fingerprints +package app.revanced.patches.youtube.layout.general.mixplaylists.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/mixplaylists/bytecode/fingerprints/FourthCreateMixPlaylistFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/mixplaylists/fingerprints/FourthCreateMixPlaylistFingerprint.kt similarity index 97% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/mixplaylists/bytecode/fingerprints/FourthCreateMixPlaylistFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/general/mixplaylists/fingerprints/FourthCreateMixPlaylistFingerprint.kt index c408b0a13..c4cf9a5d3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/mixplaylists/bytecode/fingerprints/FourthCreateMixPlaylistFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/mixplaylists/fingerprints/FourthCreateMixPlaylistFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.mixplaylists.bytecode.fingerprints +package app.revanced.patches.youtube.layout.general.mixplaylists.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourcdIdPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/mixplaylists/bytecode/fingerprints/SecondCreateMixPlaylistFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/mixplaylists/fingerprints/SecondCreateMixPlaylistFingerprint.kt similarity index 97% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/mixplaylists/bytecode/fingerprints/SecondCreateMixPlaylistFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/general/mixplaylists/fingerprints/SecondCreateMixPlaylistFingerprint.kt index 1945be15e..5d34c5a90 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/mixplaylists/bytecode/fingerprints/SecondCreateMixPlaylistFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/mixplaylists/fingerprints/SecondCreateMixPlaylistFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.mixplaylists.bytecode.fingerprints +package app.revanced.patches.youtube.layout.general.mixplaylists.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/mixplaylists/bytecode/fingerprints/ThirdCreateMixPlaylistFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/mixplaylists/fingerprints/ThirdCreateMixPlaylistFingerprint.kt similarity index 97% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/mixplaylists/bytecode/fingerprints/ThirdCreateMixPlaylistFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/general/mixplaylists/fingerprints/ThirdCreateMixPlaylistFingerprint.kt index 20cd78dc7..42a129880 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/mixplaylists/bytecode/fingerprints/ThirdCreateMixPlaylistFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/mixplaylists/fingerprints/ThirdCreateMixPlaylistFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.mixplaylists.bytecode.fingerprints +package app.revanced.patches.youtube.layout.general.mixplaylists.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourcdIdPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/mixplaylists/bytecode/patch/MixPlaylistsBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/mixplaylists/patch/MixPlaylistsPatch.kt similarity index 78% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/mixplaylists/bytecode/patch/MixPlaylistsBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/general/mixplaylists/patch/MixPlaylistsPatch.kt index c9298566d..c0a03f696 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/mixplaylists/bytecode/patch/MixPlaylistsBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/mixplaylists/patch/MixPlaylistsPatch.kt @@ -1,7 +1,8 @@ -package app.revanced.patches.youtube.layout.general.mixplaylists.bytecode.patch +package app.revanced.patches.youtube.layout.general.mixplaylists.patch import app.revanced.extensions.injectHideCall 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 @@ -10,17 +11,23 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult 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.mixplaylists.bytecode.fingerprints.* +import app.revanced.patches.youtube.layout.general.mixplaylists.fingerprints.* +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch import org.jf.dexlib2.iface.instruction.Instruction import org.jf.dexlib2.iface.instruction.OneRegisterInstruction import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction import org.jf.dexlib2.iface.instruction.formats.Instruction21c -@Name("hide-mix-playlists-bytecode-patch") +@Patch +@Name("hide-mix-playlists") +@Description("Removes mix playlists from home feed and video player.") +@DependsOn([SettingsPatch::class]) @YouTubeCompatibility @Version("0.0.1") -class MixPlaylistsBytecodePatch : BytecodePatch( +class MixPlaylistsPatch : BytecodePatch( listOf( CreateMixPlaylistFingerprint, SecondCreateMixPlaylistFingerprint, @@ -44,6 +51,19 @@ class MixPlaylistsBytecodePatch : BytecodePatch( fingerprint.result?.hookMixPlaylists(boolean) ?: return fingerprint.toErrorResult() } + /* + add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: LAYOUT_SETTINGS", + "PREFERENCE_HEADER: GENERAL", + "SETTINGS: HIDE_MIX_PLAYLISTS" + ) + ) + + SettingsPatch.updatePatchStatus("hide-mix-playlists") + return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/mixplaylists/resource/patch/MixPlaylistsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/mixplaylists/resource/patch/MixPlaylistsPatch.kt deleted file mode 100644 index 6c4678ac9..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/mixplaylists/resource/patch/MixPlaylistsPatch.kt +++ /dev/null @@ -1,51 +0,0 @@ -package app.revanced.patches.youtube.layout.general.mixplaylists.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.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -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.mixplaylists.bytecode.patch.MixPlaylistsBytecodePatch -import app.revanced.patches.youtube.misc.litho.filter.patch.LithoFilterPatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper - -@Patch -@Name("hide-mix-playlists") -@Description("Removes mix playlists from home feed and video player.") -@DependsOn( - [ - LithoFilterPatch::class, - MixPlaylistsBytecodePatch::class, - SettingsPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class MixPlaylistsPatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - /* - add settings - */ - ResourceHelper.addSettings2( - context, - "PREFERENCE_CATEGORY: REVANCED_SETTINGS", - "PREFERENCE: LAYOUT_SETTINGS", - "PREFERENCE_HEADER: GENERAL", - "SETTINGS: HIDE_MIX_PLAYLISTS" - ) - - ResourceHelper.patchSuccess( - context, - "hide-mix-playlists" - ) - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/personalinformation/bytecode/fingerprints/AccountSwitcherAccessibilityLabelFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/personalinformation/fingerprints/AccountSwitcherAccessibilityLabelFingerprint.kt similarity index 96% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/personalinformation/bytecode/fingerprints/AccountSwitcherAccessibilityLabelFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/general/personalinformation/fingerprints/AccountSwitcherAccessibilityLabelFingerprint.kt index 5c8c77874..c4aa885cf 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/personalinformation/bytecode/fingerprints/AccountSwitcherAccessibilityLabelFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/personalinformation/fingerprints/AccountSwitcherAccessibilityLabelFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.personalinformation.bytecode.fingerprints +package app.revanced.patches.youtube.layout.general.personalinformation.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourcdIdPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/personalinformation/bytecode/patch/HideEmailAddressBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/personalinformation/patch/HideEmailAddressPatch.kt similarity index 69% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/personalinformation/bytecode/patch/HideEmailAddressBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/general/personalinformation/patch/HideEmailAddressPatch.kt index f0d4b08f6..db653420e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/personalinformation/bytecode/patch/HideEmailAddressBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/personalinformation/patch/HideEmailAddressPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.personalinformation.bytecode.patch +package app.revanced.patches.youtube.layout.general.personalinformation.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Name @@ -9,15 +9,20 @@ 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.personalinformation.bytecode.fingerprints.AccountSwitcherAccessibilityLabelFingerprint +import app.revanced.patches.youtube.layout.general.personalinformation.fingerprints.AccountSwitcherAccessibilityLabelFingerprint +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 -@Name("hide-email-address-bytecode-patch") +@Patch +@Name("hide-email-address") +@DependsOn([SettingsPatch::class]) @YouTubeCompatibility @Version("0.0.1") -class HideEmailAddressBytecodePatch : BytecodePatch( +class HideEmailAddressPatch : BytecodePatch( listOf( AccountSwitcherAccessibilityLabelFingerprint ) @@ -38,6 +43,19 @@ class HideEmailAddressBytecodePatch : BytecodePatch( } } ?: return AccountSwitcherAccessibilityLabelFingerprint.toErrorResult() + /* + add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: LAYOUT_SETTINGS", + "PREFERENCE_HEADER: GENERAL", + "SETTINGS: HIDE_EMAIL_ADDRESS" + ) + ) + + SettingsPatch.updatePatchStatus("hide-email-address") + return PatchResultSuccess() } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/personalinformation/resource/patch/HideEmailAddressPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/personalinformation/resource/patch/HideEmailAddressPatch.kt deleted file mode 100644 index 72ed058ba..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/personalinformation/resource/patch/HideEmailAddressPatch.kt +++ /dev/null @@ -1,49 +0,0 @@ -package app.revanced.patches.youtube.layout.general.personalinformation.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.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -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.personalinformation.bytecode.patch.HideEmailAddressBytecodePatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper - -@Patch -@Name("hide-email-address") -@Description("Hides the email address in the account switcher.") -@DependsOn( - [ - HideEmailAddressBytecodePatch::class, - SettingsPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class HideEmailAddressPatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - /* - add settings - */ - ResourceHelper.addSettings2( - context, - "PREFERENCE_CATEGORY: REVANCED_SETTINGS", - "PREFERENCE: LAYOUT_SETTINGS", - "PREFERENCE_HEADER: GENERAL", - "SETTINGS: HIDE_EMAIL_ADDRESS" - ) - - ResourceHelper.patchSuccess( - context, - "hide-email-address" - ) - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/pivotbar/createbutton/bytecode/fingerprints/PivotBarFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/pivotbar/createbutton/fingerprints/PivotBarFingerprint.kt similarity index 59% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/pivotbar/createbutton/bytecode/fingerprints/PivotBarFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/general/pivotbar/createbutton/fingerprints/PivotBarFingerprint.kt index a17054565..3d306d007 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/pivotbar/createbutton/bytecode/fingerprints/PivotBarFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/pivotbar/createbutton/fingerprints/PivotBarFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.pivotbar.createbutton.bytecode.fingerprints +package app.revanced.patches.youtube.layout.general.pivotbar.createbutton.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint @@ -15,11 +15,11 @@ object PivotBarFingerprint : MethodFingerprint( Opcode.MOVE_RESULT_OBJECT, Opcode.RETURN_OBJECT ), - customFingerprint = { - it.definingClass == "Lcom/google/android/apps/youtube/app/ui/pivotbar/PivotBar;" && - it.implementation?.instructions?.any { - it.opcode.ordinal == Opcode.CONST.ordinal && - (it as? WideLiteralInstruction)?.wideLiteral == SharedResourcdIdPatch.imageWithTextTabId - } == true + customFingerprint = { methodDef -> + methodDef.definingClass == "Lcom/google/android/apps/youtube/app/ui/pivotbar/PivotBar;" && + methodDef.implementation?.instructions?.any { + it.opcode.ordinal == Opcode.CONST.ordinal && + (it as? WideLiteralInstruction)?.wideLiteral == SharedResourcdIdPatch.imageWithTextTabId + } == true } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/pivotbar/createbutton/bytecode/patch/CreateButtonRemoverBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/pivotbar/createbutton/patch/CreateButtonRemoverPatch.kt similarity index 76% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/pivotbar/createbutton/bytecode/patch/CreateButtonRemoverBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/general/pivotbar/createbutton/patch/CreateButtonRemoverPatch.kt index 9f2b7fc04..ae8bf7049 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/pivotbar/createbutton/bytecode/patch/CreateButtonRemoverBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/pivotbar/createbutton/patch/CreateButtonRemoverPatch.kt @@ -1,6 +1,7 @@ -package app.revanced.patches.youtube.layout.general.pivotbar.createbutton.bytecode.patch +package app.revanced.patches.youtube.layout.general.pivotbar.createbutton.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 @@ -8,21 +9,30 @@ 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.general.pivotbar.createbutton.bytecode.fingerprints.PivotBarFingerprint +import app.revanced.patches.youtube.layout.general.pivotbar.createbutton.fingerprints.PivotBarFingerprint import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourcdIdPatch +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.GENERAL_LAYOUT import app.revanced.util.pivotbar.InjectionUtils.REGISTER_TEMPLATE_REPLACEMENT import app.revanced.util.pivotbar.InjectionUtils.injectHook import org.jf.dexlib2.dexbacked.reference.DexBackedMethodReference import org.jf.dexlib2.iface.instruction.ReferenceInstruction -@Name("hide-create-button-bytecode-patch") -@DependsOn([SharedResourcdIdPatch::class]) +@Patch +@Name("hide-create-button") +@Description("Hides the create button in the navigation bar.") +@DependsOn( + [ + SettingsPatch::class, + SharedResourcdIdPatch::class + ] +) @YouTubeCompatibility @Version("0.0.1") -class CreateButtonRemoverBytecodePatch : BytecodePatch( +class CreateButtonRemoverPatch : BytecodePatch( listOf( PivotBarCreateButtonViewFingerprint, PivotBarFingerprint @@ -58,6 +68,19 @@ class CreateButtonRemoverBytecodePatch : BytecodePatch( injectHook(hook, createButtonInstructions.indexOf(instruction) + 2) + /* + add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: LAYOUT_SETTINGS", + "PREFERENCE_HEADER: GENERAL", + "SETTINGS: HIDE_CREATE_BUTTON" + ) + ) + + SettingsPatch.updatePatchStatus("hide-create-button") + return PatchResultSuccess() } return PivotBarCreateButtonViewFingerprint.toErrorResult() diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/pivotbar/createbutton/resource/patch/CreateButtonRemoverPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/pivotbar/createbutton/resource/patch/CreateButtonRemoverPatch.kt deleted file mode 100644 index 5bb9adcbe..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/pivotbar/createbutton/resource/patch/CreateButtonRemoverPatch.kt +++ /dev/null @@ -1,49 +0,0 @@ -package app.revanced.patches.youtube.layout.general.pivotbar.createbutton.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.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -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.createbutton.bytecode.patch.CreateButtonRemoverBytecodePatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper - -@Patch -@Name("hide-create-button") -@Description("Hides the create button in the navigation bar.") -@DependsOn( - [ - CreateButtonRemoverBytecodePatch::class, - SettingsPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class CreateButtonRemoverPatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - /* - add settings - */ - ResourceHelper.addSettings2( - context, - "PREFERENCE_CATEGORY: REVANCED_SETTINGS", - "PREFERENCE: LAYOUT_SETTINGS", - "PREFERENCE_HEADER: GENERAL", - "SETTINGS: HIDE_CREATE_BUTTON" - ) - - ResourceHelper.patchSuccess( - context, - "hide-create-button" - ) - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/pivotbar/shortsbutton/bytecode/fingerprints/PivotBarEnumFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/pivotbar/shortsbutton/fingerprints/PivotBarEnumFingerprint.kt similarity index 93% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/pivotbar/shortsbutton/bytecode/fingerprints/PivotBarEnumFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/general/pivotbar/shortsbutton/fingerprints/PivotBarEnumFingerprint.kt index 01b850689..ce666d0d8 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/pivotbar/shortsbutton/bytecode/fingerprints/PivotBarEnumFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/pivotbar/shortsbutton/fingerprints/PivotBarEnumFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.pivotbar.shortsbutton.bytecode.fingerprints +package app.revanced.patches.youtube.layout.general.pivotbar.shortsbutton.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/general/pivotbar/shortsbutton/bytecode/fingerprints/PivotBarShortsButtonViewFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/pivotbar/shortsbutton/fingerprints/PivotBarShortsButtonViewFingerprint.kt similarity index 92% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/pivotbar/shortsbutton/bytecode/fingerprints/PivotBarShortsButtonViewFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/general/pivotbar/shortsbutton/fingerprints/PivotBarShortsButtonViewFingerprint.kt index cd3734980..2af8999da 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/pivotbar/shortsbutton/bytecode/fingerprints/PivotBarShortsButtonViewFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/pivotbar/shortsbutton/fingerprints/PivotBarShortsButtonViewFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.pivotbar.shortsbutton.bytecode.fingerprints +package app.revanced.patches.youtube.layout.general.pivotbar.shortsbutton.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/general/pivotbar/shortsbutton/bytecode/patch/ShortsButtonRemoverBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/pivotbar/shortsbutton/patch/ShortsButtonRemoverPatch.kt similarity index 75% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/pivotbar/shortsbutton/bytecode/patch/ShortsButtonRemoverBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/general/pivotbar/shortsbutton/patch/ShortsButtonRemoverPatch.kt index 80c2cec6e..58b3d50da 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/pivotbar/shortsbutton/bytecode/patch/ShortsButtonRemoverBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/pivotbar/shortsbutton/patch/ShortsButtonRemoverPatch.kt @@ -1,6 +1,7 @@ -package app.revanced.patches.youtube.layout.general.pivotbar.shortsbutton.bytecode.patch +package app.revanced.patches.youtube.layout.general.pivotbar.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 @@ -9,20 +10,29 @@ 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.general.pivotbar.shortsbutton.bytecode.fingerprints.PivotBarEnumFingerprint -import app.revanced.patches.youtube.layout.general.pivotbar.shortsbutton.bytecode.fingerprints.PivotBarShortsButtonViewFingerprint +import app.revanced.patches.youtube.layout.general.pivotbar.shortsbutton.fingerprints.PivotBarEnumFingerprint +import app.revanced.patches.youtube.layout.general.pivotbar.shortsbutton.fingerprints.PivotBarShortsButtonViewFingerprint import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourcdIdPatch +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.GENERAL_LAYOUT import app.revanced.util.pivotbar.InjectionUtils.REGISTER_TEMPLATE_REPLACEMENT import app.revanced.util.pivotbar.InjectionUtils.injectHook +@Patch @Name("hide-shorts-button") -@DependsOn([SharedResourcdIdPatch::class]) +@Description("Hides the shorts button in the navigation bar.") +@DependsOn( + [ + SettingsPatch::class, + SharedResourcdIdPatch::class + ] +) @YouTubeCompatibility @Version("0.0.1") -class ShortsButtonRemoverBytecodePatch : BytecodePatch( +class ShortsButtonRemoverPatch : BytecodePatch( listOf(PivotBarCreateButtonViewFingerprint) ) { override fun execute(context: BytecodeContext): PatchResult { @@ -62,6 +72,22 @@ class ShortsButtonRemoverBytecodePatch : BytecodePatch( } ?: return PivotBarCreateButtonViewFingerprint.toErrorResult() + /* + add settings + */ + + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: LAYOUT_SETTINGS", + "PREFERENCE_HEADER: GENERAL", + "SETTINGS: SHORTS_COMPONENT.PARENT", + "SETTINGS: SHORTS_COMPONENT_PARENT.A", + "SETTINGS: HIDE_SHORTS_BUTTON" + ) + ) + + SettingsPatch.updatePatchStatus("hide-shorts-button") + return PatchResultSuccess() } private companion object { diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/pivotbar/shortsbutton/resource/patch/ShortsButtonRemoverPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/pivotbar/shortsbutton/resource/patch/ShortsButtonRemoverPatch.kt deleted file mode 100644 index bcb321bff..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/pivotbar/shortsbutton/resource/patch/ShortsButtonRemoverPatch.kt +++ /dev/null @@ -1,51 +0,0 @@ -package app.revanced.patches.youtube.layout.general.pivotbar.shortsbutton.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.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -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.shortsbutton.bytecode.patch.ShortsButtonRemoverBytecodePatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper - -@Patch -@Name("hide-shorts-button") -@Description("Hides the shorts button in the navigation bar.") -@DependsOn( - [ - ShortsButtonRemoverBytecodePatch::class, - SettingsPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class ShortsButtonRemoverPatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - /* - add settings - */ - ResourceHelper.addSettings4( - context, - "PREFERENCE_CATEGORY: REVANCED_SETTINGS", - "PREFERENCE: LAYOUT_SETTINGS", - "PREFERENCE_HEADER: GENERAL", - "SETTINGS: SHORTS_COMPONENT.PARENT", - "SETTINGS: SHORTS_COMPONENT_PARENT.A", - "SETTINGS: HIDE_SHORTS_BUTTON" - ) - - ResourceHelper.patchSuccess( - context, - "hide-shorts-button" - ) - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/shortscomponent/bytecode/patch/ShortsComponentBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/shortscomponent/patch/ShortsComponentPatch.kt similarity index 76% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/shortscomponent/bytecode/patch/ShortsComponentBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/general/shortscomponent/patch/ShortsComponentPatch.kt index e8d17dbc7..f13d92701 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/shortscomponent/bytecode/patch/ShortsComponentBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/shortscomponent/patch/ShortsComponentPatch.kt @@ -1,7 +1,8 @@ -package app.revanced.patches.youtube.layout.general.shortscomponent.bytecode.patch +package app.revanced.patches.youtube.layout.general.shortscomponent.patch import app.revanced.extensions.findMutableMethodOf import app.revanced.extensions.injectHideCall +import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext @@ -10,19 +11,30 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError 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.patch.mapping.ResourceMappingPatch -import app.revanced.util.bytecode.BytecodeHelper +import app.revanced.patches.youtube.misc.litho.patch.LithoFilterPatch +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +import app.revanced.util.bytecode.BytecodeHelper.updatePatchStatus import org.jf.dexlib2.Opcode import org.jf.dexlib2.iface.instruction.OneRegisterInstruction import org.jf.dexlib2.iface.instruction.formats.Instruction21c import org.jf.dexlib2.iface.instruction.formats.Instruction31i -@Name("hide-shorts-component-bytecode-patch") -@DependsOn([ResourceMappingPatch::class]) +@Patch +@Name("hide-shorts-component") +@Description("Hides other Shorts components.") +@DependsOn( + [ + LithoFilterPatch::class, + ResourceMappingPatch::class, + SettingsPatch::class + ] +) @YouTubeCompatibility @Version("0.0.1") -class ShortsComponentBytecodePatch : BytecodePatch() { +class ShortsComponentPatch : BytecodePatch() { // list of resource names to get the id of private val resourceIds = arrayOf( @@ -88,11 +100,31 @@ class ShortsComponentBytecodePatch : BytecodePatch() { } } } - val errorIndex = patchSuccessArray.indexOf(false) - return if (errorIndex == -1) { - BytecodeHelper.patchStatus(context, "ShortsComponent") - PatchResultSuccess() + + val errorIndex: Int = patchSuccessArray.indexOf(false) + + if (errorIndex == -1) { + context.updatePatchStatus("ShortsComponent") + + /* + add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: LAYOUT_SETTINGS", + "PREFERENCE_HEADER: GENERAL", + "SETTINGS: SHORTS_COMPONENT.PARENT", + "SETTINGS: SHORTS_COMPONENT_PARENT.A", + "SETTINGS: SHORTS_COMPONENT_PARENT.B", + "SETTINGS: HIDE_SHORTS_COMPONENTS", + "SETTINGS: HIDE_SHORTS_SHELF" + ) + ) + + SettingsPatch.updatePatchStatus("hide-shorts-component") + + return PatchResultSuccess() } else - PatchResultError("Instruction not found: $errorIndex") + return PatchResultError("Instruction not found: $errorIndex") } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/shortscomponent/resource/patch/ShortsComponentPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/shortscomponent/resource/patch/ShortsComponentPatch.kt deleted file mode 100644 index b585fdeca..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/shortscomponent/resource/patch/ShortsComponentPatch.kt +++ /dev/null @@ -1,64 +0,0 @@ -package app.revanced.patches.youtube.layout.general.shortscomponent.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.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -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.shortscomponent.bytecode.patch.ShortsComponentBytecodePatch -import app.revanced.patches.youtube.misc.litho.filter.patch.LithoFilterPatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper - -@Patch -@Name("hide-shorts-component") -@Description("Hides other Shorts components.") -@DependsOn( - [ - LithoFilterPatch::class, - ShortsComponentBytecodePatch::class, - SettingsPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class ShortsComponentPatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - /* - add settings - */ - ResourceHelper.addSettings5( - context, - "PREFERENCE_CATEGORY: REVANCED_SETTINGS", - "PREFERENCE: LAYOUT_SETTINGS", - "PREFERENCE_HEADER: GENERAL", - "SETTINGS: SHORTS_COMPONENT.PARENT", - "SETTINGS: SHORTS_COMPONENT_PARENT.A", - "SETTINGS: SHORTS_COMPONENT_PARENT.B", - "SETTINGS: HIDE_SHORTS_COMPONENTS" - ) - - ResourceHelper.addSettings4( - context, - "PREFERENCE_CATEGORY: REVANCED_SETTINGS", - "PREFERENCE: LAYOUT_SETTINGS", - "PREFERENCE_HEADER: GENERAL", - "SETTINGS: SHORTS_COMPONENT.PARENT", - "SETTINGS: SHORTS_COMPONENT_PARENT.A", - "SETTINGS: HIDE_SHORTS_SHELF" - ) - - ResourceHelper.patchSuccess( - context, - "hide-shorts-component" - ) - - return PatchResultSuccess() - } -} \ No newline at end of file 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/fingerprints/HideSnackbarFingerprint.kt similarity index 84% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/snackbar/bytecode/fingerprints/HideSnackbarFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/general/snackbar/fingerprints/HideSnackbarFingerprint.kt index 899198fc6..37c9ab33d 100644 --- 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/fingerprints/HideSnackbarFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.snackbar.bytecode.fingerprints +package app.revanced.patches.youtube.layout.general.snackbar.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint 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/patch/HideSnackbarPatch.kt similarity index 59% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/snackbar/bytecode/patch/HideSnackbarBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/general/snackbar/patch/HideSnackbarPatch.kt index de17af348..924142925 100644 --- 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/patch/HideSnackbarPatch.kt @@ -1,6 +1,7 @@ -package app.revanced.patches.youtube.layout.general.snackbar.bytecode.patch +package app.revanced.patches.youtube.layout.general.snackbar.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 @@ -9,15 +10,21 @@ 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.patcher.util.smali.ExternalLabel import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.layout.general.snackbar.bytecode.fingerprints.HideSnackbarFingerprint +import app.revanced.patches.youtube.layout.general.snackbar.fingerprints.HideSnackbarFingerprint +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.GENERAL_LAYOUT -@Name("hide-snackbar-bytecode-patch") +@Patch +@Name("hide-snackbar") +@Description("Hides the snackbar action popup.") +@DependsOn([SettingsPatch::class]) @YouTubeCompatibility @Version("0.0.1") -class HideSnackbarBytecodePatch : BytecodePatch( +class HideSnackbarPatch : BytecodePatch( listOf( HideSnackbarFingerprint ) @@ -35,6 +42,19 @@ class HideSnackbarBytecodePatch : BytecodePatch( ) } ?: return HideSnackbarFingerprint.toErrorResult() + /* + add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: LAYOUT_SETTINGS", + "PREFERENCE_HEADER: GENERAL", + "SETTINGS: HIDE_SNACKBAR" + ) + ) + + SettingsPatch.updatePatchStatus("hide-snackbar") + 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 deleted file mode 100644 index 122dc2a42..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/snackbar/resource/patch/HideSnackbarPatch.kt +++ /dev/null @@ -1,49 +0,0 @@ -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.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -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.snackbar.bytecode.patch.HideSnackbarBytecodePatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.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/kotlin/app/revanced/patches/youtube/layout/general/startupshortsreset/bytecode/fingerprints/UserWasInShortsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/startupshortsreset/fingerprints/UserWasInShortsFingerprint.kt similarity index 95% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/startupshortsreset/bytecode/fingerprints/UserWasInShortsFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/general/startupshortsreset/fingerprints/UserWasInShortsFingerprint.kt index 039e006a8..13b5e313f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/startupshortsreset/bytecode/fingerprints/UserWasInShortsFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/startupshortsreset/fingerprints/UserWasInShortsFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.startupshortsreset.bytecode.fingerprints +package app.revanced.patches.youtube.layout.general.startupshortsreset.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/startupshortsreset/bytecode/patch/HideShortsOnStartupBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/startupshortsreset/patch/HideShortsOnStartupPatch.kt similarity index 65% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/startupshortsreset/bytecode/patch/HideShortsOnStartupBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/general/startupshortsreset/patch/HideShortsOnStartupPatch.kt index d10b80219..9a92718a2 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/startupshortsreset/bytecode/patch/HideShortsOnStartupBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/startupshortsreset/patch/HideShortsOnStartupPatch.kt @@ -1,6 +1,7 @@ -package app.revanced.patches.youtube.layout.general.startupshortsreset.bytecode.patch +package app.revanced.patches.youtube.layout.general.startupshortsreset.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 @@ -9,16 +10,22 @@ 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.patcher.util.smali.ExternalLabel import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.layout.general.startupshortsreset.bytecode.fingerprints.UserWasInShortsFingerprint +import app.revanced.patches.youtube.layout.general.startupshortsreset.fingerprints.UserWasInShortsFingerprint +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 -@Name("hide-startup-shorts-player-bytecode-patch") +@Patch +@Name("hide-startup-shorts-player") +@Description("Disables playing YouTube Shorts when launching YouTube.") +@DependsOn([SettingsPatch::class]) @YouTubeCompatibility @Version("0.0.1") -class HideShortsOnStartupBytecodePatch : BytecodePatch( +class HideShortsOnStartupPatch : BytecodePatch( listOf( UserWasInShortsFingerprint ) @@ -41,6 +48,21 @@ class HideShortsOnStartupBytecodePatch : BytecodePatch( } } ?: return UserWasInShortsFingerprint.toErrorResult() + /* + add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: LAYOUT_SETTINGS", + "PREFERENCE_HEADER: GENERAL", + "SETTINGS: SHORTS_COMPONENT.PARENT", + "SETTINGS: SHORTS_COMPONENT_PARENT.B", + "SETTINGS: HIDE_STARTUP_SHORTS_PLAYER" + ) + ) + + SettingsPatch.updatePatchStatus("hide-startup-shorts-player") + return PatchResultSuccess() } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/startupshortsreset/resource/patch/HideShortsOnStartupPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/startupshortsreset/resource/patch/HideShortsOnStartupPatch.kt deleted file mode 100644 index e02820920..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/startupshortsreset/resource/patch/HideShortsOnStartupPatch.kt +++ /dev/null @@ -1,51 +0,0 @@ -package app.revanced.patches.youtube.layout.general.startupshortsreset.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.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -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.startupshortsreset.bytecode.patch.HideShortsOnStartupBytecodePatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper - -@Patch -@Name("hide-startup-shorts-player") -@Description("Disables playing YouTube Shorts when launching YouTube.") -@DependsOn( - [ - HideShortsOnStartupBytecodePatch::class, - SettingsPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class HideShortsOnStartupPatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - /* - add settings - */ - ResourceHelper.addSettings4( - context, - "PREFERENCE_CATEGORY: REVANCED_SETTINGS", - "PREFERENCE: LAYOUT_SETTINGS", - "PREFERENCE_HEADER: GENERAL", - "SETTINGS: SHORTS_COMPONENT.PARENT", - "SETTINGS: SHORTS_COMPONENT_PARENT.B", - "SETTINGS: HIDE_STARTUP_SHORTS_PLAYER" - ) - - ResourceHelper.patchSuccess( - context, - "hide-startup-shorts-player" - ) - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/stories/bytecode/patch/HideStoriesBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/stories/patch/HideStoriesPatch.kt similarity index 69% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/stories/bytecode/patch/HideStoriesBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/general/stories/patch/HideStoriesPatch.kt index 67723fe2d..d89214c37 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/stories/bytecode/patch/HideStoriesBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/stories/patch/HideStoriesPatch.kt @@ -1,25 +1,36 @@ -package app.revanced.patches.youtube.layout.general.stories.bytecode.patch +package app.revanced.patches.youtube.layout.general.stories.patch import app.revanced.extensions.findMutableMethodOf import app.revanced.extensions.injectHideCall -import app.revanced.extensions.toResult +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.PatchResultError +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.patch.mapping.ResourceMappingPatch +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch import org.jf.dexlib2.Opcode import org.jf.dexlib2.iface.instruction.formats.Instruction22c import org.jf.dexlib2.iface.instruction.formats.Instruction31i -@Name("hide-stories-bytecode-patch") -@DependsOn([ResourceMappingPatch::class]) +@Patch +@Name("hide-stories") +@Description("Hides YouTube Stories shelf on the feed.") +@DependsOn( + [ + ResourceMappingPatch::class, + SettingsPatch::class + ] +) @YouTubeCompatibility @Version("0.0.1") -class HideStoriesBytecodePatch : BytecodePatch() { +class HideStoriesPatch : BytecodePatch() { // list of resource names to get the id of private val resourceIds = arrayOf( @@ -59,6 +70,25 @@ class HideStoriesBytecodePatch : BytecodePatch() { } } } - return toResult(patchSuccessArray.indexOf(false)) + + val errorIndex: Int = patchSuccessArray.indexOf(false) + + if (errorIndex == -1) { + /* + add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: LAYOUT_SETTINGS", + "PREFERENCE_HEADER: GENERAL", + "SETTINGS: HIDE_STORIES_SHELF" + ) + ) + + SettingsPatch.updatePatchStatus("hide-stories") + + return PatchResultSuccess() + } else + return PatchResultError("Instruction not found: $errorIndex") } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/stories/resource/patch/HideStoriesPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/stories/resource/patch/HideStoriesPatch.kt deleted file mode 100644 index 01f119364..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/stories/resource/patch/HideStoriesPatch.kt +++ /dev/null @@ -1,49 +0,0 @@ -package app.revanced.patches.youtube.layout.general.stories.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.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -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.stories.bytecode.patch.HideStoriesBytecodePatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper - -@Patch -@Name("hide-stories") -@Description("Hides YouTube Stories shelf on the feed.") -@DependsOn( - [ - HideStoriesBytecodePatch::class, - SettingsPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class HideStoriesPatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - /* - add settings - */ - ResourceHelper.addSettings2( - context, - "PREFERENCE_CATEGORY: REVANCED_SETTINGS", - "PREFERENCE: LAYOUT_SETTINGS", - "PREFERENCE_HEADER: GENERAL", - "SETTINGS: HIDE_STORIES_SHELF" - ) - - ResourceHelper.patchSuccess( - context, - "hide-stories" - ) - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/bytecode/fingerprints/MiniPlayerDimensionsCalculatorFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/fingerprints/MiniPlayerDimensionsCalculatorFingerprint.kt similarity index 66% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/bytecode/fingerprints/MiniPlayerDimensionsCalculatorFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/fingerprints/MiniPlayerDimensionsCalculatorFingerprint.kt index affe6ac0e..283d3ed26 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/bytecode/fingerprints/MiniPlayerDimensionsCalculatorFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/fingerprints/MiniPlayerDimensionsCalculatorFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.tabletminiplayer.bytecode.fingerprints +package app.revanced.patches.youtube.layout.general.tabletminiplayer.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint @@ -11,9 +11,9 @@ object MiniPlayerDimensionsCalculatorFingerprint : MethodFingerprint( "V", AccessFlags.PUBLIC or AccessFlags.FINAL, customFingerprint = { methodDef -> - methodDef.implementation?.instructions?.any { instruction -> - instruction.opcode.ordinal == Opcode.CONST.ordinal && - (instruction as? WideLiteralInstruction)?.wideLiteral == SharedResourcdIdPatch.floatybarQueueLabelId + methodDef.implementation?.instructions?.any { + it.opcode.ordinal == Opcode.CONST.ordinal && + (it as? WideLiteralInstruction)?.wideLiteral == SharedResourcdIdPatch.floatybarQueueLabelId } == true } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/bytecode/fingerprints/MiniPlayerOverrideFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/fingerprints/MiniPlayerOverrideFingerprint.kt similarity index 94% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/bytecode/fingerprints/MiniPlayerOverrideFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/fingerprints/MiniPlayerOverrideFingerprint.kt index 8589afe2d..a957fd711 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/bytecode/fingerprints/MiniPlayerOverrideFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/fingerprints/MiniPlayerOverrideFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.tabletminiplayer.bytecode.fingerprints +package app.revanced.patches.youtube.layout.general.tabletminiplayer.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/bytecode/fingerprints/MiniPlayerOverrideNoContextFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/fingerprints/MiniPlayerOverrideNoContextFingerprint.kt similarity index 94% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/bytecode/fingerprints/MiniPlayerOverrideNoContextFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/fingerprints/MiniPlayerOverrideNoContextFingerprint.kt index 3c9bba6d5..3dead74d0 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/bytecode/fingerprints/MiniPlayerOverrideNoContextFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/fingerprints/MiniPlayerOverrideNoContextFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.tabletminiplayer.bytecode.fingerprints +package app.revanced.patches.youtube.layout.general.tabletminiplayer.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/bytecode/fingerprints/MiniPlayerResponseModelSizeCheckFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/fingerprints/MiniPlayerResponseModelSizeCheckFingerprint.kt similarity index 95% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/bytecode/fingerprints/MiniPlayerResponseModelSizeCheckFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/fingerprints/MiniPlayerResponseModelSizeCheckFingerprint.kt index 61386f496..967bb0ad2 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/bytecode/fingerprints/MiniPlayerResponseModelSizeCheckFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/fingerprints/MiniPlayerResponseModelSizeCheckFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.tabletminiplayer.bytecode.fingerprints +package app.revanced.patches.youtube.layout.general.tabletminiplayer.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/bytecode/patch/TabletMiniPlayerBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/patch/TabletMiniPlayerPatch.kt similarity index 81% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/bytecode/patch/TabletMiniPlayerBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/patch/TabletMiniPlayerPatch.kt index bcc36ffe8..10f5d2338 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/bytecode/patch/TabletMiniPlayerBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/patch/TabletMiniPlayerPatch.kt @@ -1,6 +1,7 @@ -package app.revanced.patches.youtube.layout.general.tabletminiplayer.bytecode.patch +package app.revanced.patches.youtube.layout.general.tabletminiplayer.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 @@ -11,18 +12,27 @@ 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.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.layout.general.tabletminiplayer.bytecode.fingerprints.* +import app.revanced.patches.youtube.layout.general.tabletminiplayer.fingerprints.* import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourcdIdPatch +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 -@Name("enable-tablet-miniplayer-bytecode-patch") -@DependsOn([SharedResourcdIdPatch::class]) +@Patch +@Name("enable-tablet-miniplayer") +@Description("Enables the tablet mini player layout.") +@DependsOn( + [ + SettingsPatch::class, + SharedResourcdIdPatch::class + ] +) @YouTubeCompatibility @Version("0.0.1") -class TabletMiniPlayerBytecodePatch : BytecodePatch( +class TabletMiniPlayerPatch : BytecodePatch( listOf( MiniPlayerDimensionsCalculatorFingerprint, MiniPlayerResponseModelSizeCheckFingerprint @@ -50,6 +60,19 @@ class TabletMiniPlayerBytecodePatch : BytecodePatch( } } ?: return MiniPlayerDimensionsCalculatorFingerprint.toErrorResult() + /* + add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: LAYOUT_SETTINGS", + "PREFERENCE_HEADER: GENERAL", + "SETTINGS: ENABLE_TABLET_MINIPLAYER" + ) + ) + + SettingsPatch.updatePatchStatus("enable-tablet-miniplayer") + return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/resource/patch/TabletMiniPlayerPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/resource/patch/TabletMiniPlayerPatch.kt deleted file mode 100644 index 4d3513ace..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/tabletminiplayer/resource/patch/TabletMiniPlayerPatch.kt +++ /dev/null @@ -1,49 +0,0 @@ -package app.revanced.patches.youtube.layout.general.tabletminiplayer.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.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -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.tabletminiplayer.bytecode.patch.TabletMiniPlayerBytecodePatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper - -@Patch -@Name("enable-tablet-miniplayer") -@Description("Enables the tablet mini player layout.") -@DependsOn( - [ - TabletMiniPlayerBytecodePatch::class, - SettingsPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class TabletMiniPlayerPatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - /* - add settings - */ - ResourceHelper.addSettings2( - context, - "PREFERENCE_CATEGORY: REVANCED_SETTINGS", - "PREFERENCE: LAYOUT_SETTINGS", - "PREFERENCE_HEADER: GENERAL", - "SETTINGS: ENABLE_TABLET_MINIPLAYER" - ) - - ResourceHelper.patchSuccess( - context, - "enable-tablet-miniplayer" - ) - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/bytecode/fingerprints/WideSearchbarOneFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/fingerprints/WideSearchbarOneFingerprint.kt similarity index 95% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/bytecode/fingerprints/WideSearchbarOneFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/fingerprints/WideSearchbarOneFingerprint.kt index 862e91606..b81c41e80 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/bytecode/fingerprints/WideSearchbarOneFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/fingerprints/WideSearchbarOneFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.widesearchbar.bytecode.fingerprints +package app.revanced.patches.youtube.layout.general.widesearchbar.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/bytecode/fingerprints/WideSearchbarOneParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/fingerprints/WideSearchbarOneParentFingerprint.kt similarity index 95% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/bytecode/fingerprints/WideSearchbarOneParentFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/fingerprints/WideSearchbarOneParentFingerprint.kt index 78f8f6cbf..d39c5de52 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/bytecode/fingerprints/WideSearchbarOneParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/fingerprints/WideSearchbarOneParentFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.widesearchbar.bytecode.fingerprints +package app.revanced.patches.youtube.layout.general.widesearchbar.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/bytecode/fingerprints/WideSearchbarTwoFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/fingerprints/WideSearchbarTwoFingerprint.kt similarity index 95% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/bytecode/fingerprints/WideSearchbarTwoFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/fingerprints/WideSearchbarTwoFingerprint.kt index f4d74abae..68a33f689 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/bytecode/fingerprints/WideSearchbarTwoFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/fingerprints/WideSearchbarTwoFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.widesearchbar.bytecode.fingerprints +package app.revanced.patches.youtube.layout.general.widesearchbar.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/bytecode/fingerprints/WideSearchbarTwoParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/fingerprints/WideSearchbarTwoParentFingerprint.kt similarity index 95% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/bytecode/fingerprints/WideSearchbarTwoParentFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/fingerprints/WideSearchbarTwoParentFingerprint.kt index 540565202..4621ddbe8 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/bytecode/fingerprints/WideSearchbarTwoParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/fingerprints/WideSearchbarTwoParentFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.general.widesearchbar.bytecode.fingerprints +package app.revanced.patches.youtube.layout.general.widesearchbar.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/bytecode/patch/WideSearchbarBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/patch/WideSearchbarPatch.kt similarity index 74% rename from src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/bytecode/patch/WideSearchbarBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/patch/WideSearchbarPatch.kt index 64b394067..ffd17156b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/bytecode/patch/WideSearchbarBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/patch/WideSearchbarPatch.kt @@ -1,6 +1,7 @@ -package app.revanced.patches.youtube.layout.general.widesearchbar.bytecode.patch +package app.revanced.patches.youtube.layout.general.widesearchbar.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 @@ -10,15 +11,21 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion. 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.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.layout.general.widesearchbar.bytecode.fingerprints.* +import app.revanced.patches.youtube.layout.general.widesearchbar.fingerprints.* +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.GENERAL_LAYOUT -@Name("enable-wide-searchbar-bytecode-patch") +@Patch +@Name("enable-wide-searchbar") +@Description("Replaces the search icon with a wide search bar. This will hide the YouTube logo when active.") +@DependsOn([SettingsPatch::class]) @YouTubeCompatibility @Version("0.0.1") -class WideSearchbarBytecodePatch : BytecodePatch( +class WideSearchbarPatch : BytecodePatch( listOf( WideSearchbarOneParentFingerprint, WideSearchbarTwoParentFingerprint @@ -46,6 +53,19 @@ class WideSearchbarBytecodePatch : BytecodePatch( } ?: return parentFingerprint.toErrorResult() } + /* + add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: LAYOUT_SETTINGS", + "PREFERENCE_HEADER: GENERAL", + "SETTINGS: ENABLE_WIDE_SEARCHBAR" + ) + ) + + SettingsPatch.updatePatchStatus("enable-wide-searchbar") + return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/resource/patch/WideSearchbarPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/resource/patch/WideSearchbarPatch.kt deleted file mode 100644 index 93cd2b5a9..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/widesearchbar/resource/patch/WideSearchbarPatch.kt +++ /dev/null @@ -1,49 +0,0 @@ -package app.revanced.patches.youtube.layout.general.widesearchbar.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.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -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.widesearchbar.bytecode.patch.WideSearchbarBytecodePatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper - -@Patch -@Name("enable-wide-searchbar") -@Description("Replaces the search icon with a wide search bar. This will hide the YouTube logo when active.") -@DependsOn( - [ - WideSearchbarBytecodePatch::class, - SettingsPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class WideSearchbarPatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - /* - add settings - */ - ResourceHelper.addSettings2( - context, - "PREFERENCE_CATEGORY: REVANCED_SETTINGS", - "PREFERENCE: LAYOUT_SETTINGS", - "PREFERENCE_HEADER: GENERAL", - "SETTINGS: ENABLE_WIDE_SEARCHBAR" - ) - - ResourceHelper.patchSuccess( - context, - "enable-wide-searchbar" - ) - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/autoplaybutton/bytecode/patch/HideAutoplayButtonBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/player/autoplaybutton/patch/HideAutoplayButtonPatch.kt similarity index 77% rename from src/main/kotlin/app/revanced/patches/youtube/layout/player/autoplaybutton/bytecode/patch/HideAutoplayButtonBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/player/autoplaybutton/patch/HideAutoplayButtonPatch.kt index 5af1cd050..d4cef1996 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/autoplaybutton/bytecode/patch/HideAutoplayButtonBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/player/autoplaybutton/patch/HideAutoplayButtonPatch.kt @@ -1,6 +1,7 @@ -package app.revanced.patches.youtube.layout.player.autoplaybutton.bytecode.patch +package app.revanced.patches.youtube.layout.player.autoplaybutton.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 @@ -9,21 +10,30 @@ 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.patcher.util.smali.ExternalLabel import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.shared.fingerprints.LayoutConstructorFingerprint import app.revanced.patches.shared.patch.mapping.ResourceMappingPatch +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.PLAYER_LAYOUT import org.jf.dexlib2.iface.instruction.Instruction import org.jf.dexlib2.iface.instruction.ReferenceInstruction import org.jf.dexlib2.iface.instruction.WideLiteralInstruction import org.jf.dexlib2.iface.reference.MethodReference -@Name("hide-autoplay-button-bytecode-patch") -@DependsOn([ResourceMappingPatch::class]) +@Patch +@Name("hide-autoplay-button") +@Description("Hides the autoplay button in the video player.") +@DependsOn( + [ + ResourceMappingPatch::class, + SettingsPatch::class + ] +) @YouTubeCompatibility @Version("0.0.1") -class HideAutoplayButtonBytecodePatch : BytecodePatch( +class HideAutoplayButtonPatch : BytecodePatch( listOf( LayoutConstructorFingerprint ) @@ -57,6 +67,19 @@ class HideAutoplayButtonBytecodePatch : BytecodePatch( } } ?: return LayoutConstructorFingerprint.toErrorResult() + /* + add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: LAYOUT_SETTINGS", + "PREFERENCE_HEADER: PLAYER", + "SETTINGS: HIDE_AUTOPLAY_BUTTON" + ) + ) + + SettingsPatch.updatePatchStatus("hide-autoplay-button") + return PatchResultSuccess() } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/autoplaybutton/resource/patch/HideAutoplayButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/player/autoplaybutton/resource/patch/HideAutoplayButtonPatch.kt deleted file mode 100644 index 00f8a3748..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/autoplaybutton/resource/patch/HideAutoplayButtonPatch.kt +++ /dev/null @@ -1,49 +0,0 @@ -package app.revanced.patches.youtube.layout.player.autoplaybutton.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.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -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.player.autoplaybutton.bytecode.patch.HideAutoplayButtonBytecodePatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper - -@Patch -@Name("hide-autoplay-button") -@Description("Hides the autoplay button in the video player.") -@DependsOn( - [ - HideAutoplayButtonBytecodePatch::class, - SettingsPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class HideAutoplayButtonPatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - /* - add settings - */ - ResourceHelper.addSettings2( - context, - "PREFERENCE_CATEGORY: REVANCED_SETTINGS", - "PREFERENCE: LAYOUT_SETTINGS", - "PREFERENCE_HEADER: PLAYER", - "SETTINGS: HIDE_AUTOPLAY_BUTTON" - ) - - ResourceHelper.patchSuccess( - context, - "hide-autoplay-button" - ) - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/captionsbutton/bytecode/patch/HideCaptionsButtonBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/player/captionsbutton/patch/HideCaptionsButtonPatch.kt similarity index 68% rename from src/main/kotlin/app/revanced/patches/youtube/layout/player/captionsbutton/bytecode/patch/HideCaptionsButtonBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/player/captionsbutton/patch/HideCaptionsButtonPatch.kt index 594379740..e19beea95 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/captionsbutton/bytecode/patch/HideCaptionsButtonBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/player/captionsbutton/patch/HideCaptionsButtonPatch.kt @@ -1,6 +1,7 @@ -package app.revanced.patches.youtube.layout.player.captionsbutton.bytecode.patch +package app.revanced.patches.youtube.layout.player.captionsbutton.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 @@ -8,12 +9,18 @@ import app.revanced.patcher.extensions.addInstruction 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.SubtitleButtonControllerFingerprint +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.PLAYER_LAYOUT import org.jf.dexlib2.Opcode -@Name("hide-captions-button-bytecode-patch") +@Patch +@Name("hide-captions-button") +@Description("Hides the captions button in the video player.") +@DependsOn([SettingsPatch::class]) @YouTubeCompatibility @Version("0.0.1") class HideCaptionsButtonBytecodePatch : BytecodePatch( @@ -38,6 +45,19 @@ class HideCaptionsButtonBytecodePatch : BytecodePatch( } } ?: return SubtitleButtonControllerFingerprint.toErrorResult() + /* + add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: LAYOUT_SETTINGS", + "PREFERENCE_HEADER: PLAYER", + "SETTINGS: HIDE_CAPTIONS_BUTTON" + ) + ) + + SettingsPatch.updatePatchStatus("hide-captions-button") + return PatchResultSuccess() } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/captionsbutton/resource/patch/HideCaptionsButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/player/captionsbutton/resource/patch/HideCaptionsButtonPatch.kt deleted file mode 100644 index e71f444ec..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/captionsbutton/resource/patch/HideCaptionsButtonPatch.kt +++ /dev/null @@ -1,49 +0,0 @@ -package app.revanced.patches.youtube.layout.player.captionsbutton.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.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -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.player.captionsbutton.bytecode.patch.HideCaptionsButtonBytecodePatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper - -@Patch -@Name("hide-player-captions-button") -@Description("Hides the captions button in the video player.") -@DependsOn( - [ - HideCaptionsButtonBytecodePatch::class, - SettingsPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class HideCaptionsButtonPatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - /* - add settings - */ - ResourceHelper.addSettings2( - context, - "PREFERENCE_CATEGORY: REVANCED_SETTINGS", - "PREFERENCE: LAYOUT_SETTINGS", - "PREFERENCE_HEADER: PLAYER", - "SETTINGS: HIDE_CAPTIONS_BUTTON" - ) - - ResourceHelper.patchSuccess( - context, - "hide-captions-button" - ) - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/castbutton/bytecode/patch/HideCastButtonBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/player/castbutton/patch/HideCastButtonPatch.kt similarity index 61% rename from src/main/kotlin/app/revanced/patches/youtube/layout/player/castbutton/bytecode/patch/HideCastButtonBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/player/castbutton/patch/HideCastButtonPatch.kt index 68c5a1dd8..a5d184a23 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/castbutton/bytecode/patch/HideCastButtonBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/player/castbutton/patch/HideCastButtonPatch.kt @@ -1,5 +1,6 @@ -package app.revanced.patches.youtube.layout.player.castbutton.bytecode.patch +package app.revanced.patches.youtube.layout.player.castbutton.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 @@ -7,13 +8,19 @@ import app.revanced.patcher.extensions.addInstructions 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.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.PLAYER_LAYOUT -@Name("hide-cast-button-bytecode-patch") +@Patch +@Name("hide-cast-button") +@Description("Hides the cast button in the video player.") +@DependsOn([SettingsPatch::class]) @YouTubeCompatibility @Version("0.0.1") -class HideCastButtonBytecodePatch : BytecodePatch() { +class HideCastButtonPatch : BytecodePatch() { override fun execute(context: BytecodeContext): PatchResult { context.classes.forEach { classDef -> classDef.methods.forEach { method -> @@ -31,6 +38,19 @@ class HideCastButtonBytecodePatch : BytecodePatch() { } } + /* + add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: LAYOUT_SETTINGS", + "PREFERENCE_HEADER: PLAYER", + "SETTINGS: HIDE_CAST_BUTTON" + ) + ) + + SettingsPatch.updatePatchStatus("hide-cast-button") + return PatchResultSuccess() } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/castbutton/resource/patch/HideCastButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/player/castbutton/resource/patch/HideCastButtonPatch.kt deleted file mode 100644 index d4ccc2414..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/castbutton/resource/patch/HideCastButtonPatch.kt +++ /dev/null @@ -1,49 +0,0 @@ -package app.revanced.patches.youtube.layout.player.castbutton.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.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -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.player.castbutton.bytecode.patch.HideCastButtonBytecodePatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper - -@Patch -@Name("hide-cast-button") -@Description("Hides the cast button in the video player.") -@DependsOn( - [ - HideCastButtonBytecodePatch::class, - SettingsPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class HideCastButtonPatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - /* - add settings - */ - ResourceHelper.addSettings2( - context, - "PREFERENCE_CATEGORY: REVANCED_SETTINGS", - "PREFERENCE: LAYOUT_SETTINGS", - "PREFERENCE_HEADER: PLAYER", - "SETTINGS: HIDE_CAST_BUTTON" - ) - - ResourceHelper.patchSuccess( - context, - "hide-cast-button" - ) - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/endscreencards/bytecode/fingerprints/LayoutCircleFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/player/endscreencards/fingerprints/LayoutCircleFingerprint.kt similarity index 97% rename from src/main/kotlin/app/revanced/patches/youtube/layout/player/endscreencards/bytecode/fingerprints/LayoutCircleFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/player/endscreencards/fingerprints/LayoutCircleFingerprint.kt index bd4240ca8..50b91822c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/endscreencards/bytecode/fingerprints/LayoutCircleFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/player/endscreencards/fingerprints/LayoutCircleFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.player.endscreencards.bytecode.fingerprints +package app.revanced.patches.youtube.layout.player.endscreencards.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourcdIdPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/endscreencards/bytecode/fingerprints/LayoutIconFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/player/endscreencards/fingerprints/LayoutIconFingerprint.kt similarity index 97% rename from src/main/kotlin/app/revanced/patches/youtube/layout/player/endscreencards/bytecode/fingerprints/LayoutIconFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/player/endscreencards/fingerprints/LayoutIconFingerprint.kt index efbcd112f..2982f8c50 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/endscreencards/bytecode/fingerprints/LayoutIconFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/player/endscreencards/fingerprints/LayoutIconFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.player.endscreencards.bytecode.fingerprints +package app.revanced.patches.youtube.layout.player.endscreencards.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourcdIdPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/endscreencards/bytecode/fingerprints/LayoutVideoFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/player/endscreencards/fingerprints/LayoutVideoFingerprint.kt similarity index 97% rename from src/main/kotlin/app/revanced/patches/youtube/layout/player/endscreencards/bytecode/fingerprints/LayoutVideoFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/player/endscreencards/fingerprints/LayoutVideoFingerprint.kt index ba0bdf171..fdf4043ec 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/endscreencards/bytecode/fingerprints/LayoutVideoFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/player/endscreencards/fingerprints/LayoutVideoFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.player.endscreencards.bytecode.fingerprints +package app.revanced.patches.youtube.layout.player.endscreencards.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourcdIdPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/endscreencards/bytecode/patch/HideEndscreenCardsBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/player/endscreencards/patch/HideEndscreenCardsPatch.kt similarity index 63% rename from src/main/kotlin/app/revanced/patches/youtube/layout/player/endscreencards/bytecode/patch/HideEndscreenCardsBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/player/endscreencards/patch/HideEndscreenCardsPatch.kt index f5ad54773..e26da9073 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/endscreencards/bytecode/patch/HideEndscreenCardsBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/player/endscreencards/patch/HideEndscreenCardsPatch.kt @@ -1,7 +1,8 @@ -package app.revanced.patches.youtube.layout.player.endscreencards.bytecode.patch +package app.revanced.patches.youtube.layout.player.endscreencards.patch import app.revanced.extensions.injectHideCall 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 @@ -10,14 +11,26 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult 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.player.endscreencards.bytecode.fingerprints.* +import app.revanced.patches.youtube.layout.player.endscreencards.fingerprints.* +import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourcdIdPatch +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch import org.jf.dexlib2.iface.instruction.formats.Instruction21c -@Name("hide-endscreen-cards-bytecode-patch") +@Patch +@Name("hide-endscreen-cards") +@Description("Hides the suggested video cards at the end of a video in fullscreen.") +@DependsOn( + [ + SettingsPatch::class, + SharedResourcdIdPatch::class + ] +) @YouTubeCompatibility @Version("0.0.1") -class HideEndscreenCardsBytecodePatch : BytecodePatch( +class HideEndscreenCardsPatch : BytecodePatch( listOf( LayoutCircleFingerprint, LayoutIconFingerprint, @@ -42,6 +55,19 @@ class HideEndscreenCardsBytecodePatch : BytecodePatch( it.result?.injectHideCalls() ?: return it.toErrorResult() } + /* + add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: LAYOUT_SETTINGS", + "PREFERENCE_HEADER: PLAYER", + "SETTINGS: HIDE_ENDSCREEN_CARDS" + ) + ) + + SettingsPatch.updatePatchStatus("hide-endscreen-cards") + return PatchResultSuccess() } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/endscreencards/resource/patch/HideEndscreenCardsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/player/endscreencards/resource/patch/HideEndscreenCardsPatch.kt deleted file mode 100644 index dc805dcde..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/endscreencards/resource/patch/HideEndscreenCardsPatch.kt +++ /dev/null @@ -1,49 +0,0 @@ -package app.revanced.patches.youtube.layout.player.endscreencards.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.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -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.player.endscreencards.bytecode.patch.HideEndscreenCardsBytecodePatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper - -@Patch -@Name("hide-endscreen-cards") -@Description("Hides the suggested video cards at the end of a video in fullscreen.") -@DependsOn( - [ - HideEndscreenCardsBytecodePatch::class, - SettingsPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class HideEndscreenCardsPatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - /* - add settings - */ - ResourceHelper.addSettings2( - context, - "PREFERENCE_CATEGORY: REVANCED_SETTINGS", - "PREFERENCE: LAYOUT_SETTINGS", - "PREFERENCE_HEADER: PLAYER", - "SETTINGS: HIDE_ENDSCREEN_CARDS" - ) - - ResourceHelper.patchSuccess( - context, - "hide-endscreen-cards" - ) - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/infocards/bytecode/fingerprints/InfocardsIncognitoFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/player/infocards/fingerprints/InfocardsIncognitoFingerprint.kt similarity index 87% rename from src/main/kotlin/app/revanced/patches/youtube/layout/player/infocards/bytecode/fingerprints/InfocardsIncognitoFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/player/infocards/fingerprints/InfocardsIncognitoFingerprint.kt index f3cd0aa96..5c264975a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/infocards/bytecode/fingerprints/InfocardsIncognitoFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/player/infocards/fingerprints/InfocardsIncognitoFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.player.infocards.bytecode.fingerprints +package app.revanced.patches.youtube.layout.player.infocards.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/infocards/bytecode/fingerprints/InfocardsIncognitoParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/player/infocards/fingerprints/InfocardsIncognitoParentFingerprint.kt similarity index 88% rename from src/main/kotlin/app/revanced/patches/youtube/layout/player/infocards/bytecode/fingerprints/InfocardsIncognitoParentFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/player/infocards/fingerprints/InfocardsIncognitoParentFingerprint.kt index a0731f26f..d40930773 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/infocards/bytecode/fingerprints/InfocardsIncognitoParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/player/infocards/fingerprints/InfocardsIncognitoParentFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.player.infocards.bytecode.fingerprints +package app.revanced.patches.youtube.layout.player.infocards.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/infocards/bytecode/patch/HideInfoCardsBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/player/infocards/patch/HideInfocardsPatch.kt similarity index 57% rename from src/main/kotlin/app/revanced/patches/youtube/layout/player/infocards/bytecode/patch/HideInfoCardsBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/player/infocards/patch/HideInfocardsPatch.kt index ce08dbad6..3eaf49d2a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/infocards/bytecode/patch/HideInfoCardsBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/player/infocards/patch/HideInfocardsPatch.kt @@ -1,6 +1,7 @@ -package app.revanced.patches.youtube.layout.player.infocards.bytecode.patch +package app.revanced.patches.youtube.layout.player.infocards.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 @@ -9,15 +10,21 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion. 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.player.infocards.bytecode.fingerprints.InfocardsIncognitoFingerprint -import app.revanced.patches.youtube.layout.player.infocards.bytecode.fingerprints.InfocardsIncognitoParentFingerprint +import app.revanced.patches.youtube.layout.player.infocards.fingerprints.InfocardsIncognitoFingerprint +import app.revanced.patches.youtube.layout.player.infocards.fingerprints.InfocardsIncognitoParentFingerprint +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.PLAYER_LAYOUT -@Name("hide-info-cards-bytecode-patch") +@Patch +@Name("hide-info-cards") +@Description("Hides info-cards in videos.") +@DependsOn([SettingsPatch::class]) @YouTubeCompatibility @Version("0.0.1") -class HideInfoCardsBytecodePatch : BytecodePatch( +class HideInfocardsPatch : BytecodePatch( listOf(InfocardsIncognitoParentFingerprint) ) { override fun execute(context: BytecodeContext): PatchResult { @@ -33,6 +40,19 @@ class HideInfoCardsBytecodePatch : BytecodePatch( ) ?: return InfocardsIncognitoFingerprint.toErrorResult() } ?: return InfocardsIncognitoParentFingerprint.toErrorResult() + /* + add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: LAYOUT_SETTINGS", + "PREFERENCE_HEADER: PLAYER", + "SETTINGS: HIDE_INFO_CARDS" + ) + ) + + SettingsPatch.updatePatchStatus("hide-info-cards") + return PatchResultSuccess() } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/infocards/resource/patch/HideInfocardsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/player/infocards/resource/patch/HideInfocardsPatch.kt deleted file mode 100644 index 290af397a..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/infocards/resource/patch/HideInfocardsPatch.kt +++ /dev/null @@ -1,49 +0,0 @@ -package app.revanced.patches.youtube.layout.player.infocards.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.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -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.player.infocards.bytecode.patch.HideInfoCardsBytecodePatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper - -@Patch -@Name("hide-info-cards") -@Description("Hides info-cards in videos.") -@DependsOn( - [ - HideInfoCardsBytecodePatch::class, - SettingsPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class HideInfoCardsPatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - /* - add settings - */ - ResourceHelper.addSettings2( - context, - "PREFERENCE_CATEGORY: REVANCED_SETTINGS", - "PREFERENCE: LAYOUT_SETTINGS", - "PREFERENCE_HEADER: PLAYER", - "SETTINGS: HIDE_INFO_CARDS" - ) - - ResourceHelper.patchSuccess( - context, - "hide-info-cards" - ) - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/livechatbutton/patch/HideLiveChatButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/player/livechatbutton/patch/HideLiveChatButtonPatch.kt index e0d24b2ce..d420af3d3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/livechatbutton/patch/HideLiveChatButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/player/livechatbutton/patch/HideLiveChatButtonPatch.kt @@ -12,7 +12,6 @@ import app.revanced.patcher.patch.annotations.Patch import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.youtube.misc.playerbutton.patch.PlayerButtonPatch import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper @Patch @Name("hide-live-chat-button") @@ -31,18 +30,15 @@ class HideLiveChatButtonPatch : ResourcePatch { /* add settings */ - ResourceHelper.addSettings2( - context, - "PREFERENCE_CATEGORY: REVANCED_SETTINGS", - "PREFERENCE: LAYOUT_SETTINGS", - "PREFERENCE_HEADER: PLAYER", - "SETTINGS: HIDE_LIVE_CHATS_BUTTON" + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: LAYOUT_SETTINGS", + "PREFERENCE_HEADER: PLAYER", + "SETTINGS: HIDE_LIVE_CHATS_BUTTON" + ) ) - ResourceHelper.patchSuccess( - context, - "hide-live-chat-button" - ) + SettingsPatch.updatePatchStatus("hide-live-chat-button") return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/nextprevbutton/patch/HideNextPrevButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/player/nextprevbutton/patch/HideNextPrevButtonPatch.kt index 4d8fe8a18..ad983ea18 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/nextprevbutton/patch/HideNextPrevButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/player/nextprevbutton/patch/HideNextPrevButtonPatch.kt @@ -12,7 +12,6 @@ import app.revanced.patcher.patch.annotations.Patch import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.youtube.misc.playerbutton.patch.PlayerButtonPatch import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper @Patch @Name("hide-next-prev-button") @@ -31,19 +30,16 @@ class HideNextPrevButtonPatch : ResourcePatch { /* add settings */ - ResourceHelper.addSettings3( - context, - "PREFERENCE_CATEGORY: REVANCED_SETTINGS", - "PREFERENCE: LAYOUT_SETTINGS", - "PREFERENCE_HEADER: PLAYER", - "SETTINGS: HIDE_NEXT_BUTTON", - "SETTINGS: HIDE_PREV_BUTTON" + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: LAYOUT_SETTINGS", + "PREFERENCE_HEADER: PLAYER", + "SETTINGS: HIDE_NEXT_BUTTON", + "SETTINGS: HIDE_PREV_BUTTON" + ) ) - ResourceHelper.patchSuccess( - context, - "hide-next-prev-button" - ) + SettingsPatch.updatePatchStatus("hide-next-prev-button") return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/playeroverlayfilter/bytecode/patch/PlayerOverlayFilterBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/player/playeroverlayfilter/patch/PlayerOverlayFilterPatch.kt similarity index 76% rename from src/main/kotlin/app/revanced/patches/youtube/layout/player/playeroverlayfilter/bytecode/patch/PlayerOverlayFilterBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/player/playeroverlayfilter/patch/PlayerOverlayFilterPatch.kt index 61207c46b..7703e63d4 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/playeroverlayfilter/bytecode/patch/PlayerOverlayFilterBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/player/playeroverlayfilter/patch/PlayerOverlayFilterPatch.kt @@ -1,7 +1,7 @@ -package app.revanced.patches.youtube.layout.player.playeroverlayfilter.bytecode.patch +package app.revanced.patches.youtube.layout.player.playeroverlayfilter.patch import app.revanced.extensions.findMutableMethodOf -import app.revanced.extensions.toResult +import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext @@ -9,19 +9,30 @@ 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.PatchResultError +import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn +import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.shared.patch.mapping.ResourceMappingPatch +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch import org.jf.dexlib2.Opcode import org.jf.dexlib2.iface.instruction.formats.Instruction21c import org.jf.dexlib2.iface.instruction.formats.Instruction31i -@DependsOn([ResourceMappingPatch::class]) -@Name("hide-player-overlay-filter-bytecode-patch") +@Patch +@Name("hide-player-overlay-filter") +@Description("Remove the dark filter layer from the player's background.") +@DependsOn( + [ + ResourceMappingPatch::class, + SettingsPatch::class + ] +) @YouTubeCompatibility @Version("0.0.1") -class PlayerOverlayFilterBytecodePatch : BytecodePatch() { +class PlayerOverlayFilterPatch : BytecodePatch() { // list of resource names to get the id of private val resourceIds = arrayOf( @@ -72,6 +83,25 @@ class PlayerOverlayFilterBytecodePatch : BytecodePatch() { } } } - return toResult(patchSuccessArray.indexOf(false)) + + val errorIndex: Int = patchSuccessArray.indexOf(false) + + if (errorIndex == -1) { + /* + add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: LAYOUT_SETTINGS", + "PREFERENCE_HEADER: PLAYER", + "SETTINGS: HIDE_PLAYER_OVERLAY_FILTER" + ) + ) + + SettingsPatch.updatePatchStatus("hide-player-overlay-filter") + + return PatchResultSuccess() + } else + return PatchResultError("Instruction not found: $errorIndex") } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/playeroverlayfilter/resource/patch/PlayerOverlayFilterPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/player/playeroverlayfilter/resource/patch/PlayerOverlayFilterPatch.kt deleted file mode 100644 index 11ee32423..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/playeroverlayfilter/resource/patch/PlayerOverlayFilterPatch.kt +++ /dev/null @@ -1,49 +0,0 @@ -package app.revanced.patches.youtube.layout.player.playeroverlayfilter.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.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -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.player.playeroverlayfilter.bytecode.patch.PlayerOverlayFilterBytecodePatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper - -@Patch -@Name("hide-player-overlay-filter") -@Description("Remove the dark filter layer from the player's background.") -@DependsOn( - [ - SettingsPatch::class, - PlayerOverlayFilterBytecodePatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class PlayerOverlayFilterPatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - /* - add settings - */ - ResourceHelper.addSettings2( - context, - "PREFERENCE_CATEGORY: REVANCED_SETTINGS", - "PREFERENCE: LAYOUT_SETTINGS", - "PREFERENCE_HEADER: PLAYER", - "SETTINGS: HIDE_PALYER_OVERLAY_FILTER" - ) - - ResourceHelper.patchSuccess( - context, - "hide-player-overlay-filter" - ) - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/suggestactions/bytecode/patch/SuggestedActionsBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/player/suggestactions/patch/SuggestedActionsPatch.kt similarity index 69% rename from src/main/kotlin/app/revanced/patches/youtube/layout/player/suggestactions/bytecode/patch/SuggestedActionsBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/player/suggestactions/patch/SuggestedActionsPatch.kt index d769cc9fc..a77d3b923 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/suggestactions/bytecode/patch/SuggestedActionsBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/player/suggestactions/patch/SuggestedActionsPatch.kt @@ -1,25 +1,36 @@ -package app.revanced.patches.youtube.layout.player.suggestactions.bytecode.patch +package app.revanced.patches.youtube.layout.player.suggestactions.patch import app.revanced.extensions.findMutableMethodOf import app.revanced.extensions.injectHideCall -import app.revanced.extensions.toResult +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.PatchResultError +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.patch.mapping.ResourceMappingPatch +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch import org.jf.dexlib2.Opcode import org.jf.dexlib2.iface.instruction.formats.Instruction22c import org.jf.dexlib2.iface.instruction.formats.Instruction31i -@DependsOn([ResourceMappingPatch::class]) -@Name("hide-suggested-actions-bytecode-patch") +@Patch +@Name("hide-suggested-actions") +@Description("Hide the suggested actions bar inside the player.") +@DependsOn( + [ + ResourceMappingPatch::class, + SettingsPatch::class + ] +) @YouTubeCompatibility @Version("0.0.1") -class SuggestedActionsBytecodePatch : BytecodePatch() { +class SuggestedActionsPatch : BytecodePatch() { // list of resource names to get the id of private val resourceIds = arrayOf( @@ -57,6 +68,25 @@ class SuggestedActionsBytecodePatch : BytecodePatch() { } } } - return toResult(patchSuccessArray.indexOf(false)) + + val errorIndex: Int = patchSuccessArray.indexOf(false) + + if (errorIndex == -1) { + /* + add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: LAYOUT_SETTINGS", + "PREFERENCE_HEADER: PLAYER", + "SETTINGS: HIDE_SUGGESTED_ACTION" + ) + ) + + SettingsPatch.updatePatchStatus("hide-suggested-actions") + + return PatchResultSuccess() + } else + return PatchResultError("Instruction not found: $errorIndex") } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/suggestactions/resource/patch/SuggestedActionsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/player/suggestactions/resource/patch/SuggestedActionsPatch.kt deleted file mode 100644 index b6192bb22..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/suggestactions/resource/patch/SuggestedActionsPatch.kt +++ /dev/null @@ -1,49 +0,0 @@ -package app.revanced.patches.youtube.layout.player.suggestactions.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.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -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.player.suggestactions.bytecode.patch.SuggestedActionsBytecodePatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper - -@Patch -@Name("hide-suggested-actions") -@Description("Hide the suggested actions bar inside the player.") -@DependsOn( - [ - SettingsPatch::class, - SuggestedActionsBytecodePatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class SuggestedActionsPatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - /* - add settings - */ - ResourceHelper.addSettings2( - context, - "PREFERENCE_CATEGORY: REVANCED_SETTINGS", - "PREFERENCE: LAYOUT_SETTINGS", - "PREFERENCE_HEADER: PLAYER", - "SETTINGS: HIDE_SUGGESTED_ACTION" - ) - - ResourceHelper.patchSuccess( - context, - "hide-suggested-actions" - ) - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/watermark/bytecode/fingerprints/HideWatermarkFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/player/watermark/fingerprints/HideWatermarkFingerprint.kt similarity index 84% rename from src/main/kotlin/app/revanced/patches/youtube/layout/player/watermark/bytecode/fingerprints/HideWatermarkFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/player/watermark/fingerprints/HideWatermarkFingerprint.kt index 587681d93..87e1b9f26 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/watermark/bytecode/fingerprints/HideWatermarkFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/player/watermark/fingerprints/HideWatermarkFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.player.watermark.bytecode.fingerprints +package app.revanced.patches.youtube.layout.player.watermark.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/watermark/bytecode/fingerprints/HideWatermarkParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/player/watermark/fingerprints/HideWatermarkParentFingerprint.kt similarity index 80% rename from src/main/kotlin/app/revanced/patches/youtube/layout/player/watermark/bytecode/fingerprints/HideWatermarkParentFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/player/watermark/fingerprints/HideWatermarkParentFingerprint.kt index 588c52a4a..7ad5c2044 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/watermark/bytecode/fingerprints/HideWatermarkParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/player/watermark/fingerprints/HideWatermarkParentFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.player.watermark.bytecode.fingerprints +package app.revanced.patches.youtube.layout.player.watermark.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/watermark/bytecode/patch/HideChannelWatermarkBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/player/watermark/patch/HideChannelWatermarkPatch.kt similarity index 66% rename from src/main/kotlin/app/revanced/patches/youtube/layout/player/watermark/bytecode/patch/HideChannelWatermarkBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/player/watermark/patch/HideChannelWatermarkPatch.kt index 8e5d920ed..cee6b6389 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/watermark/bytecode/patch/HideChannelWatermarkBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/player/watermark/patch/HideChannelWatermarkPatch.kt @@ -1,6 +1,7 @@ -package app.revanced.patches.youtube.layout.player.watermark.bytecode.patch +package app.revanced.patches.youtube.layout.player.watermark.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 @@ -11,13 +12,19 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion. 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.player.watermark.bytecode.fingerprints.HideWatermarkFingerprint -import app.revanced.patches.youtube.layout.player.watermark.bytecode.fingerprints.HideWatermarkParentFingerprint +import app.revanced.patches.youtube.layout.player.watermark.fingerprints.HideWatermarkFingerprint +import app.revanced.patches.youtube.layout.player.watermark.fingerprints.HideWatermarkParentFingerprint +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.PLAYER_LAYOUT import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction -@Name("hide-channel-watermark-bytecode-patch") +@Patch +@Name("hide-channel-watermark") +@Description("Hides creator's watermarks on videos.") +@DependsOn([SettingsPatch::class]) @YouTubeCompatibility @Version("0.0.1") class HideChannelWatermarkBytecodePatch : BytecodePatch( @@ -44,6 +51,19 @@ class HideChannelWatermarkBytecodePatch : BytecodePatch( } ?: return HideWatermarkFingerprint.toErrorResult() } ?: return HideWatermarkParentFingerprint.toErrorResult() + /* + add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: LAYOUT_SETTINGS", + "PREFERENCE_HEADER: PLAYER", + "SETTINGS: HIDE_CHANNEL_WATERMARK" + ) + ) + + SettingsPatch.updatePatchStatus("hide-channel-watermark") + return PatchResultSuccess() } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/watermark/resource/patch/HideChannelWatermarkPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/player/watermark/resource/patch/HideChannelWatermarkPatch.kt deleted file mode 100644 index 86e65f6df..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/watermark/resource/patch/HideChannelWatermarkPatch.kt +++ /dev/null @@ -1,49 +0,0 @@ -package app.revanced.patches.youtube.layout.player.watermark.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.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -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.player.watermark.bytecode.patch.HideChannelWatermarkBytecodePatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper - -@Patch -@Name("hide-channel-watermark") -@Description("Hides creator's watermarks on videos.") -@DependsOn( - [ - HideChannelWatermarkBytecodePatch::class, - SettingsPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class HideChannelWatermarkPatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - /* - add settings - */ - ResourceHelper.addSettings2( - context, - "PREFERENCE_CATEGORY: REVANCED_SETTINGS", - "PREFERENCE: LAYOUT_SETTINGS", - "PREFERENCE_HEADER: PLAYER", - "SETTINGS: HIDE_CHANNEL_WATERMARK" - ) - - ResourceHelper.patchSuccess( - context, - "hide-channel-watermark" - ) - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/customseekbarcolor/resource/patch/CustomSeekbarColorPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/customseekbarcolor/resource/patch/CustomSeekbarColorPatch.kt deleted file mode 100644 index 65f62a70f..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/customseekbarcolor/resource/patch/CustomSeekbarColorPatch.kt +++ /dev/null @@ -1,49 +0,0 @@ -package app.revanced.patches.youtube.layout.seekbar.customseekbarcolor.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.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -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.seekbar.customseekbarcolor.bytecode.patch.CustomSeekbarColorBytecodePatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper - -@Patch -@Name("custom-seekbar-color") -@Description("Change seekbar color in dark mode.") -@DependsOn( - [ - CustomSeekbarColorBytecodePatch::class, - SettingsPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class CustomSeekbarColorPatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - /* - add settings - */ - ResourceHelper.addSettings2( - context, - "PREFERENCE_CATEGORY: REVANCED_SETTINGS", - "PREFERENCE: LAYOUT_SETTINGS", - "PREFERENCE_HEADER: SEEKBAR", - "SETTINGS: CUSTOM_SEEKBAR_COLOR" - ) - - ResourceHelper.patchSuccess( - context, - "custom-seekbar-color" - ) - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/customseekbarcolor/bytecode/patch/CustomSeekbarColorBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbarcolor/patch/SeekbarColorPatch.kt similarity index 69% rename from src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/customseekbarcolor/bytecode/patch/CustomSeekbarColorBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbarcolor/patch/SeekbarColorPatch.kt index 8e48cd4fb..f8f71d548 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/customseekbarcolor/bytecode/patch/CustomSeekbarColorBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbarcolor/patch/SeekbarColorPatch.kt @@ -1,26 +1,37 @@ -package app.revanced.patches.youtube.layout.seekbar.customseekbarcolor.bytecode.patch +package app.revanced.patches.youtube.layout.seekbar.seekbarcolor.patch import app.revanced.extensions.findMutableMethodOf -import app.revanced.extensions.toResult +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.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultError +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.patch.mapping.ResourceMappingPatch +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.SEEKBAR_LAYOUT import org.jf.dexlib2.Opcode import org.jf.dexlib2.iface.instruction.OneRegisterInstruction import org.jf.dexlib2.iface.instruction.formats.Instruction31i -@DependsOn([ResourceMappingPatch::class]) -@Name("custom-seekbar-color-bytecode-patch") +@Patch +@Name("custom-seekbar-color") +@Description("Change seekbar color in dark mode.") +@DependsOn( + [ + ResourceMappingPatch::class, + SettingsPatch::class + ] +) @YouTubeCompatibility @Version("0.0.1") -class CustomSeekbarColorBytecodePatch : BytecodePatch() { +class SeekbarColorPatch : BytecodePatch() { // list of resource names to get the id of private val resourceIds = arrayOf( @@ -62,6 +73,25 @@ class CustomSeekbarColorBytecodePatch : BytecodePatch() { } } } - return toResult(patchSuccessArray.indexOf(false)) + + val errorIndex: Int = patchSuccessArray.indexOf(false) + + if (errorIndex == -1) { + /* + add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: LAYOUT_SETTINGS", + "PREFERENCE_HEADER: SEEKBAR", + "SETTINGS: CUSTOM_SEEKBAR_COLOR" + ) + ) + + SettingsPatch.updatePatchStatus("custom-seekbar-color") + + return PatchResultSuccess() + } else + return PatchResultError("Instruction not found: $errorIndex") } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbartapping/bytecode/fingerprints/SeekbarTappingFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbartapping/fingerprints/SeekbarTappingFingerprint.kt similarity index 97% rename from src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbartapping/bytecode/fingerprints/SeekbarTappingFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbartapping/fingerprints/SeekbarTappingFingerprint.kt index 73cd94302..e2b5e92c3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbartapping/bytecode/fingerprints/SeekbarTappingFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbartapping/fingerprints/SeekbarTappingFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.seekbar.seekbartapping.bytecode.fingerprints +package app.revanced.patches.youtube.layout.seekbar.seekbartapping.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbartapping/bytecode/fingerprints/SeekbarTappingParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbartapping/fingerprints/SeekbarTappingParentFingerprint.kt similarity index 66% rename from src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbartapping/bytecode/fingerprints/SeekbarTappingParentFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbartapping/fingerprints/SeekbarTappingParentFingerprint.kt index 8aa73e4bc..f979c3c86 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbartapping/bytecode/fingerprints/SeekbarTappingParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbartapping/fingerprints/SeekbarTappingParentFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.seekbar.seekbartapping.bytecode.fingerprints +package app.revanced.patches.youtube.layout.seekbar.seekbartapping.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint @@ -11,9 +11,9 @@ object SeekbarTappingParentFingerprint : MethodFingerprint( returnType = "L", access = AccessFlags.PUBLIC or AccessFlags.FINAL, customFingerprint = { methodDef -> - methodDef.implementation?.instructions?.any { instruction -> - instruction.opcode.ordinal == Opcode.CONST.ordinal && - (instruction as? WideLiteralInstruction)?.wideLiteral == SharedResourcdIdPatch.accessibilityProgressTimeLabelId + methodDef.implementation?.instructions?.any { + it.opcode.ordinal == Opcode.CONST.ordinal && + (it as? WideLiteralInstruction)?.wideLiteral == SharedResourcdIdPatch.accessibilityProgressTimeLabelId } == true } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbartapping/bytecode/patch/SeekbarTappingBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbartapping/patch/SeekbarTappingPatch.kt similarity index 78% rename from src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbartapping/bytecode/patch/SeekbarTappingBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbartapping/patch/SeekbarTappingPatch.kt index 705bedf72..cb6ccc056 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbartapping/bytecode/patch/SeekbarTappingBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbartapping/patch/SeekbarTappingPatch.kt @@ -1,6 +1,7 @@ -package app.revanced.patches.youtube.layout.seekbar.seekbartapping.bytecode.patch +package app.revanced.patches.youtube.layout.seekbar.seekbartapping.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 @@ -10,21 +11,31 @@ 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.patcher.util.smali.ExternalLabel import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.layout.seekbar.seekbartapping.bytecode.fingerprints.* +import app.revanced.patches.youtube.layout.seekbar.seekbartapping.fingerprints.SeekbarTappingFingerprint +import app.revanced.patches.youtube.layout.seekbar.seekbartapping.fingerprints.SeekbarTappingParentFingerprint import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourcdIdPatch +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.SEEKBAR_LAYOUT import org.jf.dexlib2.Opcode import org.jf.dexlib2.iface.Method import org.jf.dexlib2.iface.instruction.formats.Instruction11n import org.jf.dexlib2.iface.instruction.formats.Instruction35c -@Name("enable-seekbar-tapping-bytecode-patch") -@DependsOn([SharedResourcdIdPatch::class]) +@Patch +@Name("enable-seekbar-tapping") +@Description("Enables tap-to-seek on the seekbar of the video player.") +@DependsOn( + [ + SettingsPatch::class, + SharedResourcdIdPatch::class + ] +) @YouTubeCompatibility @Version("0.0.1") -class SeekbarTappingBytecodePatch : BytecodePatch( +class SeekbarTappingPatch : BytecodePatch( listOf( SeekbarTappingParentFingerprint, SeekbarTappingFingerprint @@ -76,6 +87,19 @@ class SeekbarTappingBytecodePatch : BytecodePatch( } } ?: return SeekbarTappingFingerprint.toErrorResult() + /* + add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: LAYOUT_SETTINGS", + "PREFERENCE_HEADER: SEEKBAR", + "SETTINGS: ENABLE_SEEKBAR_TAPPING" + ) + ) + + SettingsPatch.updatePatchStatus("enable-seekbar-tapping") + return PatchResultSuccess() } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbartapping/resource/patch/SeekbarTappingPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbartapping/resource/patch/SeekbarTappingPatch.kt deleted file mode 100644 index 85c679b99..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbartapping/resource/patch/SeekbarTappingPatch.kt +++ /dev/null @@ -1,49 +0,0 @@ -package app.revanced.patches.youtube.layout.seekbar.seekbartapping.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.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -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.seekbar.seekbartapping.bytecode.patch.SeekbarTappingBytecodePatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper - -@Patch -@Name("enable-seekbar-tapping") -@Description("Enables tap-to-seek on the seekbar of the video player.") -@DependsOn( - [ - SeekbarTappingBytecodePatch::class, - SettingsPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class SeekbarTappingPatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - /* - add settings - */ - ResourceHelper.addSettings2( - context, - "PREFERENCE_CATEGORY: REVANCED_SETTINGS", - "PREFERENCE: LAYOUT_SETTINGS", - "PREFERENCE_HEADER: SEEKBAR", - "SETTINGS: ENABLE_SEEKBAR_TAPPING" - ) - - ResourceHelper.patchSuccess( - context, - "enable-seekbar-tapping" - ) - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/timeandseekbar/bytecode/fingerprints/TimeCounterFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/timeandseekbar/fingerprints/TimeCounterFingerprint.kt similarity index 94% rename from src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/timeandseekbar/bytecode/fingerprints/TimeCounterFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/timeandseekbar/fingerprints/TimeCounterFingerprint.kt index 8bfc6835d..65ffe48dc 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/timeandseekbar/bytecode/fingerprints/TimeCounterFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/timeandseekbar/fingerprints/TimeCounterFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.seekbar.timeandseekbar.bytecode.fingerprints +package app.revanced.patches.youtube.layout.seekbar.timeandseekbar.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/timeandseekbar/bytecode/fingerprints/TimeCounterParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/timeandseekbar/fingerprints/TimeCounterParentFingerprint.kt similarity index 96% rename from src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/timeandseekbar/bytecode/fingerprints/TimeCounterParentFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/timeandseekbar/fingerprints/TimeCounterParentFingerprint.kt index e5955e474..77e310880 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/timeandseekbar/bytecode/fingerprints/TimeCounterParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/timeandseekbar/fingerprints/TimeCounterParentFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.seekbar.timeandseekbar.bytecode.fingerprints +package app.revanced.patches.youtube.layout.seekbar.timeandseekbar.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/timeandseekbar/bytecode/patch/HideTimeAndSeekbarBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/timeandseekbar/patch/HideTimeAndSeekbarPatch.kt similarity index 71% rename from src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/timeandseekbar/bytecode/patch/HideTimeAndSeekbarBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/timeandseekbar/patch/HideTimeAndSeekbarPatch.kt index 932d9830c..9f2cc7fe4 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/timeandseekbar/bytecode/patch/HideTimeAndSeekbarBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/timeandseekbar/patch/HideTimeAndSeekbarPatch.kt @@ -1,6 +1,7 @@ -package app.revanced.patches.youtube.layout.seekbar.timeandseekbar.bytecode.patch +package app.revanced.patches.youtube.layout.seekbar.timeandseekbar.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 @@ -11,19 +12,29 @@ 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.patcher.util.smali.ExternalLabel import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.layout.seekbar.timeandseekbar.bytecode.fingerprints.TimeCounterFingerprint -import app.revanced.patches.youtube.layout.seekbar.timeandseekbar.bytecode.fingerprints.TimeCounterParentFingerprint +import app.revanced.patches.youtube.layout.seekbar.timeandseekbar.fingerprints.TimeCounterFingerprint +import app.revanced.patches.youtube.layout.seekbar.timeandseekbar.fingerprints.TimeCounterParentFingerprint import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourcdIdPatch +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch import app.revanced.patches.youtube.misc.timebar.patch.HookTimebarPatch import app.revanced.util.integrations.Constants.SEEKBAR_LAYOUT -@DependsOn([HookTimebarPatch::class, SharedResourcdIdPatch::class]) -@Name("hide-time-and-seekbar-bytecode-patch") +@Patch +@Name("hide-time-and-seekbar") +@Description("Hides progress bar and time counter on videos.") +@DependsOn( + [ + HookTimebarPatch::class, + SettingsPatch::class, + SharedResourcdIdPatch::class + ] +) @YouTubeCompatibility @Version("0.0.1") -class HideTimeAndSeekbarBytecodePatch : BytecodePatch( +class HideTimeAndSeekbarPatch : BytecodePatch( listOf( TimeCounterParentFingerprint ) @@ -49,6 +60,19 @@ class HideTimeAndSeekbarBytecodePatch : BytecodePatch( } ?: return TimeCounterFingerprint.toErrorResult() } ?: return TimeCounterParentFingerprint.toErrorResult() + /* + add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: LAYOUT_SETTINGS", + "PREFERENCE_HEADER: SEEKBAR", + "SETTINGS: HIDE_TIME_AND_SEEKBAR" + ) + ) + + SettingsPatch.updatePatchStatus("hide-time-and-seekbar") + return PatchResultSuccess() } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/timeandseekbar/resource/patch/HideTimeAndSeekbarPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/timeandseekbar/resource/patch/HideTimeAndSeekbarPatch.kt deleted file mode 100644 index fce8848fb..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/timeandseekbar/resource/patch/HideTimeAndSeekbarPatch.kt +++ /dev/null @@ -1,49 +0,0 @@ -package app.revanced.patches.youtube.layout.seekbar.timeandseekbar.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.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -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.seekbar.timeandseekbar.bytecode.patch.HideTimeAndSeekbarBytecodePatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper - -@Patch -@Name("hide-time-and-seekbar") -@Description("Hides progress bar and time counter on videos.") -@DependsOn( - [ - HideTimeAndSeekbarBytecodePatch::class, - SettingsPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class HideTimeAndSeekbarPatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - /* - add settings - */ - ResourceHelper.addSettings2( - context, - "PREFERENCE_CATEGORY: REVANCED_SETTINGS", - "PREFERENCE: LAYOUT_SETTINGS", - "PREFERENCE_HEADER: SEEKBAR", - "SETTINGS: HIDE_TIME_AND_SEEKBAR" - ) - - ResourceHelper.patchSuccess( - context, - "hide-time-and-seekbar" - ) - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/clientspoof/bytecode/fingerprints/UserAgentHeaderBuilderFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/clientspoof/fingerprints/UserAgentHeaderBuilderFingerprint.kt similarity index 81% rename from src/main/kotlin/app/revanced/patches/youtube/misc/clientspoof/bytecode/fingerprints/UserAgentHeaderBuilderFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/misc/clientspoof/fingerprints/UserAgentHeaderBuilderFingerprint.kt index c9a6817d3..24dc8022b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/clientspoof/bytecode/fingerprints/UserAgentHeaderBuilderFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/clientspoof/fingerprints/UserAgentHeaderBuilderFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.clientspoof.bytecode.fingerprints +package app.revanced.patches.youtube.misc.clientspoof.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/clientspoof/bytecode/patch/ClientSpoofBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/clientspoof/patch/ClientSpoofPatch.kt similarity index 65% rename from src/main/kotlin/app/revanced/patches/youtube/misc/clientspoof/bytecode/patch/ClientSpoofBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/misc/clientspoof/patch/ClientSpoofPatch.kt index f07d65fb6..c30fcf4e4 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/clientspoof/bytecode/patch/ClientSpoofBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/clientspoof/patch/ClientSpoofPatch.kt @@ -1,6 +1,7 @@ -package app.revanced.patches.youtube.misc.clientspoof.bytecode.patch +package app.revanced.patches.youtube.misc.clientspoof.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 @@ -9,15 +10,21 @@ 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.misc.clientspoof.bytecode.fingerprints.UserAgentHeaderBuilderFingerprint +import app.revanced.patches.youtube.misc.clientspoof.fingerprints.UserAgentHeaderBuilderFingerprint import app.revanced.patches.youtube.misc.microg.shared.Constants.PACKAGE_NAME +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction -@Name("client-spoof-bytecode-patch") +@Patch +@Name("client-spoof") +@Description("Spoofs the YouTube client to prevent playback issues.") +@DependsOn([SettingsPatch::class]) @YouTubeCompatibility @Version("0.0.1") -class ClientSpoofBytecodePatch : BytecodePatch( +class ClientSpoofPatch : BytecodePatch( listOf(UserAgentHeaderBuilderFingerprint) ) { override fun execute(context: BytecodeContext): PatchResult { @@ -31,6 +38,11 @@ class ClientSpoofBytecodePatch : BytecodePatch( } } ?: return UserAgentHeaderBuilderFingerprint.toErrorResult() + /* + update settings + */ + SettingsPatch.updatePatchStatus("client-spoof") + return PatchResultSuccess() } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/clientspoof/resource/patch/ClientSpoofPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/clientspoof/resource/patch/ClientSpoofPatch.kt deleted file mode 100644 index 9769f06f7..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/clientspoof/resource/patch/ClientSpoofPatch.kt +++ /dev/null @@ -1,38 +0,0 @@ -package app.revanced.patches.youtube.misc.clientspoof.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.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -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.clientspoof.bytecode.patch.ClientSpoofBytecodePatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper - -@Patch -@Name("client-spoof") -@Description("Spoofs the YouTube client to prevent playback issues.") -@DependsOn( - [ - ClientSpoofBytecodePatch::class, - SettingsPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class ClientSpoofPatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - ResourceHelper.patchSuccess( - context, - "client-spoof" - ) - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/externalbrowser/bytecode/fingerprints/ExternalBrowserPrimaryFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/externalbrowser/fingerprints/ExternalBrowserPrimaryFingerprint.kt similarity index 87% rename from src/main/kotlin/app/revanced/patches/youtube/misc/externalbrowser/bytecode/fingerprints/ExternalBrowserPrimaryFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/misc/externalbrowser/fingerprints/ExternalBrowserPrimaryFingerprint.kt index d9ffcc3a2..b6c594a11 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/externalbrowser/bytecode/fingerprints/ExternalBrowserPrimaryFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/externalbrowser/fingerprints/ExternalBrowserPrimaryFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.externalbrowser.bytecode.fingerprints +package app.revanced.patches.youtube.misc.externalbrowser.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/externalbrowser/bytecode/fingerprints/ExternalBrowserSecondaryFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/externalbrowser/fingerprints/ExternalBrowserSecondaryFingerprint.kt similarity index 86% rename from src/main/kotlin/app/revanced/patches/youtube/misc/externalbrowser/bytecode/fingerprints/ExternalBrowserSecondaryFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/misc/externalbrowser/fingerprints/ExternalBrowserSecondaryFingerprint.kt index ba99acd1d..a206ea44f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/externalbrowser/bytecode/fingerprints/ExternalBrowserSecondaryFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/externalbrowser/fingerprints/ExternalBrowserSecondaryFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.externalbrowser.bytecode.fingerprints +package app.revanced.patches.youtube.misc.externalbrowser.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/externalbrowser/bytecode/fingerprints/ExternalBrowserTertiaryFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/externalbrowser/fingerprints/ExternalBrowserTertiaryFingerprint.kt similarity index 87% rename from src/main/kotlin/app/revanced/patches/youtube/misc/externalbrowser/bytecode/fingerprints/ExternalBrowserTertiaryFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/misc/externalbrowser/fingerprints/ExternalBrowserTertiaryFingerprint.kt index eafbe88dd..4b5498966 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/externalbrowser/bytecode/fingerprints/ExternalBrowserTertiaryFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/externalbrowser/fingerprints/ExternalBrowserTertiaryFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.externalbrowser.bytecode.fingerprints +package app.revanced.patches.youtube.misc.externalbrowser.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/externalbrowser/bytecode/patch/ExternalBrowserBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/externalbrowser/patch/ExternalBrowserPatch.kt similarity index 67% rename from src/main/kotlin/app/revanced/patches/youtube/misc/externalbrowser/bytecode/patch/ExternalBrowserBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/misc/externalbrowser/patch/ExternalBrowserPatch.kt index 06c62da1a..2de146ceb 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/externalbrowser/bytecode/patch/ExternalBrowserBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/externalbrowser/patch/ExternalBrowserPatch.kt @@ -1,6 +1,7 @@ -package app.revanced.patches.youtube.misc.externalbrowser.bytecode.patch +package app.revanced.patches.youtube.misc.externalbrowser.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 @@ -8,15 +9,21 @@ import app.revanced.patcher.extensions.addInstructions 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.externalbrowser.bytecode.fingerprints.* +import app.revanced.patches.youtube.misc.externalbrowser.fingerprints.* +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.MISC_PATH import org.jf.dexlib2.iface.instruction.formats.Instruction21c -@Name("enable-external-browser-bytecode-patch") +@Patch +@Name("enable-external-browser") +@Description("Open url outside the app in an external browser.") +@DependsOn([SettingsPatch::class]) @YouTubeCompatibility @Version("0.0.1") -class ExternalBrowserBytecodePatch : BytecodePatch( +class ExternalBrowserPatch : BytecodePatch( listOf( ExternalBrowserPrimaryFingerprint, ExternalBrowserSecondaryFingerprint, @@ -43,6 +50,17 @@ class ExternalBrowserBytecodePatch : BytecodePatch( } } + /* + add settings + */ + SettingsPatch.addPreference( + arrayOf( + "SETTINGS: ENABLE_EXTERNAL_BROWSER" + ) + ) + + SettingsPatch.updatePatchStatus("enable-external-browser") + return PatchResultSuccess() } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/externalbrowser/resource/patch/ExternalBrowserPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/externalbrowser/resource/patch/ExternalBrowserPatch.kt deleted file mode 100644 index 873370d69..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/externalbrowser/resource/patch/ExternalBrowserPatch.kt +++ /dev/null @@ -1,48 +0,0 @@ -package app.revanced.patches.youtube.misc.externalbrowser.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.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -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.externalbrowser.bytecode.patch.ExternalBrowserBytecodePatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper - -@Patch -@Name("enable-external-browser") -@Description("Use an external browser to open the url.") -@DependsOn( - [ - ExternalBrowserBytecodePatch::class, - SettingsPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class ExternalBrowserPatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - /* - add settings - */ - ResourceHelper.addSettings( - context, - "PREFERENCE_CATEGORY: REVANCED_EXTENDED_SETTINGS", - "PREFERENCE: MISC_SETTINGS", - "SETTINGS: ENABLE_EXTERNAL_BROWSER" - ) - - ResourceHelper.patchSuccess( - context, - "enable-external-browser" - ) - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/extended/forcevp9/bytecode/fingerprints/Vp9PrimaryFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/forcevp9/fingerprints/Vp9PrimaryFingerprint.kt similarity index 84% rename from src/main/kotlin/app/revanced/patches/youtube/extended/forcevp9/bytecode/fingerprints/Vp9PrimaryFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/misc/forcevp9/fingerprints/Vp9PrimaryFingerprint.kt index 69baa8bc5..3c6ad418e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/extended/forcevp9/bytecode/fingerprints/Vp9PrimaryFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/forcevp9/fingerprints/Vp9PrimaryFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.extended.forcevp9.bytecode.fingerprints +package app.revanced.patches.youtube.misc.forcevp9.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/extended/forcevp9/bytecode/fingerprints/Vp9PropsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/forcevp9/fingerprints/Vp9PropsFingerprint.kt similarity index 83% rename from src/main/kotlin/app/revanced/patches/youtube/extended/forcevp9/bytecode/fingerprints/Vp9PropsFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/misc/forcevp9/fingerprints/Vp9PropsFingerprint.kt index 5cfb91c76..d7eca5278 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/extended/forcevp9/bytecode/fingerprints/Vp9PropsFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/forcevp9/fingerprints/Vp9PropsFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.extended.forcevp9.bytecode.fingerprints +package app.revanced.patches.youtube.misc.forcevp9.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/extended/forcevp9/bytecode/fingerprints/Vp9PropsParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/forcevp9/fingerprints/Vp9PropsParentFingerprint.kt similarity index 70% rename from src/main/kotlin/app/revanced/patches/youtube/extended/forcevp9/bytecode/fingerprints/Vp9PropsParentFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/misc/forcevp9/fingerprints/Vp9PropsParentFingerprint.kt index 84a50b9da..925701537 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/extended/forcevp9/bytecode/fingerprints/Vp9PropsParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/forcevp9/fingerprints/Vp9PropsParentFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.extended.forcevp9.bytecode.fingerprints +package app.revanced.patches.youtube.misc.forcevp9.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/extended/forcevp9/bytecode/fingerprints/Vp9SecondaryFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/forcevp9/fingerprints/Vp9SecondaryFingerprint.kt similarity index 85% rename from src/main/kotlin/app/revanced/patches/youtube/extended/forcevp9/bytecode/fingerprints/Vp9SecondaryFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/misc/forcevp9/fingerprints/Vp9SecondaryFingerprint.kt index 917cd2b08..3a6804969 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/extended/forcevp9/bytecode/fingerprints/Vp9SecondaryFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/forcevp9/fingerprints/Vp9SecondaryFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.extended.forcevp9.bytecode.fingerprints +package app.revanced.patches.youtube.misc.forcevp9.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/extended/forcevp9/bytecode/patch/ForceVP9CodecBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/forcevp9/patch/ForceVP9CodecPatch.kt similarity index 85% rename from src/main/kotlin/app/revanced/patches/youtube/extended/forcevp9/bytecode/patch/ForceVP9CodecBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/misc/forcevp9/patch/ForceVP9CodecPatch.kt index 1e4d63a4b..4f9861694 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/extended/forcevp9/bytecode/patch/ForceVP9CodecBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/forcevp9/patch/ForceVP9CodecPatch.kt @@ -1,6 +1,7 @@ -package app.revanced.patches.youtube.extended.forcevp9.bytecode.patch +package app.revanced.patches.youtube.misc.forcevp9.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 @@ -12,20 +13,26 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult 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.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.shared.fingerprints.LayoutSwitchFingerprint -import app.revanced.patches.youtube.extended.forcevp9.bytecode.fingerprints.* +import app.revanced.patches.youtube.misc.forcevp9.fingerprints.* +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.EXTENDED_PATH import org.jf.dexlib2.Opcode import org.jf.dexlib2.dexbacked.reference.DexBackedFieldReference import org.jf.dexlib2.iface.instruction.OneRegisterInstruction import org.jf.dexlib2.iface.instruction.ReferenceInstruction -@Name("force-vp9-codec-bytecode-patch") +@Patch +@Name("force-vp9-codec") +@Description("Forces the VP9 codec for videos.") +@DependsOn([SettingsPatch::class]) @YouTubeCompatibility @Version("0.0.1") -class ForceVP9CodecBytecodePatch : BytecodePatch( +class ForceVP9CodecPatch : BytecodePatch( listOf( LayoutSwitchFingerprint, Vp9PropsParentFingerprint @@ -54,6 +61,18 @@ class ForceVP9CodecBytecodePatch : BytecodePatch( } ?: return Vp9PropsFingerprint.toErrorResult() } ?: return Vp9PropsParentFingerprint.toErrorResult() + /* + add settings + */ + SettingsPatch.addPreference( + arrayOf( + "SETTINGS: EXPERIMENTAL_FLAGS", + "SETTINGS: ENABLE_VP9_CODEC" + ) + ) + + SettingsPatch.updatePatchStatus("force-vp9-codec") + return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/youtube/extended/layoutswitch/bytecode/patch/LayoutSwitchBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/layoutswitch/patch/LayoutSwitchPatch.kt similarity index 59% rename from src/main/kotlin/app/revanced/patches/youtube/extended/layoutswitch/bytecode/patch/LayoutSwitchBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/misc/layoutswitch/patch/LayoutSwitchPatch.kt index 9fd50fcd5..86367692f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/extended/layoutswitch/bytecode/patch/LayoutSwitchBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/layoutswitch/patch/LayoutSwitchPatch.kt @@ -1,6 +1,7 @@ -package app.revanced.patches.youtube.extended.layoutswitch.bytecode.patch +package app.revanced.patches.youtube.misc.layoutswitch.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 @@ -8,14 +9,20 @@ import app.revanced.patcher.extensions.addInstructions 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.LayoutSwitchFingerprint +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.EXTENDED_PATH -@Name("layout-switch-bytecode-patch") +@Patch +@Name("layout-switch") +@Description("Tricks the dpi to use some tablet/phone layouts.") +@DependsOn([SettingsPatch::class]) @YouTubeCompatibility @Version("0.0.1") -class LayoutSwitchBytecodePatch : BytecodePatch( +class LayoutSwitchPatch : BytecodePatch( listOf( LayoutSwitchFingerprint ) @@ -29,6 +36,18 @@ class LayoutSwitchBytecodePatch : BytecodePatch( """ ) ?: return LayoutSwitchFingerprint.toErrorResult() + /* + add settings + */ + SettingsPatch.addPreference( + arrayOf( + "SETTINGS: EXPERIMENTAL_FLAGS", + "SETTINGS: LAYOUT_SWITCH" + ) + ) + + SettingsPatch.updatePatchStatus("layout-switch") + return PatchResultSuccess() } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/fingerprints/LithoFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/litho/fingerprints/LithoFingerprint.kt similarity index 89% rename from src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/fingerprints/LithoFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/misc/litho/fingerprints/LithoFingerprint.kt index 6038c90a5..784016c39 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/fingerprints/LithoFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/litho/fingerprints/LithoFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.litho.filter.fingerprints +package app.revanced.patches.youtube.misc.litho.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/patch/LithoFilterPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/litho/patch/LithoFilterPatch.kt similarity index 90% rename from src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/patch/LithoFilterPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/misc/litho/patch/LithoFilterPatch.kt index 65f5ef154..2860e0cca 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/patch/LithoFilterPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/litho/patch/LithoFilterPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.litho.filter.patch +package app.revanced.patches.youtube.misc.litho.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Version @@ -11,9 +11,9 @@ import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.misc.doublebacktoclose.patch.DoubleBackToClosePatch -import app.revanced.patches.youtube.misc.litho.filter.fingerprints.LithoFingerprint -import app.revanced.patches.youtube.misc.swiperefresh.patch.SwipeRefreshPatch +import app.revanced.patches.youtube.ads.doublebacktoclose.patch.DoubleBackToClosePatch +import app.revanced.patches.youtube.misc.litho.fingerprints.LithoFingerprint +import app.revanced.patches.youtube.ads.swiperefresh.patch.SwipeRefreshPatch import app.revanced.util.integrations.Constants.ADS_PATH import org.jf.dexlib2.Opcode import org.jf.dexlib2.builder.instruction.BuilderInstruction21c diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/bytecode/patch/MicroGBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/bytecode/patch/MicroGBytecodePatch.kt index a1c8042ef..4910c56f0 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/bytecode/patch/MicroGBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/bytecode/patch/MicroGBytecodePatch.kt @@ -9,11 +9,11 @@ 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.patch.options.PatchOptions -import app.revanced.patches.youtube.layout.player.castbutton.resource.patch.HideCastButtonPatch -import app.revanced.patches.youtube.misc.clientspoof.resource.patch.ClientSpoofPatch +import app.revanced.patches.youtube.layout.player.castbutton.patch.HideCastButtonPatch +import app.revanced.patches.youtube.misc.clientspoof.patch.ClientSpoofPatch import app.revanced.patches.youtube.misc.microg.bytecode.fingerprints.* import app.revanced.patches.youtube.misc.microg.shared.Constants.PACKAGE_NAME -import app.revanced.util.bytecode.BytecodeHelper +import app.revanced.util.bytecode.BytecodeHelper.injectInit import app.revanced.util.microg.MicroGBytecodeHelper @Name("microg-support-bytecode-patch") @@ -38,20 +38,20 @@ class MicroGBytecodePatch : BytecodePatch( ) { override fun execute(context: BytecodeContext): PatchResult { - val packageName = PatchOptions.YouTube_PackageName + val packageName = PatchOptions.YouTubePackageName!! // apply common microG patch MicroGBytecodeHelper.patchBytecode( context, arrayOf( MicroGBytecodeHelper.packageNameTransform( PACKAGE_NAME, - "$packageName" + packageName ) ), MicroGBytecodeHelper.PrimeMethodTransformationData( PrimeFingerprint, PACKAGE_NAME, - "$packageName" + packageName ), listOf( ServiceCheckFingerprint, @@ -62,7 +62,7 @@ class MicroGBytecodePatch : BytecodePatch( ) ) - BytecodeHelper.injectInit(context, "MicroGPatch", "checkAvailability") + context.injectInit("MicroGPatch", "checkAvailability") return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/resource/patch/MicroGPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/resource/patch/MicroGPatch.kt index 5bf22ec90..d611189d3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/resource/patch/MicroGPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/resource/patch/MicroGPatch.kt @@ -16,9 +16,9 @@ import app.revanced.patches.youtube.misc.microg.shared.Constants.PACKAGE_NAME import app.revanced.patches.youtube.misc.microg.shared.Constants.SPOOFED_PACKAGE_NAME import app.revanced.patches.youtube.misc.microg.shared.Constants.SPOOFED_PACKAGE_SIGNATURE import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.microg.MicroGManifestHelper -import app.revanced.util.microg.MicroGResourceHelper -import app.revanced.util.resources.ResourceHelper +import app.revanced.util.microg.MicroGManifestHelper.addSpoofingMetadata +import app.revanced.util.microg.MicroGResourceHelper.patchManifest +import app.revanced.util.resources.ResourceHelper.setMicroG @Patch @Name("microg-support") @@ -35,22 +35,19 @@ import app.revanced.util.resources.ResourceHelper class MicroGPatch : ResourcePatch { override fun execute(context: ResourceContext): PatchResult { - val packageName = PatchOptions.YouTube_PackageName + val packageName = PatchOptions.YouTubePackageName!! /* add settings */ - ResourceHelper.addSettings( - context, - "PREFERENCE_CATEGORY: MICROG_SETTINGS", - "PREFERENCE: MICROG_SETTINGS", - "SETTINGS: MICROG_SETTINGS" - ) - - ResourceHelper.patchSuccess( - context, - "microg-support" + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE_CATEGORY: MICROG_SETTINGS", + "PREFERENCE: MICROG_SETTINGS", + "SETTINGS: MICROG_SETTINGS" + ) ) + SettingsPatch.updatePatchStatus("microg-support") val settingsFragment = context["res/xml/settings_fragment.xml"] settingsFragment.writeText( @@ -61,18 +58,19 @@ class MicroGPatch : ResourcePatch { ) // update manifest - MicroGResourceHelper.patchManifest( - context, + context.patchManifest( PACKAGE_NAME, - "$packageName" + packageName ) // add metadata to manifest - MicroGManifestHelper.addSpoofingMetadata( - context, + context.addSpoofingMetadata( SPOOFED_PACKAGE_NAME, SPOOFED_PACKAGE_SIGNATURE ) + + setMicroG(packageName) + return PatchResultSuccess() } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/bytecode/fingerprints/KidsMinimizedPlaybackPolicyControllerFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/KidsMinimizedPlaybackPolicyControllerFingerprint.kt similarity index 89% rename from src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/bytecode/fingerprints/KidsMinimizedPlaybackPolicyControllerFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/KidsMinimizedPlaybackPolicyControllerFingerprint.kt index b560b0df4..cc1550f95 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/bytecode/fingerprints/KidsMinimizedPlaybackPolicyControllerFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/KidsMinimizedPlaybackPolicyControllerFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.minimizedplayback.bytecode.fingerprints +package app.revanced.patches.youtube.misc.minimizedplayback.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/bytecode/fingerprints/MinimizedPlaybackManagerFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/MinimizedPlaybackManagerFingerprint.kt similarity index 88% rename from src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/bytecode/fingerprints/MinimizedPlaybackManagerFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/MinimizedPlaybackManagerFingerprint.kt index 54b55a2c6..339f4fffc 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/bytecode/fingerprints/MinimizedPlaybackManagerFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/MinimizedPlaybackManagerFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.minimizedplayback.bytecode.fingerprints +package app.revanced.patches.youtube.misc.minimizedplayback.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/bytecode/fingerprints/MinimizedPlaybackSettingsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/MinimizedPlaybackSettingsFingerprint.kt similarity index 92% rename from src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/bytecode/fingerprints/MinimizedPlaybackSettingsFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/MinimizedPlaybackSettingsFingerprint.kt index 165928914..2e6a6b875 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/bytecode/fingerprints/MinimizedPlaybackSettingsFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/MinimizedPlaybackSettingsFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.minimizedplayback.bytecode.fingerprints +package app.revanced.patches.youtube.misc.minimizedplayback.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/bytecode/fingerprints/PipControllerFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/PipControllerFingerprint.kt similarity index 86% rename from src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/bytecode/fingerprints/PipControllerFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/PipControllerFingerprint.kt index 53c21092c..42bb0f89c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/bytecode/fingerprints/PipControllerFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/fingerprints/PipControllerFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.minimizedplayback.bytecode.fingerprints +package app.revanced.patches.youtube.misc.minimizedplayback.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/bytecode/patch/MinimizedPlaybackBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/patch/MinimizedPlaybackPatch.kt similarity index 83% rename from src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/bytecode/patch/MinimizedPlaybackBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/patch/MinimizedPlaybackPatch.kt index 758fba4ae..5a8d1bf8f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/bytecode/patch/MinimizedPlaybackBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/patch/MinimizedPlaybackPatch.kt @@ -1,6 +1,7 @@ -package app.revanced.patches.youtube.misc.minimizedplayback.bytecode.patch +package app.revanced.patches.youtube.misc.minimizedplayback.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 @@ -12,27 +13,32 @@ 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.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.misc.minimizedplayback.bytecode.fingerprints.* +import app.revanced.patches.youtube.misc.minimizedplayback.fingerprints.* import app.revanced.patches.youtube.misc.playertype.patch.PlayerTypeHookPatch import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourcdIdPatch +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.MISC_PATH import org.jf.dexlib2.iface.instruction.ReferenceInstruction import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction import org.jf.dexlib2.iface.reference.MethodReference -@Name("enable-minimized-playback-bytecode-patch") +@Patch +@Name("enable-minimized-playback") +@Description("Enables minimized and background playback.") @DependsOn( [ PlayerTypeHookPatch::class, + SettingsPatch::class, SharedResourcdIdPatch::class ] ) @YouTubeCompatibility @Version("0.0.1") -class MinimizedPlaybackBytecodePatch : BytecodePatch( +class MinimizedPlaybackPatch : BytecodePatch( listOf( KidsMinimizedPlaybackPolicyControllerFingerprint, MinimizedPlaybackManagerFingerprint, @@ -55,6 +61,17 @@ class MinimizedPlaybackBytecodePatch : BytecodePatch( PipControllerFingerprint.result?.hookShortsPiP()?:return PipControllerFingerprint.toErrorResult() + /* + add settings + */ + SettingsPatch.addPreference( + arrayOf( + "SETTINGS: ENABLE_MINIMIZED_PLAYBACK" + ) + ) + + SettingsPatch.updatePatchStatus("enable-minimized-playback") + return PatchResultSuccess() } @@ -66,7 +83,8 @@ class MinimizedPlaybackBytecodePatch : BytecodePatch( "$MISC_PATH/MinimizedPlaybackPatch;->isNotPlayingShorts(Z)Z" fun MutableMethod.walkMutable( - context: BytecodeContext) { + context: BytecodeContext + ) { val booleanCalls = implementation!!.instructions.withIndex() .filter { ((it.value as? ReferenceInstruction)?.reference as? MethodReference)?.returnType == "Z" } diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/resource/patch/MinimizedPlaybackPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/resource/patch/MinimizedPlaybackPatch.kt deleted file mode 100644 index ad30e6fef..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/resource/patch/MinimizedPlaybackPatch.kt +++ /dev/null @@ -1,48 +0,0 @@ -package app.revanced.patches.youtube.misc.minimizedplayback.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.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -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.minimizedplayback.bytecode.patch.MinimizedPlaybackBytecodePatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper - -@Patch -@Name("enable-minimized-playback") -@Description("Enables minimized and background playback.") -@DependsOn( - [ - MinimizedPlaybackBytecodePatch::class, - SettingsPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class MinimizedPlaybackPatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - /* - add settings - */ - ResourceHelper.addSettings( - context, - "PREFERENCE_CATEGORY: REVANCED_SETTINGS", - "PREFERENCE: MISC_SETTINGS", - "SETTINGS: ENABLE_MINIMIZED_PLAYBACK" - ) - - ResourceHelper.patchSuccess( - context, - "enable-minimized-playback" - ) - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/extended/oldlayout/bytecode/fingerprints/OldLayoutFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/oldlayout/fingerprints/OldLayoutFingerprint.kt similarity index 85% rename from src/main/kotlin/app/revanced/patches/youtube/extended/oldlayout/bytecode/fingerprints/OldLayoutFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/misc/oldlayout/fingerprints/OldLayoutFingerprint.kt index 95b840212..bf3a68c91 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/extended/oldlayout/bytecode/fingerprints/OldLayoutFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/oldlayout/fingerprints/OldLayoutFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.extended.oldlayout.bytecode.fingerprints +package app.revanced.patches.youtube.misc.oldlayout.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/extended/oldlayout/bytecode/patch/OldLayoutBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/oldlayout/patch/OldLayoutPatch.kt similarity index 63% rename from src/main/kotlin/app/revanced/patches/youtube/extended/oldlayout/bytecode/patch/OldLayoutBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/misc/oldlayout/patch/OldLayoutPatch.kt index 8bbc718d0..071938253 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/extended/oldlayout/bytecode/patch/OldLayoutBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/oldlayout/patch/OldLayoutPatch.kt @@ -1,6 +1,7 @@ -package app.revanced.patches.youtube.extended.oldlayout.bytecode.patch +package app.revanced.patches.youtube.misc.oldlayout.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 @@ -8,15 +9,21 @@ import app.revanced.patcher.extensions.addInstructions 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.extended.oldlayout.bytecode.fingerprints.OldLayoutFingerprint +import app.revanced.patches.youtube.misc.oldlayout.fingerprints.OldLayoutFingerprint +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.EXTENDED_PATH import org.jf.dexlib2.iface.instruction.OneRegisterInstruction -@Name("enable-old-layout-bytecode-patch") +@Patch +@Name("enable-old-layout") +@Description("Spoof the YouTube client version to use the old layout.") +@DependsOn([SettingsPatch::class]) @YouTubeCompatibility @Version("0.0.1") -class OldLayoutBytecodePatch : BytecodePatch( +class OldLayoutPatch : BytecodePatch( listOf( OldLayoutFingerprint ) @@ -37,6 +44,18 @@ class OldLayoutBytecodePatch : BytecodePatch( } } ?: return OldLayoutFingerprint.toErrorResult() + /* + add settings + */ + SettingsPatch.addPreference( + arrayOf( + "SETTINGS: EXPERIMENTAL_FLAGS", + "SETTINGS: ENABLE_OLD_LAYOUT" + ) + ) + + SettingsPatch.updatePatchStatus("enable-old-layout") + return PatchResultSuccess() } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/openlinksdirectly/bytecode/fingerprints/OpenLinksDirectlyFingerprintPrimary.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/openlinksdirectly/fingerprints/OpenLinksDirectlyFingerprintPrimary.kt similarity index 87% rename from src/main/kotlin/app/revanced/patches/youtube/misc/openlinksdirectly/bytecode/fingerprints/OpenLinksDirectlyFingerprintPrimary.kt rename to src/main/kotlin/app/revanced/patches/youtube/misc/openlinksdirectly/fingerprints/OpenLinksDirectlyFingerprintPrimary.kt index f77355eae..3ce320776 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/openlinksdirectly/bytecode/fingerprints/OpenLinksDirectlyFingerprintPrimary.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/openlinksdirectly/fingerprints/OpenLinksDirectlyFingerprintPrimary.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.openlinksdirectly.bytecode.fingerprints +package app.revanced.patches.youtube.misc.openlinksdirectly.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/openlinksdirectly/bytecode/fingerprints/OpenLinksDirectlyFingerprintSecondary.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/openlinksdirectly/fingerprints/OpenLinksDirectlyFingerprintSecondary.kt similarity index 89% rename from src/main/kotlin/app/revanced/patches/youtube/misc/openlinksdirectly/bytecode/fingerprints/OpenLinksDirectlyFingerprintSecondary.kt rename to src/main/kotlin/app/revanced/patches/youtube/misc/openlinksdirectly/fingerprints/OpenLinksDirectlyFingerprintSecondary.kt index 3d1d6bf9d..3f524991a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/openlinksdirectly/bytecode/fingerprints/OpenLinksDirectlyFingerprintSecondary.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/openlinksdirectly/fingerprints/OpenLinksDirectlyFingerprintSecondary.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.openlinksdirectly.bytecode.fingerprints +package app.revanced.patches.youtube.misc.openlinksdirectly.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/openlinksdirectly/bytecode/patch/OpenLinksDirectlyBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/openlinksdirectly/patch/OpenLinksDirectlyPatch.kt similarity index 72% rename from src/main/kotlin/app/revanced/patches/youtube/misc/openlinksdirectly/bytecode/patch/OpenLinksDirectlyBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/misc/openlinksdirectly/patch/OpenLinksDirectlyPatch.kt index d2cf7463f..3ba677607 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/openlinksdirectly/bytecode/patch/OpenLinksDirectlyBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/openlinksdirectly/patch/OpenLinksDirectlyPatch.kt @@ -1,6 +1,7 @@ -package app.revanced.patches.youtube.misc.openlinksdirectly.bytecode.patch +package app.revanced.patches.youtube.misc.openlinksdirectly.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 @@ -9,17 +10,23 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult 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.openlinksdirectly.bytecode.fingerprints.* +import app.revanced.patches.youtube.misc.openlinksdirectly.fingerprints.* +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch import app.revanced.util.integrations.Constants.MISC_PATH import org.jf.dexlib2.iface.instruction.Instruction import org.jf.dexlib2.iface.instruction.formats.Instruction11x import org.jf.dexlib2.iface.instruction.formats.Instruction35c -@Name("enable-open-links-directly-bytecode-patch") +@Patch +@Name("enable-open-links-directly") +@Description("Skips over redirection URLs to external links.") +@DependsOn([SettingsPatch::class]) @YouTubeCompatibility @Version("0.0.1") -class OpenLinksDirectlyBytecodePatch : BytecodePatch( +class OpenLinksDirectlyPatch : BytecodePatch( listOf( OpenLinksDirectlyFingerprintPrimary, OpenLinksDirectlyFingerprintSecondary @@ -34,6 +41,17 @@ class OpenLinksDirectlyBytecodePatch : BytecodePatch( fingerprint.result?.hookUriParser(boolean) ?: return fingerprint.toErrorResult() } + /* + add settings + */ + SettingsPatch.addPreference( + arrayOf( + "SETTINGS: ENABLE_OPEN_LINKS_DIRECTLY" + ) + ) + + SettingsPatch.updatePatchStatus("enable-open-links-directly") + return PatchResultSuccess() } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/openlinksdirectly/resource/patch/OpenLinksDirectlyPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/openlinksdirectly/resource/patch/OpenLinksDirectlyPatch.kt deleted file mode 100644 index 94fc00e21..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/openlinksdirectly/resource/patch/OpenLinksDirectlyPatch.kt +++ /dev/null @@ -1,48 +0,0 @@ -package app.revanced.patches.youtube.misc.openlinksdirectly.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.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -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.openlinksdirectly.bytecode.patch.OpenLinksDirectlyBytecodePatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper - -@Patch -@Name("enable-open-links-directly") -@Description("Skips over redirection URLs to external links.") -@DependsOn( - [ - OpenLinksDirectlyBytecodePatch::class, - SettingsPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class OpenLinksDirectlyPatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - /* - add settings - */ - ResourceHelper.addSettings( - context, - "PREFERENCE_CATEGORY: REVANCED_EXTENDED_SETTINGS", - "PREFERENCE: MISC_SETTINGS", - "SETTINGS: ENABLE_OPEN_LINKS_DIRECTLY" - ) - - ResourceHelper.patchSuccess( - context, - "enable-open-links-directly" - ) - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/pipnotification/resource/patch/PiPNotificationPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/pipnotification/resource/patch/PiPNotificationPatch.kt deleted file mode 100644 index 22163da2f..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/pipnotification/resource/patch/PiPNotificationPatch.kt +++ /dev/null @@ -1,38 +0,0 @@ -package app.revanced.patches.youtube.misc.pipnotification.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.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -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.pipnotification.bytecode.patch.PiPNotificationBytecodePatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper - -@Patch -@Name("hide-pip-notification") -@Description("Disable pip notification when you first launch pip mode.") -@DependsOn( - [ - PiPNotificationBytecodePatch::class, - SettingsPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class PiPNotificationPatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - ResourceHelper.patchSuccess( - context, - "hide-pip-notification" - ) - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playerbuttonoverlay/patch/PlayerButtonOverlayPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/playerbuttonoverlay/patch/PlayerButtonOverlayPatch.kt index f9a19fe20..0f7d3706e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/playerbuttonoverlay/patch/PlayerButtonOverlayPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/playerbuttonoverlay/patch/PlayerButtonOverlayPatch.kt @@ -43,10 +43,7 @@ class PlayerButtonOverlayPatch : ResourcePatch { } } - ResourceHelper.patchSuccess( - context, - "remove-player-button-background" - ) + SettingsPatch.updatePatchStatus("remove-player-button-background") return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/bytecode/patch/PlayerControlsBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/patch/PlayerControlsBytecodePatch.kt similarity index 100% rename from src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/bytecode/patch/PlayerControlsBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/patch/PlayerControlsBytecodePatch.kt diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/bytecode/fingerprints/DislikeFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/fingerprints/DislikeFingerprint.kt similarity index 78% rename from src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/bytecode/fingerprints/DislikeFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/fingerprints/DislikeFingerprint.kt index b36e768fd..1d4e882ed 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/bytecode/fingerprints/DislikeFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/fingerprints/DislikeFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.returnyoutubedislike.bytecode.fingerprints +package app.revanced.patches.youtube.misc.returnyoutubedislike.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/bytecode/fingerprints/LikeFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/fingerprints/LikeFingerprint.kt similarity index 78% rename from src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/bytecode/fingerprints/LikeFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/fingerprints/LikeFingerprint.kt index 6714c8258..92f6d7e02 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/bytecode/fingerprints/LikeFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/fingerprints/LikeFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.returnyoutubedislike.bytecode.fingerprints +package app.revanced.patches.youtube.misc.returnyoutubedislike.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/bytecode/fingerprints/RemoveLikeFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/fingerprints/RemoveLikeFingerprint.kt similarity index 79% rename from src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/bytecode/fingerprints/RemoveLikeFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/fingerprints/RemoveLikeFingerprint.kt index 65abc863a..8e7d9a651 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/bytecode/fingerprints/RemoveLikeFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/fingerprints/RemoveLikeFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.returnyoutubedislike.bytecode.fingerprints +package app.revanced.patches.youtube.misc.returnyoutubedislike.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/bytecode/fingerprints/ShortsTextComponentParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/fingerprints/ShortsTextComponentParentFingerprint.kt similarity index 85% rename from src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/bytecode/fingerprints/ShortsTextComponentParentFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/fingerprints/ShortsTextComponentParentFingerprint.kt index a8b121218..66ce47a3c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/bytecode/fingerprints/ShortsTextComponentParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/fingerprints/ShortsTextComponentParentFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.returnyoutubedislike.bytecode.fingerprints +package app.revanced.patches.youtube.misc.returnyoutubedislike.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/bytecode/fingerprints/TextComponentSpecFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/fingerprints/TextComponentSpecFingerprint.kt similarity index 86% rename from src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/bytecode/fingerprints/TextComponentSpecFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/fingerprints/TextComponentSpecFingerprint.kt index df50e17fb..e2a2baa40 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/bytecode/fingerprints/TextComponentSpecFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/fingerprints/TextComponentSpecFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.returnyoutubedislike.bytecode.fingerprints +package app.revanced.patches.youtube.misc.returnyoutubedislike.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import org.jf.dexlib2.iface.instruction.NarrowLiteralInstruction diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/bytecode/patch/ReturnYouTubeDislikeBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/patch/ReturnYouTubeDislikePatch.kt similarity index 84% rename from src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/bytecode/patch/ReturnYouTubeDislikeBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/patch/ReturnYouTubeDislikePatch.kt index 75dee919f..5aaa6b00d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/bytecode/patch/ReturnYouTubeDislikeBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/patch/ReturnYouTubeDislikePatch.kt @@ -1,6 +1,7 @@ -package app.revanced.patches.youtube.misc.returnyoutubedislike.bytecode.patch +package app.revanced.patches.youtube.misc.returnyoutubedislike.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 @@ -12,22 +13,27 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn +import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.misc.returnyoutubedislike.bytecode.fingerprints.* +import app.revanced.patches.youtube.misc.returnyoutubedislike.fingerprints.* +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch import app.revanced.patches.youtube.misc.videoid.mainstream.patch.MainstreamVideoIdPatch import app.revanced.util.integrations.Constants.UTILS_PATH import org.jf.dexlib2.iface.instruction.OneRegisterInstruction -@Name("return-youtube-dislike-bytecode-patch") +@Patch +@Name("return-youtube-dislike") +@Description("Shows the dislike count of videos using the Return YouTube Dislike API.") @DependsOn( [ - MainstreamVideoIdPatch::class + MainstreamVideoIdPatch::class, + SettingsPatch::class ] ) @YouTubeCompatibility @Version("0.0.1") -class ReturnYouTubeDislikeBytecodePatch : BytecodePatch( +class ReturnYouTubeDislikePatch : BytecodePatch( listOf( DislikeFingerprint, LikeFingerprint, @@ -73,8 +79,6 @@ class ReturnYouTubeDislikeBytecodePatch : BytecodePatch( } ?: return ShortsTextComponentParentFingerprint.toErrorResult() - MainstreamVideoIdPatch.injectCall("$INTEGRATIONS_RYD_CLASS_DESCRIPTOR->newVideoLoaded(Ljava/lang/String;)V") - val createComponentResult = TextComponentSpecFingerprint.result ?: return PatchResultError("Failed to find TextComponentSpecFingerprint method.") val createComponentMethod = createComponentResult.mutableMethod @@ -90,6 +94,15 @@ class ReturnYouTubeDislikeBytecodePatch : BytecodePatch( """ ) + MainstreamVideoIdPatch.injectCall("$INTEGRATIONS_RYD_CLASS_DESCRIPTOR->newVideoLoaded(Ljava/lang/String;)V") + + /* + add ReVanced Settings + */ + SettingsPatch.addReVancedPreference("ryd_settings") + + SettingsPatch.updatePatchStatus("return-youtube-dislike") + return PatchResultSuccess() } private companion object { diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/resource/patch/ReturnYouTubeDislikePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/resource/patch/ReturnYouTubeDislikePatch.kt deleted file mode 100644 index 119b9c302..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/returnyoutubedislike/resource/patch/ReturnYouTubeDislikePatch.kt +++ /dev/null @@ -1,46 +0,0 @@ -package app.revanced.patches.youtube.misc.returnyoutubedislike.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.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -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.returnyoutubedislike.bytecode.patch.ReturnYouTubeDislikeBytecodePatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper - -@Patch -@Name("return-youtube-dislike") -@Description("Shows the dislike count of videos using the Return YouTube Dislike API.") -@DependsOn( - [ - SettingsPatch::class, - ReturnYouTubeDislikeBytecodePatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class ReturnYouTubeDislikePatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - /* - add ReVanced Settings - */ - ResourceHelper.addReVancedSettings( - context, - "PREFERENCE: RETURN_YOUTUBE_DISLIKE" - ) - - ResourceHelper.patchSuccess( - context, - "return-youtube-dislike" - ) - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/resource/patch/SettingsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/settings/resource/patch/SettingsPatch.kt index 007b3dc76..424465b38 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/resource/patch/SettingsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/settings/resource/patch/SettingsPatch.kt @@ -14,7 +14,9 @@ import app.revanced.patches.shared.patch.settings.AbstractSettingsResourcePatch import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourcdIdPatch import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsBytecodePatch -import app.revanced.util.resources.ResourceHelper +import app.revanced.util.resources.ResourceHelper.addPreference +import app.revanced.util.resources.ResourceHelper.addReVancedPreference +import app.revanced.util.resources.ResourceHelper.updatePatchStatus import app.revanced.util.resources.ResourceUtils import app.revanced.util.resources.ResourceUtils.copyResources import org.w3c.dom.Element @@ -39,6 +41,7 @@ class SettingsPatch : AbstractSettingsResourcePatch( ) { override fun execute(context: ResourceContext): PatchResult { super.execute(context) + contexts = context /* * create directory for the untranslated language resources @@ -60,6 +63,11 @@ class SettingsPatch : AbstractSettingsResourcePatch( context.copyResources("youtube/settings", resourceGroup) } + /* + * initialize ReVanced Settings + */ + addReVancedPreference("extended_settings") + /* * remove revanced settings divider */ @@ -84,16 +92,21 @@ class SettingsPatch : AbstractSettingsResourcePatch( } } - /* - add settings - */ - ResourceHelper.addSettings( - context, - "PREFERENCE_CATEGORY: REVANCED_EXTENDED_SETTINGS", - "PREFERENCE: EXTENDED_SETTINGS", - "SETTINGS: ABOUT" - ) - return PatchResultSuccess() } + companion object { + private lateinit var contexts: ResourceContext + + internal fun addPreference(settingArray: Array) { + contexts.addPreference(settingArray) + } + + internal fun updatePatchStatus(patchTitle: String) { + contexts.updatePatchStatus(patchTitle) + } + + internal fun addReVancedPreference(key: String) { + contexts.addReVancedPreference(key) + } + } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt index 9b34295a8..0bd2c17f0 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt @@ -15,7 +15,8 @@ import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourcdIdPatch import app.revanced.patches.youtube.misc.sponsorblock.bytecode.fingerprints.* import app.revanced.patches.youtube.misc.timebar.patch.HookTimebarPatch import app.revanced.patches.youtube.misc.videoid.mainstream.patch.MainstreamVideoIdPatch -import app.revanced.util.bytecode.BytecodeHelper +import app.revanced.util.bytecode.BytecodeHelper.injectInit +import app.revanced.util.bytecode.BytecodeHelper.updatePatchStatus import org.jf.dexlib2.Opcode import org.jf.dexlib2.builder.BuilderInstruction import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction @@ -128,8 +129,8 @@ class SponsorBlockBytecodePatch : BytecodePatch( "invoke-static/range {p$instanceRegister}, $INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR->addSkipSponsorView15(Landroid/view/View;)V" ) - BytecodeHelper.injectInit(context, "FirstRun", "initializationSB") - BytecodeHelper.patchStatus(context, "Sponsorblock") + context.injectInit("FirstRun", "initializationSB") + context.updatePatchStatus("Sponsorblock") return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/sponsorblock/resource/patch/SponsorBlockResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/sponsorblock/resource/patch/SponsorBlockResourcePatch.kt index 81254e589..e42b6b778 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/sponsorblock/resource/patch/SponsorBlockResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/sponsorblock/resource/patch/SponsorBlockResourcePatch.kt @@ -13,7 +13,6 @@ import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch import app.revanced.patches.youtube.misc.sponsorblock.bytecode.patch.SponsorBlockBytecodePatch import app.revanced.patches.youtube.misc.sponsorblock.bytecode.patch.SponsorBlockSecondaryBytecodePatch -import app.revanced.util.resources.ResourceHelper import app.revanced.util.resources.ResourceUtils import app.revanced.util.resources.ResourceUtils.copyResources import app.revanced.util.resources.ResourceUtils.copyXmlNode @@ -98,15 +97,9 @@ class SponsorBlockResourcePatch : ResourcePatch { /* add ReVanced Settings */ - ResourceHelper.addReVancedSettings( - context, - "PREFERENCE: SPONSOR_BLOCK" - ) + SettingsPatch.addReVancedPreference("sponsorblock_settings") - ResourceHelper.patchSuccess( - context, - "sponsorblock" - ) + SettingsPatch.updatePatchStatus("sponsorblock") return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/tooltip/resource/patch/TooltipContentViewPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/tooltip/resource/patch/TooltipContentViewPatch.kt deleted file mode 100644 index 39ede06b3..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/tooltip/resource/patch/TooltipContentViewPatch.kt +++ /dev/null @@ -1,38 +0,0 @@ -package app.revanced.patches.youtube.misc.tooltip.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.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -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.settings.resource.patch.SettingsPatch -import app.revanced.patches.youtube.misc.tooltip.bytecode.patch.TooltipContentViewBytecodePatch -import app.revanced.util.resources.ResourceHelper - -@Patch -@Name("hide-tooltip-content") -@Description("Hides the tooltip box that appears on first install.") -@DependsOn( - [ - TooltipContentViewBytecodePatch::class, - SettingsPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class MinimizedPlaybackPatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - ResourceHelper.patchSuccess( - context, - "hide-tooltip-content" - ) - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/translations/patch/TranslationsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/translations/patch/TranslationsPatch.kt index 905863743..96e390fc5 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/translations/patch/TranslationsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/translations/patch/TranslationsPatch.kt @@ -11,23 +11,20 @@ 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.settings.resource.patch.SettingsPatch -import app.revanced.util.resources.ResourceHelper +import app.revanced.util.resources.ResourceHelper.addTranslations @Patch @Name("translations") -@Description("Add Crowdin Translations.") +@Description("Add Crowdin translations for YouTube.") @DependsOn([SettingsPatch::class]) @YouTubeCompatibility @Version("0.0.1") class TranslationsPatch : ResourcePatch { override fun execute(context: ResourceContext): PatchResult { - ResourceHelper.addTranslations(context, "youtube", LANGUAGE_LIST) + context.addTranslations("youtube", LANGUAGE_LIST) - ResourceHelper.patchSuccess( - context, - "translations" - ) + SettingsPatch.updatePatchStatus("translations") return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/youtube/swipe/swipecontrols/resource/patch/SwipeControlsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/swipe/swipecontrols/resource/patch/SwipeControlsPatch.kt index a50ae391a..58869d266 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/swipe/swipecontrols/resource/patch/SwipeControlsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/swipe/swipecontrols/resource/patch/SwipeControlsPatch.kt @@ -11,9 +11,8 @@ 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.settings.resource.patch.SettingsPatch -import app.revanced.patches.youtube.swipe.swipebrightnessinhdr.bytecode.patch.SwipeGestureBrightnessInHDRPatch import app.revanced.patches.youtube.swipe.swipecontrols.bytecode.patch.SwipeControlsBytecodePatch -import app.revanced.util.resources.ResourceHelper +import app.revanced.patches.youtube.swipe.swipecontrolshdr.patch.SwipeControlsHDRPatch import app.revanced.util.resources.ResourceUtils import app.revanced.util.resources.ResourceUtils.copyResources @@ -24,7 +23,7 @@ import app.revanced.util.resources.ResourceUtils.copyResources [ SettingsPatch::class, SwipeControlsBytecodePatch::class, - SwipeGestureBrightnessInHDRPatch::class + SwipeControlsHDRPatch::class ] ) @YouTubeCompatibility @@ -35,17 +34,14 @@ class SwipeControlsPatch : ResourcePatch { /* add settings */ - ResourceHelper.addSettings( - context, - "PREFERENCE_CATEGORY: REVANCED_SETTINGS", - "PREFERENCE: SWIPE_SETTINGS", - "SETTINGS: SWIPE_CONTROLS" + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: SWIPE_SETTINGS", + "SETTINGS: SWIPE_CONTROLS" + ) ) - ResourceHelper.patchSuccess( - context, - "swipe-controls" - ) + SettingsPatch.updatePatchStatus("swipe-controls") context.copyResources( "youtube/swipecontrols", diff --git a/src/main/kotlin/app/revanced/patches/youtube/swipe/swipebrightnessinhdr/bytecode/fingerprints/HDRVideoFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/swipe/swipecontrolshdr/fingerprints/HDRVideoFingerprint.kt similarity index 70% rename from src/main/kotlin/app/revanced/patches/youtube/swipe/swipebrightnessinhdr/bytecode/fingerprints/HDRVideoFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/swipe/swipecontrolshdr/fingerprints/HDRVideoFingerprint.kt index c58deadc9..e33467592 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/swipe/swipebrightnessinhdr/bytecode/fingerprints/HDRVideoFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/swipe/swipecontrolshdr/fingerprints/HDRVideoFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.swipe.swipebrightnessinhdr.bytecode.fingerprints +package app.revanced.patches.youtube.swipe.swipecontrolshdr.fingerprints import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/swipe/swipebrightnessinhdr/bytecode/patch/SwipeGestureBrightnessInHDRPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/swipe/swipecontrolshdr/patch/SwipeControlsHDRPatch.kt similarity index 81% rename from src/main/kotlin/app/revanced/patches/youtube/swipe/swipebrightnessinhdr/bytecode/patch/SwipeGestureBrightnessInHDRPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/swipe/swipecontrolshdr/patch/SwipeControlsHDRPatch.kt index dc068e89c..a75354129 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/swipe/swipebrightnessinhdr/bytecode/patch/SwipeGestureBrightnessInHDRPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/swipe/swipecontrolshdr/patch/SwipeControlsHDRPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.swipe.swipebrightnessinhdr.bytecode.patch +package app.revanced.patches.youtube.swipe.swipecontrolshdr.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Name @@ -11,13 +11,13 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patches.shared.annotation.YouTubeCompatibility -import app.revanced.patches.youtube.swipe.swipebrightnessinhdr.bytecode.fingerprints.HDRVideoFingerprint +import app.revanced.patches.youtube.swipe.swipecontrolshdr.fingerprints.HDRVideoFingerprint import app.revanced.util.integrations.Constants.SWIPE_PATH -@Name("enable-swipe-gesture-brightness-in-hdr-patch") +@Name("swipe-controls-hdr") @YouTubeCompatibility @Version("0.0.1") -class SwipeGestureBrightnessInHDRPatch : BytecodePatch( +class SwipeControlsHDRPatch : BytecodePatch( listOf( HDRVideoFingerprint ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/customspeed/bytecode/patch/CustomVideoSpeedBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/customspeed/bytecode/patch/CustomVideoSpeedBytecodePatch.kt index 871df1000..877aad973 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/customspeed/bytecode/patch/CustomVideoSpeedBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/customspeed/bytecode/patch/CustomVideoSpeedBytecodePatch.kt @@ -37,7 +37,8 @@ class CustomVideoSpeedBytecodePatch : BytecodePatch( ) { override fun execute(context: BytecodeContext): PatchResult { val speed = PatchOptions.CustomSpeedArrays - val splits = speed!!.replace(" ","").split(",") + ?: return PatchResultError("Invalid video speed array.") + val splits = speed.replace(" ","").split(",") if (splits.isEmpty()) throw IllegalArgumentException("Invalid speed elements") val videoSpeedsArray = splits.map { it.toFloat().toRawBits() } diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/customspeed/resource/patch/CustomVideoSpeedPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/customspeed/resource/patch/CustomVideoSpeedPatch.kt index aa91a06eb..878b3240d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/customspeed/resource/patch/CustomVideoSpeedPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/customspeed/resource/patch/CustomVideoSpeedPatch.kt @@ -14,7 +14,9 @@ import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.shared.patch.options.PatchOptions import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch import app.revanced.patches.youtube.video.customspeed.bytecode.patch.CustomVideoSpeedBytecodePatch -import app.revanced.util.resources.ResourceHelper +import app.revanced.util.resources.ResourceHelper.addSpeedEntries +import app.revanced.util.resources.ResourceHelper.addSpeedEntryValues +import app.revanced.util.resources.ResourceHelper.replaceCustomSpeed import app.revanced.util.resources.ResourceUtils.copyXmlNode @Patch @@ -35,7 +37,7 @@ class CustomVideoSpeedPatch : ResourcePatch { /* * Copy arrays */ - context.copyXmlNode("youtube/speed/host", "values/arrays.xml", "resources") + context.copyXmlNode("youtube/customspeed/host", "values/arrays.xml", "resources") val speed = PatchOptions.CustomSpeedArrays ?: return PatchResultError("Invalid video speed array.") @@ -44,26 +46,23 @@ class CustomVideoSpeedPatch : ResourcePatch { if (splits.isEmpty()) throw IllegalArgumentException("Invalid speed elements") val speedElements = splits.map { it } for (index in 0 until splits.count()) { - ResourceHelper.addEntryValues(context, speedElements[index]) - ResourceHelper.addEntries(context, speedElements[index] + "x") + context.addSpeedEntries(speedElements[index] + "x") + context.addSpeedEntryValues(speedElements[index]) } - ResourceHelper.addSpeed(context) + context.replaceCustomSpeed() /* add settings */ - ResourceHelper.addSettings( - context, - "PREFERENCE_CATEGORY: REVANCED_EXTENDED_SETTINGS", - "PREFERENCE: VIDEO_SETTINGS", - "SETTINGS: CUSTOM_VIDEO_SPEED" + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: VIDEO_SETTINGS", + "SETTINGS: CUSTOM_VIDEO_SPEED" + ) ) - ResourceHelper.patchSuccess( - context, - "custom-video-speed" - ) + SettingsPatch.updatePatchStatus("custom-video-speed") return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/quality/resource/patch/VideoQualityPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/quality/resource/patch/VideoQualityPatch.kt index c5124dc4b..913ae7ef3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/quality/resource/patch/VideoQualityPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/quality/resource/patch/VideoQualityPatch.kt @@ -12,7 +12,6 @@ import app.revanced.patcher.patch.annotations.Patch import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch import app.revanced.patches.youtube.video.quality.bytecode.patch.VideoQualityBytecodePatch -import app.revanced.util.resources.ResourceHelper import app.revanced.util.resources.ResourceUtils.copyXmlNode @Patch @@ -39,17 +38,14 @@ class VideoQualityPatch : ResourcePatch { /* add settings */ - ResourceHelper.addSettings( - context, - "PREFERENCE_CATEGORY: REVANCED_EXTENDED_SETTINGS", - "PREFERENCE: VIDEO_SETTINGS", - "SETTINGS: DEFAULT_VIDEO_QUALITY" + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: VIDEO_SETTINGS", + "SETTINGS: DEFAULT_VIDEO_QUALITY" + ) ) - ResourceHelper.patchSuccess( - context, - "default-video-quality" - ) + SettingsPatch.updatePatchStatus("default-video-quality") return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/bytecode/patch/VideoSpeedBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/bytecode/patch/VideoSpeedBytecodePatch.kt index d8c826505..b99bb7cfd 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/speed/bytecode/patch/VideoSpeedBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/speed/bytecode/patch/VideoSpeedBytecodePatch.kt @@ -17,7 +17,7 @@ import app.revanced.patcher.util.smali.toInstructions import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.youtube.misc.videoid.legacy.patch.LegacyVideoIdPatch import app.revanced.patches.youtube.video.speed.bytecode.fingerprints.* -import app.revanced.util.bytecode.BytecodeHelper +import app.revanced.util.bytecode.BytecodeHelper.updatePatchStatus import app.revanced.util.integrations.Constants.VIDEO_PATH import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.dexbacked.reference.DexBackedMethodReference @@ -114,7 +114,7 @@ class VideoSpeedBytecodePatch : BytecodePatch( LegacyVideoIdPatch.injectCall("$INTEGRATIONS_VIDEO_SPEED_CLASS_DESCRIPTOR->newVideoStarted(Ljava/lang/String;)V") - BytecodeHelper.patchStatus(context, "VideoSpeed") + context.updatePatchStatus("VideoSpeed") return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/resource/patch/VideoSpeedPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/resource/patch/VideoSpeedPatch.kt index 433a6e7a4..fde15cbd7 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/speed/resource/patch/VideoSpeedPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/speed/resource/patch/VideoSpeedPatch.kt @@ -12,7 +12,6 @@ import app.revanced.patcher.patch.annotations.Patch import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch import app.revanced.patches.youtube.video.speed.bytecode.patch.VideoSpeedBytecodePatch -import app.revanced.util.resources.ResourceHelper @Patch @Name("default-video-speed") @@ -31,17 +30,14 @@ class VideoSpeedPatch : ResourcePatch { /* add settings */ - ResourceHelper.addSettings( - context, - "PREFERENCE_CATEGORY: REVANCED_EXTENDED_SETTINGS", - "PREFERENCE: VIDEO_SETTINGS", - "SETTINGS: DEFAULT_VIDEO_SPEED" + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: VIDEO_SETTINGS", + "SETTINGS: DEFAULT_VIDEO_SPEED" + ) ) - ResourceHelper.patchSuccess( - context, - "default-video-speed" - ) + SettingsPatch.updatePatchStatus("default-video-speed") return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/util/bytecode/BytecodeHelper.kt b/src/main/kotlin/app/revanced/util/bytecode/BytecodeHelper.kt index b109fadbf..5f2d903cd 100644 --- a/src/main/kotlin/app/revanced/util/bytecode/BytecodeHelper.kt +++ b/src/main/kotlin/app/revanced/util/bytecode/BytecodeHelper.kt @@ -7,35 +7,31 @@ import app.revanced.util.integrations.Constants.UTILS_PATH internal object BytecodeHelper { - fun injectInit( - context: BytecodeContext, - descriptor: String, - methods: String + internal fun BytecodeContext.injectInit( + methods: String, + descriptor: String ) { - context.classes.forEach { classDef -> + this.classes.forEach { classDef -> classDef.methods.forEach { method -> if (classDef.type.endsWith("WatchWhileActivity;") && method.name == "onCreate") { val hookMethod = - context.proxy(classDef).mutableClass.methods.first { it.name == "onCreate" } + this.proxy(classDef).mutableClass.methods.first { it.name == "onCreate" } hookMethod.addInstruction( 2, - "invoke-static {}, $UTILS_PATH/$descriptor;->$methods()V" + "invoke-static {}, $UTILS_PATH/$methods;->$descriptor()V" ) } } } } - fun patchStatus( - context: BytecodeContext, - name: String - ) { - context.classes.forEach { classDef -> + internal fun BytecodeContext.updatePatchStatus(patch: String) { + this.classes.forEach { classDef -> classDef.methods.forEach { method -> - if (classDef.type.endsWith("PatchStatus;") && method.name == name) { + if (classDef.type.endsWith("PatchStatus;") && method.name == patch) { val patchStatusMethod = - context.proxy(classDef).mutableClass.methods.first { it.name == name } + this.proxy(classDef).mutableClass.methods.first { it.name == patch } patchStatusMethod.replaceInstruction( 0, diff --git a/src/main/kotlin/app/revanced/util/microg/MicroGBytecodeHelper.kt b/src/main/kotlin/app/revanced/util/microg/MicroGBytecodeHelper.kt index b4b4038cb..6b7d68d41 100644 --- a/src/main/kotlin/app/revanced/util/microg/MicroGBytecodeHelper.kt +++ b/src/main/kotlin/app/revanced/util/microg/MicroGBytecodeHelper.kt @@ -1,7 +1,6 @@ package app.revanced.util.microg import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstruction import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.replaceInstruction import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint @@ -21,17 +20,6 @@ import org.jf.dexlib2.immutable.reference.ImmutableStringReference * Helper class for applying bytecode patches needed for the microg-support patches. */ internal object MicroGBytecodeHelper { - /** - * Hook a method to check the availability of MicroG. - * - * @param fingerprint The fingerprint of the method to add the call for the notice in. - */ - fun injectNotice(fingerprint: MethodFingerprint) { - fingerprint.result!!.mutableMethod.addInstruction( - 0, - "invoke-static {}, Lapp/revanced/integrations/patches/MicroGSupport;->checkAvailability()V" - ) - } /** * Transform strings with package name out of [fromPackageName] and [toPackageName]. diff --git a/src/main/kotlin/app/revanced/util/microg/MicroGManifestHelper.kt b/src/main/kotlin/app/revanced/util/microg/MicroGManifestHelper.kt index 003fa00e3..ed1cba0ed 100644 --- a/src/main/kotlin/app/revanced/util/microg/MicroGManifestHelper.kt +++ b/src/main/kotlin/app/revanced/util/microg/MicroGManifestHelper.kt @@ -17,16 +17,14 @@ internal object MicroGManifestHelper { * Add manifest entries needed for package and signature spoofing when using MicroG. * Note: this only adds metadata entries for signature spoofing, other changes may still be required to make a microG patch work. * - * @param context Resource context. * @param spoofedPackage The package to spoof. * @param spoofedSignature The signature to spoof. */ - fun addSpoofingMetadata( - context: ResourceContext, + fun ResourceContext.addSpoofingMetadata( spoofedPackage: String, spoofedSignature: String ) { - context.xmlEditor["AndroidManifest.xml"].use { + this.xmlEditor["AndroidManifest.xml"].use { val applicationNode = it .file .getElementsByTagName("application") diff --git a/src/main/kotlin/app/revanced/util/microg/MicroGResourceHelper.kt b/src/main/kotlin/app/revanced/util/microg/MicroGResourceHelper.kt index f5c033c8e..6bb8f576c 100644 --- a/src/main/kotlin/app/revanced/util/microg/MicroGResourceHelper.kt +++ b/src/main/kotlin/app/revanced/util/microg/MicroGResourceHelper.kt @@ -9,18 +9,16 @@ internal object MicroGResourceHelper { /** * Patch the manifest to work with MicroG. * - * @param context Bytecode context. * @param fromPackageName Original package name. * @param toPackageName The package name to accept. * @param toName The new name of the app. */ - fun patchManifest( - context: ResourceContext, + fun ResourceContext.patchManifest( fromPackageName: String, toPackageName: String ) { - val manifest = context["AndroidManifest.xml"].readText() - context["AndroidManifest.xml"].writeText( + val manifest = this["AndroidManifest.xml"].readText() + this["AndroidManifest.xml"].writeText( manifest.replace( "package=\"$fromPackageName", "package=\"$toPackageName" diff --git a/src/main/kotlin/app/revanced/util/resources/IconHelper.kt b/src/main/kotlin/app/revanced/util/resources/IconHelper.kt index 92e7dc0a7..a1de8ce2f 100644 --- a/src/main/kotlin/app/revanced/util/resources/IconHelper.kt +++ b/src/main/kotlin/app/revanced/util/resources/IconHelper.kt @@ -1,16 +1,13 @@ package app.revanced.util.resources import app.revanced.patcher.data.ResourceContext +import org.w3c.dom.Element import java.nio.file.Files import java.nio.file.StandardCopyOption -import org.w3c.dom.Element internal object IconHelper { - fun customIcon( - context: ResourceContext, - iconName: String - ) { + internal fun ResourceContext.customIcon(iconName: String) { val launchIcon = arrayOf( "adaptiveproduct_youtube_background_color_108", "adaptiveproduct_youtube_foreground_color_108", @@ -26,7 +23,6 @@ internal object IconHelper { ) copyResources( - context, "youtube", iconName, "launchericon", @@ -35,7 +31,6 @@ internal object IconHelper { ) copyResources( - context, "youtube", iconName, "splashicon", @@ -44,13 +39,12 @@ internal object IconHelper { ) monochromeIcon( - context, "youtube", "adaptive_monochrome_ic_youtube_launcher", iconName ) - context.xmlEditor["res/values-v31/styles.xml"].use { editor -> + this.xmlEditor["res/values-v31/styles.xml"].use { editor -> with(editor.file) { val resourcesNode = getElementsByTagName("resources").item(0) as Element @@ -65,10 +59,7 @@ internal object IconHelper { } } - fun customIconMusic( - context: ResourceContext, - iconName: String - ) { + internal fun ResourceContext.customIconMusic(iconName: String) { val launchIcon = arrayOf( "adaptiveproduct_youtube_music_background_color_108", "adaptiveproduct_youtube_music_foreground_color_108", @@ -76,7 +67,6 @@ internal object IconHelper { ) copyResources( - context, "music", iconName, "launchericon", @@ -85,17 +75,13 @@ internal object IconHelper { ) monochromeIcon( - context, "music", "ic_app_icons_themed_youtube_music", iconName ) } - fun customIconMusicAdditional( - context: ResourceContext, - iconName: String - ) { + internal fun ResourceContext.customIconMusicAdditional(iconName: String) { val record = arrayOf( "hdpi", "large-hdpi", @@ -121,29 +107,25 @@ internal object IconHelper { ) copyMusicResources( - context, iconName, record, "record" ) copyMusicResources( - context, iconName, actionbarLogo, "action_bar_logo" ) copyMusicResources( - context, iconName, actionbarLogoRelease, "action_bar_logo_release" ) } - private fun copyResources( - context: ResourceContext, + private fun ResourceContext.copyResources( appName: String, iconName: String, iconPath: String, @@ -159,16 +141,15 @@ internal object IconHelper { ).forEach { size -> iconArray.forEach iconLoop@{ name -> Files.copy( - this.javaClass.classLoader.getResourceAsStream("$appName/branding/$iconName/$iconPath/$size/$name.png")!!, - context["res"].resolve("$directory-$size").resolve("$name.png").toPath(), + ResourceUtils.javaClass.classLoader.getResourceAsStream("$appName/branding/$iconName/$iconPath/$size/$name.png")!!, + this["res"].resolve("$directory-$size").resolve("$name.png").toPath(), StandardCopyOption.REPLACE_EXISTING ) } } } - private fun monochromeIcon( - context: ResourceContext, + private fun ResourceContext.monochromeIcon( appName: String, monochromeIconName: String, iconName: String @@ -176,15 +157,14 @@ internal object IconHelper { try { val relativePath = "drawable/$monochromeIconName.xml" Files.copy( - this.javaClass.classLoader.getResourceAsStream("$appName/branding/$iconName/monochromeicon/$relativePath")!!, - context["res"].resolve(relativePath).toPath(), + ResourceUtils.javaClass.classLoader.getResourceAsStream("$appName/branding/$iconName/monochromeicon/$relativePath")!!, + this["res"].resolve(relativePath).toPath(), StandardCopyOption.REPLACE_EXISTING ) } catch (_: Exception) {} } - private fun copyMusicResources( - context: ResourceContext, + private fun ResourceContext.copyMusicResources( iconName: String, iconArray: Array, resourceNames: String @@ -193,8 +173,8 @@ internal object IconHelper { val relativePath = "drawable-$path/$resourceNames.png" Files.copy( - this.javaClass.classLoader.getResourceAsStream("music/branding/$iconName/resource/$relativePath")!!, - context["res"].resolve(relativePath).toPath(), + ResourceUtils.javaClass.classLoader.getResourceAsStream("music/branding/$iconName/resource/$relativePath")!!, + this["res"].resolve(relativePath).toPath(), StandardCopyOption.REPLACE_EXISTING ) } diff --git a/src/main/kotlin/app/revanced/util/resources/ResourceHelper.kt b/src/main/kotlin/app/revanced/util/resources/ResourceHelper.kt index 48c524e7f..5fb906e6d 100644 --- a/src/main/kotlin/app/revanced/util/resources/ResourceHelper.kt +++ b/src/main/kotlin/app/revanced/util/resources/ResourceHelper.kt @@ -1,20 +1,36 @@ package app.revanced.util.resources +import app.revanced.extensions.doRecursively import app.revanced.patcher.data.ResourceContext +import org.w3c.dom.Element +import org.w3c.dom.Node import java.nio.file.Files import java.nio.file.StandardCopyOption -import org.w3c.dom.Element + +private fun Node.adoptChild(tagName: String, targetNode: Node, block: Element.() -> Unit) { + val child = ownerDocument.createElement(tagName) + child.block() + parentNode.insertBefore(child, targetNode) +} + internal object ResourceHelper { - fun addEntryValues( - context: ResourceContext, - speed: String - ) { - val path = "res/values/arrays.xml" + private const val TARGET_ARRAY_PATH = "res/values/arrays.xml" - context.xmlEditor[path].use { editor -> - with(editor.file) { + private const val TARGET_PREFERENCE_PATH = "res/xml/revanced_prefs.xml" + + private const val TARGET_SETTINGS_PATH = "res/xml/settings_fragment.xml" + + private var targetPackage = "com.google.android.youtube" + + fun setMicroG (newPackage: String) { + targetPackage = newPackage + } + + internal fun ResourceContext.addSpeedEntryValues(speedEntryValues: String) { + xmlEditor[TARGET_ARRAY_PATH].use { + with(it.file) { val resourcesNode = getElementsByTagName("resources").item(0) as Element val newElement: Element = createElement("item") @@ -22,8 +38,8 @@ internal object ResourceHelper { for (i in 0 until resourcesNode.childNodes.length) { val node = resourcesNode.childNodes.item(i) as? Element ?: continue - if (node.getAttribute("name") == "revanced_video_speed_entry_values") { - newElement.appendChild(createTextNode(speed)) + if (node.getAttribute("name") == "revanced_custom_video_speed_entry_value") { + newElement.appendChild(createTextNode(speedEntryValues)) node.appendChild(newElement) } @@ -32,14 +48,9 @@ internal object ResourceHelper { } } - fun addEntries( - context: ResourceContext, - speed: String - ) { - val path = "res/values/arrays.xml" - - context.xmlEditor[path].use { editor -> - with(editor.file) { + internal fun ResourceContext.addSpeedEntries(speedEntries: String) { + xmlEditor[TARGET_ARRAY_PATH].use { + with(it.file) { val resourcesNode = getElementsByTagName("resources").item(0) as Element val newElement: Element = createElement("item") @@ -47,166 +58,113 @@ internal object ResourceHelper { for (i in 0 until resourcesNode.childNodes.length) { val node = resourcesNode.childNodes.item(i) as? Element ?: continue - if (node.getAttribute("name") == "revanced_video_speed_entries") { - newElement.appendChild(createTextNode(speed)) + if (node.getAttribute("name") == "revanced_custom_video_speed_entry") { + newElement.appendChild(createTextNode(speedEntries)) node.appendChild(newElement) } } } } - context[path].writeText( - context[path].readText().replace("1.0x", "@string/shorts_speed_control_normal_label") + this[TARGET_ARRAY_PATH].writeText( + this[TARGET_ARRAY_PATH].readText().replace("1.0x", "@string/shorts_speed_control_normal_label") ) } - fun addSpeed( - context: ResourceContext - ) { - val prefs = context["res/xml/revanced_prefs.xml"] + internal fun ResourceContext.replaceCustomSpeed() { + val prefs = this[TARGET_PREFERENCE_PATH] prefs.writeText( prefs.readText() .replace( - "revanced_default_video_speed\"", - "revanced_default_video_speed\" android:entries=\"@array/revanced_video_speed_entries\" android:entryValues=\"@array/revanced_video_speed_entry_values\"" + "revanced_default_video_speed_entry", + "revanced_custom_video_speed_entry" ) ) } - fun addSettings( - context: ResourceContext, - PreferenceCategory: String, - Preference: String, - Settings: String - ) { - val prefs = context["res/xml/revanced_prefs.xml"] - prefs.writeText( - prefs.readText() - .replace("", "") - .replace("", "") - .replace("", "") - ) - } + internal fun ResourceContext.addPreference(settingArray: Array) { + val prefs = this[TARGET_PREFERENCE_PATH] - fun addSettings2( - context: ResourceContext, - PreferenceCategory: String, - Preference: String, - Settings: String, - Settings2: String - ) { - val prefs = context["res/xml/revanced_prefs.xml"] - prefs.writeText( - prefs.readText() - .replace("", "") - .replace("", "") - .replace("", "") - .replace("", "") - ) - } - - fun addSettings3( - context: ResourceContext, - PreferenceCategory: String, - Preference: String, - Settings: String, - Settings2: String, - Settings3: String - ) { - val prefs = context["res/xml/revanced_prefs.xml"] - prefs.writeText( - prefs.readText() - .replace("", "") - .replace("", "") - .replace("", "") - .replace("", "") - .replace("", "") - ) - } - - fun addSettings4( - context: ResourceContext, - PreferenceCategory: String, - Preference: String, - Settings: String, - Settings2: String, - Settings3: String, - Settings4: String - ) { - val prefs = context["res/xml/revanced_prefs.xml"] - prefs.writeText( - prefs.readText() - .replace("", "") - .replace("", "") - .replace("", "") - .replace("", "") - .replace("", "") - .replace("", "") - ) - } - - fun addSettings5( - context: ResourceContext, - PreferenceCategory: String, - Preference: String, - Settings: String, - Settings2: String, - Settings3: String, - Settings4: String, - Settings5: String - ) { - val prefs = context["res/xml/revanced_prefs.xml"] - prefs.writeText( - prefs.readText() - .replace("", "") - .replace("", "") - .replace("", "") - .replace("", "") - .replace("", "") - .replace("", "") - .replace("", "") - ) - } - - fun initReVancedSettings( - context: ResourceContext - ) { - val fragment = context["res/xml/settings_fragment.xml"] - fragment.writeText( - fragment.readText().replace( - "DeveloperPrefsFragment\" app:iconSpaceReserved=\"false\" />", - "DeveloperPrefsFragment\" app:iconSpaceReserved=\"false\" />" + settingArray.forEach preferenceLoop@{ preference -> + prefs.writeText( + prefs.readText() + .replace("", "") ) - ) + } } - fun addTranslations( - context: ResourceContext, + internal fun ResourceContext.updatePatchStatus(patchTitle: String) { + updatePatchStatusSettings(patchTitle, "@string/revanced_patches_included") + } + + internal fun ResourceContext.updatePatchStatusLabel(appName: String) { + updatePatchStatusSettings("labels", appName) + } + + internal fun ResourceContext.updatePatchStatusIcon(iconName: String) { + updatePatchStatusSettings("icons", "@string/revanced_icons_$iconName") + } + + internal fun ResourceContext.updatePatchStatusTheme(themeName: String) { + updatePatchStatusSettings("themes", "@string/revanced_themes_$themeName") + } + + private fun ResourceContext.updatePatchStatusSettings( + patchTitle: String, + updateText: String + ) { + this.xmlEditor[TARGET_PREFERENCE_PATH].use { editor -> + editor.file.doRecursively loop@{ + if (it !is Element) return@loop + + it.getAttributeNode("android:title")?.let { attribute -> + if (attribute.textContent == patchTitle) { + it.getAttributeNode("android:summary").textContent = updateText + } + } + } + } + } + + internal fun ResourceContext.addReVancedPreference(key: String) { + val targetClass = "com.google.android.apps.youtube.app.settings.videoquality.VideoQualitySettingsActivity" + + this.xmlEditor[TARGET_SETTINGS_PATH].use { editor -> + with (editor.file) { + doRecursively loop@{ + if (it !is Element) return@loop + it.getAttributeNode("android:key")?.let { attribute -> + if (attribute.textContent == "@string/about_key" && it.getAttributeNode("app:iconSpaceReserved").textContent == "false") { + it.adoptChild("Preference", it) { + setAttribute("android:title", "@string/revanced_" + key + "_title") + setAttribute("android:summary", "@string/revanced_" + key + "_summary") + this.appendChild(ownerDocument.createElement("intent").also { intentNode -> + intentNode.setAttribute("android:targetPackage", targetPackage) + intentNode.setAttribute("android:data", key) + intentNode.setAttribute("android:targetClass", targetClass) + }) + } + it.getAttributeNode("app:iconSpaceReserved").textContent = "true" + return@loop + } + } + } + + doRecursively loop@{ + if (it !is Element) return@loop + + it.getAttributeNode("app:iconSpaceReserved")?.let { attribute -> + if (attribute.textContent == "true") { + attribute.textContent = "false" + } + } + } + } + } + } + + internal fun ResourceContext.addTranslations( sourceDirectory: String, languageArray: Array ) { @@ -214,90 +172,13 @@ internal object ResourceHelper { val directory = "values-$language-v21" val relativePath = "$language/strings.xml" - context["res/$directory"].mkdir() + this["res/$directory"].mkdir() Files.copy( - this.javaClass.classLoader.getResourceAsStream("$sourceDirectory/translations/$relativePath")!!, - context["res"].resolve("$directory/strings.xml").toPath(), + ResourceUtils.javaClass.classLoader.getResourceAsStream("$sourceDirectory/translations/$relativePath")!!, + this["res"].resolve("$directory/strings.xml").toPath(), StandardCopyOption.REPLACE_EXISTING ) } } - - fun addReVancedSettings( - context: ResourceContext, - Preference: String - ) { - val fragment = context["res/xml/settings_fragment.xml"] - fragment.writeText( - fragment.readText() - .replace("", "") - ) - } - - fun patchSuccess( - context: ResourceContext, - name: String - ) { - val prefs = context["res/xml/revanced_prefs.xml"] - prefs.writeText( - prefs.readText().replace( - "\"$name\" android:summary=\"@string/revanced_patches_excluded", - "\"$name\" android:summary=\"@string/revanced_patches_included" - ) - ) - } - - fun themePatchSuccess( - context: ResourceContext, - before: String, - after: String - ) { - val prefs = context["res/xml/revanced_prefs.xml"] - prefs.writeText( - prefs.readText().replace( - "@string/revanced_themes_$before", - "@string/revanced_themes_$after" - ) - ) - } - - fun iconPatchSuccess( - context: ResourceContext, - targeticon: String - ) { - val prefs = context["res/xml/revanced_prefs.xml"] - prefs.writeText( - prefs.readText() - .replace( - "@string/revanced_icons_blue", - "@string/revanced_icons_default" - ).replace( - "@string/revanced_icons_red", - "@string/revanced_icons_default" - ).replace( - "@string/revanced_icons_revancify", - "@string/revanced_icons_default" - ) - .replace( - "@string/revanced_icons_default", - "@string/revanced_icons_$targeticon" - ) - ) - } - - fun labelPatchSuccess( - context: ResourceContext, - appName: String - ) { - val prefs = context["res/xml/revanced_prefs.xml"] - prefs.writeText( - prefs.readText().replace( - "@string/revanced_labels_default", - appName - ) - ) - } - } \ No newline at end of file diff --git a/src/main/resources/youtube/customspeed/host/values/arrays.xml b/src/main/resources/youtube/customspeed/host/values/arrays.xml new file mode 100644 index 000000000..a93b48962 --- /dev/null +++ b/src/main/resources/youtube/customspeed/host/values/arrays.xml @@ -0,0 +1,9 @@ + + + + @string/quality_auto + + + -2.0 + + diff --git a/src/main/resources/youtube/overlaybuttons/host/values/arrays.xml b/src/main/resources/youtube/overlaybuttons/host/values/arrays.xml new file mode 100644 index 000000000..21f5f7b69 --- /dev/null +++ b/src/main/resources/youtube/overlaybuttons/host/values/arrays.xml @@ -0,0 +1,21 @@ + + + + PowerTube + NewPipe + NewPipe x SponsorBlock + Seal + + + ussr.razar.youtube_dl + org.schabi.newpipe + org.polymorphicshade.newpipe + com.junkfood.seal + + + https://github.com/razar-dev/PowerTube/releases/latest + https://github.com/TeamNewPipe/NewPipe/releases/latest + https://github.com/polymorphicshade/NewPipe/releases/latest + https://github.com/JunkFood02/Seal/releases/latest + + diff --git a/src/main/resources/youtube/quality/host/values/arrays.xml b/src/main/resources/youtube/quality/host/values/arrays.xml index 1cb9e66dd..adc399d5e 100644 --- a/src/main/resources/youtube/quality/host/values/arrays.xml +++ b/src/main/resources/youtube/quality/host/values/arrays.xml @@ -1,6 +1,6 @@ - + @string/quality_auto 144p 240p @@ -11,7 +11,7 @@ 1440p 2160p - + -2 144 240 diff --git a/src/main/resources/youtube/settings/host/values/strings.xml b/src/main/resources/youtube/settings/host/values/strings.xml index 493353280..ff15f3c6b 100644 --- a/src/main/resources/youtube/settings/host/values/strings.xml +++ b/src/main/resources/youtube/settings/host/values/strings.xml @@ -44,11 +44,11 @@ Please install MicroG MicroG is not found MicroG does not run in the background - Notification settings "1. Google device registration and Cloud Messaging need to be enabled for notifications. 2. ReVanced needs to be shown as registered under Cloud Messaging. 3. Current State in Cloud Messaging must be Connected." - MicroG settings + Notification settings + MicroG settings minutes Choose the segment category "The segment lasts from %02d:%02d to %02d:%02d (%d minutes %02d seconds) @@ -258,9 +258,8 @@ Is it ready to submit?" Experimental Flags Report issues or leave suggestions here ReVanced Extended Issue Center - ReVanced Extended settings - Extended related settings - Extended settings + ReVanced Extended specific settings + ReVanced Extended settings Captions are enabled when playing a video with captioning is enforced "Captions aren't enabled when playing a video with captioning is enforced" Hide auto captions @@ -504,7 +503,8 @@ Since these setting is quite outdated, it may not be valid" Failed to change default mobile data quality Changing default Wi-Fi quality to: Failed to change default WI-FI quality - ReVanced settings + SponsorBlock related settings + SponsorBlock settings Swipe controls related settings Swipe controls settings The amount of threshold for swipe to occur @@ -547,8 +547,6 @@ Since these setting is quite outdated, it may not be valid" There are guidelines Guidelines contain tips and rules about submitting segments View guidelines - SponsorBlock settings - SponsorBlock related settings Switched successfully. reload the video Switching mirror API server to main API server.. Endcards/Credits diff --git a/src/main/resources/youtube/settings/layout/revanced_settings_toolbar.xml b/src/main/resources/youtube/settings/layout/revanced_settings_toolbar.xml index a3f474767..ea1df1280 100644 --- a/src/main/resources/youtube/settings/layout/revanced_settings_toolbar.xml +++ b/src/main/resources/youtube/settings/layout/revanced_settings_toolbar.xml @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/src/main/resources/youtube/settings/xml/revanced_prefs.xml b/src/main/resources/youtube/settings/xml/revanced_prefs.xml index 64f858c76..7019fb143 100644 --- a/src/main/resources/youtube/settings/xml/revanced_prefs.xml +++ b/src/main/resources/youtube/settings/xml/revanced_prefs.xml @@ -3,14 +3,13 @@ xmlns:android="http://schemas.android.com/apk/res/android" xmlns:yt="http://schemas.android.com/apk/res-auto"> - + + + + + + + + + + + + + + @@ -185,8 +205,8 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + @@ -350,7 +335,6 @@ - + - + \ No newline at end of file diff --git a/src/main/resources/youtube/speed/host/values/arrays.xml b/src/main/resources/youtube/speed/host/values/arrays.xml index d2325410e..d040507d6 100644 --- a/src/main/resources/youtube/speed/host/values/arrays.xml +++ b/src/main/resources/youtube/speed/host/values/arrays.xml @@ -1,9 +1,25 @@ - - -2.0 - - + @string/quality_auto + 0.25x + 0.5x + 0.75x + @string/shorts_speed_control_normal_label + 1.25x + 1.5x + 1.75x + 2.0x + + + -2.0 + 0.25 + 0.5 + 0.75 + 1.0 + 1.25 + 1.5 + 1.75 + 2.0