1
1
package app.revanced.patches.youtube.layout.sponsorblock
2
2
3
3
import app.revanced.patcher.data.ResourceContext
4
+ import app.revanced.patcher.patch.PatchException
4
5
import app.revanced.patcher.patch.ResourcePatch
5
6
import app.revanced.patcher.patch.annotation.Patch
6
7
import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch
@@ -18,9 +19,9 @@ internal object SponsorBlockResourcePatch : ResourcePatch() {
18
19
StringsPatch .includePatchStrings(" SponsorBlock" )
19
20
SettingsPatch .addPreference(
20
21
Preference (
21
- " revanced_sponsorblock_settings_title " ,
22
- " revanced_sponsorblock_settings_summary " ,
23
- SettingsPatch .createReVancedSettingsIntent(" sponsorblock_settings_intent " )
22
+ " revanced_sb_settings_title " ,
23
+ " revanced_sb_settings_summary " ,
24
+ SettingsPatch .createReVancedSettingsIntent(" revanced_sb_settings_intent " )
24
25
)
25
26
)
26
27
@@ -34,28 +35,18 @@ internal object SponsorBlockResourcePatch : ResourcePatch() {
34
35
" youtube/sponsorblock" ,
35
36
ResourceGroup (
36
37
" drawable" ,
37
- " revanced_ic_sb_adjust .xml" ,
38
- " revanced_ic_sb_compare .xml" ,
39
- " revanced_ic_sb_edit .xml" ,
40
- " revanced_ic_sb_logo .xml" ,
41
- " revanced_ic_sb_publish .xml" ,
42
- " revanced_ic_sb_voting .xml"
38
+ " revanced_sb_adjust .xml" ,
39
+ " revanced_sb_compare .xml" ,
40
+ " revanced_sb_edit .xml" ,
41
+ " revanced_sb_logo .xml" ,
42
+ " revanced_sb_publish .xml" ,
43
+ " revanced_sb_voting .xml"
43
44
),
44
45
ResourceGroup (
45
46
" layout" ,
46
- " inline_sponsor_overlay.xml" ,
47
- " new_segment.xml" ,
48
- " skip_sponsor_button.xml"
49
- ),
50
- ResourceGroup (
51
- // required resource for back button, because when the base APK is used, this resource will not exist
52
- " drawable" ,
53
- " revanced_ic_sb_adjust.xml" ,
54
- " revanced_ic_sb_compare.xml" ,
55
- " revanced_ic_sb_edit.xml" ,
56
- " revanced_ic_sb_logo.xml" ,
57
- " revanced_ic_sb_publish.xml" ,
58
- " revanced_ic_sb_voting.xml"
47
+ " revanced_sb_inline_sponsor_overlay.xml" ,
48
+ " revanced_sb_new_segment.xml" ,
49
+ " revanced_sb_skip_sponsor_button.xml"
59
50
),
60
51
ResourceGroup (
61
52
// required resource for back button, because when the base APK is used, this resource will not exist
@@ -71,6 +62,8 @@ internal object SponsorBlockResourcePatch : ResourcePatch() {
71
62
val hostingResourceStream =
72
63
classLoader.getResourceAsStream(" youtube/sponsorblock/host/layout/youtube_controls_layout.xml" )!!
73
64
65
+ var modifiedYouTubeControlsLayout = false
66
+
74
67
val targetXmlEditor = context.xmlEditor[" res/layout/youtube_controls_layout.xml" ]
75
68
" RelativeLayout" .copyXmlNode(
76
69
context.xmlEditor[hostingResourceStream],
@@ -94,8 +87,11 @@ internal object SponsorBlockResourcePatch : ResourcePatch() {
94
87
95
88
view.attributes.getNamedItem(" android:layout_toStartOf" ).nodeValue = votingButtonId
96
89
90
+ modifiedYouTubeControlsLayout = true
97
91
break
98
92
}
93
+
94
+ if (! modifiedYouTubeControlsLayout) throw PatchException (" Could not modify control layout" )
99
95
}.close() // close afterwards
100
96
}
101
97
}
0 commit comments