fix minimal miniplayer using incorrectly sized bold icons

This commit is contained in:
LisoUseInAIKyrios
2025-10-20 11:40:37 +04:00
parent 5449357f7f
commit 0389073600
3 changed files with 49 additions and 1 deletions

View File

@@ -379,6 +379,19 @@ public final class MiniplayerPatch {
return original;
}
/**
* Injection point.
*/
public static boolean allowBoldIcons(boolean original) {
if (CURRENT_TYPE == MINIMAL) {
// Minimal player does not have the correct pause/play icon (it's too large).
// Use the non bold icons instead.
return false;
}
return original;
}
/**
* Injection point.
*/

View File

@@ -207,3 +207,13 @@ internal val playerOverlaysLayoutFingerprint by fingerprint {
method.definingClass == YOUTUBE_PLAYER_OVERLAYS_LAYOUT_CLASS_NAME
}
}
internal val miniplayerSetIconsFingerprint by fingerprint {
returns("V")
parameters("I", "Ljava/lang/Runnable;")
instructions(
resourceLiteral(ResourceType.DRAWABLE, "yt_fill_pause_white_36"),
resourceLiteral(ResourceType.DRAWABLE, "yt_fill_pause_black_36")
)
}

View File

@@ -29,6 +29,7 @@ import com.android.tools.smali.dexlib2.iface.Method
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
import com.android.tools.smali.dexlib2.immutable.ImmutableMethod
import com.android.tools.smali.dexlib2.immutable.ImmutableMethodParameter
@@ -321,7 +322,7 @@ val miniplayerPatch = bytecodePatch(
"""
invoke-static { v$register }, $EXTENSION_CLASS_DESCRIPTOR->getMiniplayerDefaultSize(I)I
move-result v$register
""",
"""
)
}
@@ -386,6 +387,30 @@ val miniplayerPatch = bytecodePatch(
// endregion
// region fix minimal miniplayer using the wrong pause/play bold icons.
if (is_20_31_or_greater) {
miniplayerSetIconsFingerprint.method.apply {
findInstructionIndicesReversedOrThrow {
val reference = getReference<MethodReference>()
opcode == Opcode.INVOKE_INTERFACE
&& reference?.returnType == "Z" && reference.parameterTypes.isEmpty()
}.forEach { index ->
val register = getInstruction<OneRegisterInstruction>(index + 1).registerA
addInstructions(
index + 2,
"""
invoke-static { v$register }, $EXTENSION_CLASS_DESCRIPTOR->allowBoldIcons(Z)Z
move-result v$register
"""
)
}
}
}
// endregion
// region Add hooks to hide modern miniplayer buttons.
listOf(