feat(YouTube - Alternative thumbnails): Selectively enable for home / subscription / search (#2926)

Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
LisoUseInAIKyrios 2024-03-29 13:30:00 +04:00 committed by GitHub
parent 3c1daa3030
commit 8549e1ba58
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 68 additions and 33 deletions

View file

@ -22,6 +22,8 @@ import app.revanced.patches.youtube.layout.thumbnails.fingerprints.cronet.reques
import app.revanced.patches.youtube.layout.thumbnails.fingerprints.cronet.request.callback.OnResponseStartedFingerprint import app.revanced.patches.youtube.layout.thumbnails.fingerprints.cronet.request.callback.OnResponseStartedFingerprint
import app.revanced.patches.youtube.layout.thumbnails.fingerprints.cronet.request.callback.OnSucceededFingerprint import app.revanced.patches.youtube.layout.thumbnails.fingerprints.cronet.request.callback.OnSucceededFingerprint
import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch
import app.revanced.patches.youtube.misc.navigation.NavigationBarHookPatch
import app.revanced.patches.youtube.misc.playertype.PlayerTypeHookPatch
import app.revanced.patches.youtube.misc.settings.SettingsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch
import app.revanced.util.resultOrThrow import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.AccessFlags
@ -38,6 +40,8 @@ import com.android.tools.smali.dexlib2.immutable.ImmutableMethod
IntegrationsPatch::class, IntegrationsPatch::class,
SettingsPatch::class, SettingsPatch::class,
AddResourcesPatch::class, AddResourcesPatch::class,
NavigationBarHookPatch::class,
PlayerTypeHookPatch::class
], ],
compatiblePackages = [ compatiblePackages = [
CompatiblePackage( CompatiblePackage(
@ -127,25 +131,45 @@ object AlternativeThumbnailsPatch : BytecodePatch(
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
AddResourcesPatch(this::class) AddResourcesPatch(this::class)
val entries = "revanced_alt_thumbnail_options_entries"
val values = "revanced_alt_thumbnail_options_entry_values"
SettingsPatch.PreferenceScreen.ALTERNATIVE_THUMBNAILS.addPreferences( SettingsPatch.PreferenceScreen.ALTERNATIVE_THUMBNAILS.addPreferences(
NonInteractivePreference( ListPreference("revanced_alt_thumbnail_home",
"revanced_alt_thumbnail_about", summaryKey = null,
null, // Summary is dynamically updated based on the current settings. entriesKey = entries,
tag = "app.revanced.integrations.youtube.settings.preference.AlternativeThumbnailsStatusPreference", entryValuesKey = values
),
ListPreference("revanced_alt_thumbnail_subscription",
summaryKey = null,
entriesKey = entries,
entryValuesKey = values
),
ListPreference("revanced_alt_thumbnail_library",
summaryKey = null,
entriesKey = entries,
entryValuesKey = values
),
ListPreference("revanced_alt_thumbnail_player",
summaryKey = null,
entriesKey = entries,
entryValuesKey = values
),
ListPreference("revanced_alt_thumbnail_search",
summaryKey = null,
entriesKey = entries,
entryValuesKey = values
), ),
SwitchPreference("revanced_alt_thumbnail_dearrow"),
SwitchPreference("revanced_alt_thumbnail_dearrow_connection_toast"),
TextPreference("revanced_alt_thumbnail_dearrow_api_url"),
NonInteractivePreference( NonInteractivePreference(
"revanced_alt_thumbnail_dearrow_about", "revanced_alt_thumbnail_dearrow_about",
// Custom about preference with link to the DeArrow website. // Custom about preference with link to the DeArrow website.
tag = "app.revanced.integrations.youtube.settings.preference.AlternativeThumbnailsAboutDeArrowPreference", tag = "app.revanced.integrations.youtube.settings.preference.AlternativeThumbnailsAboutDeArrowPreference",
selectable = true, selectable = true,
), ),
SwitchPreference("revanced_alt_thumbnail_stills"), SwitchPreference("revanced_alt_thumbnail_dearrow_connection_toast"),
ListPreference("revanced_alt_thumbnail_stills_time", summaryKey = null), TextPreference("revanced_alt_thumbnail_dearrow_api_url"),
SwitchPreference("revanced_alt_thumbnail_stills_fast"),
NonInteractivePreference("revanced_alt_thumbnail_stills_about"), NonInteractivePreference("revanced_alt_thumbnail_stills_about"),
SwitchPreference("revanced_alt_thumbnail_stills_fast"),
ListPreference("revanced_alt_thumbnail_stills_time", summaryKey = null)
) )
fun MethodFingerprint.alsoResolve(fingerprint: MethodFingerprint) = fun MethodFingerprint.alsoResolve(fingerprint: MethodFingerprint) =

View file

@ -44,15 +44,28 @@
</string-array> </string-array>
</patch> </patch>
<patch id="layout.thumbnails.AlternativeThumbnailsPatch"> <patch id="layout.thumbnails.AlternativeThumbnailsPatch">
<string-array name="revanced_alt_thumbnail_options_entries">
<item>@string/revanced_alt_thumbnail_options_entry_1</item>
<item>@string/revanced_alt_thumbnail_options_entry_2</item>
<item>@string/revanced_alt_thumbnail_options_entry_3</item>
<item>@string/revanced_alt_thumbnail_options_entry_4</item>
</string-array>
<string-array name="revanced_alt_thumbnail_options_entry_values">
<!-- Enum names from Integrations -->
<item>ORIGINAL</item>
<item>DEARROW</item>
<item>DEARROW_STILL_IMAGES</item>
<item>STILL_IMAGES</item>
</string-array>
<string-array name="revanced_alt_thumbnail_stills_time_entries"> <string-array name="revanced_alt_thumbnail_stills_time_entries">
<item>@string/revanced_alt_thumbnail_stills_time_entry_1</item> <item>@string/revanced_alt_thumbnail_stills_time_entry_1</item>
<item>@string/revanced_alt_thumbnail_stills_time_entry_2</item> <item>@string/revanced_alt_thumbnail_stills_time_entry_2</item>
<item>@string/revanced_alt_thumbnail_stills_time_entry_3</item> <item>@string/revanced_alt_thumbnail_stills_time_entry_3</item>
</string-array> </string-array>
<string-array name="revanced_alt_thumbnail_stills_time_entry_values"> <string-array name="revanced_alt_thumbnail_stills_time_entry_values">
<item>1</item> <item>BEGINNING</item>
<item>2</item> <item>MIDDLE</item>
<item>3</item> <item>END</item>
</string-array> </string-array>
</patch> </patch>
<patch id="video.quality.RememberVideoQualityPatch"> <patch id="video.quality.RememberVideoQualityPatch">

View file

@ -847,33 +847,31 @@
<string name="revanced_seekbar_custom_color_invalid">Invalid seekbar color value. Using default value.</string> <string name="revanced_seekbar_custom_color_invalid">Invalid seekbar color value. Using default value.</string>
</patch> </patch>
<patch id="layout.thumbnails.AlternativeThumbnailsPatch"> <patch id="layout.thumbnails.AlternativeThumbnailsPatch">
<string name="revanced_alt_thumbnail_about_title">Thumbnails in use</string> <string name="revanced_alt_thumbnail_home_title">Home tab</string>
<string name="revanced_alt_thumbnail_dearrow_title">Enable DeArrow thumbnails</string> <string name="revanced_alt_thumbnail_subscription_title">Subscription tab</string>
<string name="revanced_alt_thumbnail_dearrow_summary_on">Using DeArrow thumbnails</string> <string name="revanced_alt_thumbnail_library_title">\'You\' tab</string>
<string name="revanced_alt_thumbnail_dearrow_summary_off">Not using DeArrow thumbnails</string> <string name="revanced_alt_thumbnail_player_title">Player playlists, recommendations</string>
<string name="revanced_alt_thumbnail_search_title">Search results</string>
<string name="revanced_alt_thumbnail_options_entry_1">Original thumbnails</string>
<string name="revanced_alt_thumbnail_options_entry_2">DeArrow &amp; Original thumbnails</string>
<string name="revanced_alt_thumbnail_options_entry_3">DeArrow &amp; Still captures</string>
<string name="revanced_alt_thumbnail_options_entry_4">Still captures</string>
<string name="revanced_alt_thumbnail_dearrow_about_title">DeArrow</string>
<string name="revanced_alt_thumbnail_dearrow_about_summary">DeArrow provides crowd-sourced thumbnails for YouTube videos. These thumbnails are often more relevant than those provided by YouTube\n\nIf enabled, video URLs will be sent to the API server and no other data is sent. If a video does not have DeArrow thumbnails, then the original or still captures are shown\n\nTap here to learn more about DeArrow</string>
<string name="revanced_alt_thumbnail_dearrow_connection_toast_title">Show a toast if API is not available</string> <string name="revanced_alt_thumbnail_dearrow_connection_toast_title">Show a toast if API is not available</string>
<string name="revanced_alt_thumbnail_dearrow_connection_toast_summary_on">Toast is shown if DeArrow is not available</string> <string name="revanced_alt_thumbnail_dearrow_connection_toast_summary_on">Toast is shown if DeArrow is not available</string>
<string name="revanced_alt_thumbnail_dearrow_connection_toast_summary_off">Toast is not shown if DeArrow is not available</string> <string name="revanced_alt_thumbnail_dearrow_connection_toast_summary_off">Toast is not shown if DeArrow is not available</string>
<string name="revanced_alt_thumbnail_dearrow_api_url_title">DeArrow API endpoint</string> <string name="revanced_alt_thumbnail_dearrow_api_url_title">DeArrow API endpoint</string>
<string name="revanced_alt_thumbnail_dearrow_api_url_summary">The URL of the DeArrow thumbnail cache endpoint. Do not change this unless you know what you\'re doing</string> <string name="revanced_alt_thumbnail_dearrow_api_url_summary">The URL of the DeArrow thumbnail cache endpoint</string>
<string name="revanced_alt_thumbnail_dearrow_about_title">About DeArrow</string> <string name="revanced_alt_thumbnail_stills_about_title">Still video captures</string>
<string name="revanced_alt_thumbnail_dearrow_about_summary">DeArrow provides crowd-sourced thumbnails for YouTube videos. These thumbnails are often more relevant than those provided by YouTube. If enabled, video URLs will be sent to the API server and no other data is sent\n\nTap here to learn more about DeArrow</string> <string name="revanced_alt_thumbnail_stills_about_summary">Still captures are taken from the beginning/middle/end of each video. These images are built into YouTube and no external API is used</string>
<string name="revanced_alt_thumbnail_stills_title">Enable still video captures</string>
<string name="revanced_alt_thumbnail_stills_summary_on">Using YouTube still video captures</string>
<string name="revanced_alt_thumbnail_stills_summary_off">Not using YouTube still video captures</string>
<string name="revanced_alt_thumbnail_stills_time_title">Video time to take the still from</string>
<string name="revanced_alt_thumbnail_stills_time_entry_1">Beginning of video</string>
<string name="revanced_alt_thumbnail_stills_time_entry_2">Middle of video</string>
<string name="revanced_alt_thumbnail_stills_time_entry_3">End of video</string>
<string name="revanced_alt_thumbnail_stills_fast_title">Use fast still captures</string> <string name="revanced_alt_thumbnail_stills_fast_title">Use fast still captures</string>
<string name="revanced_alt_thumbnail_stills_fast_summary_on">Using medium quality still captures. Thumbnails will load faster, but live streams, unreleased, or very old videos may show blank thumbnails</string> <string name="revanced_alt_thumbnail_stills_fast_summary_on">Using medium quality still captures. Thumbnails will load faster, but live streams, unreleased, or very old videos may show blank thumbnails</string>
<string name="revanced_alt_thumbnail_stills_fast_summary_off">Using high quality still captures</string> <string name="revanced_alt_thumbnail_stills_fast_summary_off">Using high quality still captures</string>
<string name="revanced_alt_thumbnail_stills_about_title">About still video captures</string> <string name="revanced_alt_thumbnail_stills_time_title">Video time to take still captures from</string>
<string name="revanced_alt_thumbnail_stills_about_summary">Still captures are taken from the beginning/middle/end of each video. These images are built into YouTube and no external API is used</string> <string name="revanced_alt_thumbnail_stills_time_entry_1">Beginning of video</string>
<string name="revanced_alt_thumbnail_about_status_disabled">Showing original YouTube thumbnails</string> <string name="revanced_alt_thumbnail_stills_time_entry_2">Middle of video</string>
<string name="revanced_alt_thumbnail_about_status_stills">Showing still video captures</string> <string name="revanced_alt_thumbnail_stills_time_entry_3">End of video</string>
<string name="revanced_alt_thumbnail_about_status_dearrow">Showing DeArrow thumbnails. If a video has no DeArrow thumbnails then the original YouTube thumbnails are shown</string>
<string name="revanced_alt_thumbnail_about_status_dearrow_stills">Showing DeArrow thumbnails. If a video has no DeArrow thumbnails then still video captures are shown</string>
<string name="revanced_alt_thumbnail_dearrow_error">DeArrow temporarily not available (status code: %s)</string> <string name="revanced_alt_thumbnail_dearrow_error">DeArrow temporarily not available (status code: %s)</string>
<string name="revanced_alt_thumbnail_dearrow_error_generic">DeArrow temporarily not available</string> <string name="revanced_alt_thumbnail_dearrow_error_generic">DeArrow temporarily not available</string>
</patch> </patch>