|
| 1 | +package app.revanced.patches.youtube.layout.seekbar |
| 2 | + |
| 3 | +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions |
| 4 | +import app.revanced.patcher.patch.bytecodePatch |
| 5 | +import app.revanced.patches.all.misc.resources.addResources |
| 6 | +import app.revanced.patches.all.misc.resources.addResourcesPatch |
| 7 | +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference |
| 8 | +import app.revanced.patches.youtube.interaction.seekbar.fullscreenSeekbarThumbnailsQualityFingerprint |
| 9 | +import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch |
| 10 | +import app.revanced.patches.youtube.misc.playservice.is_19_17_or_greater |
| 11 | +import app.revanced.patches.youtube.misc.playservice.versionCheckPatch |
| 12 | +import app.revanced.patches.youtube.misc.settings.PreferenceScreen |
| 13 | + |
| 14 | +private const val EXTENSION_CLASS_DESCRIPTOR = |
| 15 | + "Lapp/revanced/extension/youtube/patches/SeekbarThumbnailsPatch;" |
| 16 | + |
| 17 | +@Suppress("unused") |
| 18 | +val seekbarThumbnailsPatch = bytecodePatch( |
| 19 | + name = "Seekbar thumbnails", |
| 20 | + description = "Adds an option to use high quality fullscreen seekbar thumbnails.", |
| 21 | +) { |
| 22 | + dependsOn( |
| 23 | + sharedExtensionPatch, |
| 24 | + addResourcesPatch, |
| 25 | + versionCheckPatch, |
| 26 | + ) |
| 27 | + |
| 28 | + compatibleWith( |
| 29 | + "com.google.android.youtube"( |
| 30 | + "18.38.44", |
| 31 | + "18.49.37", |
| 32 | + "19.16.39", |
| 33 | + "19.25.37", |
| 34 | + "19.34.42", |
| 35 | + ) |
| 36 | + ) |
| 37 | + |
| 38 | + val fullscreenSeekbarThumbnailsQualityMatch by fullscreenSeekbarThumbnailsQualityFingerprint() |
| 39 | + |
| 40 | + execute { |
| 41 | + addResources("youtube", "layout.seekbar.seekbarThumbnailsPatch") |
| 42 | + |
| 43 | + PreferenceScreen.SEEKBAR.addPreferences( |
| 44 | + if (!is_19_17_or_greater) { |
| 45 | + SwitchPreference( |
| 46 | + key = "revanced_seekbar_thumbnails_high_quality", |
| 47 | + summaryOnKey = "revanced_seekbar_thumbnails_high_quality_legacy_summary_on", |
| 48 | + summaryOffKey = "revanced_seekbar_thumbnails_high_quality_legacy_summary_on" |
| 49 | + ) |
| 50 | + } else { |
| 51 | + SwitchPreference("revanced_seekbar_thumbnails_high_quality") |
| 52 | + } |
| 53 | + ) |
| 54 | + |
| 55 | + fullscreenSeekbarThumbnailsQualityMatch.mutableMethod.addInstructions( |
| 56 | + 0, |
| 57 | + """ |
| 58 | + invoke-static { }, $EXTENSION_CLASS_DESCRIPTOR->useHighQualityFullscreenThumbnails()Z |
| 59 | + move-result v0 |
| 60 | + return v0 |
| 61 | + """ |
| 62 | + ) |
| 63 | + } |
| 64 | +} |
0 commit comments