feat(YouTube - Theme): Disable gradient loading screen
This commit is contained in:
parent
c4cb1e6f99
commit
90d5877950
|
@ -1,24 +1,50 @@
|
||||||
package app.revanced.patches.youtube.layout.theme
|
package app.revanced.patches.youtube.layout.theme
|
||||||
|
|
||||||
|
import app.revanced.extensions.exception
|
||||||
|
import app.revanced.extensions.indexOfFirstWideLiteralInstructionValue
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||||
|
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||||
import app.revanced.patcher.patch.BytecodePatch
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||||
import app.revanced.patcher.patch.annotation.Patch
|
import app.revanced.patcher.patch.annotation.Patch
|
||||||
import app.revanced.patcher.patch.options.types.StringPatchOption.Companion.stringPatchOption
|
import app.revanced.patcher.patch.options.types.StringPatchOption.Companion.stringPatchOption
|
||||||
|
import app.revanced.patches.shared.settings.preference.impl.StringResource
|
||||||
|
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
|
||||||
import app.revanced.patches.youtube.layout.seekbar.SeekbarColorBytecodePatch
|
import app.revanced.patches.youtube.layout.seekbar.SeekbarColorBytecodePatch
|
||||||
|
import app.revanced.patches.youtube.layout.theme.fingerprints.UseGradientLoadingScreenFingerprint
|
||||||
|
import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch
|
||||||
|
import app.revanced.patches.youtube.misc.settings.SettingsPatch
|
||||||
|
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
|
|
||||||
@Patch(
|
@Patch(
|
||||||
name = "Theme",
|
name = "Theme",
|
||||||
description = "Applies a custom theme.",
|
description = "Applies a custom theme.",
|
||||||
dependencies = [LithoColorHookPatch::class, SeekbarColorBytecodePatch::class, ThemeResourcePatch::class],
|
dependencies = [
|
||||||
|
LithoColorHookPatch::class,
|
||||||
|
SeekbarColorBytecodePatch::class,
|
||||||
|
ThemeResourcePatch::class,
|
||||||
|
IntegrationsPatch::class,
|
||||||
|
SettingsPatch::class
|
||||||
|
],
|
||||||
compatiblePackages = [
|
compatiblePackages = [
|
||||||
CompatiblePackage("com.google.android.youtube")
|
CompatiblePackage(
|
||||||
|
"com.google.android.youtube",
|
||||||
|
[
|
||||||
|
"18.37.36",
|
||||||
|
"18.38.44 "
|
||||||
|
]
|
||||||
|
)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
object ThemeBytecodePatch : BytecodePatch() {
|
object ThemeBytecodePatch : BytecodePatch(
|
||||||
|
setOf(UseGradientLoadingScreenFingerprint)
|
||||||
|
) {
|
||||||
private const val INTEGRATIONS_CLASS_DESCRIPTOR =
|
private const val INTEGRATIONS_CLASS_DESCRIPTOR =
|
||||||
"Lapp/revanced/integrations/patches/theme/ThemeLithoComponentsPatch;"
|
"Lapp/revanced/integrations/patches/theme/ThemePatch;"
|
||||||
|
|
||||||
|
internal const val GRADIENT_LOADING_SCREEN_AB_CONSTANT = 45412406L
|
||||||
|
|
||||||
internal val darkThemeBackgroundColor by stringPatchOption(
|
internal val darkThemeBackgroundColor by stringPatchOption(
|
||||||
key = "darkThemeBackgroundColor",
|
key = "darkThemeBackgroundColor",
|
||||||
|
@ -35,6 +61,34 @@ object ThemeBytecodePatch : BytecodePatch() {
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun execute(context: BytecodeContext) {
|
override fun execute(context: BytecodeContext) {
|
||||||
|
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
|
||||||
|
SwitchPreference(
|
||||||
|
"revanced_gradient_loading_screen",
|
||||||
|
StringResource("revanced_gradient_loading_screen_title", "Enable gradient loading screen"),
|
||||||
|
StringResource(
|
||||||
|
"revanced_gradient_loading_screen_summary_on",
|
||||||
|
"Loading screen will have a gradient background"
|
||||||
|
),
|
||||||
|
StringResource(
|
||||||
|
"revanced_gradient_loading_screen_summary_off",
|
||||||
|
"Loading screen will have a solid background"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
UseGradientLoadingScreenFingerprint.result?.mutableMethod?.apply {
|
||||||
|
val isEnabledIndex = indexOfFirstWideLiteralInstructionValue(GRADIENT_LOADING_SCREEN_AB_CONSTANT) + 3
|
||||||
|
val isEnabledRegister = getInstruction<OneRegisterInstruction>(isEnabledIndex - 1).registerA
|
||||||
|
|
||||||
|
addInstructions(
|
||||||
|
isEnabledIndex,
|
||||||
|
"""
|
||||||
|
invoke-static { }, $INTEGRATIONS_CLASS_DESCRIPTOR->gradientLoadingScreenEnabled()Z
|
||||||
|
move-result v$isEnabledRegister
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
} ?: throw UseGradientLoadingScreenFingerprint.exception
|
||||||
|
|
||||||
LithoColorHookPatch.lithoColorOverrideHook(INTEGRATIONS_CLASS_DESCRIPTOR, "getValue")
|
LithoColorHookPatch.lithoColorOverrideHook(INTEGRATIONS_CLASS_DESCRIPTOR, "getValue")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
package app.revanced.patches.youtube.layout.theme.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patches.youtube.layout.theme.ThemeBytecodePatch.GRADIENT_LOADING_SCREEN_AB_CONSTANT
|
||||||
|
import app.revanced.util.patch.LiteralValueFingerprint
|
||||||
|
|
||||||
|
object UseGradientLoadingScreenFingerprint : LiteralValueFingerprint(
|
||||||
|
literalSupplier = { GRADIENT_LOADING_SCREEN_AB_CONSTANT }
|
||||||
|
)
|
Loading…
Reference in a new issue