mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-28 21:00:19 +02:00
feat(YouTube Music/Settings): add Open MicroG
settings
This commit is contained in:
parent
1f001b4ce6
commit
6633eb515f
@ -7,13 +7,23 @@ import app.revanced.patcher.patch.annotation.Patch
|
|||||||
import app.revanced.patches.music.utils.microg.Constants.MUSIC_PACKAGE_NAME
|
import app.revanced.patches.music.utils.microg.Constants.MUSIC_PACKAGE_NAME
|
||||||
import app.revanced.patches.music.utils.microg.Constants.SPOOFED_PACKAGE_NAME
|
import app.revanced.patches.music.utils.microg.Constants.SPOOFED_PACKAGE_NAME
|
||||||
import app.revanced.patches.music.utils.microg.Constants.SPOOFED_PACKAGE_SIGNATURE
|
import app.revanced.patches.music.utils.microg.Constants.SPOOFED_PACKAGE_SIGNATURE
|
||||||
|
import app.revanced.patches.music.utils.settings.SettingsPatch
|
||||||
import app.revanced.patches.shared.patch.packagename.PackageNamePatch
|
import app.revanced.patches.shared.patch.packagename.PackageNamePatch
|
||||||
|
import app.revanced.util.enum.CategoryType
|
||||||
|
import app.revanced.util.microg.Constants.MICROG_PACKAGE_NAME
|
||||||
import app.revanced.util.microg.MicroGManifestHelper.addSpoofingMetadata
|
import app.revanced.util.microg.MicroGManifestHelper.addSpoofingMetadata
|
||||||
import app.revanced.util.microg.MicroGResourceHelper.patchManifest
|
import app.revanced.util.microg.MicroGResourceHelper.patchManifest
|
||||||
|
import app.revanced.util.resources.MusicResourceHelper.addMicroGPreference
|
||||||
import app.revanced.util.resources.MusicResourceHelper.setMicroG
|
import app.revanced.util.resources.MusicResourceHelper.setMicroG
|
||||||
|
|
||||||
@Patch(dependencies = [PackageNamePatch::class])
|
@Patch(
|
||||||
|
dependencies = [
|
||||||
|
PackageNamePatch::class,
|
||||||
|
SettingsPatch::class
|
||||||
|
]
|
||||||
|
)
|
||||||
object MicroGResourcePatch : ResourcePatch() {
|
object MicroGResourcePatch : ResourcePatch() {
|
||||||
|
private const val MICROG_TARGET_CLASS = "org.microg.gms.ui.SettingsActivity"
|
||||||
override fun execute(context: ResourceContext) {
|
override fun execute(context: ResourceContext) {
|
||||||
val packageName = PackageNamePatch.PackageNameYouTubeMusic
|
val packageName = PackageNamePatch.PackageNameYouTubeMusic
|
||||||
?: throw PatchException("Invalid package name.")
|
?: throw PatchException("Invalid package name.")
|
||||||
@ -35,5 +45,12 @@ object MicroGResourcePatch : ResourcePatch() {
|
|||||||
|
|
||||||
context.setMicroG(packageName)
|
context.setMicroG(packageName)
|
||||||
|
|
||||||
|
context.addMicroGPreference(
|
||||||
|
CategoryType.MISC.value,
|
||||||
|
"microg_settings",
|
||||||
|
MICROG_PACKAGE_NAME,
|
||||||
|
MICROG_TARGET_CLASS
|
||||||
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -10,16 +10,21 @@ internal object Constants {
|
|||||||
*/
|
*/
|
||||||
const val MICROG_VENDOR = "com.mgoogle"
|
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
|
* 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
|
* meta-data for microG package signature spoofing on patched builds
|
||||||
*/
|
*/
|
||||||
const val META_SPOOFED_PACKAGE_SIGNATURE =
|
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
|
* meta-data for microG package detection
|
||||||
|
@ -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(
|
internal fun ResourceContext.addMusicPreference(
|
||||||
category: String,
|
category: String,
|
||||||
key: String,
|
key: String,
|
||||||
|
@ -1,5 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
<string name="microg_not_installed_notice">Please install MicroG.</string>
|
||||||
|
<string name="microg_not_installed_warning">MicroG is not found.</string>
|
||||||
|
<string name="microg_not_running_warning">MicroG does not run in the background.</string>
|
||||||
|
<string name="microg_settings_summary">Enable cloud messaging settings to receive notifications.</string>
|
||||||
|
<string name="microg_settings_title">Open MicroG</string>
|
||||||
|
|
||||||
<string name="revanced_category_account">Account</string>
|
<string name="revanced_category_account">Account</string>
|
||||||
<string name="revanced_category_action_bar">Action Bar</string>
|
<string name="revanced_category_action_bar">Action Bar</string>
|
||||||
<string name="revanced_category_ads">Ads</string>
|
<string name="revanced_category_ads">Ads</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user