Skip to content

Commit

Permalink
feat(YouTube/Seekbar components): add `Enable high quality thumbnails…
Browse files Browse the repository at this point in the history
…` setting
  • Loading branch information
inotia00 committed Oct 26, 2024
1 parent e644186 commit 8af117b
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import app.revanced.patches.shared.drawable.DrawableColorPatch
import app.revanced.patches.youtube.player.seekbar.fingerprints.CairoSeekbarConfigFingerprint
import app.revanced.patches.youtube.player.seekbar.fingerprints.ControlsOverlayStyleFingerprint
import app.revanced.patches.youtube.player.seekbar.fingerprints.SeekbarTappingFingerprint
import app.revanced.patches.youtube.player.seekbar.fingerprints.SeekbarThumbnailsQualityFingerprint
import app.revanced.patches.youtube.player.seekbar.fingerprints.ShortsSeekbarColorFingerprint
import app.revanced.patches.youtube.player.seekbar.fingerprints.ThumbnailPreviewConfigFingerprint
import app.revanced.patches.youtube.player.seekbar.fingerprints.TimeCounterFingerprint
Expand All @@ -23,6 +24,7 @@ import app.revanced.patches.youtube.utils.fingerprints.SeekbarFingerprint
import app.revanced.patches.youtube.utils.fingerprints.SeekbarOnDrawFingerprint
import app.revanced.patches.youtube.utils.fingerprints.TotalTimeFingerprint
import app.revanced.patches.youtube.utils.flyoutmenu.FlyoutMenuHookPatch
import app.revanced.patches.youtube.utils.integrations.Constants.PATCH_STATUS_CLASS_DESCRIPTOR
import app.revanced.patches.youtube.utils.integrations.Constants.PLAYER_CLASS_DESCRIPTOR
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.InlineTimeBarColorizedBarPlayedColorDark
Expand All @@ -40,6 +42,7 @@ import app.revanced.util.indexOfFirstWideLiteralInstructionValueOrThrow
import app.revanced.util.injectLiteralInstructionBooleanCall
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import app.revanced.util.updatePatchStatus
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.NarrowLiteralInstruction
Expand Down Expand Up @@ -68,6 +71,7 @@ object SeekbarComponentsPatch : BaseBytecodePatch(
PlayerSeekbarColorFingerprint,
SeekbarFingerprint,
SeekbarTappingFingerprint,
SeekbarThumbnailsQualityFingerprint,
ShortsSeekbarColorFingerprint,
TimelineMarkerArrayFingerprint,
ThumbnailPreviewConfigFingerprint,
Expand Down Expand Up @@ -212,6 +216,15 @@ object SeekbarComponentsPatch : BaseBytecodePatch(

// endregion

// region patch for high quality thumbnails

SeekbarThumbnailsQualityFingerprint.injectLiteralInstructionBooleanCall(
45399684,
"$PLAYER_CLASS_DESCRIPTOR->enableHighQualityFullscreenThumbnails()Z"
)

// endregion

// region patch for hide chapter

TimelineMarkerArrayFingerprint.resultOrThrow().let {
Expand Down Expand Up @@ -299,6 +312,8 @@ object SeekbarComponentsPatch : BaseBytecodePatch(
)

settingArray += "SETTINGS: RESTORE_OLD_SEEKBAR_THUMBNAILS"

context.updatePatchStatus(PATCH_STATUS_CLASS_DESCRIPTOR, "OldSeekbarThumbnailsDefaultBoolean")
}
?: println("WARNING: Restore old seekbar thumbnails setting is not supported in this version. Use YouTube 19.16.39 or earlier.")

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package app.revanced.patches.youtube.player.seekbar.fingerprints

import app.revanced.util.fingerprint.LiteralValueFingerprint

internal object SeekbarThumbnailsQualityFingerprint : LiteralValueFingerprint(
returnType = "Z",
parameters = emptyList(),
literalSupplier = { 45399684 },
)
8 changes: 8 additions & 0 deletions src/main/resources/youtube/settings/host/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,14 @@ Tap and hold to undo."</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>
<string name="revanced_enable_seekbar_thumbnails_high_quality_title">Enable high quality thumbnails</string>
<string name="revanced_enable_seekbar_thumbnails_high_quality_summary_on">Seekbar thumbnails are high quality.</string>
<string name="revanced_enable_seekbar_thumbnails_high_quality_summary_off">Seekbar thumbnails are medium quality.</string>
<string name="revanced_enable_seekbar_thumbnails_high_quality_dialog_message">"This will restore thumbnails to livestreams that do not have seekbar thumbnails.

Internet data usage may be higher, and seekbar thumbnails will have a slight delay before showing.

This feature works best with a very fast internet connection."</string>
<string name="revanced_enable_cairo_seekbar_title">Enable Cairo seekbar</string>
<string name="revanced_enable_cairo_seekbar_summary_on">"Cairo seekbar is enabled.

Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/youtube/settings/xml/revanced_prefs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -450,9 +450,13 @@
<SwitchPreference android:title="@string/revanced_disable_seekbar_chapters_title" android:key="revanced_disable_seekbar_chapters" android:summaryOn="@string/revanced_disable_seekbar_chapters_summary_on" android:summaryOff="@string/revanced_disable_seekbar_chapters_summary_off" />
<SwitchPreference android:title="@string/revanced_hide_seekbar_chapter_label_title" android:key="revanced_hide_seekbar_chapter_label" android:summaryOn="@string/revanced_hide_seekbar_chapter_label_summary_on" android:summaryOff="@string/revanced_hide_seekbar_chapter_label_summary_off" />
<SwitchPreference android:title="@string/revanced_hide_time_stamp_title" android:key="revanced_hide_time_stamp" android:summaryOn="@string/revanced_hide_time_stamp_summary_on" android:summaryOff="@string/revanced_hide_time_stamp_summary_off" />SETTINGS: SEEKBAR_COMPONENTS -->

<!-- SETTINGS: RESTORE_OLD_SEEKBAR_THUMBNAILS
<SwitchPreference android:title="@string/revanced_restore_old_seekbar_thumbnails_title" android:key="revanced_restore_old_seekbar_thumbnails" android:summaryOn="@string/revanced_restore_old_seekbar_thumbnails_summary_on" android:summaryOff="@string/revanced_restore_old_seekbar_thumbnails_summary_off" />SETTINGS: RESTORE_OLD_SEEKBAR_THUMBNAILS -->

<!-- SETTINGS: SEEKBAR_COMPONENTS
<SwitchPreference android:title="@string/revanced_enable_seekbar_thumbnails_high_quality_title" android:key="revanced_enable_seekbar_thumbnails_high_quality" android:summaryOn="@string/revanced_enable_seekbar_thumbnails_high_quality_summary_on" android:summaryOff="@string/revanced_enable_seekbar_thumbnails_high_quality_summary_off" />SETTINGS: SEEKBAR_COMPONENTS -->

<!-- SETTINGS: ENABLE_CAIRO_SEEKBAR
<PreferenceCategory android:title="@string/revanced_preference_category_experimental_flag" android:layout="@layout/revanced_settings_preferences_category"/>
<SwitchPreference android:title="@string/revanced_enable_cairo_seekbar_title" android:key="revanced_enable_cairo_seekbar" android:summaryOn="@string/revanced_enable_cairo_seekbar_summary_on" android:summaryOff="@string/revanced_enable_cairo_seekbar_summary_off" />SETTINGS: ENABLE_CAIRO_SEEKBAR -->
Expand Down

0 comments on commit 8af117b

Please sign in to comment.