mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-21 16:57:18 +02:00
feat(youtube/custom-seekbar-color): change chapter seekbar color when quickly touching and seeking
This commit is contained in:
parent
3c6c7d3965
commit
9eb15b2e34
@ -9,7 +9,7 @@ object SeekbarColorFingerprint : MethodFingerprint(
|
||||
customFingerprint = { methodDef ->
|
||||
methodDef.implementation?.instructions?.any {
|
||||
it.opcode.ordinal == Opcode.CONST.ordinal &&
|
||||
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.timeBarPlayedDarkLabelId
|
||||
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.inlineTimeBarColorizedBarPlayedColorDarkId
|
||||
} == true
|
||||
}
|
||||
)
|
@ -6,11 +6,13 @@ import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.addInstruction
|
||||
import app.revanced.patcher.extensions.addInstructions
|
||||
import app.revanced.patcher.extensions.instruction
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||
import app.revanced.patches.shared.annotation.YouTubeCompatibility
|
||||
import app.revanced.patches.shared.fingerprints.ControlsOverlayStyleFingerprint
|
||||
import app.revanced.patches.youtube.layout.seekbar.seekbarcolor.bytecode.fingerprints.*
|
||||
@ -40,30 +42,36 @@ class SeekbarColorBytecodePatch : BytecodePatch(
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
SeekbarColorFingerprint.result?.mutableMethod?.let { method ->
|
||||
with (method.implementation!!.instructions) {
|
||||
val insertIndex = this.indexOfFirst {
|
||||
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.timeBarPlayedDarkLabelId
|
||||
} + 2
|
||||
val insertIndex = arrayOf(
|
||||
SharedResourceIdPatch.inlineTimeBarColorizedBarPlayedColorDarkId,
|
||||
SharedResourceIdPatch.inlineTimeBarPlayedNotHighlightedColorId
|
||||
).map { id ->
|
||||
this.indexOfFirst {
|
||||
(it as? WideLiteralInstruction)?.wideLiteral == id
|
||||
} + 2
|
||||
}
|
||||
|
||||
val insertRegister = (elementAt(insertIndex) as OneRegisterInstruction).registerA
|
||||
|
||||
method.addInstructions(
|
||||
insertIndex + 1, """
|
||||
invoke-static {v$insertRegister}, $SEEKBAR->enableCustomSeekbarColorDarkMode(I)I
|
||||
move-result v$insertRegister
|
||||
"""
|
||||
)
|
||||
method.hook(insertIndex[0])
|
||||
method.hook(insertIndex[1])
|
||||
}
|
||||
} ?: return SeekbarColorFingerprint.toErrorResult()
|
||||
|
||||
ControlsOverlayStyleFingerprint.result?.let { parentResult ->
|
||||
ProgressColorFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.mutableMethod?.addInstructions(
|
||||
0, """
|
||||
invoke-static {p1}, $SEEKBAR->enableCustomSeekbarColor(I)I
|
||||
invoke-static {p1}, $SEEKBAR->getSeekbarClickedColorValue(I)I
|
||||
move-result p1
|
||||
"""
|
||||
) ?: return ProgressColorFingerprint.toErrorResult()
|
||||
} ?: return ControlsOverlayStyleFingerprint.toErrorResult()
|
||||
|
||||
|
||||
/**
|
||||
* Context called when playing a video in the PlayStore
|
||||
* If this context is not overridden, Exception occurs when reading a value from SharedPreference (ROOT Build)
|
||||
*
|
||||
* TODO: merging into abstract integrations patch
|
||||
*/
|
||||
ControlsOverlayParentFingerprint.result?.let { parentResult ->
|
||||
ControlsOverlayFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.mutableMethod?.addInstruction(
|
||||
0,
|
||||
@ -75,4 +83,17 @@ class SeekbarColorBytecodePatch : BytecodePatch(
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
private companion object {
|
||||
fun MutableMethod.hook(insertIndex: Int) {
|
||||
val insertRegister = (instruction(insertIndex) as OneRegisterInstruction).registerA
|
||||
|
||||
addInstructions(
|
||||
insertIndex + 1, """
|
||||
invoke-static {v$insertRegister}, $SEEKBAR->overrideSeekbarColor(I)I
|
||||
move-result v$insertRegister
|
||||
"""
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,8 @@ class SharedResourceIdPatch : ResourcePatch {
|
||||
var filterBarHeightLabelId: Long = -1
|
||||
var floatyBarTopMarginLabelId: Long = -1
|
||||
var imageOnlyTabId: Long = -1
|
||||
var inlineTimeBarColorizedBarPlayedColorDarkId: Long = -1
|
||||
var inlineTimeBarPlayedNotHighlightedColorId: Long = -1
|
||||
var layoutCircle: Long = -1
|
||||
var layoutIcon: Long = -1
|
||||
var layoutVideo: Long = -1
|
||||
@ -50,7 +52,6 @@ class SharedResourceIdPatch : ResourcePatch {
|
||||
var searchSuggestionEntryLabelId: Long = -1
|
||||
var scrubbingLabelId: Long = -1
|
||||
var slimMetadataToggleButtonLabelId: Long = -1
|
||||
var timeBarPlayedDarkLabelId: Long = -1
|
||||
var tooltipLabelId: Long = -1
|
||||
var videoQualityFragmentLabelId: Long = -1
|
||||
}
|
||||
@ -77,6 +78,8 @@ class SharedResourceIdPatch : ResourcePatch {
|
||||
filterBarHeightLabelId = find(DIMEN, "filter_bar_height")
|
||||
floatyBarTopMarginLabelId = find(DIMEN, "floaty_bar_button_top_margin")
|
||||
imageOnlyTabId = find(LAYOUT, "image_only_tab")
|
||||
inlineTimeBarColorizedBarPlayedColorDarkId = find(COLOR, "inline_time_bar_colorized_bar_played_color_dark")
|
||||
inlineTimeBarPlayedNotHighlightedColorId = find(COLOR, "inline_time_bar_played_not_highlighted_color")
|
||||
layoutCircle = find(LAYOUT, "endscreen_element_layout_circle")
|
||||
layoutIcon = find(LAYOUT, "endscreen_element_layout_icon")
|
||||
layoutVideo = find(LAYOUT, "endscreen_element_layout_video")
|
||||
@ -93,7 +96,6 @@ class SharedResourceIdPatch : ResourcePatch {
|
||||
searchSuggestionEntryLabelId = find(LAYOUT, "search_suggestion_entry")
|
||||
scrubbingLabelId = find(DIMEN, "vertical_touch_offset_to_enter_fine_scrubbing")
|
||||
slimMetadataToggleButtonLabelId = find(COLOR, "slim_metadata_toggle_button")
|
||||
timeBarPlayedDarkLabelId = find(COLOR, "inline_time_bar_colorized_bar_played_color_dark")
|
||||
tooltipLabelId = find(LAYOUT, "tooltip_content_view")
|
||||
videoQualityFragmentLabelId = find(LAYOUT, "video_quality_bottom_sheet_list_fragment_title")
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user