feat(YouTube Music/Settings): add Open MicroG settings

This commit is contained in:
inotia00
2023-11-25 13:30:56 +09:00
parent 1f001b4ce6
commit 6633eb515f
4 changed files with 58 additions and 3 deletions

View File

@ -10,16 +10,21 @@ internal object Constants {
*/
const val MICROG_VENDOR = "com.mgoogle"
/**
* microG package name
*/
const val MICROG_PACKAGE_NAME = "$MICROG_VENDOR.android.gms"
/**
* meta-data for microG package name spoofing on patched builds
*/
const val META_SPOOFED_PACKAGE_NAME = "$MICROG_VENDOR.android.gms.SPOOFED_PACKAGE_NAME"
const val META_SPOOFED_PACKAGE_NAME = "$MICROG_PACKAGE_NAME.SPOOFED_PACKAGE_NAME"
/**
* meta-data for microG package signature spoofing on patched builds
*/
const val META_SPOOFED_PACKAGE_SIGNATURE =
"$MICROG_VENDOR.android.gms.SPOOFED_PACKAGE_SIGNATURE"
"$MICROG_PACKAGE_NAME.SPOOFED_PACKAGE_SIGNATURE"
/**
* meta-data for microG package detection

View File

@ -107,6 +107,33 @@ internal object MusicResourceHelper {
)
}
internal fun ResourceContext.addMicroGPreference(
category: String,
key: String,
packageName: String,
targetClassName: String
) {
this.xmlEditor[YOUTUBE_MUSIC_SETTINGS_PATH].use { editor ->
val tags = editor.file.getElementsByTagName(YOUTUBE_MUSIC_PREFERENCE_SCREEN_TAG_NAME)
List(tags.length) { tags.item(it) as Element }
.filter { it.getAttribute("android:key").contains("revanced_settings_$category") }
.forEach {
it.adoptChild("Preference") {
setAttribute("android:title", "@string/$key" + "_title")
setAttribute("android:summary", "@string/$key" + "_summary")
this.adoptChild("intent") {
setAttribute("android:targetPackage", packageName)
setAttribute("android:data", key)
setAttribute(
"android:targetClass",
targetClassName
)
}
}
}
}
}
internal fun ResourceContext.addMusicPreference(
category: String,
key: String,