mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-04-29 22:24:31 +02:00
fix(YouTube/SponsorBlock): changed to selectable through options.json
This commit is contained in:
parent
0d39521fa7
commit
1edc5f1c64
@ -4,6 +4,7 @@ import app.revanced.patcher.data.ResourceContext
|
||||
import app.revanced.patcher.patch.ResourcePatch
|
||||
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patcher.patch.options.types.BooleanPatchOption.Companion.booleanPatchOption
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.util.resources.ResourceUtils
|
||||
import app.revanced.util.resources.ResourceUtils.copyResources
|
||||
@ -41,12 +42,41 @@ import app.revanced.util.resources.ResourceUtils.copyXmlNode
|
||||
)
|
||||
@Suppress("unused")
|
||||
object SponsorBlockPatch : ResourcePatch() {
|
||||
internal var OutlineIcon by booleanPatchOption(
|
||||
key = "OutlineIcon",
|
||||
default = false,
|
||||
title = "Outline icons",
|
||||
description = "Apply the outline icon"
|
||||
)
|
||||
|
||||
override fun execute(context: ResourceContext) {
|
||||
/**
|
||||
* merge SponsorBlock drawables to main drawables
|
||||
*/
|
||||
|
||||
if (OutlineIcon == true) {
|
||||
arrayOf(
|
||||
ResourceUtils.ResourceGroup(
|
||||
"layout",
|
||||
"inline_sponsor_overlay.xml",
|
||||
"new_segment.xml",
|
||||
"skip_sponsor_button.xml"
|
||||
),
|
||||
ResourceUtils.ResourceGroup(
|
||||
"drawable",
|
||||
"ic_sb_adjust.xml",
|
||||
"ic_sb_backward.xml",
|
||||
"ic_sb_compare.xml",
|
||||
"ic_sb_edit.xml",
|
||||
"ic_sb_forward.xml",
|
||||
"ic_sb_logo.xml",
|
||||
"ic_sb_publish.xml",
|
||||
"ic_sb_voting.xml",
|
||||
"ns_bg.xml"
|
||||
)
|
||||
).forEach { resourceGroup ->
|
||||
context.copyResources("youtube/sponsorblock/outline", resourceGroup)
|
||||
}
|
||||
} else {
|
||||
arrayOf(
|
||||
ResourceUtils.ResourceGroup(
|
||||
"layout",
|
||||
@ -55,26 +85,22 @@ object SponsorBlockPatch : ResourcePatch() {
|
||||
"skip_sponsor_button.xml"
|
||||
),
|
||||
ResourceUtils.ResourceGroup(
|
||||
// required resource for back button, because when the base APK is used, this resource will not exist
|
||||
"drawable",
|
||||
"ic_sb_adjust.xml",
|
||||
"ic_sb_compare.xml",
|
||||
"ic_sb_edit.xml",
|
||||
"ic_sb_logo.xml",
|
||||
"ic_sb_publish.xml",
|
||||
"ns_bg.xml",
|
||||
"ic_sb_forward.xml",
|
||||
"ic_sb_backward.xml",
|
||||
"ic_sb_voting.xml"
|
||||
)
|
||||
).forEach { resourceGroup ->
|
||||
context.copyResources("youtube/sponsorblock", resourceGroup)
|
||||
context.copyResources("youtube/sponsorblock/default", resourceGroup)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* merge xml nodes from the host to their real xml files
|
||||
*/
|
||||
|
||||
// collect all host resources
|
||||
val hostingXmlResources = mapOf("layout" to arrayOf("youtube_controls_layout"))
|
||||
|
||||
@ -82,7 +108,7 @@ object SponsorBlockPatch : ResourcePatch() {
|
||||
hostingXmlResources.forEach { (path, resources) ->
|
||||
resources.forEach { resource ->
|
||||
val hostingResourceStream =
|
||||
this.javaClass.classLoader.getResourceAsStream("youtube/sponsorblock/host/$path/$resource.xml")!!
|
||||
this.javaClass.classLoader.getResourceAsStream("youtube/sponsorblock/shared/host/$path/$resource.xml")!!
|
||||
|
||||
val targetXmlEditor = context.xmlEditor["res/$path/$resource.xml"]
|
||||
"RelativeLayout".copyXmlNode(
|
||||
|
@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:tint="#FFFFFF"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:pathData="M12,2C6.49,2 2,6.49 2,12s4.49,10 10,10 10,-4.49 10,-10S17.51,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8zM15,12c0,1.66 -1.34,3 -3,3s-3,-1.34 -3,-3 1.34,-3 3,-3 3,1.34 3,3z" />
|
||||
</vector>
|
@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:tint="#FFFFFF"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M10,3L5,3c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h5v2h2L12,1h-2v2zM10,18L5,18l5,-6v6zM19,3h-5v2h5v13l-5,-6v9h5c1.1,0 2,-0.9 2,-2L21,5c0,-1.1 -0.9,-2 -2,-2z" />
|
||||
</vector>
|
@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:tint="#FFFFFF"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M3,17.25V21h3.75L17.81,9.94l-3.75,-3.75L3,17.25zM20.71,7.04c0.39,-0.39 0.39,-1.02 0,-1.41l-2.34,-2.34c-0.39,-0.39 -1.02,-0.39 -1.41,0l-1.83,1.83 3.75,3.75 1.83,-1.83z" />
|
||||
</vector>
|
@ -0,0 +1,13 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:alpha="0.95"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:pathData="M12,22.7994C11.55,22.7994 11.1,22.7094 10.74,22.4394 4.89,18.8394 1.29,12.6294 1.2,5.7894 1.2,4.8894 1.65,3.9894 2.46,3.5394 8.4,0.3894 15.6,0.3894 21.54,3.6294 22.35,3.9894 22.8,4.8894 22.8,5.7894 22.71,12.6294 19.11,18.8394 13.35,22.4394 12.9,22.7094 12.45,22.7994 12,22.7994ZM12,1.9194c-3.15,0 -6.3,0.81 -9.18,2.34 -0.54,0.27 -0.9,0.9 -0.9,1.53 0.09,6.57 3.51,12.51 9.18,16.02 0.54,0.36 1.26,0.36 1.8,0C18.57,18.3894 21.9,12.3594 22.08,5.7894 22.08,5.1594 21.72,4.5294 21.18,4.2594 18.3,2.7294 15.15,1.9194 12,1.9194Z" />
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:pathData="M20.73,4.9794C15.24,2.0994 8.76,2.0994 3.27,4.9794 3,5.1594 2.82,5.4294 2.82,5.7894c0.09,6.48 3.51,12.06 8.73,15.3 0.27,0.18 0.63,0.18 0.9,0 5.13,-3.15 8.64,-8.82 8.73,-15.3C21.18,5.4294 21,5.1594 20.73,4.9794ZM9.66,15.1494L9.66,6.7794l7.29,4.23z" />
|
||||
</vector>
|
@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:tint="#FFFFFF"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:pathData="M5,5c0,0.55 0.45,1 1,1h12c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1L6,4c-0.55,0 -1,0.45 -1,1zM7.41,14L9,14v5c0,0.55 0.45,1 1,1h4c0.55,0 1,-0.45 1,-1v-5h1.59c0.89,0 1.34,-1.08 0.71,-1.71L12.71,7.7c-0.39,-0.39 -1.02,-0.39 -1.41,0l-4.59,4.59c-0.63,0.63 -0.19,1.71 0.7,1.71z" />
|
||||
</vector>
|
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<app.revanced.integrations.sponsorblock.ui.SkipSponsorButton
|
||||
android:id="@+id/sb_skip_highlight_button"
|
||||
android:contentDescription="@string/sb_skip_button_compact_highlight"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginBottom="@dimen/inline_controls_bottom_bar_height"
|
||||
android:focusable="true"
|
||||
android:visibility="gone" />
|
||||
|
||||
<app.revanced.integrations.sponsorblock.ui.SkipSponsorButton
|
||||
android:id="@+id/sb_skip_sponsor_button"
|
||||
android:contentDescription="@string/sb_skip_button_compact"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginBottom="@dimen/inline_controls_bottom_bar_height"
|
||||
android:focusable="true"
|
||||
android:visibility="gone" />
|
||||
|
||||
<app.revanced.integrations.sponsorblock.ui.NewSegmentLayout
|
||||
android:id="@+id/sb_new_segment_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginBottom="@dimen/brand_interaction_default_bottom_margin"
|
||||
android:focusable="true"
|
||||
android:visibility="gone" />
|
||||
</merge>
|
@ -0,0 +1,107 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:yt="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/sb_new_segment_container"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="#66000000"
|
||||
android:gravity="start|center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="36.0dip">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/sb_new_segment_rewind"
|
||||
android:layout_width="45.0dip"
|
||||
android:layout_height="36.0dip"
|
||||
android:layout_gravity="start|center"
|
||||
android:alpha="1.0"
|
||||
android:background="@android:color/transparent"
|
||||
android:contentDescription="@null"
|
||||
android:paddingStart="10.0dip"
|
||||
android:paddingTop="3.0dip"
|
||||
android:paddingEnd="5.0dip"
|
||||
android:paddingBottom="3.0dip"
|
||||
android:src="@drawable/player_fast_rewind" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/sb_new_segment_forward"
|
||||
android:layout_width="45.0dip"
|
||||
android:layout_height="36.0dip"
|
||||
android:layout_gravity="start|center"
|
||||
android:alpha="1.0"
|
||||
android:background="@android:color/transparent"
|
||||
android:contentDescription="@null"
|
||||
android:paddingStart="5.0dip"
|
||||
android:paddingTop="3.0dip"
|
||||
android:paddingEnd="5.0dip"
|
||||
android:paddingBottom="3.0dip"
|
||||
android:src="@drawable/player_fast_forward" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/sb_new_segment_adjust"
|
||||
android:layout_width="45.0dip"
|
||||
android:layout_height="36.0dip"
|
||||
android:layout_gravity="start|center"
|
||||
android:alpha="1.0"
|
||||
android:background="@android:color/transparent"
|
||||
android:contentDescription="@null"
|
||||
android:paddingStart="5.0dip"
|
||||
android:paddingTop="3.0dip"
|
||||
android:paddingEnd="10.0dip"
|
||||
android:paddingBottom="3.0dip"
|
||||
android:src="@drawable/ic_sb_adjust" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="36.0dip">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/sb_new_segment_compare"
|
||||
android:layout_width="45.0dip"
|
||||
android:layout_height="36.0dip"
|
||||
android:layout_gravity="start|center"
|
||||
android:alpha="1.0"
|
||||
android:background="@android:color/transparent"
|
||||
android:contentDescription="@null"
|
||||
android:paddingStart="10.0dip"
|
||||
android:paddingTop="3.0dip"
|
||||
android:paddingEnd="5.0dip"
|
||||
android:paddingBottom="3.0dip"
|
||||
android:src="@drawable/ic_sb_compare" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/sb_new_segment_edit"
|
||||
android:layout_width="45.0dip"
|
||||
android:layout_height="36.0dip"
|
||||
android:layout_gravity="start|center"
|
||||
android:alpha="1.0"
|
||||
android:background="@android:color/transparent"
|
||||
android:contentDescription="@null"
|
||||
android:paddingStart="5.0dip"
|
||||
android:paddingTop="3.0dip"
|
||||
android:paddingEnd="5.0dip"
|
||||
android:paddingBottom="3.0dip"
|
||||
android:src="@drawable/ic_sb_edit" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/sb_new_segment_publish"
|
||||
android:layout_width="45.0dip"
|
||||
android:layout_height="36.0dip"
|
||||
android:layout_gravity="start|center"
|
||||
android:alpha="1.0"
|
||||
android:background="@android:color/transparent"
|
||||
android:contentDescription="@null"
|
||||
android:paddingStart="5.0dip"
|
||||
android:paddingTop="3.0dip"
|
||||
android:paddingEnd="10.0dip"
|
||||
android:paddingBottom="3.0dip"
|
||||
android:src="@drawable/ic_sb_publish" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</merge>
|
@ -0,0 +1,11 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:alpha="0.95"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="#ffffffff">
|
||||
<path
|
||||
android:fillColor="#ffffffff"
|
||||
android:pathData="M87.69,528.42Q61.75,528.42 43.95,510.83Q26.15,493.23 26.15,466.89L26.15,232.77Q26.15,226.05 28.92,219.54Q31.69,213.04 37.29,207.44L219.08,25.65L234.62,41.19Q238.26,44.92 240.82,49.76Q243.38,54.6 243.38,58.58L243.38,64.42L208.62,214.58L404.04,214.58Q427.82,214.58 443.6,230.5Q459.39,246.42 459.39,269.96L459.39,282.29Q459.39,288.5 458.39,293.1Q457.39,297.7 455.39,302.58L368.15,504.42Q362.97,515.86 353.46,522.14Q343.96,528.42 331.79,528.42L87.69,528.42ZM333.39,491.5L422.46,283.35L422.46,276.11Q422.46,265.73 415.54,258.61Q408.61,251.5 397.85,251.5L164.15,251.5L196.77,100.62L63.08,234.46L63.08,466.89Q63.08,477.65 70,484.58Q76.92,491.5 87.69,491.5L333.39,491.5ZM740.92,933.35L725.24,917.77Q721.88,914.35 719.25,909.51Q716.61,904.66 716.61,900.4L716.61,894.58L751.38,744.42L555.96,744.42Q532.18,744.42 516.4,728.69Q500.61,712.96 500.61,689.04L500.61,677.05Q500.61,670.89 501.61,666.35Q502.61,661.81 504.61,656.42L591.85,454.58Q596.92,443.58 606.35,437.08Q615.77,430.58 628.15,430.58L872.31,430.58Q898.24,430.58 916.05,448.38Q933.85,466.18 933.85,492.11L933.85,726.27Q933.85,733.5 930.94,740.02Q928.04,746.54 922.61,751.65L740.92,933.35ZM626.61,467.5L537.54,675.65L537.54,682.89Q537.54,693.65 544.46,700.58Q551.39,707.5 562.15,707.5L795.85,707.5L763.23,858.77L896.92,724.92L896.92,492.11Q896.92,481.73 890,474.61Q883.08,467.5 872.31,467.5L626.61,467.5ZM63.08,466.89L63.08,234.46L63.08,234.46L63.08,251.5L63.08,251.5Q63.08,251.5 63.08,258.61Q63.08,265.73 63.08,276.11L63.08,283.35L63.08,491.5L63.08,491.5Q63.08,491.5 63.08,484.58Q63.08,477.65 63.08,466.89ZM896.92,492.11L896.92,724.92L896.92,724.92L896.92,707.5L896.92,707.5Q896.92,707.5 896.92,700.58Q896.92,693.65 896.92,682.89L896.92,675.65L896.92,467.5L896.92,467.5Q896.92,467.5 896.92,474.61Q896.92,481.73 896.92,492.11Z"/>
|
||||
</vector>
|
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:yt="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/sb_skip_sponsor_button_container"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="32dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:padding="8dp">
|
||||
|
||||
<com.google.android.libraries.youtube.common.ui.YouTubeTextView
|
||||
android:id="@+id/sb_skip_sponsor_button_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:includeFontPadding="false"
|
||||
android:paddingRight="@dimen/ad_overlay_ad_text_padding"
|
||||
android:singleLine="true"
|
||||
android:text="@string/sb_skip_button_compact"
|
||||
android:textColor="@color/skip_ad_button_foreground_color"
|
||||
android:textSize="@dimen/extra_small_font_size"
|
||||
yt:robotoFont="light" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/sb_skip_sponsor_button_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:alpha="0.8"
|
||||
android:contentDescription="@null"
|
||||
android:src="@drawable/quantum_ic_skip_next_white_24" />
|
||||
</LinearLayout>
|
||||
</merge>
|
Loading…
x
Reference in New Issue
Block a user