mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-30 22:00:19 +02:00
refactor(YouTube Music/Settings): improve behavior of settings patches
This commit is contained in:
parent
5bc7908a02
commit
1e3481ff6a
@ -21,7 +21,7 @@ object IntentHookPatch : BytecodePatch(
|
|||||||
it.mutableMethod.apply {
|
it.mutableMethod.apply {
|
||||||
addInstructionsWithLabels(
|
addInstructionsWithLabels(
|
||||||
1, """
|
1, """
|
||||||
invoke-static {p0}, $MUSIC_INTEGRATIONS_PATH/settingsmenu/SharedPreferenceChangeListener;->initializeSettings(Landroid/app/Activity;)Z
|
invoke-static {p0}, $MUSIC_INTEGRATIONS_PATH/settingsmenu/ReVancedSettingActivity;->initializeSettings(Landroid/app/Activity;)Z
|
||||||
move-result v0
|
move-result v0
|
||||||
if-eqz v0, :show
|
if-eqz v0, :show
|
||||||
return-void
|
return-void
|
||||||
|
@ -26,8 +26,15 @@ object SettingsBytecodePatch : BytecodePatch(
|
|||||||
SettingsHeadersFragmentFingerprint
|
SettingsHeadersFragmentFingerprint
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
|
private const val INTEGRATIONS_ACTIVITY_CLASS_DESCRIPTOR =
|
||||||
|
"$MUSIC_INTEGRATIONS_PATH/settingsmenu/ReVancedSettingActivity;"
|
||||||
|
private const val INTEGRATIONS_FRAGMENT_CLASS_DESCRIPTOR =
|
||||||
|
"$MUSIC_INTEGRATIONS_PATH/settingsmenu/ReVancedSettingsFragment;"
|
||||||
override fun execute(context: BytecodeContext) {
|
override fun execute(context: BytecodeContext) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add instructions to prevent the new player layout from being loaded when you first install the app.
|
||||||
|
*/
|
||||||
NewPlayerLayoutFingerprint.result?.let {
|
NewPlayerLayoutFingerprint.result?.let {
|
||||||
it.mutableMethod.apply {
|
it.mutableMethod.apply {
|
||||||
val insertIndex = implementation!!.instructions.size - 1
|
val insertIndex = implementation!!.instructions.size - 1
|
||||||
@ -40,6 +47,9 @@ object SettingsBytecodePatch : BytecodePatch(
|
|||||||
}
|
}
|
||||||
} ?: throw NewPlayerLayoutFingerprint.exception
|
} ?: throw NewPlayerLayoutFingerprint.exception
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inject settings Activity.
|
||||||
|
*/
|
||||||
SettingsHeadersFragmentFingerprint.result?.let {
|
SettingsHeadersFragmentFingerprint.result?.let {
|
||||||
it.mutableMethod.apply {
|
it.mutableMethod.apply {
|
||||||
val targetIndex = it.scanResult.patternScanResult!!.endIndex
|
val targetIndex = it.scanResult.patternScanResult!!.endIndex
|
||||||
@ -47,11 +57,14 @@ object SettingsBytecodePatch : BytecodePatch(
|
|||||||
|
|
||||||
addInstruction(
|
addInstruction(
|
||||||
targetIndex + 1,
|
targetIndex + 1,
|
||||||
"invoke-static {v$targetRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->setActivity(Ljava/lang/Object;)V"
|
"invoke-static {v$targetRegister}, $INTEGRATIONS_ACTIVITY_CLASS_DESCRIPTOR->setActivity(Ljava/lang/Object;)V"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} ?: throw SettingsHeadersFragmentFingerprint.exception
|
} ?: throw SettingsHeadersFragmentFingerprint.exception
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Values are loaded when preferences change.
|
||||||
|
*/
|
||||||
PreferenceFingerprint.result?.let {
|
PreferenceFingerprint.result?.let {
|
||||||
it.mutableMethod.apply {
|
it.mutableMethod.apply {
|
||||||
val targetIndex = it.scanResult.patternScanResult!!.endIndex
|
val targetIndex = it.scanResult.patternScanResult!!.endIndex
|
||||||
@ -60,7 +73,7 @@ object SettingsBytecodePatch : BytecodePatch(
|
|||||||
|
|
||||||
addInstruction(
|
addInstruction(
|
||||||
targetIndex,
|
targetIndex,
|
||||||
"invoke-static {v$keyRegister, v$valueRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->onPreferenceChanged(Ljava/lang/String;Z)V"
|
"invoke-static {v$keyRegister, v$valueRegister}, $INTEGRATIONS_FRAGMENT_CLASS_DESCRIPTOR->onPreferenceChanged(Ljava/lang/String;Z)V"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} ?: throw PreferenceFingerprint.exception
|
} ?: throw PreferenceFingerprint.exception
|
||||||
@ -69,7 +82,4 @@ object SettingsBytecodePatch : BytecodePatch(
|
|||||||
context.injectInit("InitializationPatch", "initializeReVancedSettings", false)
|
context.injectInit("InitializationPatch", "initializeReVancedSettings", false)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private const val INTEGRATIONS_CLASS_DESCRIPTOR =
|
|
||||||
"$MUSIC_INTEGRATIONS_PATH/settingsmenu/SharedPreferenceChangeListener;"
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user