generated from ReVanced/revanced-patches-template
-
-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(YouTube): Add
Seekbar thumbnails
patch (#3813)
- Loading branch information
1 parent
1576b92
commit 50e3d0e
Showing
7 changed files
with
102 additions
and
3 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
...s/shared/src/main/java/app/revanced/extension/youtube/patches/SeekbarThumbnailsPatch.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package app.revanced.extension.youtube.patches; | ||
|
||
import app.revanced.extension.youtube.settings.Settings; | ||
|
||
@SuppressWarnings("unused") | ||
public class SeekbarThumbnailsPatch { | ||
|
||
private static final boolean SEEKBAR_THUMBNAILS_HIGH_QUALITY_ENABLED = Settings.SEEKBAR_THUMBNAILS_HIGH_QUALITY.get(); | ||
|
||
/** | ||
* Injection point. | ||
*/ | ||
public static boolean useHighQualityFullscreenThumbnails() { | ||
return SEEKBAR_THUMBNAILS_HIGH_QUALITY_ENABLED; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
...rc/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/SeekbarThumbnailsPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package app.revanced.patches.youtube.layout.seekbar | ||
|
||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions | ||
import app.revanced.patcher.patch.bytecodePatch | ||
import app.revanced.patches.all.misc.resources.addResources | ||
import app.revanced.patches.all.misc.resources.addResourcesPatch | ||
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference | ||
import app.revanced.patches.youtube.interaction.seekbar.fullscreenSeekbarThumbnailsQualityFingerprint | ||
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch | ||
import app.revanced.patches.youtube.misc.playservice.is_19_17_or_greater | ||
import app.revanced.patches.youtube.misc.playservice.versionCheckPatch | ||
import app.revanced.patches.youtube.misc.settings.PreferenceScreen | ||
|
||
private const val EXTENSION_CLASS_DESCRIPTOR = | ||
"Lapp/revanced/extension/youtube/patches/SeekbarThumbnailsPatch;" | ||
|
||
@Suppress("unused") | ||
val seekbarThumbnailsPatch = bytecodePatch( | ||
name = "Seekbar thumbnails", | ||
description = "Adds an option to use high quality fullscreen seekbar thumbnails.", | ||
) { | ||
dependsOn( | ||
sharedExtensionPatch, | ||
addResourcesPatch, | ||
versionCheckPatch, | ||
) | ||
|
||
compatibleWith( | ||
"com.google.android.youtube"( | ||
"18.38.44", | ||
"18.49.37", | ||
"19.16.39", | ||
"19.25.37", | ||
"19.34.42", | ||
) | ||
) | ||
|
||
val fullscreenSeekbarThumbnailsQualityMatch by fullscreenSeekbarThumbnailsQualityFingerprint() | ||
|
||
execute { | ||
addResources("youtube", "layout.seekbar.seekbarThumbnailsPatch") | ||
|
||
PreferenceScreen.SEEKBAR.addPreferences( | ||
if (!is_19_17_or_greater) { | ||
SwitchPreference( | ||
key = "revanced_seekbar_thumbnails_high_quality", | ||
summaryOnKey = "revanced_seekbar_thumbnails_high_quality_legacy_summary_on", | ||
summaryOffKey = "revanced_seekbar_thumbnails_high_quality_legacy_summary_on" | ||
) | ||
} else { | ||
SwitchPreference("revanced_seekbar_thumbnails_high_quality") | ||
} | ||
) | ||
|
||
fullscreenSeekbarThumbnailsQualityMatch.mutableMethod.addInstructions( | ||
0, | ||
""" | ||
invoke-static { }, $EXTENSION_CLASS_DESCRIPTOR->useHighQualityFullscreenThumbnails()Z | ||
move-result v0 | ||
return v0 | ||
""" | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters