refactor: better method is used for settings-framework

This commit is contained in:
inotia00 2023-02-18 01:57:43 +09:00
parent ef370c82d1
commit b3ed1c0f93

View File

@ -11,15 +11,16 @@ internal object MicroGResourceHelper {
*
* @param fromPackageName Original package name.
* @param toPackageName The package name to accept.
* @param toName The new name of the app.
*/
fun ResourceContext.patchManifest(
fromPackageName: String,
toPackageName: String
) {
val manifest = this["AndroidManifest.xml"].readText()
this["AndroidManifest.xml"].writeText(
manifest.replace(
val manifest = this["AndroidManifest.xml"]
manifest.writeText(
manifest.readText()
.replace(
"package=\"$fromPackageName",
"package=\"$toPackageName"
).replace(
@ -40,4 +41,25 @@ internal object MicroGResourceHelper {
)
)
}
/**
* Patch the settings fragment to work with MicroG.
*
* @param fromPackageName Original package name.
* @param toPackageName The package name to accept.
*/
fun ResourceContext.patchSetting(
fromPackageName: String,
toPackageName: String
) {
val prefs = this["res/xml/settings_fragment.xml"]
prefs.writeText(
prefs.readText()
.replace(
"android:targetPackage=\"$fromPackageName",
"android:targetPackage=\"$toPackageName"
)
)
}
}