mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-03 08:04:36 +02:00
add bitrate-default-value
patch
This commit is contained in:
parent
63c2145d13
commit
8f12e6ae93
@ -0,0 +1,43 @@
|
||||
package app.revanced.patches.music.misc.bitrate.patch
|
||||
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.ResourceContext
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.ResourcePatch
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility
|
||||
|
||||
@Patch
|
||||
@Name("bitrate-default-value")
|
||||
@Description("Set the audio quality to 'Always High' when you first install the app.")
|
||||
@YouTubeMusicCompatibility
|
||||
@Version("0.0.1")
|
||||
class BitrateDefaultValuePatch : ResourcePatch {
|
||||
override fun execute(context: ResourceContext): PatchResult {
|
||||
context.xmlEditor[RESOURCE_FILE_PATH].use { editor ->
|
||||
editor.file.getElementsByTagName("com.google.android.apps.youtube.music.ui.preference.PreferenceCategoryCompat").item(0).childNodes.apply {
|
||||
arrayOf("BitrateAudioMobile", "BitrateAudioWiFi").forEach {
|
||||
for (i in 1 until length) {
|
||||
val view = item(i)
|
||||
if (
|
||||
view.hasAttributes() &&
|
||||
view.attributes.getNamedItem("android:key").nodeValue.endsWith(it)
|
||||
) {
|
||||
view.attributes.getNamedItem("android:defaultValue").nodeValue = "Always High"
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val RESOURCE_FILE_PATH = "res/xml/data_saving_settings.xml"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user