mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-01 23:24:28 +02:00
add enable-zen-mode
patch
This commit is contained in:
parent
33dd92ec93
commit
f31203bfba
@ -0,0 +1,19 @@
|
||||
package app.revanced.patches.music.layout.zenmode.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
object ZenModeFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("L", "J"),
|
||||
opcodes = listOf(
|
||||
Opcode.MOVE_RESULT,
|
||||
Opcode.INVOKE_STATIC,
|
||||
Opcode.MOVE_RESULT,
|
||||
Opcode.GOTO,
|
||||
Opcode.NOP
|
||||
)
|
||||
)
|
@ -0,0 +1,73 @@
|
||||
package app.revanced.patches.music.layout.zenmode.patch
|
||||
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.*
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patches.music.misc.integrations.patch.MusicIntegrationsPatch
|
||||
import app.revanced.patches.music.misc.settings.patch.MusicSettingsPatch
|
||||
import app.revanced.patches.music.layout.zenmode.fingerprints.ZenModeFingerprint
|
||||
import app.revanced.shared.annotation.YouTubeMusicCompatibility
|
||||
import app.revanced.shared.fingerprints.MiniplayerColorParentFingerprint
|
||||
import app.revanced.shared.util.integrations.Constants.MUSIC_SETTINGS_PATH
|
||||
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import org.jf.dexlib2.iface.reference.FieldReference
|
||||
|
||||
@Patch
|
||||
@Name("enable-zen-mode")
|
||||
@Description("Adds a grey tint to the video player to reduce eye strain.")
|
||||
@DependsOn([MusicIntegrationsPatch::class, MusicSettingsPatch::class])
|
||||
@YouTubeMusicCompatibility
|
||||
@Version("0.0.1")
|
||||
class ZenModePatch : BytecodePatch(
|
||||
listOf(
|
||||
ZenModeFingerprint, MiniplayerColorParentFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
|
||||
val miniplayerColorParentResult = MiniplayerColorParentFingerprint.result!!
|
||||
|
||||
ZenModeFingerprint.resolve(context, miniplayerColorParentResult.classDef)
|
||||
val ZenModeResult = ZenModeFingerprint.result!!
|
||||
val ZenModeMethod = ZenModeResult.mutableMethod
|
||||
val ZenModeInstructions = ZenModeMethod.implementation!!.instructions
|
||||
|
||||
val startIndex = ZenModeResult.scanResult.patternScanResult!!.startIndex
|
||||
|
||||
val firstRegister = (ZenModeMethod.instruction(startIndex) as OneRegisterInstruction).registerA
|
||||
val secondRegister = (ZenModeMethod.instruction(startIndex + 2) as OneRegisterInstruction).registerA
|
||||
val dummyRegister = secondRegister + 1
|
||||
|
||||
val referenceIndex = ZenModeResult.scanResult.patternScanResult!!.endIndex + 1
|
||||
val Ref = (ZenModeInstructions.elementAt(referenceIndex) as ReferenceInstruction).reference as FieldReference
|
||||
|
||||
val insertIndex = referenceIndex + 1
|
||||
|
||||
ZenModeMethod.addInstructions(
|
||||
insertIndex, """
|
||||
invoke-static {}, $MUSIC_SETTINGS_PATH->enableZenMode()Z
|
||||
move-result v$dummyRegister
|
||||
if-eqz v$dummyRegister, :off
|
||||
const v$dummyRegister, -0xfcfcfd
|
||||
if-ne v$firstRegister, v$dummyRegister, :off
|
||||
const v$firstRegister, -0xbfbfc0
|
||||
const v$secondRegister, -0xbfbfc0
|
||||
:off
|
||||
sget-object v0, ${Ref.type}->${Ref.name}:${Ref.type}
|
||||
"""
|
||||
)
|
||||
|
||||
ZenModeMethod.removeInstruction(insertIndex - 1)
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
@ -16,6 +16,8 @@
|
||||
<string name="revanced_enable_tablet_mode_summary">"Enable landscape mode on phone.
|
||||
(requires an app restart)"</string>
|
||||
<string name="revanced_enable_tablet_mode_title">Enable tablet mode</string>
|
||||
<string name="revanced_enable_zen_mode_summary">Adds a grey tint to the video player to reduce eye strain.</string>
|
||||
<string name="revanced_enable_zen_mode_title">Enable zen mode</string>
|
||||
<string name="revanced_hide_cast_button_summary">Hides the cast button at the top of the homepage and at the top of the player.</string>
|
||||
<string name="revanced_hide_cast_button_title">Hide cast button</string>
|
||||
<string name="revanced_hide_compact_header_summary">"Hides the music category bar at the top of the homepage.
|
||||
|
@ -8,6 +8,7 @@
|
||||
<com.google.android.apps.youtube.music.ui.preference.PreferenceCategoryCompat android:title="@string/revanced_category_design" android:key="revanced_settings_design">
|
||||
<com.google.android.apps.youtube.music.ui.preference.SwitchCompatPreference android:title="@string/revanced_enable_black_navbar_title" android:key="revanced_enable_black_navbar" android:summary="@string/revanced_enable_black_navbar_summary" android:defaultValue="true" />
|
||||
<com.google.android.apps.youtube.music.ui.preference.SwitchCompatPreference android:title="@string/revanced_enable_color_match_player_title" android:key="revanced_enable_color_match_player" android:summary="@string/revanced_enable_color_match_player_summary" android:defaultValue="true" />
|
||||
<com.google.android.apps.youtube.music.ui.preference.SwitchCompatPreference android:title="@string/revanced_enable_zen_mode_title" android:key="revanced_enable_zen_mode" android:summary="@string/revanced_enable_zen_mode_summary" android:defaultValue="false" />
|
||||
</com.google.android.apps.youtube.music.ui.preference.PreferenceCategoryCompat>
|
||||
<com.google.android.apps.youtube.music.ui.preference.PreferenceCategoryCompat android:title="@string/revanced_category_listening" android:key="revanced_settings_listening">
|
||||
<com.google.android.apps.youtube.music.ui.preference.SwitchCompatPreference android:title="@string/revanced_enable_opus_codec_title" android:key="revanced_enable_opus_codec" android:summary="@string/revanced_enable_opus_codec_summary" android:defaultValue="true" />
|
||||
|
@ -7,6 +7,7 @@
|
||||
<com.google.android.apps.youtube.music.ui.preference.PreferenceCategoryCompat android:title="@string/revanced_category_design" android:key="revanced_settings_design">
|
||||
<com.google.android.apps.youtube.music.ui.preference.SwitchCompatPreference android:title="@string/revanced_enable_black_navbar_title" android:key="revanced_enable_black_navbar" android:summary="@string/revanced_enable_black_navbar_summary" android:defaultValue="true" />
|
||||
<com.google.android.apps.youtube.music.ui.preference.SwitchCompatPreference android:title="@string/revanced_enable_color_match_player_title" android:key="revanced_enable_color_match_player" android:summary="@string/revanced_enable_color_match_player_summary" android:defaultValue="true" />
|
||||
<com.google.android.apps.youtube.music.ui.preference.SwitchCompatPreference android:title="@string/revanced_enable_zen_mode_title" android:key="revanced_enable_zen_mode" android:summary="@string/revanced_enable_zen_mode_summary" android:defaultValue="false" />
|
||||
</com.google.android.apps.youtube.music.ui.preference.PreferenceCategoryCompat>
|
||||
<com.google.android.apps.youtube.music.ui.preference.PreferenceCategoryCompat android:title="@string/revanced_category_listening" android:key="revanced_settings_listening">
|
||||
<com.google.android.apps.youtube.music.ui.preference.SwitchCompatPreference android:title="@string/revanced_enable_opus_codec_title" android:key="revanced_enable_opus_codec" android:summary="@string/revanced_enable_opus_codec_summary" android:defaultValue="true" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user