mirror of
https://github.com/revanced/revanced-patches
synced 2024-12-28 05:55:53 +01:00
feat(YouTube): Add Seekbar thumbnails
patch (#3813)
This commit is contained in:
parent
beb643678d
commit
5988b75975
@ -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;
|
||||
}
|
||||
}
|
@ -250,6 +250,7 @@ public class Settings extends BaseSettings {
|
||||
public static final BooleanSetting SEEKBAR_TAPPING = new BooleanSetting("revanced_seekbar_tapping", TRUE);
|
||||
public static final BooleanSetting SLIDE_TO_SEEK = new BooleanSetting("revanced_slide_to_seek", FALSE, true);
|
||||
public static final BooleanSetting RESTORE_OLD_SEEKBAR_THUMBNAILS = new BooleanSetting("revanced_restore_old_seekbar_thumbnails", TRUE);
|
||||
public static final BooleanSetting SEEKBAR_THUMBNAILS_HIGH_QUALITY = new BooleanSetting("revanced_seekbar_thumbnails_high_quality", FALSE, true, "revanced_seekbar_thumbnails_high_quality_dialog_message");
|
||||
public static final BooleanSetting HIDE_SEEKBAR = new BooleanSetting("revanced_hide_seekbar", FALSE, true);
|
||||
public static final BooleanSetting HIDE_SEEKBAR_THUMBNAIL = new BooleanSetting("revanced_hide_seekbar_thumbnail", FALSE);
|
||||
public static final BooleanSetting SEEKBAR_CUSTOM_COLOR = new BooleanSetting("revanced_seekbar_custom_color", FALSE, true);
|
||||
|
@ -1196,6 +1196,10 @@ public final class app/revanced/patches/youtube/layout/seekbar/SeekbarColorPatch
|
||||
public static final fun getSeekbarColorPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/youtube/layout/seekbar/SeekbarThumbnailsPatchKt {
|
||||
public static final fun getSeekbarThumbnailsPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/youtube/layout/shortsautoplay/ShortsAutoplayPatchKt {
|
||||
public static final fun getShortsAutoplayPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
|
@ -117,3 +117,10 @@ internal val slideToSeekFingerprint = fingerprint {
|
||||
)
|
||||
literal { 67108864 }
|
||||
}
|
||||
|
||||
internal val fullscreenSeekbarThumbnailsQualityFingerprint = fingerprint {
|
||||
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
|
||||
returns("Z")
|
||||
parameters()
|
||||
literal { 45399684L }
|
||||
}
|
||||
|
@ -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
|
||||
"""
|
||||
)
|
||||
}
|
||||
}
|
@ -2,7 +2,6 @@ package app.revanced.patches.youtube.layout.seekbar
|
||||
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.instructions
|
||||
import app.revanced.patcher.patch.PatchException
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import app.revanced.patches.all.misc.resources.addResources
|
||||
import app.revanced.patches.all.misc.resources.addResourcesPatch
|
||||
@ -11,6 +10,7 @@ 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
|
||||
import java.util.logging.Logger
|
||||
|
||||
private const val EXTENSION_CLASS_DESCRIPTOR =
|
||||
"Lapp/revanced/extension/youtube/patches/RestoreOldSeekbarThumbnailsPatch;"
|
||||
@ -39,8 +39,7 @@ val restoreOldSeekbarThumbnailsPatch = bytecodePatch(
|
||||
|
||||
execute {
|
||||
if (is_19_17_or_greater) {
|
||||
// Give a more informative error, if the user has turned off version checks.
|
||||
throw PatchException("'Restore old seekbar thumbnails' cannot be patched to any version after 19.16.39")
|
||||
return@execute Logger.getLogger(this::class.java.name).severe("'Restore old seekbar thumbnails' cannot be patched to any version after 19.16.39")
|
||||
}
|
||||
|
||||
addResources("youtube", "layout.seekbar.restoreOldSeekbarThumbnailsPatch")
|
||||
|
@ -762,6 +762,14 @@ This is because Crowdin requires temporarily flattening this file and removing t
|
||||
<string name="revanced_wide_searchbar_summary_on">Wide search bar is enabled</string>
|
||||
<string name="revanced_wide_searchbar_summary_off">Wide search bar is disabled</string>
|
||||
</patch>
|
||||
<patch id="layout.seekbar.seekbarThumbnailsPatch">
|
||||
<string name="revanced_seekbar_thumbnails_high_quality_title">Enable high quality thumbnails</string>
|
||||
<string name="revanced_seekbar_thumbnails_high_quality_summary_on">Seekbar thumbnails are high quality</string>
|
||||
<string name="revanced_seekbar_thumbnails_high_quality_summary_off">Seekbar thumbnails are medium quality</string>
|
||||
<string name="revanced_seekbar_thumbnails_high_quality_legacy_summary_on">Fullscreen seekbar thumbnails are high quality</string>
|
||||
<string name="revanced_seekbar_thumbnails_high_quality_legacy_summary_off">Fullscreen seekbar thumbnails are medium quality</string>
|
||||
<string name="revanced_seekbar_thumbnails_high_quality_dialog_message">This will restore thumbnails to livestreams that do not have seekbar thumbnails.\n\nInternet data usage may be higher, and seekbar thumbnails will have a slight delay before showing.\n\nThis feature works best with a very fast internet connection.</string>
|
||||
</patch>
|
||||
<patch id="layout.seekbar.restoreOldSeekbarThumbnailsPatch">
|
||||
<string name="revanced_restore_old_seekbar_thumbnails_title">Restore old seekbar thumbnails</string>
|
||||
<string name="revanced_restore_old_seekbar_thumbnails_summary_on">Seekbar thumbnails will appear above the seekbar</string>
|
||||
|
Loading…
Reference in New Issue
Block a user