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

feat(Translations): Translations for YouTube and Twitch #2366

Closed
wants to merge 206 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
206 commits
Select commit Hold shift + click to select a range
c8052e6
move youtube resources into subdirectory
LisoUseInAIKyrios Jun 5, 2023
ed9b6a6
removed all StringResource usage for YouTube
LisoUseInAIKyrios Jun 5, 2023
8b29278
sorting by title now done in integrations
LisoUseInAIKyrios Jun 5, 2023
b4bcc8e
youtube translations
LisoUseInAIKyrios Jun 5, 2023
0d1f405
no longer needed
LisoUseInAIKyrios Jun 5, 2023
6baec1a
use same minimum version as YouTube. Not that it matters.
LisoUseInAIKyrios Jun 5, 2023
5f28ace
cleanup
LisoUseInAIKyrios Jun 5, 2023
024174c
adding annotation, moving code
LisoUseInAIKyrios Jun 6, 2023
f3c0da8
extract strings for twitch
LisoUseInAIKyrios Jun 6, 2023
af0e185
rename class
LisoUseInAIKyrios Jun 6, 2023
9d4f0e2
hide the last bits of StringResource
LisoUseInAIKyrios Jun 6, 2023
e77dbfc
twitch translations stubs
LisoUseInAIKyrios Jun 6, 2023
096581d
no functional changes: renamed classes
LisoUseInAIKyrios Jun 6, 2023
964384e
fixing escaping
LisoUseInAIKyrios Jun 6, 2023
14286a3
fixing twitch
LisoUseInAIKyrios Jun 6, 2023
0c71637
cleanup
LisoUseInAIKyrios Jun 6, 2023
31d8cfe
simplify array resources
LisoUseInAIKyrios Jun 6, 2023
29b86a3
fixing stuff
LisoUseInAIKyrios Jun 6, 2023
76df5f3
comments are in integrations
LisoUseInAIKyrios Jun 6, 2023
b0441ec
more clear
LisoUseInAIKyrios Jun 6, 2023
696475c
strings that don't need, or should not be translated
LisoUseInAIKyrios Jun 6, 2023
98ff8f5
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Jun 7, 2023
d695cc6
fixing merge
LisoUseInAIKyrios Jun 7, 2023
bda7d17
moving YouTube microg strings to localized file
LisoUseInAIKyrios Jun 7, 2023
01c14d5
fixing merge
LisoUseInAIKyrios Jun 7, 2023
12574bc
more non translatable text
LisoUseInAIKyrios Jun 7, 2023
eee722a
added option to throw an exception if destination files exist.
LisoUseInAIKyrios Jun 7, 2023
cdd6d24
Merge branch 'dev' into localization
LisoUseInAIKyrios Jun 8, 2023
0dcd794
move non-translatable strings into separate file.
LisoUseInAIKyrios Jun 8, 2023
0bac41f
comments
LisoUseInAIKyrios Jun 8, 2023
4be097c
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Jun 10, 2023
4c6485e
SponsorBlock has removed the leaderboard (the api end point no longer…
LisoUseInAIKyrios Jun 10, 2023
308b7a7
no functional changes: renamed classes
LisoUseInAIKyrios Jun 10, 2023
5e3c04a
no functional changes: renamed classes
LisoUseInAIKyrios Jun 10, 2023
853e882
tiktok translations
LisoUseInAIKyrios Jun 10, 2023
37c78b8
Revert "tiktok translations"
LisoUseInAIKyrios Jun 10, 2023
18c036a
twitch machine translations
LisoUseInAIKyrios Jun 10, 2023
c174120
turned off, for now
LisoUseInAIKyrios Jun 10, 2023
349cc6e
Merge branch 'dev' into localization
LisoUseInAIKyrios Jun 10, 2023
ba4218c
Merge branch 'dev' into localization
LisoUseInAIKyrios Jun 11, 2023
d40082b
Verify the regex matches the end of the path, in case the user likes …
LisoUseInAIKyrios Jun 11, 2023
db4420b
Merge branch 'dev' into localization
LisoUseInAIKyrios Jun 12, 2023
7b0025b
Merge branch 'dev' into localization
LisoUseInAIKyrios Jun 13, 2023
e25876b
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Jun 15, 2023
4cef4cb
fixing merge
LisoUseInAIKyrios Jun 15, 2023
b699f8d
no point translating this dead patch.
LisoUseInAIKyrios Jun 15, 2023
311cc71
use same ordering as shown in the app.
LisoUseInAIKyrios Jun 15, 2023
d4eb9fb
use revanced prefix
LisoUseInAIKyrios Jun 15, 2023
26358fe
use revanced prefix
LisoUseInAIKyrios Jun 15, 2023
2aff527
fixing stuff
LisoUseInAIKyrios Jun 15, 2023
5b40257
comments
LisoUseInAIKyrios Jun 15, 2023
ee276ba
making resource names more consistent
LisoUseInAIKyrios Jun 16, 2023
22cecb1
Merge branch 'dev' into localization
LisoUseInAIKyrios Jun 16, 2023
357f2a3
logging out is no longer needed nor works, as YouTube now always give…
LisoUseInAIKyrios Jun 16, 2023
63f06d2
Merge remote-tracking branch 'origin/localization' into localization
LisoUseInAIKyrios Jun 16, 2023
e98bffb
adjust strings
LisoUseInAIKyrios Jun 16, 2023
774e81a
Merge branch 'dev' into localization
LisoUseInAIKyrios Jun 16, 2023
bfdbf3a
fixing RTL languages
LisoUseInAIKyrios Jun 16, 2023
5261aea
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Jun 18, 2023
66ecccf
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Jun 18, 2023
9a92dab
finishing merge
LisoUseInAIKyrios Jun 18, 2023
5394766
committing missing resources lost in refactoring
LisoUseInAIKyrios Jun 20, 2023
519b7bb
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Jun 21, 2023
17ba726
Merge branch 'dev' into localization
LisoUseInAIKyrios Jun 22, 2023
c2d146f
Adding last untranslated strings.
LisoUseInAIKyrios Jun 22, 2023
4dc1242
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Jun 23, 2023
d6947b0
finishing merge
LisoUseInAIKyrios Jun 23, 2023
7dd42c9
downloading appears to be working again.
LisoUseInAIKyrios Jun 25, 2023
69363f9
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Jun 28, 2023
a155350
this should be the last non-localized string
LisoUseInAIKyrios Jun 28, 2023
e5d4e82
Merge branch 'revanced:main' into localization
LisoUseInAIKyrios Jul 1, 2023
dbafeb1
Merge branch 'dev' into localization
LisoUseInAIKyrios Jul 1, 2023
87ce721
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Jul 3, 2023
4492623
finishing merge
LisoUseInAIKyrios Jul 3, 2023
12d50bc
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Jul 5, 2023
7ee8319
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Jul 6, 2023
7e01c93
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Jul 8, 2023
e906b41
Merge branch 'dev' into localization
LisoUseInAIKyrios Jul 8, 2023
6b120ea
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Jul 11, 2023
3c99acb
resolving merge specific conflicts
LisoUseInAIKyrios Jul 11, 2023
cb37081
fixing merge
LisoUseInAIKyrios Jul 11, 2023
66365f0
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Jul 14, 2023
1c9c100
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Jul 16, 2023
4d684b0
fixing merge
LisoUseInAIKyrios Jul 16, 2023
5b480c3
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Jul 19, 2023
ea26235
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Jul 20, 2023
75154a3
merge specific updates changes
LisoUseInAIKyrios Jul 20, 2023
f32c942
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Jul 20, 2023
31d4586
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Jul 21, 2023
e607a46
merge specific changes
LisoUseInAIKyrios Jul 21, 2023
d8d13a0
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Jul 22, 2023
c7abe2a
Use latest patch naming
LisoUseInAIKyrios Jul 22, 2023
1ca4b81
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Jul 28, 2023
bd48c39
merge specific changes
LisoUseInAIKyrios Jul 28, 2023
6b21039
fixing merge
LisoUseInAIKyrios Jul 28, 2023
4f45656
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Jul 30, 2023
6da28e3
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Jul 30, 2023
86a698b
merge specific changes
LisoUseInAIKyrios Jul 30, 2023
1d73b48
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Aug 1, 2023
dd13f20
remove deprecated version annotation
LisoUseInAIKyrios Aug 1, 2023
eed733b
fixing string
LisoUseInAIKyrios Aug 1, 2023
dab6548
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Aug 3, 2023
94fb588
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Aug 6, 2023
f81af8b
merge specific changes
LisoUseInAIKyrios Aug 6, 2023
a5f5255
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Aug 6, 2023
f220bae
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Aug 7, 2023
329df81
merge specific changes
LisoUseInAIKyrios Aug 7, 2023
7ec5996
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Aug 7, 2023
9b15c4d
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Aug 7, 2023
9b67a99
merge specific changes
LisoUseInAIKyrios Aug 7, 2023
58ea296
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Aug 7, 2023
284096a
merge specific changes
LisoUseInAIKyrios Aug 7, 2023
a5337eb
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Aug 23, 2023
24a6aff
merge specific changes
LisoUseInAIKyrios Aug 23, 2023
470485b
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Aug 24, 2023
607816c
distinct names from other integration patches
LisoUseInAIKyrios Aug 24, 2023
1e2afc0
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Aug 26, 2023
8e2c187
fixing merge conflicts
LisoUseInAIKyrios Aug 26, 2023
8135f90
fixing merge
LisoUseInAIKyrios Aug 27, 2023
a81e8cb
revert "AppNameSettingsPatch" back to just "SettingsPatch"
LisoUseInAIKyrios Sep 5, 2023
1770d12
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Sep 7, 2023
6a86ca9
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Sep 8, 2023
7066824
extracted strings to individual patch files
LisoUseInAIKyrios Sep 10, 2023
27f6c4f
Code to merge English strings into a single xml file, and gradle task…
LisoUseInAIKyrios Sep 10, 2023
3f9ef71
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Sep 14, 2023
c340575
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Sep 15, 2023
3c8db65
Moved Twitch strings to individual files
LisoUseInAIKyrios Sep 15, 2023
bfd6271
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Sep 18, 2023
0bc62b2
extract string
LisoUseInAIKyrios Sep 18, 2023
bad9f9d
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Sep 20, 2023
3cc26cc
fixing merge
LisoUseInAIKyrios Sep 20, 2023
72e2ed5
chore(release): 2.191.0-dev.6 [skip ci]
semantic-release-bot Sep 22, 2023
715aef8
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Sep 22, 2023
1500420
cleanup of merge
LisoUseInAIKyrios Sep 22, 2023
b31fec3
fixing initialization error
LisoUseInAIKyrios Sep 22, 2023
7eef4b2
Fixing missing string. Desperately need to hook aapt up to the conso…
LisoUseInAIKyrios Sep 22, 2023
489bfbe
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Sep 23, 2023
0b2c5a4
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Sep 24, 2023
649e5f0
merge specific changes
LisoUseInAIKyrios Sep 24, 2023
fba965a
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Sep 25, 2023
1624b66
merge specific changes
LisoUseInAIKyrios Sep 25, 2023
dffccce
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Sep 25, 2023
ec90583
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Sep 26, 2023
09d5b83
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Oct 2, 2023
e81eb88
merge specific changes
LisoUseInAIKyrios Oct 2, 2023
42e7dc9
refactor: rename string file to match pat
LisoUseInAIKyrios Oct 2, 2023
92e71e8
merge specific updates
LisoUseInAIKyrios Oct 2, 2023
514de4d
refactor: no functional changes: rearrange strings to the same order …
LisoUseInAIKyrios Oct 2, 2023
642f900
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Oct 3, 2023
6fcc0e6
merge specific changes
LisoUseInAIKyrios Oct 3, 2023
c0c2fc2
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Oct 14, 2023
82012ef
merge specific changes
LisoUseInAIKyrios Oct 14, 2023
e9f17b4
Validate strings have been merged before using, since resource compil…
LisoUseInAIKyrios Oct 14, 2023
3b7ab0b
fix importing wrong class
LisoUseInAIKyrios Oct 14, 2023
3940670
Merge branch 'dev' into localization
LisoUseInAIKyrios Oct 14, 2023
0630f7a
Update src/main/kotlin/app/revanced/util/resources/ResourceUtils.kt
LisoUseInAIKyrios Oct 14, 2023
9f097d4
importing duplicate strings almost always indicates an problem
LisoUseInAIKyrios Oct 14, 2023
fd43e61
description
LisoUseInAIKyrios Oct 14, 2023
b5ee03b
Comments
LisoUseInAIKyrios Oct 14, 2023
44024c0
Sorting is now done in integrations based on the localized language i…
LisoUseInAIKyrios Oct 14, 2023
9938eec
correctly handle `formatted="true"`
LisoUseInAIKyrios Oct 14, 2023
665e79e
refactor: Slight refactoring
oSumAtrIX Oct 14, 2023
c2ce152
no functional changes: rename methods and comments
LisoUseInAIKyrios Oct 14, 2023
be2f234
removing as it's generated.
LisoUseInAIKyrios Oct 14, 2023
4b73834
remove gradle merge task, as it appears CrowdIn will work as desired …
LisoUseInAIKyrios Oct 14, 2023
37ff920
No functional changes: renamed Utils classes.
LisoUseInAIKyrios Oct 14, 2023
50e34e2
fixing merge
LisoUseInAIKyrios Oct 14, 2023
d78aac0
fixing overlooked refactor
LisoUseInAIKyrios Oct 15, 2023
d33028e
Comments
LisoUseInAIKyrios Oct 15, 2023
afd9465
refactor: Use `SettingsPatch` instead of `SettingsResourcePath`
oSumAtrIX Oct 16, 2023
155ab5e
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Oct 31, 2023
81cb847
merge specific changes
LisoUseInAIKyrios Oct 31, 2023
4573811
extract Strings bundling into it's own patch
LisoUseInAIKyrios Oct 31, 2023
7df1cee
fix typo
LisoUseInAIKyrios Oct 31, 2023
48b9466
comments
LisoUseInAIKyrios Oct 31, 2023
2a1bd8b
removed resource callback that is no longer needed
LisoUseInAIKyrios Oct 31, 2023
9b21fad
comments
LisoUseInAIKyrios Oct 31, 2023
35fa271
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Nov 5, 2023
282dd81
merge specific changes
LisoUseInAIKyrios Nov 5, 2023
4eab894
No longer need to check since resource compilation now shows errors
LisoUseInAIKyrios Nov 5, 2023
80f3e91
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Nov 6, 2023
56587eb
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Nov 10, 2023
c55ca6e
merge specific changes
LisoUseInAIKyrios Nov 10, 2023
ec4745b
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Nov 11, 2023
4eabbc1
merge specific changes
LisoUseInAIKyrios Nov 11, 2023
8d59193
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Nov 13, 2023
2056fda
merge specific changes
LisoUseInAIKyrios Nov 13, 2023
b869ab1
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Nov 17, 2023
f0404e1
merge specific changes
LisoUseInAIKyrios Nov 17, 2023
261b130
feat(YouTube):Add `Disable rolling number animations` patch (#3298)
LisoUseInAIKyrios Nov 19, 2023
a3e275b
fix(Twitch - Settings): Constrain to last working version
oSumAtrIX Nov 19, 2023
9b855f0
fix(Yuka - Unlock premium): Constrain to last working version
oSumAtrIX Nov 19, 2023
2fbf17d
chore(release): 2.198.1-dev.2 [skip ci]
semantic-release-bot Nov 19, 2023
f3b3b24
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Nov 20, 2023
2f3a13f
merge specific changes
LisoUseInAIKyrios Nov 20, 2023
0240466
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Nov 23, 2023
635664f
merge specific changes
LisoUseInAIKyrios Nov 23, 2023
83558e2
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Nov 26, 2023
f4c35f1
merge specific changes
LisoUseInAIKyrios Nov 26, 2023
a8619fd
extract strings
LisoUseInAIKyrios Nov 28, 2023
dc1959f
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Nov 28, 2023
36f1a50
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Nov 30, 2023
9bfd661
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Dec 2, 2023
2929ad3
Merge remote-tracking branch 'upstream/dev' into localization
LisoUseInAIKyrios Dec 10, 2023
4cdfc9b
added shared string patch support. added better exception logging if…
LisoUseInAIKyrios Dec 10, 2023
dbc5485
rearrange packages
LisoUseInAIKyrios Dec 10, 2023
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
146 changes: 85 additions & 61 deletions api/revanced-patches.api

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package app.revanced.patches.music.misc.gms

import app.revanced.patches.music.misc.gms.Constants.MUSIC_PACKAGE_NAME
import app.revanced.patches.music.misc.gms.Constants.REVANCED_MUSIC_PACKAGE_NAME
import app.revanced.patches.music.misc.gms.GmsCoreSupportResourcePatch.gmsCoreVendorOption
import app.revanced.patches.music.misc.gms.YTMusicGmsCoreSupportResourcePatch.gmsCoreVendorOption
import app.revanced.patches.music.misc.gms.fingerprints.*
import app.revanced.patches.shared.misc.gms.AbstractGmsCoreSupportPatch
import app.revanced.patches.youtube.misc.gms.fingerprints.CastContextFetchFingerprint
Expand All @@ -19,7 +19,7 @@ object GmsCoreSupportPatch : AbstractGmsCoreSupportPatch(
CastDynamiteModuleV2Fingerprint,
CastContextFetchFingerprint,
),
abstractGmsCoreSupportResourcePatch = GmsCoreSupportResourcePatch,
abstractGmsCoreSupportResourcePatch = YTMusicGmsCoreSupportResourcePatch,
compatiblePackages = setOf(CompatiblePackage("com.google.android.apps.youtube.music")),
fingerprints = setOf(
ServiceCheckFingerprint,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
package app.revanced.patches.music.misc.gms

import app.revanced.patcher.data.ResourceContext
import app.revanced.patches.music.misc.gms.Constants.MUSIC_PACKAGE_NAME
import app.revanced.patches.music.misc.gms.Constants.REVANCED_MUSIC_PACKAGE_NAME
import app.revanced.patches.youtube.misc.strings.StringsPatch
import app.revanced.patches.shared.misc.gms.AbstractGmsCoreSupportResourcePatch

object GmsCoreSupportResourcePatch : AbstractGmsCoreSupportResourcePatch(
object YTMusicGmsCoreSupportResourcePatch : AbstractGmsCoreSupportResourcePatch(
fromPackageName = MUSIC_PACKAGE_NAME,
toPackageName = REVANCED_MUSIC_PACKAGE_NAME,
spoofedPackageSignature = "afb0fed5eeaebdd86f56a97742f4b6b33ef59875"
)
) {
override fun execute(context: ResourceContext) {
// Strings used by different target apps.
StringsPatch.includeSharedPatchStrings("GmsCoreSupport");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package app.revanced.patches.music.misc.strings

import app.revanced.patches.shared.strings.AbstractStringsResourcePatch

object StringsPatch : AbstractStringsResourcePatch(
"music/stringspatch/values"
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.options.PatchOption.PatchExtensions.stringPatchOption
import app.revanced.patches.all.misc.packagename.ChangePackageNamePatch
import app.revanced.util.mergeStrings
import org.w3c.dom.Element
import org.w3c.dom.Node

Expand Down Expand Up @@ -39,7 +38,6 @@ abstract class AbstractGmsCoreSupportResourcePatch(
protected val gmsCoreVendor by gmsCoreVendorOption

override fun execute(context: ResourceContext) {
context.mergeStrings("gms/host/values/strings.xml")
context.patchManifest()
context.addSpoofingMetadata()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.util.DomFileEditor
import app.revanced.patches.shared.settings.preference.BasePreference
import app.revanced.patches.shared.settings.preference.BaseResource
import app.revanced.patches.shared.settings.preference.addPreference
import app.revanced.patches.shared.settings.preference.addResource
import app.revanced.patches.shared.settings.preference.impl.ArrayResource
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.util.ResourceGroup
import app.revanced.util.copyResources
import org.w3c.dom.Node
Expand All @@ -24,6 +22,10 @@ abstract class AbstractSettingsResourcePatch(
private val preferenceFileName: String,
private val sourceDirectory: String,
) : ResourcePatch(), Closeable {

private lateinit var arraysEditor: DomFileEditor
private lateinit var revancedPreferencesEditor: DomFileEditor

override fun execute(context: ResourceContext) {
/* copy preference template from source dir */
context.copyResources(
Expand All @@ -34,88 +36,37 @@ abstract class AbstractSettingsResourcePatch(
)

/* prepare xml editors */
stringsEditor = context.xmlEditor["res/values/strings.xml"]
arraysEditor = context.xmlEditor["res/values/arrays.xml"]
arraysNode = arraysEditor.getNode("resources")

revancedPreferencesEditor = context.xmlEditor["res/xml/$preferenceFileName.xml"]
revancedPreferenceNode = revancedPreferencesEditor.getNode("PreferenceScreen")
}

internal companion object {
private var revancedPreferenceNode: Node? = null
private var stringsNode: Node? = null
private var arraysNode: Node? = null

private var strings = mutableListOf<StringResource>()

private var revancedPreferencesEditor: DomFileEditor? = null
set(value) {
field = value
revancedPreferenceNode = value.getNode("PreferenceScreen")
}
private var stringsEditor: DomFileEditor? = null
set(value) {
field = value
stringsNode = value.getNode("resources")
}
private var arraysEditor: DomFileEditor? = null
set(value) {
field = value
arraysNode = value.getNode("resources")
}
override fun close() {
revancedPreferencesEditor.close()
arraysEditor.close()
}

/**
* Add a new string to the resources.
*
* @param identifier The key of the string.
* @param value The value of the string.
* @throws IllegalArgumentException if the string already exists.
*/
fun addString(identifier: String, value: String, formatted: Boolean) =
StringResource(identifier, value, formatted).include()
internal companion object {
private lateinit var arraysNode: Node
private lateinit var revancedPreferenceNode: Node

/**
* Add an array to the resources.
*
* @param arrayResource The array resource to add.
*/
fun addArray(arrayResource: ArrayResource) =
arraysNode!!.addResource(arrayResource) { it.include() }
internal fun addArray(arrayResource: ArrayResource) = arraysNode.addResource(arrayResource)

/**
* Add a preference to the settings.
*
* @param preference The preference to add.
*/
fun addPreference(preference: BasePreference) =
revancedPreferenceNode!!.addPreference(preference) { it.include() }

/**
* Add a new resource to the resources.
*
* @throws IllegalArgumentException if the resource already exists.
*/
internal fun BaseResource.include() {
when (this) {
is StringResource -> {
if (strings.any { it.name == name }) return
strings.add(this)
}

is ArrayResource -> addArray(this)
else -> throw NotImplementedError("Unsupported resource type")
}
}

internal fun DomFileEditor?.getNode(tagName: String) = this!!.file.getElementsByTagName(tagName).item(0)
}

override fun close() {
// merge all strings, skip duplicates
strings.forEach {
stringsNode!!.addResource(it)
}
fun addPreference(preference: BasePreference) = revancedPreferenceNode.addPreference(preference)

revancedPreferencesEditor?.close()
stringsEditor?.close()
arraysEditor?.close()
internal fun DomFileEditor?.getNode(tagName: String) =
this!!.file.getElementsByTagName(tagName).item(0)
}
}
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
package app.revanced.patches.shared.settings.preference

import app.revanced.patches.shared.settings.preference.impl.StringResource
import org.w3c.dom.Document
import org.w3c.dom.Element

/**
* Base preference class for all preferences.
*
* @param key The key of the preference.
* @param title The title of the preference.
* @param titleKey The title of the preference.
* @param tag The tag of the preference.
* @param summary The summary of the preference.
* @param summaryKey The summary of the preference.
*/
abstract class BasePreference(
val key: String?,
val title: StringResource,
val summary: StringResource? = null,
val titleKey: String,
val summaryKey: String? = null,
val tag: String
) {
/**
* Serialize preference element to XML.
* Overriding methods should invoke super and operate on its return value.
* @param ownerDocument Target document to create elements from.
* @param resourceCallback Called when a resource has been processed.
* @return The serialized element.
*/
open fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit): Element =
open fun serialize(ownerDocument: Document): Element =
ownerDocument.createElement(tag).apply {
if (key != null) setAttribute("android:key", key)
setAttribute("android:title", "@string/${title.also { resourceCallback.invoke(it) }.name}")
addSummary(summary?.also { resourceCallback.invoke(it) })
setAttribute("android:title", "@string/$titleKey")
addSummary(summaryKey)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ abstract class BaseResource(
* Serialize resource element to XML.
* Overriding methods should invoke super and operate on its return value.
* @param ownerDocument Target document to create elements from.
* @param resourceCallback Called when a resource has been processed.
*/
open fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit = { }): Element {
open fun serialize(ownerDocument: Document): Element {
return ownerDocument.createElement(tag).apply {
setAttribute("name", name)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
package app.revanced.patches.shared.settings.preference

import app.revanced.patches.shared.settings.preference.impl.StringResource
import org.w3c.dom.Element
import org.w3c.dom.Node

/**
* Add a resource node child
*
* @param resource The resource to add.
* @param resourceCallback Called when a resource has been processed.
*/
internal fun Node.addResource(resource: BaseResource, resourceCallback: (BaseResource) -> Unit = { }) {
appendChild(resource.serialize(ownerDocument, resourceCallback))
internal fun Node.addResource(resource: BaseResource) {
appendChild(resource.serialize(ownerDocument))
}

/**
* Add a preference node child to the settings.
*
* @param preference The preference to add.
* @param resourceCallback Called when a resource has been processed.
*/
internal fun Node.addPreference(preference: BasePreference, resourceCallback: ((BaseResource) -> Unit) = { }) {
appendChild(preference.serialize(ownerDocument, resourceCallback))
internal fun Node.addPreference(preference: BasePreference) {
appendChild(preference.serialize(ownerDocument))
}

internal fun Element.addSummary(summaryResource: StringResource?, summaryType: SummaryType = SummaryType.DEFAULT) =
summaryResource?.let { summary ->
setAttribute("android:${summaryType.type}", "@string/${summary.name}")
internal fun Element.addSummary(summaryResourceKey: String?, summaryType: SummaryType = SummaryType.DEFAULT) {
if (summaryResourceKey != null) {
setAttribute("android:${summaryType.type}", "@string/$summaryResourceKey")
}
}

internal fun <T> Element.addDefault(default: T) {
if (default is Boolean && !(default as Boolean)) return // No need to include the default, as no value already means 'false'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,30 @@
package app.revanced.patches.shared.settings.preference

import app.revanced.patches.shared.settings.preference.impl.StringResource
import org.w3c.dom.Document

/**
* Base preference class that also has a default value.
*
* @param key The key of the preference.
* @param title The title of the preference.
* @param titleKey The title of the preference.
* @param tag The tag of the preference.
* @param summary The summary of the preference.
* @param summaryKey The summary of the preference.
* @param default The default value of the preference.
*/
abstract class DefaultBasePreference<T>(
key: String?,
title: StringResource,
summary: StringResource? = null,
titleKey: String,
summaryKey: String? = null,
tag: String,
val default: T? = null,
) : BasePreference(key, title, summary, tag) {
) : BasePreference(key, titleKey, summaryKey, tag) {

/**
* Serialize preference element to XML.
* Overriding methods should invoke super and operate on its return value.
* @param ownerDocument Target document to create elements from.
* @param resourceCallback Called when a resource has been processed.
* @return The serialized element.
*/
override fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit) =
super.serialize(ownerDocument, resourceCallback).apply { addDefault(default) }
override fun serialize(ownerDocument: Document) =
super.serialize(ownerDocument).apply { addDefault(default) }
}
Original file line number Diff line number Diff line change
@@ -1,29 +1,37 @@
package app.revanced.patches.shared.settings.preference.impl

import app.revanced.patches.shared.settings.AbstractSettingsResourcePatch
import app.revanced.patches.shared.settings.preference.BaseResource
import org.w3c.dom.Document

// TODO: allow specifying an array resource file instead of using a list of StringResources
/**
* An array resource.
*
* @param name The name of the array resource.
* @param items The items of the array resource.
* @param literalValues If the values are to be used exactly as is.
* If false, the values are treated as string resource names.
*/
class ArrayResource(
name: String,
val items: List<StringResource>
val items: Iterable<String>,
val literalValues : Boolean = false
) : BaseResource(name, "string-array") {
override fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit) =
super.serialize(ownerDocument, resourceCallback).apply {

override fun serialize(ownerDocument: Document) =
super.serialize(ownerDocument).apply {
setAttribute("name", name)

items.forEach { item ->
resourceCallback.invoke(item)

this.appendChild(ownerDocument.createElement("item").also { itemNode ->
itemNode.textContent = "@string/${item.name}"
itemNode.textContent = if (literalValues) item else "@string/$item"
})
}
}

/**
* Bundles this array with the target app.
*/
fun include() = AbstractSettingsResourcePatch.addArray(this)

}
Loading