feat(YouTube/Enable tablet mini player): add Hide rewind and forward button settings

This commit is contained in:
inotia00
2024-04-29 23:40:12 +09:00
parent 8417398042
commit df5b0c271b
6 changed files with 67 additions and 14 deletions

View File

@ -14,6 +14,8 @@ import app.revanced.patches.youtube.general.tabletminiplayer.fingerprints.Modern
import app.revanced.patches.youtube.utils.integrations.Constants.COMPATIBLE_PACKAGE
import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL_CLASS_DESCRIPTOR
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ModernMiniPlayerForwardButton
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ModernMiniPlayerRewindButton
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.YtOutlinePiPWhite
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.YtOutlineXWhite
import app.revanced.patches.youtube.utils.settings.SettingsPatch
@ -25,6 +27,7 @@ import app.revanced.util.getTargetIndexReversed
import app.revanced.util.getWalkerMethod
import app.revanced.util.indexOfFirstInstruction
import app.revanced.util.literalInstructionHook
import app.revanced.util.literalInstructionViewHook
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode
@ -93,6 +96,17 @@ object TabletMiniPlayerPatch : BaseBytecodePatch(
context.literalInstructionHook(literal, smaliInstruction)
}
arrayOf(
ModernMiniPlayerForwardButton,
ModernMiniPlayerRewindButton
).forEach { literal ->
val smaliInstruction = """
invoke-static {v$REGISTER_TEMPLATE_REPLACEMENT}, $GENERAL_CLASS_DESCRIPTOR->hideRewindAndForwardButton(Landroid/view/View;)V
"""
context.literalInstructionViewHook(literal, smaliInstruction)
}
SettingsPatch.addPreference(
arrayOf(
"SETTINGS: ENABLE_MODERN_MINI_PLAYER"

View File

@ -13,8 +13,9 @@ import app.revanced.patches.youtube.utils.playertype.PlayerTypeHookPatch
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.BottomSheetFooterText
import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.REGISTER_TEMPLATE_REPLACEMENT
import app.revanced.util.literalInstructionBooleanHook
import app.revanced.util.literalInstructionHook
import app.revanced.util.literalInstructionViewHook
import app.revanced.util.patch.BaseBytecodePatch
@Suppress("unused")
@ -45,7 +46,10 @@ object PlayerFlyoutMenuPatch : BaseBytecodePatch(
CaptionsBottomSheetFingerprint to "hideFooterCaptions",
QualityMenuViewInflateFingerprint to "hideFooterQuality"
).map { (fingerprint, name) ->
fingerprint.literalInstructionHook(BottomSheetFooterText, "$PLAYER_CLASS_DESCRIPTOR->$name(Landroid/view/View;)V")
val smaliInstruction = """
invoke-static {v$REGISTER_TEMPLATE_REPLACEMENT}, $PLAYER_CLASS_DESCRIPTOR->$name(Landroid/view/View;)V
"""
fingerprint.literalInstructionViewHook(BottomSheetFooterText, smaliInstruction)
}
LithoFilterPatch.addFilter(PANELS_FILTER_CLASS_DESCRIPTOR)

View File

@ -63,6 +63,8 @@ object SharedResourceIdPatch : ResourcePatch() {
var InsetOverlayViewLayout = -1L
var InterstitialsContainer = -1L
var MenuItemView = -1L
var ModernMiniPlayerForwardButton = -1L
var ModernMiniPlayerRewindButton = -1L
var MusicAppDeeplinkButtonView = -1L
var PanelSubHeader = -1L
var PlayerCollapseButton = -1L
@ -147,6 +149,8 @@ object SharedResourceIdPatch : ResourcePatch() {
InsetOverlayViewLayout = getId(ID, "inset_overlay_view_layout")
InterstitialsContainer = getId(ID, "interstitials_container")
MenuItemView = getId(ID, "menu_item_view")
ModernMiniPlayerForwardButton = getId(ID, "modern_miniplayer_forward_button")
ModernMiniPlayerRewindButton = getId(ID, "modern_miniplayer_rewind_button")
MusicAppDeeplinkButtonView = getId(ID, "music_app_deeplink_button_view")
PanelSubHeader = getId(ID, "panel_subheader")
PlayerCollapseButton = getId(ID, "player_collapse_button")