feat(YouTube Music - Player components): Add settings Change seekbar position and Enable thick seekbar (YouTube Music 7.29.51+, close https://github.com/inotia00/ReVanced_Extended/issues/2770)

This commit is contained in:
inotia00
2025-02-10 17:41:51 +09:00
parent a9258f848d
commit d2ea46a613
6 changed files with 113 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import app.revanced.patches.music.utils.extension.Constants.PLAYER_CLASS_DESCRIP
import app.revanced.patches.music.utils.playservice.is_7_18_or_greater
import app.revanced.patches.music.utils.resourceid.colorGrey
import app.revanced.patches.music.utils.resourceid.darkBackground
import app.revanced.patches.music.utils.resourceid.inlineTimeBarProgressColor
import app.revanced.patches.music.utils.resourceid.miniPlayerDefaultText
import app.revanced.patches.music.utils.resourceid.miniPlayerMdxPlaying
import app.revanced.patches.music.utils.resourceid.miniPlayerPlayPauseReplayButton
@ -359,6 +360,33 @@ internal val switchToggleColorFingerprint = legacyFingerprint(
)
)
internal val thickSeekBarColorFingerprint = legacyFingerprint(
name = "thickSeekBarColorFingerprint",
returnType = "V",
parameters = listOf("L"),
literals = listOf(inlineTimeBarProgressColor),
customFingerprint = { method, _ ->
method.definingClass.endsWith("/MusicPlaybackControls;")
}
)
internal val thickSeekBarFeatureFlagFingerprint = legacyFingerprint(
name = "thickSeekBarFeatureFlagFingerprint",
returnType = "Z",
parameters = emptyList(),
literals = listOf(45659062L),
)
internal val thickSeekBarInflateFingerprint = legacyFingerprint(
name = "thickSeekBarInflateFingerprint",
returnType = "V",
parameters = emptyList(),
customFingerprint = { method, _ ->
method.definingClass.endsWith("/MusicPlaybackControls;") &&
method.name == "onFinishInflate"
}
)
internal val zenModeFingerprint = legacyFingerprint(
name = "zenModeFingerprint",
returnType = "V",

View File

@ -24,6 +24,7 @@ import app.revanced.patches.music.utils.playservice.is_6_27_or_greater
import app.revanced.patches.music.utils.playservice.is_6_42_or_greater
import app.revanced.patches.music.utils.playservice.is_7_18_or_greater
import app.revanced.patches.music.utils.playservice.is_7_25_or_greater
import app.revanced.patches.music.utils.playservice.is_7_29_or_greater
import app.revanced.patches.music.utils.playservice.is_8_03_or_greater
import app.revanced.patches.music.utils.playservice.versionCheckPatch
import app.revanced.patches.music.utils.resourceid.colorGrey
@ -55,6 +56,7 @@ import app.revanced.util.fingerprint.injectLiteralInstructionBooleanCall
import app.revanced.util.fingerprint.injectLiteralInstructionViewCall
import app.revanced.util.fingerprint.matchOrNull
import app.revanced.util.fingerprint.matchOrThrow
import app.revanced.util.fingerprint.methodCall
import app.revanced.util.fingerprint.methodOrThrow
import app.revanced.util.fingerprint.mutableClassOrThrow
import app.revanced.util.fingerprint.resolvable
@ -71,6 +73,7 @@ import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.Method
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.Instruction
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
@ -488,6 +491,52 @@ val playerComponentsPatch = bytecodePatch(
// endregion
// region patch for enable thick seek bar
var thickSeekBar = false
fun MutableMethod.thickSeekBarHook(index: Int, methodName: String = "enableThickSeekBar") {
val register = getInstruction<OneRegisterInstruction>(index + 1).registerA
addInstructions(
index + 2, """
invoke-static {v$register}, $PLAYER_CLASS_DESCRIPTOR->$methodName(Z)Z
move-result v$register
"""
)
}
if (is_7_25_or_greater) {
val thickSeekBarMethodCall = thickSeekBarFeatureFlagFingerprint.methodCall()
val filter: Instruction.() -> Boolean = {
opcode == Opcode.INVOKE_VIRTUAL &&
getReference<MethodReference>()?.toString() == thickSeekBarMethodCall
}
thickSeekBarInflateFingerprint.methodOrThrow().apply {
val indexes = findInstructionIndicesReversed(filter)
thickSeekBarHook(indexes.first(), "changeSeekBarPosition")
thickSeekBarHook(indexes.last())
}
if (is_7_29_or_greater) {
thickSeekBarColorFingerprint.methodOrThrow().apply {
findInstructionIndicesReversed(filter).forEach { thickSeekBarHook(it) }
}
}
addSwitchPreference(
CategoryType.PLAYER,
"revanced_change_seekbar_position",
"false"
)
thickSeekBar = true
}
// endregion
// region patch for disable gesture in player
val playerViewPagerConstructorMethod =
@ -721,6 +770,14 @@ val playerComponentsPatch = bytecodePatch(
// endregion
if (thickSeekBar) {
addSwitchPreference(
CategoryType.PLAYER,
"revanced_enable_thick_seekbar",
"true"
)
}
// region patch for enable zen mode (~ 6.34)
// this method is used for old player background (deprecated since YT Music v6.34.51)

View File

@ -43,6 +43,8 @@ var historyMenuItem = -1L
private set
var inlineTimeBarAdBreakMarkerColor = -1L
private set
var inlineTimeBarProgressColor = -1L
private set
var interstitialsContainer = -1L
private set
var isTablet = -1L
@ -174,6 +176,10 @@ internal val sharedResourceIdPatch = resourcePatch(
COLOR,
"inline_time_bar_ad_break_marker_color"
]
inlineTimeBarProgressColor = resourceMappings[
COLOR,
"inline_time_bar_progress_color"
]
interstitialsContainer = resourceMappings[
ID,
"interstitials_container"