mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-09 02:54:37 +02:00
feat(YouTube Music): remove Enable sleep timer
patch
This commit is contained in:
parent
0ef43e4a0b
commit
bd05ad0bbb
@ -1,12 +1,14 @@
|
||||
package app.revanced.patches.music.flyoutpanel.component
|
||||
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.music.flyoutpanel.component.fingerprints.SleepTimerFingerprint
|
||||
import app.revanced.patches.music.flyoutpanel.utils.EnumUtils.getEnumIndex
|
||||
import app.revanced.patches.music.utils.fingerprints.MenuItemFingerprint
|
||||
import app.revanced.patches.music.utils.flyoutbutton.FlyoutButtonContainerPatch
|
||||
@ -46,7 +48,10 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||
)
|
||||
@Suppress("unused")
|
||||
object FlyoutPanelPatch : BytecodePatch(
|
||||
setOf(MenuItemFingerprint)
|
||||
setOf(
|
||||
MenuItemFingerprint,
|
||||
SleepTimerFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
MenuItemFingerprint.result?.let {
|
||||
@ -72,6 +77,22 @@ object FlyoutPanelPatch : BytecodePatch(
|
||||
}
|
||||
} ?: throw MenuItemFingerprint.exception
|
||||
|
||||
/**
|
||||
* Forces sleep timer menu to be enabled.
|
||||
* This method may be deperated in the future.
|
||||
*/
|
||||
SleepTimerFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val insertIndex = implementation!!.instructions.size - 1
|
||||
val targetRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
|
||||
|
||||
addInstruction(
|
||||
insertIndex,
|
||||
"const/4 v$targetRegister, 0x1"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
SettingsPatch.addMusicPreferenceWithoutSummary(
|
||||
CategoryType.FLYOUT,
|
||||
"revanced_hide_flyout_panel_add_to_queue",
|
||||
|
@ -1,4 +1,4 @@
|
||||
package app.revanced.patches.music.flyoutpanel.sleeptimer.fingerprints
|
||||
package app.revanced.patches.music.flyoutpanel.component.fingerprints
|
||||
|
||||
import app.revanced.util.fingerprint.LiteralValueFingerprint
|
||||
|
@ -1,65 +0,0 @@
|
||||
package app.revanced.patches.music.flyoutpanel.sleeptimer
|
||||
|
||||
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.annotation.CompatiblePackage
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patches.music.flyoutpanel.sleeptimer.fingerprints.SleepTimerFingerprint
|
||||
import app.revanced.patches.music.utils.integrations.Constants.FLYOUT
|
||||
import app.revanced.patches.music.utils.settings.CategoryType
|
||||
import app.revanced.patches.music.utils.settings.SettingsPatch
|
||||
import app.revanced.util.exception
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
@Patch(
|
||||
name = "Enable sleep timer",
|
||||
description = "Adds an option to add the sleep timer to the flyout menu.",
|
||||
dependencies = [SettingsPatch::class],
|
||||
compatiblePackages = [
|
||||
CompatiblePackage(
|
||||
"com.google.android.apps.youtube.music",
|
||||
[
|
||||
"6.21.52",
|
||||
"6.22.52",
|
||||
"6.23.56",
|
||||
"6.25.53",
|
||||
"6.26.51",
|
||||
"6.27.54",
|
||||
"6.28.53",
|
||||
"6.29.58",
|
||||
"6.31.55",
|
||||
"6.33.52"
|
||||
]
|
||||
)
|
||||
]
|
||||
)
|
||||
@Suppress("unused")
|
||||
object SleepTimerPatch : BytecodePatch(
|
||||
setOf(SleepTimerFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
SleepTimerFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val insertIndex = implementation!!.instructions.size - 1
|
||||
val targetRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
|
||||
|
||||
addInstructions(
|
||||
insertIndex, """
|
||||
invoke-static {}, $FLYOUT->enableSleepTimer()Z
|
||||
move-result v$targetRegister
|
||||
"""
|
||||
)
|
||||
}
|
||||
} ?: throw SleepTimerFingerprint.exception
|
||||
|
||||
SettingsPatch.addMusicPreference(
|
||||
CategoryType.FLYOUT,
|
||||
"revanced_enable_sleep_timer",
|
||||
"true"
|
||||
)
|
||||
|
||||
}
|
||||
}
|
@ -69,8 +69,6 @@ WARNING: Do not enable "New player background" while this is enabled."</string>
|
||||
<string name="revanced_enable_save_playback_speed_title">Enable save playback speed</string>
|
||||
<string name="revanced_enable_save_video_quality_summary">Remembers the last video quality selected.</string>
|
||||
<string name="revanced_enable_save_video_quality_title">Enable save video quality</string>
|
||||
<string name="revanced_enable_sleep_timer_summary">Adds the sleep timer to the flyout menu.</string>
|
||||
<string name="revanced_enable_sleep_timer_title">Enable sleep timer</string>
|
||||
<string name="revanced_enable_zen_mode_summary">Changes the player background to light grey to reduce eye strain.</string>
|
||||
<string name="revanced_enable_zen_mode_title">Enable zen mode</string>
|
||||
<string name="revanced_extended_settings_export_as_file">Export settings to file</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user