From 8e28386a1960787a38ac935d0c1c42edc72940ee Mon Sep 17 00:00:00 2001 From: inotia00 Date: Thu, 14 Sep 2023 16:37:53 +0900 Subject: [PATCH] clean up --- .../flyoutpanel/hide/patch/FlyoutPanelPatch.kt | 2 +- .../replace/patch/ReplaceDismissQueuePatch.kt | 8 +++++--- .../fingerprints/SeekBarConstructorFingerprint.kt | 6 +++++- .../resource/patch/ReturnYouTubeDislikePatch.kt | 14 +++++++++++--- .../bytecode/patch/SponsorBlockBytecodePatch.kt | 3 ++- .../resource/patch/SponsorBlockPatch.kt | 5 ++++- .../patch/VideoInformationPatch.kt | 14 +++++++++----- 7 files changed, 37 insertions(+), 15 deletions(-) diff --git a/src/main/kotlin/app/revanced/patches/music/flyoutpanel/hide/patch/FlyoutPanelPatch.kt b/src/main/kotlin/app/revanced/patches/music/flyoutpanel/hide/patch/FlyoutPanelPatch.kt index 9ae71d9a6..91060d5ca 100644 --- a/src/main/kotlin/app/revanced/patches/music/flyoutpanel/hide/patch/FlyoutPanelPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/flyoutpanel/hide/patch/FlyoutPanelPatch.kt @@ -10,9 +10,9 @@ import app.revanced.patcher.patch.BytecodePatch 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.music.utils.fingerprints.MenuItemFingerprint import app.revanced.patches.music.flyoutpanel.utils.EnumUtils.getEnumIndex import app.revanced.patches.music.utils.annotations.MusicCompatibility +import app.revanced.patches.music.utils.fingerprints.MenuItemFingerprint import app.revanced.patches.music.utils.flyoutbutton.patch.FlyoutButtonContainerResourcePatch import app.revanced.patches.music.utils.settings.resource.patch.SettingsPatch import app.revanced.util.enum.CategoryType diff --git a/src/main/kotlin/app/revanced/patches/music/flyoutpanel/replace/patch/ReplaceDismissQueuePatch.kt b/src/main/kotlin/app/revanced/patches/music/flyoutpanel/replace/patch/ReplaceDismissQueuePatch.kt index c5457950f..ab637e015 100644 --- a/src/main/kotlin/app/revanced/patches/music/flyoutpanel/replace/patch/ReplaceDismissQueuePatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/flyoutpanel/replace/patch/ReplaceDismissQueuePatch.kt @@ -9,9 +9,9 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.music.utils.fingerprints.MenuItemFingerprint import app.revanced.patches.music.flyoutpanel.utils.EnumUtils.getEnumIndex import app.revanced.patches.music.utils.annotations.MusicCompatibility +import app.revanced.patches.music.utils.fingerprints.MenuItemFingerprint import app.revanced.patches.music.utils.flyoutbutton.patch.FlyoutButtonItemResourcePatch import app.revanced.patches.music.utils.settings.resource.patch.SettingsPatch import app.revanced.patches.music.utils.videoid.patch.VideoIdPatch @@ -42,8 +42,10 @@ class ReplaceDismissQueuePatch : BytecodePatch( val textViewIndex = it.scanResult.patternScanResult!!.startIndex val imageViewIndex = it.scanResult.patternScanResult!!.endIndex - val textViewRegister = getInstruction(textViewIndex).registerA - val imageViewRegister = getInstruction(imageViewIndex).registerA + val textViewRegister = + getInstruction(textViewIndex).registerA + val imageViewRegister = + getInstruction(imageViewIndex).registerA addInstruction( enumIndex + 1, diff --git a/src/main/kotlin/app/revanced/patches/music/utils/fingerprints/SeekBarConstructorFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/utils/fingerprints/SeekBarConstructorFingerprint.kt index cee1568f5..c00253733 100644 --- a/src/main/kotlin/app/revanced/patches/music/utils/fingerprints/SeekBarConstructorFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/fingerprints/SeekBarConstructorFingerprint.kt @@ -6,5 +6,9 @@ import app.revanced.util.bytecode.isWideLiteralExists object SeekBarConstructorFingerprint : MethodFingerprint( returnType = "V", - customFingerprint = { methodDef, _ -> methodDef.isWideLiteralExists(InlineTimeBarAdBreakMarkerColor) } + customFingerprint = { methodDef, _ -> + methodDef.isWideLiteralExists( + InlineTimeBarAdBreakMarkerColor + ) + } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/music/utils/returnyoutubedislike/resource/patch/ReturnYouTubeDislikePatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/returnyoutubedislike/resource/patch/ReturnYouTubeDislikePatch.kt index b08389001..dc5cd7a0d 100644 --- a/src/main/kotlin/app/revanced/patches/music/utils/returnyoutubedislike/resource/patch/ReturnYouTubeDislikePatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/returnyoutubedislike/resource/patch/ReturnYouTubeDislikePatch.kt @@ -29,7 +29,11 @@ class ReturnYouTubeDislikePatch : ResourcePatch { context.addReVancedMusicPreference(RETURN_YOUTUBE_DISLIKE_SETTINGS_KEY) context.addSwitchPreference("revanced_ryd_enabled", "true") - context.addSwitchPreference("revanced_ryd_dislike_percentage", "false", "revanced_ryd_enabled") + context.addSwitchPreference( + "revanced_ryd_dislike_percentage", + "false", + "revanced_ryd_enabled" + ) context.addSwitchPreference("revanced_ryd_compact_layout", "false", "revanced_ryd_enabled") context.addPreferenceCategory("revanced_ryd_about") context.addAboutPreference("revanced_ryd_attribution") @@ -76,7 +80,9 @@ class ReturnYouTubeDislikePatch : ResourcePatch { this.xmlEditor[YOUTUBE_MUSIC_SETTINGS_PATH].use { editor -> val tags = editor.file.getElementsByTagName("PreferenceScreen") List(tags.length) { tags.item(it) as Element } - .filter { it.getAttribute("android:key").contains(RETURN_YOUTUBE_DISLIKE_SETTINGS_KEY) } + .filter { + it.getAttribute("android:key").contains(RETURN_YOUTUBE_DISLIKE_SETTINGS_KEY) + } .forEach { it.adoptChild(PREFERENCE_CATEGORY_TAG_NAME) { setAttribute("android:title", "@string/$category") @@ -101,7 +107,9 @@ class ReturnYouTubeDislikePatch : ResourcePatch { this.xmlEditor[YOUTUBE_MUSIC_SETTINGS_PATH].use { editor -> val tags = editor.file.getElementsByTagName("PreferenceScreen") List(tags.length) { tags.item(it) as Element } - .filter { it.getAttribute("android:key").contains(RETURN_YOUTUBE_DISLIKE_SETTINGS_KEY) } + .filter { + it.getAttribute("android:key").contains(RETURN_YOUTUBE_DISLIKE_SETTINGS_KEY) + } .forEach { it.adoptChild(SWITCH_PREFERENCE_TAG_NAME) { setAttribute("android:title", "@string/$key" + "_title") diff --git a/src/main/kotlin/app/revanced/patches/music/utils/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt index 9656cdc65..64dc0448c 100644 --- a/src/main/kotlin/app/revanced/patches/music/utils/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt @@ -123,7 +123,8 @@ class SponsorBlockBytecodePatch : BytecodePatch( MusicPlaybackControlsTimeBarOnMeasureFingerprint.result?.let { it.mutableMethod.apply { val rectangleIndex = it.scanResult.patternScanResult!!.startIndex - val rectangleReference = getInstruction(rectangleIndex).reference + val rectangleReference = + getInstruction(rectangleIndex).reference rectangleFieldName = (rectangleReference as FieldReference).name } } ?: throw MusicPlaybackControlsTimeBarOnMeasureFingerprint.exception diff --git a/src/main/kotlin/app/revanced/patches/music/utils/sponsorblock/resource/patch/SponsorBlockPatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/sponsorblock/resource/patch/SponsorBlockPatch.kt index 1e22756f7..33ba7db5a 100644 --- a/src/main/kotlin/app/revanced/patches/music/utils/sponsorblock/resource/patch/SponsorBlockPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/sponsorblock/resource/patch/SponsorBlockPatch.kt @@ -59,7 +59,10 @@ class SponsorBlockPatch : ResourcePatch { context["res/xml/sponsorblock_prefs.xml"].writeText( context["res/xml/sponsorblock_prefs.xml"].readText() - .replace("\"com.google.android.apps.youtube.music\"", "\"" + MusicResourceHelper.targetPackage + "\"") + .replace( + "\"com.google.android.apps.youtube.music\"", + "\"" + MusicResourceHelper.targetPackage + "\"" + ) ) } diff --git a/src/main/kotlin/app/revanced/patches/music/utils/videoinformation/patch/VideoInformationPatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/videoinformation/patch/VideoInformationPatch.kt index 21d4c1996..477d17e6a 100644 --- a/src/main/kotlin/app/revanced/patches/music/utils/videoinformation/patch/VideoInformationPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/videoinformation/patch/VideoInformationPatch.kt @@ -14,10 +14,10 @@ import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable import app.revanced.patches.music.utils.annotations.MusicCompatibility +import app.revanced.patches.music.utils.fingerprints.SeekBarConstructorFingerprint import app.revanced.patches.music.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.music.utils.videoinformation.fingerprints.PlayerControllerSetTimeReferenceFingerprint import app.revanced.patches.music.utils.videoinformation.fingerprints.PlayerInitFingerprint -import app.revanced.patches.music.utils.fingerprints.SeekBarConstructorFingerprint import app.revanced.patches.music.utils.videoinformation.fingerprints.SeekFingerprint import app.revanced.patches.music.utils.videoinformation.fingerprints.VideoLengthFingerprint import com.android.tools.smali.dexlib2.AccessFlags @@ -91,12 +91,15 @@ class VideoInformationPatch : BytecodePatch( ) }.result?.let { it.mutableMethod.apply { - val rectangleReference = getInstruction(implementation!!.instructions.count() - 3).reference + val rectangleReference = + getInstruction(implementation!!.instructions.count() - 3).reference rectangleFieldName = (rectangleReference as FieldReference).name val videoLengthRegisterIndex = it.scanResult.patternScanResult!!.startIndex + 1 - val videoLengthRegister = getInstruction(videoLengthRegisterIndex).registerA - val dummyRegisterForLong = videoLengthRegister + 1 // required for long values since they are wide + val videoLengthRegister = + getInstruction(videoLengthRegisterIndex).registerA + val dummyRegisterForLong = + videoLengthRegister + 1 // required for long values since they are wide addInstruction( videoLengthRegisterIndex + 1, @@ -122,7 +125,8 @@ class VideoInformationPatch : BytecodePatch( } companion object { - private const val INTEGRATIONS_CLASS_DESCRIPTOR = "Lapp/revanced/music/patches/utils/VideoInformation;" + private const val INTEGRATIONS_CLASS_DESCRIPTOR = + "Lapp/revanced/music/patches/utils/VideoInformation;" private lateinit var playerInitMethod: MutableMethod private var playerInitInsertIndex = 4