refactor(youtube): renamed some patches description

This commit is contained in:
inotia00
2023-06-28 21:48:19 +09:00
parent 5dff2ac118
commit 32ed7f245d
15 changed files with 125 additions and 218 deletions

View File

@ -28,7 +28,7 @@ import app.revanced.util.integrations.Constants.MUSIC_MISC_PATH
@Patch
@Name("share-button-hook")
@Description("Replace share button with external download button or sleep timer dialog.")
@Description("Replace share button with external download button.")
@DependsOn(
[
SettingsPatch::class,

View File

@ -12,7 +12,6 @@ import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.AdAttribution
import app.revanced.util.bytecode.BytecodeHelper.updatePatchStatus
import app.revanced.util.bytecode.getWideLiteralIndex
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.iface.instruction.formats.Instruction35c
@ -48,8 +47,6 @@ class GeneralAdsBytecodePatch : BytecodePatch() {
}
}
context.updatePatchStatus("GeneralAds")
return PatchResultSuccess()
}
}

View File

@ -53,6 +53,7 @@ class OldQualityLayoutPatch : BytecodePatch(
SettingsPatch.addPreference(
arrayOf(
"PREFERENCE: FLYOUT_PANEL_SETTINGS",
"SETTINGS: PLAYER_FLYOUT_PANEL_HEADER",
"SETTINGS: ENABLE_OLD_QUALITY_LAYOUT"
)
)

View File

@ -1,4 +1,4 @@
package app.revanced.patches.youtube.flyoutpanel.general.patch
package app.revanced.patches.youtube.flyoutpanel.player.patch
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
@ -15,8 +15,8 @@ import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
import app.revanced.util.integrations.Constants.PATCHES_PATH
@Patch
@Name("hide-flyout-panel")
@Description("Adds options to hide player settings flyout panel.")
@Name("hide-player-flyout-panel")
@Description("Hides player flyout panel components.")
@DependsOn(
[
LithoFilterPatch::class,
@ -25,9 +25,9 @@ import app.revanced.util.integrations.Constants.PATCHES_PATH
)
@YouTubeCompatibility
@Version("0.0.1")
class FlyoutPanelPatch : ResourcePatch {
class PlayerFlyoutPanelPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
LithoFilterPatch.addFilter("$PATCHES_PATH/ads/FlyoutPanelsFilter;")
LithoFilterPatch.addFilter("$PATCHES_PATH/ads/PlayerFlyoutPanelsFilter;")
/**
* Add settings
@ -35,11 +35,12 @@ class FlyoutPanelPatch : ResourcePatch {
SettingsPatch.addPreference(
arrayOf(
"PREFERENCE: FLYOUT_PANEL_SETTINGS",
"SETTINGS: FLYOUT_PANEL_COMPONENT"
"SETTINGS: PLAYER_FLYOUT_PANEL_HEADER",
"SETTINGS: HIDE_PLAYER_FLYOUT_PANEL"
)
)
SettingsPatch.updatePatchStatus("hide-flyout-panel")
SettingsPatch.updatePatchStatus("hide-player-flyout-panel")
return PatchResultSuccess()
}

View File

@ -3,15 +3,16 @@ package app.revanced.patches.youtube.general.layout.patch
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.litho.patch.LithoFilterPatch
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
import app.revanced.util.bytecode.BytecodeHelper.updatePatchStatus
import app.revanced.util.integrations.Constants.PATCHES_PATH
@Patch
@ -25,8 +26,8 @@ import app.revanced.util.integrations.Constants.PATCHES_PATH
)
@YouTubeCompatibility
@Version("0.0.1")
class LayoutComponentsPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
class LayoutComponentsPatch : BytecodePatch() {
override fun execute(context: BytecodeContext): PatchResult {
LithoFilterPatch.addFilter("$PATCHES_PATH/ads/CommunityPostFilter;")
LithoFilterPatch.addFilter("$PATCHES_PATH/ads/LayoutComponentsFilter;")
@ -45,6 +46,8 @@ class LayoutComponentsPatch : ResourcePatch {
SettingsPatch.updatePatchStatus("hide-layout-components")
context.updatePatchStatus("LayoutComponent")
return PatchResultSuccess()
}
}

View File

@ -29,7 +29,7 @@ import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@Patch
@Name("enable-tablet-miniplayer")
@Name("enable-tablet-mini-player")
@Description("Enables the tablet mini player layout.")
@DependsOn(
[
@ -85,7 +85,7 @@ class TabletMiniPlayerPatch : BytecodePatch(
)
)
SettingsPatch.updatePatchStatus("enable-tablet-miniplayer")
SettingsPatch.updatePatchStatus("enable-tablet-mini-player")
return PatchResultSuccess()
}

View File

@ -1,101 +0,0 @@
package app.revanced.patches.youtube.general.widesearchbar.patch
import app.revanced.extensions.toErrorResult
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.data.toMethodWalker
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
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.patch.annotations.Patch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.youtube.general.widesearchbar.fingerprints.SetActionBarRingoFingerprint
import app.revanced.patches.youtube.utils.fingerprints.SetToolBarPaddingFingerprint
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch.Companion.contexts
import app.revanced.util.integrations.Constants.GENERAL
@Patch
@Name("enable-wide-searchbar")
@Description("Replaces the search icon with a wide search bar. This will hide the YouTube logo when active.")
@DependsOn(
[
SettingsPatch::class,
SharedResourceIdPatch::class
]
)
@YouTubeCompatibility
@Version("0.0.1")
class WideSearchbarPatch : BytecodePatch(
listOf(
SetActionBarRingoFingerprint,
SetToolBarPaddingFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
arrayOf(
SetActionBarRingoFingerprint,
SetToolBarPaddingFingerprint
).forEach {
it.injectHook(context)
}
/**
* Set Wide SearchBar Start Margin
*/
contexts.xmlEditor[TARGET_RESOURCE_PATH].use { editor ->
val document = editor.file
with(document.getElementsByTagName("RelativeLayout").item(0)) {
if (attributes.getNamedItem(FLAG) != null) return@with
document.createAttribute(FLAG)
.apply { value = "8.0dip" }
.let(attributes::setNamedItem)
}
}
/**
* Add settings
*/
SettingsPatch.addPreference(
arrayOf(
"PREFERENCE: GENERAL_SETTINGS",
"SETTINGS: ENABLE_WIDE_SEARCHBAR"
)
)
SettingsPatch.updatePatchStatus("enable-wide-searchbar")
return PatchResultSuccess()
}
private companion object {
const val FLAG = "android:paddingStart"
const val TARGET_RESOURCE_PATH = "res/layout/action_bar_ringo_background.xml"
fun MethodFingerprint.injectHook(context: BytecodeContext) {
result?.let {
(context
.toMethodWalker(it.method)
.nextMethod(it.scanResult.patternScanResult!!.endIndex, true)
.getMethod() as MutableMethod).apply {
addInstructions(
implementation!!.instructions.size - 1, """
invoke-static {}, $GENERAL->enableWideSearchbar()Z
move-result p0
"""
)
}
} ?: throw toErrorResult()
}
}
}

View File

@ -4,6 +4,6 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.ReelPlayerBadge
import app.revanced.util.bytecode.isWideLiteralExists
object ShortsPaidContentFingerprint : MethodFingerprint(
object ShortsPaidPromotionFingerprint : MethodFingerprint(
customFingerprint = { methodDef, _ -> methodDef.isWideLiteralExists(ReelPlayerBadge) }
)

View File

@ -32,7 +32,7 @@ import app.revanced.util.integrations.Constants.PATCHES_PATH
ShortsInfoPanelPatch::class,
ShortsLikeButtonPatch::class,
ShortsNavigationBarPatch::class,
ShortsPaidContentBannerPatch::class,
ShortsPaidPromotionBannerPatch::class,
ShortsRemixButtonPatch::class,
ShortsShareButtonPatch::class,
ShortsSubscriptionsButtonPatch::class,

View File

@ -10,7 +10,7 @@ import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.youtube.shorts.shortscomponent.fingerprints.ShortsPaidContentFingerprint
import app.revanced.patches.youtube.shorts.shortscomponent.fingerprints.ShortsPaidPromotionFingerprint
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.ReelPlayerBadge
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.ReelPlayerBadge2
@ -18,14 +18,14 @@ import app.revanced.util.bytecode.getWideLiteralIndex
import app.revanced.util.integrations.Constants.SHORTS
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@Name("hide-shorts-paid-content")
@Name("hide-shorts-paid-promotion")
@YouTubeCompatibility
@Version("0.0.1")
class ShortsPaidContentBannerPatch : BytecodePatch(
listOf(ShortsPaidContentFingerprint)
class ShortsPaidPromotionBannerPatch : BytecodePatch(
listOf(ShortsPaidPromotionFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
ShortsPaidContentFingerprint.result?.let {
ShortsPaidPromotionFingerprint.result?.let {
it.mutableMethod.apply {
val primaryIndex = getWideLiteralIndex(ReelPlayerBadge) + 3
val secondaryIndex = getWideLiteralIndex(ReelPlayerBadge2) + 3
@ -38,7 +38,7 @@ class ShortsPaidContentBannerPatch : BytecodePatch(
insertHook(primaryIndex)
}
}
} ?: return ShortsPaidContentFingerprint.toErrorResult()
} ?: return ShortsPaidPromotionFingerprint.toErrorResult()
return PatchResultSuccess()
}
@ -49,7 +49,7 @@ class ShortsPaidContentBannerPatch : BytecodePatch(
addInstructions(
insertIndex + 1, """
invoke-static {v$insertRegister}, $SHORTS->hideShortsPlayerPaidContent(Landroid/view/ViewStub;)Landroid/view/ViewStub;
invoke-static {v$insertRegister}, $SHORTS->hideShortsPlayerPaidPromotionBanner(Landroid/view/ViewStub;)Landroid/view/ViewStub;
move-result-object v$insertRegister
"""
)

View File

@ -7,5 +7,5 @@ import org.jf.dexlib2.AccessFlags
object WatchWhileActivityFingerprint : MethodFingerprint(
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
parameters = emptyList(),
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("WatchWhileActivity;") && methodDef.name == "<init>" }
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("WatchWhileActivity;") }
)

View File

@ -39,7 +39,7 @@ class LithoFilterPatch : BytecodePatch(
ByteBufferFingerprint.result?.mutableMethod?.addInstruction(
0,
"sput-object p0, $ADS_PATH/ByteBufferFilterPatch;->bytebuffer:Ljava/nio/ByteBuffer;"
"sput-object p0, $ADS_PATH/LowLevelFilter;->byteBuffer:Ljava/nio/ByteBuffer;"
) ?: return ByteBufferFingerprint.toErrorResult()
generalHook("$ADS_PATH/LithoFilterPatch;->filters")