diff --git a/patches/src/main/kotlin/app/revanced/patches/music/general/spoofappversion/SpoofAppVersionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/music/general/spoofappversion/SpoofAppVersionPatch.kt index d15a5a306..1cfc4789a 100644 --- a/patches/src/main/kotlin/app/revanced/patches/music/general/spoofappversion/SpoofAppVersionPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/music/general/spoofappversion/SpoofAppVersionPatch.kt @@ -17,6 +17,7 @@ import app.revanced.patches.music.utils.settings.addPreferenceWithIntent import app.revanced.patches.music.utils.settings.addSwitchPreference import app.revanced.patches.music.utils.settings.settingsPatch import app.revanced.patches.shared.spoof.appversion.baseSpoofAppVersionPatch +import app.revanced.util.Utils.printWarn import app.revanced.util.appendAppVersion import app.revanced.util.findMethodOrThrow @@ -64,7 +65,6 @@ val spoofAppVersionPatch = resourcePatch( "6.29.59", "6.42.55", "6.51.53", - "7.06.54", "7.16.53", ), ) @@ -78,7 +78,7 @@ val spoofAppVersionPatch = resourcePatch( execute { if (is_7_25_or_greater) { - println("WARNING: \"${SPOOF_APP_VERSION.title}\" is not supported in this version. Use YouTube Music 7.24.51 or earlier.") + printWarn("\"${SPOOF_APP_VERSION.title}\" is not supported in this version. Use YouTube Music 7.24.51 or earlier.") return@execute } if (is_7_17_or_greater) { diff --git a/patches/src/main/kotlin/app/revanced/patches/music/layout/header/ChangeHeaderPatch.kt b/patches/src/main/kotlin/app/revanced/patches/music/layout/header/ChangeHeaderPatch.kt index 7bfae51e2..db08f642f 100644 --- a/patches/src/main/kotlin/app/revanced/patches/music/layout/header/ChangeHeaderPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/music/layout/header/ChangeHeaderPatch.kt @@ -9,6 +9,7 @@ import app.revanced.patches.music.utils.settings.ResourceUtils.getIconType import app.revanced.patches.music.utils.settings.ResourceUtils.updatePatchStatus import app.revanced.patches.music.utils.settings.settingsPatch import app.revanced.util.ResourceGroup +import app.revanced.util.Utils.printWarn import app.revanced.util.Utils.trimIndentMultiline import app.revanced.util.copyFile import app.revanced.util.copyResources @@ -154,7 +155,7 @@ val changeHeaderPatch = resourcePatch( val customBrandingIconIncluded = customBrandingIconType != "default" customHeader = customHeaderOption.valueOrThrow() - val warnings = "WARNING: Invalid header path: $customHeader. Does not apply patches." + val warnings = "Invalid header path: $customHeader. Does not apply patches." if (isPath) { copyFile( @@ -169,7 +170,7 @@ val changeHeaderPatch = resourcePatch( } } } else { - println(warnings) + printWarn(warnings) } updatePatchStatus(CUSTOM_HEADER_FOR_YOUTUBE_MUSIC) diff --git a/patches/src/main/kotlin/app/revanced/patches/music/misc/splash/CairoSplashAnimationPatch.kt b/patches/src/main/kotlin/app/revanced/patches/music/misc/splash/CairoSplashAnimationPatch.kt index db7ed91fb..f65f348a4 100644 --- a/patches/src/main/kotlin/app/revanced/patches/music/misc/splash/CairoSplashAnimationPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/music/misc/splash/CairoSplashAnimationPatch.kt @@ -16,6 +16,7 @@ import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.ResourceUtils.updatePatchStatus import app.revanced.patches.music.utils.settings.addSwitchPreference import app.revanced.patches.music.utils.settings.settingsPatch +import app.revanced.util.Utils.printWarn import app.revanced.util.fingerprint.injectLiteralInstructionBooleanCall import app.revanced.util.fingerprint.methodOrThrow import app.revanced.util.getReference @@ -50,7 +51,7 @@ val cairoSplashAnimationPatch = bytecodePatch( execute { if (!is_7_06_or_greater) { - println("WARNING: \"${DISABLE_CAIRO_SPLASH_ANIMATION.title}\" is not supported in this version. Use YouTube Music 7.06.54 or later.") + printWarn("\"${DISABLE_CAIRO_SPLASH_ANIMATION.title}\" is not supported in this version. Use YouTube Music 7.06.54 or later.") return@execute } else if (!is_7_20_or_greater) { cairoSplashAnimationConfigFingerprint.injectLiteralInstructionBooleanCall( diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/layout/branding/name/CustomBrandingNamePatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/layout/branding/name/CustomBrandingNamePatch.kt index f32ed7dc2..fee03bb0e 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/layout/branding/name/CustomBrandingNamePatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/layout/branding/name/CustomBrandingNamePatch.kt @@ -5,6 +5,7 @@ import app.revanced.patcher.patch.stringOption import app.revanced.patches.reddit.utils.compatibility.Constants.COMPATIBLE_PACKAGE import app.revanced.patches.reddit.utils.patch.PatchList.CUSTOM_BRANDING_NAME_FOR_REDDIT import app.revanced.patches.reddit.utils.settings.updatePatchStatus +import app.revanced.util.Utils.printInfo import app.revanced.util.valueOrThrow import java.io.FileWriter import java.nio.file.Files @@ -37,7 +38,7 @@ val customBrandingNamePatch = resourcePatch( .valueOrThrow() if (appName == ORIGINAL_APP_NAME) { - println("INFO: App name will remain unchanged as it matches the original.") + printInfo("App name will remain unchanged as it matches the original.") return@execute } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/layout/branding/packagename/ChangePackageNamePatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/layout/branding/packagename/ChangePackageNamePatch.kt index 9201291d9..a795e5b56 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/layout/branding/packagename/ChangePackageNamePatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/layout/branding/packagename/ChangePackageNamePatch.kt @@ -5,6 +5,7 @@ import app.revanced.patcher.patch.stringOption import app.revanced.patches.reddit.utils.compatibility.Constants.COMPATIBLE_PACKAGE import app.revanced.patches.reddit.utils.patch.PatchList.CHANGE_PACKAGE_NAME import app.revanced.patches.reddit.utils.settings.updatePatchStatus +import app.revanced.util.Utils.printInfo import app.revanced.util.valueOrThrow import org.w3c.dom.Element @@ -71,7 +72,7 @@ val changePackageNamePatch = resourcePatch( .valueOrThrow() if (redditPackageName == PACKAGE_NAME_REDDIT) { - println("INFO: Package name will remain unchanged as it matches the original.") + printInfo("Package name will remain unchanged as it matches the original.") return@execute } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/layout/navigation/NavigationButtonsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/layout/navigation/NavigationButtonsPatch.kt index 0a084d6b4..df3c587f5 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/layout/navigation/NavigationButtonsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/layout/navigation/NavigationButtonsPatch.kt @@ -10,6 +10,7 @@ import app.revanced.patches.reddit.utils.patch.PatchList.HIDE_NAVIGATION_BUTTONS import app.revanced.patches.reddit.utils.settings.is_2024_18_or_greater import app.revanced.patches.reddit.utils.settings.settingsPatch import app.revanced.patches.reddit.utils.settings.updatePatchStatus +import app.revanced.util.Utils.printWarn import app.revanced.util.fingerprint.methodOrThrow import app.revanced.util.fingerprint.resolvable import app.revanced.util.indexOfFirstInstructionOrThrow @@ -34,7 +35,7 @@ val navigationButtonsPatch = bytecodePatch( execute { if (is_2024_18_or_greater) { - println("WARNING: \"Hide navigation buttons\" patch is not supported in this version. Use Reddit 2024.17.0 or earlier.") + printWarn("\"Hide navigation buttons\" patch is not supported in this version. Use Reddit 2024.17.0 or earlier.") return@execute } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/actionbuttons/ShortsActionButtonsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/actionbuttons/ShortsActionButtonsPatch.kt index 561eecab5..a955491e1 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/actionbuttons/ShortsActionButtonsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/actionbuttons/ShortsActionButtonsPatch.kt @@ -9,6 +9,7 @@ import app.revanced.patches.youtube.utils.playservice.versionCheckPatch import app.revanced.patches.youtube.utils.settings.ResourceUtils.addPreference import app.revanced.patches.youtube.utils.settings.settingsPatch import app.revanced.util.ResourceGroup +import app.revanced.util.Utils.printInfo import app.revanced.util.copyResources import app.revanced.util.inputStreamFromBundledResourceOrThrow import app.revanced.util.lowerCaseOrThrow @@ -63,7 +64,7 @@ val shortsActionButtonsPatch = resourcePatch( .lowerCaseOrThrow() if (iconType == YOUTUBE_ICON) { - println("INFO: Shorts action buttons will remain unchanged as it matches the original.") + printInfo("Shorts action buttons will remain unchanged as it matches the original.") addPreference(CUSTOM_SHORTS_ACTION_BUTTONS) return@execute } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/CustomBrandingIconPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/CustomBrandingIconPatch.kt index 4abecb1a7..ededd6ab4 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/CustomBrandingIconPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/CustomBrandingIconPatch.kt @@ -147,7 +147,7 @@ val customBrandingIconPatch = resourcePatch( val copiedFiles = copyFile( launcherIconResourceGroups, appIcon, - "WARNING: Invalid app icon path: $appIcon. Does not apply patches." + "Invalid app icon path: $appIcon. Does not apply patches." ) if (copiedFiles) updatePatchStatusIcon("custom") diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/header/ChangeHeaderPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/header/ChangeHeaderPatch.kt index b9c01c833..986292470 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/header/ChangeHeaderPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/header/ChangeHeaderPatch.kt @@ -7,6 +7,7 @@ import app.revanced.patches.youtube.utils.patch.PatchList.CUSTOM_HEADER_FOR_YOUT import app.revanced.patches.youtube.utils.settings.ResourceUtils.getIconType import app.revanced.patches.youtube.utils.settings.settingsPatch import app.revanced.util.ResourceGroup +import app.revanced.util.Utils.printWarn import app.revanced.util.Utils.trimIndentMultiline import app.revanced.util.copyFile import app.revanced.util.copyResources @@ -125,7 +126,7 @@ val changeHeaderPatch = resourcePatch( customBrandingIconType != "default" && customBrandingIconType != "custom" customHeader = customHeaderOption.valueOrThrow() - val warnings = "WARNING: Invalid header path: $customHeader. Does not apply patches." + val warnings = "Invalid header path: $customHeader. Does not apply patches." if (isPath) { copyFile( @@ -140,7 +141,7 @@ val changeHeaderPatch = resourcePatch( } } } else { - println(warnings) + printWarn(warnings) return@execute } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/player/components/PlayerComponentsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/player/components/PlayerComponentsPatch.kt index cfa71953e..3934b2277 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/player/components/PlayerComponentsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/player/components/PlayerComponentsPatch.kt @@ -35,6 +35,7 @@ import app.revanced.patches.youtube.utils.youtubeControlsOverlayFingerprint import app.revanced.patches.youtube.video.information.hookVideoInformation import app.revanced.patches.youtube.video.information.videoInformationPatch import app.revanced.util.REGISTER_TEMPLATE_REPLACEMENT +import app.revanced.util.Utils.printWarn import app.revanced.util.findMethodOrThrow import app.revanced.util.fingerprint.injectLiteralInstructionBooleanCall import app.revanced.util.fingerprint.injectLiteralInstructionViewCall @@ -382,7 +383,7 @@ val playerComponentsPatch = bytecodePatch( name == "onClick" }.hookInitVideoPanel(0) } else { - println("WARNING: target Opcode not found in ${fingerprint.first}") + printWarn("target Opcode not found in ${fingerprint.first}") } } } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/player/fullscreen/FullscreenComponentsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/player/fullscreen/FullscreenComponentsPatch.kt index 6c47216a9..f00ad80bd 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/player/fullscreen/FullscreenComponentsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/player/fullscreen/FullscreenComponentsPatch.kt @@ -28,6 +28,7 @@ import app.revanced.patches.youtube.utils.resourceid.sharedResourceIdPatch import app.revanced.patches.youtube.utils.settings.ResourceUtils.addPreference import app.revanced.patches.youtube.utils.settings.settingsPatch import app.revanced.patches.youtube.utils.youtubeControlsOverlayFingerprint +import app.revanced.util.Utils.printWarn import app.revanced.util.findMethodOrThrow import app.revanced.util.fingerprint.methodOrThrow import app.revanced.util.fingerprint.mutableClassOrThrow @@ -321,7 +322,7 @@ val fullscreenComponentsPatch = bytecodePatch( settingArray += "SETTINGS: KEEP_LANDSCAPE_MODE" } else { - println("WARNING: \"Keep landscape mode\" is not supported in this version. Use YouTube 19.16.39 or earlier.") + printWarn("\"Keep landscape mode\" is not supported in this version. Use YouTube 19.16.39 or earlier.") } // endregion diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/player/seekbar/SeekbarComponentsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/player/seekbar/SeekbarComponentsPatch.kt index c4691d7d3..49c3fb886 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/player/seekbar/SeekbarComponentsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/player/seekbar/SeekbarComponentsPatch.kt @@ -35,6 +35,7 @@ import app.revanced.patches.youtube.utils.settings.ResourceUtils.getContext import app.revanced.patches.youtube.utils.settings.settingsPatch import app.revanced.patches.youtube.utils.totalTimeFingerprint import app.revanced.patches.youtube.video.information.videoInformationPatch +import app.revanced.util.Utils.printWarn import app.revanced.util.copyXmlNode import app.revanced.util.findElementByAttributeValueOrThrow import app.revanced.util.findMethodsOrThrow @@ -468,7 +469,7 @@ val seekbarComponentsPatch = bytecodePatch( updatePatchStatus(PATCH_STATUS_CLASS_DESCRIPTOR, "OldSeekbarThumbnailsDefaultBoolean") } else { - println("WARNING: \"Restore old seekbar thumbnails\" is not supported in this version. Use YouTube 19.16.39 or earlier.") + printWarn("\"Restore old seekbar thumbnails\" is not supported in this version. Use YouTube 19.16.39 or earlier.") } // endregion diff --git a/patches/src/main/kotlin/app/revanced/util/BytecodeUtils.kt b/patches/src/main/kotlin/app/revanced/util/BytecodeUtils.kt index ad3f5468f..9f9c0989d 100644 --- a/patches/src/main/kotlin/app/revanced/util/BytecodeUtils.kt +++ b/patches/src/main/kotlin/app/revanced/util/BytecodeUtils.kt @@ -20,6 +20,7 @@ import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMu import app.revanced.patches.shared.mapping.get import app.revanced.patches.shared.mapping.resourceMappingPatch import app.revanced.patches.shared.mapping.resourceMappings +import app.revanced.util.Utils.printWarn import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.Method @@ -135,7 +136,7 @@ internal fun MutableMethod.addInstructionsAtControlFlowLabel( fun Method.indexOfFirstResourceId(resourceName: String): Int { val resourceId = resourceMappings["id", resourceName] if (resourceId == -1L) { - println("WARNING: Could not find resource type: id name: $name") + printWarn("Could not find resource type: id name: $name") return -1 } return indexOfFirstLiteralInstruction(resourceId) diff --git a/patches/src/main/kotlin/app/revanced/util/ResourceUtils.kt b/patches/src/main/kotlin/app/revanced/util/ResourceUtils.kt index 89cef3780..89be81890 100644 --- a/patches/src/main/kotlin/app/revanced/util/ResourceUtils.kt +++ b/patches/src/main/kotlin/app/revanced/util/ResourceUtils.kt @@ -5,6 +5,7 @@ import app.revanced.patcher.patch.Patch import app.revanced.patcher.patch.PatchException import app.revanced.patcher.patch.ResourcePatchContext import app.revanced.patcher.util.Document +import app.revanced.util.Utils.printWarn import org.w3c.dom.Element import org.w3c.dom.Node import org.w3c.dom.NodeList @@ -202,7 +203,7 @@ fun ResourcePatchContext.copyFile( return true } catch (_: Exception) { - println(warning) + printWarn(warning) } } return false diff --git a/patches/src/main/kotlin/app/revanced/util/Utils.kt b/patches/src/main/kotlin/app/revanced/util/Utils.kt index 57f0edf03..e56cce162 100644 --- a/patches/src/main/kotlin/app/revanced/util/Utils.kt +++ b/patches/src/main/kotlin/app/revanced/util/Utils.kt @@ -1,8 +1,18 @@ package app.revanced.util +import java.util.logging.Logger + internal object Utils { internal fun String.trimIndentMultiline() = this.split("\n") .joinToString("\n") { it.trimIndent() } // Remove the leading whitespace from each line. .trimIndent() // Remove the leading newline. + + private val logger = Logger.getLogger(this::class.java.name) + + internal fun printInfo(msg: String) = + logger.info(msg) + + internal fun printWarn(msg: String) = + logger.warning(msg) }