fix(Reddit/Settings): patch option RVX settings menu name does not apply to header in ReVanced Extended settings

This commit is contained in:
inotia00
2024-06-23 20:43:56 +09:00
parent 6bc2257663
commit 035655a8a9
2 changed files with 20 additions and 15 deletions

View File

@ -33,14 +33,27 @@ object SettingsBytecodePatch : BytecodePatch(
private const val INTEGRATIONS_METHOD_DESCRIPTOR = private const val INTEGRATIONS_METHOD_DESCRIPTOR =
"$INTEGRATIONS_PATH/settings/ActivityHook;->initialize(Landroid/app/Activity;)V" "$INTEGRATIONS_PATH/settings/ActivityHook;->initialize(Landroid/app/Activity;)V"
private lateinit var acknowledgementsLabelBuilderMethod: MutableMethod
private lateinit var settingsStatusLoadMethod: MutableMethod private lateinit var settingsStatusLoadMethod: MutableMethod
internal fun updateSettingsStatus(description: String) { internal fun updateSettingsLabel(label: String) =
acknowledgementsLabelBuilderMethod.apply {
val insertIndex =
getWideLiteralInstructionIndex(LabelAcknowledgements) + 3
val insertRegister =
getInstruction<OneRegisterInstruction>(insertIndex - 1).registerA
addInstruction(
insertIndex,
"const-string v$insertRegister, \"$label\""
)
}
internal fun updateSettingsStatus(description: String) =
settingsStatusLoadMethod.addInstruction( settingsStatusLoadMethod.addInstruction(
0, 0,
"invoke-static {}, $INTEGRATIONS_PATH/settings/SettingsStatus;->$description()V" "invoke-static {}, $INTEGRATIONS_PATH/settings/SettingsStatus;->$description()V"
) )
}
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
@ -62,19 +75,9 @@ object SettingsBytecodePatch : BytecodePatch(
/** /**
* Replace settings label * Replace settings label
*/ */
AcknowledgementsLabelBuilderFingerprint.resultOrThrow().let { acknowledgementsLabelBuilderMethod = AcknowledgementsLabelBuilderFingerprint
it.mutableMethod.apply { .resultOrThrow()
val insertIndex = .mutableMethod
getWideLiteralInstructionIndex(LabelAcknowledgements) + 3
val insertRegister =
getInstruction<OneRegisterInstruction>(insertIndex - 1).registerA
addInstruction(
insertIndex,
"const-string v$insertRegister, \"ReVanced Extended\""
)
}
}
/** /**
* Initialize settings activity * Initialize settings activity

View File

@ -54,5 +54,7 @@ object SettingsPatch : BaseResourcePatch(
) )
) )
} }
SettingsBytecodePatch.updateSettingsLabel(settingsLabel)
} }
} }