Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(YouTube): Merge Restore old seekbar thumbnails into Seekbar thumbnails #3860

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
package app.revanced.extension.youtube.patches;

import app.revanced.extension.shared.settings.Setting;
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();
public static final class SeekbarThumbnailsHighQualityAvailability implements Setting.Availability {
@Override
public boolean isAvailable() {
return VersionCheckPatch.IS_19_17_OR_GREATER || !Settings.RESTORE_OLD_SEEKBAR_THUMBNAILS.get();
}
}

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;
}

/**
* Injection point.
*/
public static boolean useFullscreenSeekbarThumbnails() {
return !Settings.RESTORE_OLD_SEEKBAR_THUMBNAILS.get();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import app.revanced.extension.shared.Utils;

public class VersionCheckPatch {
public static final boolean IS_19_17_OR_GREATER = Utils.getAppVersionName().compareTo("19.17.00") >= 0;
public static final boolean IS_19_20_OR_GREATER = Utils.getAppVersionName().compareTo("19.20.00") >= 0;
public static final boolean IS_19_21_OR_GREATER = Utils.getAppVersionName().compareTo("19.21.00") >= 0;
public static final boolean IS_19_26_OR_GREATER = Utils.getAppVersionName().compareTo("19.26.00") >= 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import static app.revanced.extension.youtube.patches.MiniplayerPatch.MiniplayerHideExpandCloseAvailability;
import static app.revanced.extension.youtube.patches.MiniplayerPatch.MiniplayerType;
import static app.revanced.extension.youtube.patches.MiniplayerPatch.MiniplayerType.*;
import static app.revanced.extension.youtube.patches.SeekbarThumbnailsPatch.SeekbarThumbnailsHighQualityAvailability;
import static app.revanced.extension.youtube.sponsorblock.objects.CategoryBehaviour.*;

import app.revanced.extension.shared.Logger;
Expand Down Expand Up @@ -256,7 +257,8 @@ 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 SEEKBAR_THUMBNAILS_HIGH_QUALITY = new BooleanSetting("revanced_seekbar_thumbnails_high_quality", FALSE, true,
"revanced_seekbar_thumbnails_high_quality_dialog_message", new SeekbarThumbnailsHighQualityAvailability());
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);
Expand Down
4 changes: 0 additions & 4 deletions patches/api/patches.api
Original file line number Diff line number Diff line change
Expand Up @@ -1192,10 +1192,6 @@ public final class app/revanced/patches/youtube/layout/seekbar/FingerprintsKt {
public static final field PLAYER_SEEKBAR_GRADIENT_FEATURE_FLAG J
}

public final class app/revanced/patches/youtube/layout/seekbar/RestoreOldSeekbarThumbnailsPatchKt {
public static final fun getRestoreOldSeekbarThumbnailsPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
}

public final class app/revanced/patches/youtube/layout/seekbar/SeekbarColorPatchKt {
public static final fun getSeekbarColorPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package app.revanced.patches.youtube.interaction.seekbar

import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.instructions
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.layout.seekbar.fullscreenSeekbarThumbnailsFingerprint
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
Expand All @@ -16,7 +19,8 @@ private const val EXTENSION_CLASS_DESCRIPTOR =
@Suppress("unused")
val seekbarThumbnailsPatch = bytecodePatch(
name = "Seekbar thumbnails",
description = "Adds an option to use high quality fullscreen seekbar thumbnails.",
description = "Adds an option to use high quality fullscreen seekbar thumbnails. " +
"Patching 19.16.39 or lower adds an option to restore old seekbar thumbnails.",
) {
dependsOn(
sharedExtensionPatch,
Expand All @@ -37,20 +41,34 @@ val seekbarThumbnailsPatch = bytecodePatch(

val fullscreenSeekbarThumbnailsQualityMatch by fullscreenSeekbarThumbnailsQualityFingerprint()

val fullscreenSeekbarThumbnailsMatch by fullscreenSeekbarThumbnailsFingerprint()

execute {
addResources("youtube", "layout.seekbar.seekbarThumbnailsPatch")

PreferenceScreen.SEEKBAR.addPreferences(
if (!is_19_17_or_greater) {
if (is_19_17_or_greater) {
PreferenceScreen.SEEKBAR.addPreferences(
SwitchPreference("revanced_seekbar_thumbnails_high_quality")
)
} else {
PreferenceScreen.SEEKBAR.addPreferences(
SwitchPreference("revanced_restore_old_seekbar_thumbnails"),
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")
)

fullscreenSeekbarThumbnailsMatch.mutableMethod.apply {
val moveResultIndex = instructions.lastIndex - 1

addInstruction(
moveResultIndex,
"invoke-static { }, $EXTENSION_CLASS_DESCRIPTOR->useFullscreenSeekbarThumbnails()Z",
)
}
)
}

fullscreenSeekbarThumbnailsQualityMatch.mutableMethod.addInstructions(
0,
Expand Down

This file was deleted.

4 changes: 1 addition & 3 deletions patches/src/main/resources/addresources/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -777,9 +777,7 @@ This is because Crowdin requires temporarily flattening this file and removing t
<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_seekbar_thumbnails_high_quality_dialog_message">This will also restore thumbnails on livestreams that do not have seekbar thumbnails.\n\nSeekbar thumbnails will use the same quality as the current video.\n\nThis feature works best with a video quality of 720p or lower and when using a very fast internet connection.</string>
<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>
<string name="revanced_restore_old_seekbar_thumbnails_summary_off">Seekbar thumbnails will appear in fullscreen</string>
Expand Down
Loading