generated from ReVanced/revanced-patches-template
-
-
Notifications
You must be signed in to change notification settings - Fork 236
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate changes from old repo branch
- Loading branch information
1 parent
7d6340c
commit d41d14e
Showing
253 changed files
with
6,665 additions
and
2,044 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 9 additions & 2 deletions
11
...c/misc/gms/GmsCoreSupportResourcePatch.kt → ...gms/YTMusicGmsCoreSupportResourcePatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/kotlin/app/revanced/patches/music/misc/strings/StringsPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 7 additions & 9 deletions
16
src/main/kotlin/app/revanced/patches/shared/settings/preference/BasePreference.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 full class name for 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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 8 additions & 10 deletions
18
src/main/kotlin/app/revanced/patches/shared/settings/preference/ComponentsExtensions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 7 additions & 9 deletions
16
src/main/kotlin/app/revanced/patches/shared/settings/preference/DefaultBasePreference.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) } | ||
} |
22 changes: 15 additions & 7 deletions
22
src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/ArrayResource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
||
} |
Oops, something went wrong.