refactor(settings): remove 'layout' label in string resource and code

This commit is contained in:
inotia00
2023-04-02 14:49:32 +09:00
parent 359e6e4dae
commit f690160996
67 changed files with 264 additions and 250 deletions

View File

@ -18,7 +18,7 @@ import app.revanced.patches.youtube.layout.general.accountmenu.fingerprints.Acco
import app.revanced.patches.youtube.layout.general.accountmenu.fingerprints.AccountMenuParentFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.util.integrations.Constants.GENERAL_LAYOUT
import app.revanced.util.integrations.Constants.GENERAL
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@Patch
@ -47,7 +47,7 @@ class AccountMenuPatch : BytecodePatch(
addInstruction(
targetIndex + 1,
"invoke-static {v$register}, $GENERAL_LAYOUT->hideAccountMenu(Landroid/text/Spanned;)V"
"invoke-static {v$register}, $GENERAL->hideAccountMenu(Landroid/text/Spanned;)V"
)
}
} ?: return AccountMenuFingerprint.toErrorResult()
@ -58,7 +58,7 @@ class AccountMenuPatch : BytecodePatch(
addInstruction(
endIndex + 1,
"sput-object v$register, $GENERAL_LAYOUT->compactLink:Landroid/view/View;"
"sput-object v$register, $GENERAL->compactLink:Landroid/view/View;"
)
}
} ?: return AccountMenuParentFingerprint.toErrorResult()
@ -68,7 +68,7 @@ class AccountMenuPatch : BytecodePatch(
*/
SettingsPatch.addPreference(
arrayOf(
"PREFERENCE: GENERAL_LAYOUT_SETTINGS",
"PREFERENCE: GENERAL_SETTINGS",
"SETTINGS: HIDE_ACCOUNT_MENU"
)
)

View File

@ -20,7 +20,7 @@ import app.revanced.patches.shared.fingerprints.SubtitleTrackFingerprint
import app.revanced.patches.youtube.layout.general.autocaptions.fingerprints.StartVideoInformerFingerprint
import app.revanced.patches.youtube.misc.playertype.patch.PlayerTypeHookPatch
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.util.integrations.Constants.GENERAL_LAYOUT
import app.revanced.util.integrations.Constants.GENERAL
@Patch
@Name("hide-auto-captions")
@ -50,7 +50,7 @@ class AutoCaptionsPatch : BytecodePatch(
0,
"""
const/4 v0, ${status.value}
sput-boolean v0, $GENERAL_LAYOUT->captionsButtonStatus:Z
sput-boolean v0, $GENERAL->captionsButtonStatus:Z
"""
)
}
@ -59,10 +59,10 @@ class AutoCaptionsPatch : BytecodePatch(
SubtitleTrackFingerprint.result?.mutableMethod?.let {
it.addInstructions(
0, """
invoke-static {}, $GENERAL_LAYOUT->hideAutoCaptions()Z
invoke-static {}, $GENERAL->hideAutoCaptions()Z
move-result v0
if-eqz v0, :auto_captions_shown
sget-boolean v0, $GENERAL_LAYOUT->captionsButtonStatus:Z
sget-boolean v0, $GENERAL->captionsButtonStatus:Z
if-nez v0, :auto_captions_shown
const/4 v0, 0x1
return v0
@ -75,7 +75,7 @@ class AutoCaptionsPatch : BytecodePatch(
*/
SettingsPatch.addPreference(
arrayOf(
"PREFERENCE: GENERAL_LAYOUT_SETTINGS",
"PREFERENCE: GENERAL_SETTINGS",
"SETTINGS: HIDE_AUTO_CAPTIONS"
)
)

View File

@ -16,7 +16,7 @@ import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.layout.general.autopopuppanels.fingerprints.EngagementPanelControllerFingerprint
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.util.integrations.Constants.GENERAL_LAYOUT
import app.revanced.util.integrations.Constants.GENERAL
@Patch
@Name("hide-auto-player-popup-panels")
@ -34,7 +34,7 @@ class PlayerPopupPanelsPatch : BytecodePatch(
EngagementPanelControllerFingerprint.result?.mutableMethod?.let {
it.addInstructions(
0, """
invoke-static {}, $GENERAL_LAYOUT->hideAutoPlayerPopupPanels()Z
invoke-static {}, $GENERAL->hideAutoPlayerPopupPanels()Z
move-result v0
if-eqz v0, :player_popup_panels_shown
if-eqz p4, :player_popup_panels_shown
@ -49,7 +49,7 @@ class PlayerPopupPanelsPatch : BytecodePatch(
*/
SettingsPatch.addPreference(
arrayOf(
"PREFERENCE: GENERAL_LAYOUT_SETTINGS",
"PREFERENCE: GENERAL_SETTINGS",
"SETTINGS: HIDE_AUTO_PLAYER_POPUP_PANELS"
)
)

View File

@ -19,7 +19,7 @@ import app.revanced.patches.youtube.layout.general.categorybar.fingerprints.Rela
import app.revanced.patches.youtube.layout.general.categorybar.fingerprints.SearchResultsChipBarFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.util.integrations.Constants.GENERAL_LAYOUT
import app.revanced.util.integrations.Constants.GENERAL
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction
@ -54,7 +54,7 @@ class CategoryBarPatch : BytecodePatch(
addInstructions(
insertIndex, """
invoke-static {v$register}, $GENERAL_LAYOUT->hideCategoryBarInFeed(I)I
invoke-static {v$register}, $GENERAL->hideCategoryBarInFeed(I)I
move-result v$register
"""
)
@ -71,7 +71,7 @@ class CategoryBarPatch : BytecodePatch(
addInstruction(
insertIndex + 1,
"invoke-static {v$register}, $GENERAL_LAYOUT->hideCategoryBarInRelatedVideo(Landroid/view/View;)V"
"invoke-static {v$register}, $GENERAL->hideCategoryBarInRelatedVideo(Landroid/view/View;)V"
)
}
} ?: return RelatedChipCloudFingerprint.toErrorResult()
@ -86,7 +86,7 @@ class CategoryBarPatch : BytecodePatch(
addInstructions(
targetIndex + 1, """
invoke-static {v$register}, $GENERAL_LAYOUT->hideCategoryBarInSearchResults(I)I
invoke-static {v$register}, $GENERAL->hideCategoryBarInSearchResults(I)I
move-result v$register
"""
)
@ -98,7 +98,7 @@ class CategoryBarPatch : BytecodePatch(
*/
SettingsPatch.addPreference(
arrayOf(
"PREFERENCE: GENERAL_LAYOUT_SETTINGS",
"PREFERENCE: GENERAL_SETTINGS",
"SETTINGS: HIDE_CATEGORY_BAR"
)
)

View File

@ -16,7 +16,7 @@ import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.layout.general.channellistsubmenu.fingerprints.ChannelListSubMenuFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.util.integrations.Constants.GENERAL_LAYOUT
import app.revanced.util.integrations.Constants.GENERAL
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@Patch
@ -44,7 +44,7 @@ class ChannelListSubMenuPatch : BytecodePatch(
addInstruction(
endIndex + 1,
"invoke-static {v$register}, $GENERAL_LAYOUT->hideChannelListSubMenu(Landroid/view/View;)V"
"invoke-static {v$register}, $GENERAL->hideChannelListSubMenu(Landroid/view/View;)V"
)
}
} ?: return ChannelListSubMenuFingerprint.toErrorResult()
@ -54,7 +54,7 @@ class ChannelListSubMenuPatch : BytecodePatch(
*/
SettingsPatch.addPreference(
arrayOf(
"PREFERENCE: GENERAL_LAYOUT_SETTINGS",
"PREFERENCE: GENERAL_SETTINGS",
"SETTINGS: HIDE_CHANNEL_LIST_SUBMENU"
)
)

View File

@ -16,7 +16,7 @@ import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.layout.general.crowdfundingbox.fingerprints.CrowdfundingBoxFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.util.integrations.Constants.GENERAL_LAYOUT
import app.revanced.util.integrations.Constants.GENERAL
import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction
@Patch
@ -44,7 +44,7 @@ class CrowdfundingBoxPatch : BytecodePatch(
addInstruction(
insertIndex,
"invoke-static {v$register}, $GENERAL_LAYOUT->hideCrowdfundingBox(Landroid/view/View;)V"
"invoke-static {v$register}, $GENERAL->hideCrowdfundingBox(Landroid/view/View;)V"
)
}
} ?: return CrowdfundingBoxFingerprint.toErrorResult()
@ -54,7 +54,7 @@ class CrowdfundingBoxPatch : BytecodePatch(
*/
SettingsPatch.addPreference(
arrayOf(
"PREFERENCE: GENERAL_LAYOUT_SETTINGS",
"PREFERENCE: GENERAL_SETTINGS",
"SETTINGS: HIDE_CROWDFUNDING_BOX"
)
)

View File

@ -16,7 +16,7 @@ import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.layout.general.floatingmicrophone.fingerprints.FloatingMicrophoneFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.util.integrations.Constants.GENERAL_LAYOUT
import app.revanced.util.integrations.Constants.GENERAL
import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction
@Patch
@ -44,7 +44,7 @@ class FloatingMicrophonePatch : BytecodePatch(
addInstructions(
insertIndex + 1, """
invoke-static {v$register}, $GENERAL_LAYOUT->hideFloatingMicrophone(Z)Z
invoke-static {v$register}, $GENERAL->hideFloatingMicrophone(Z)Z
move-result v$register
"""
)
@ -56,7 +56,7 @@ class FloatingMicrophonePatch : BytecodePatch(
*/
SettingsPatch.addPreference(
arrayOf(
"PREFERENCE: GENERAL_LAYOUT_SETTINGS",
"PREFERENCE: GENERAL_SETTINGS",
"SETTINGS: HIDE_FLOATING_MICROPHONE"
)
)

View File

@ -15,6 +15,7 @@ import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.shared.patch.mapping.ResourceMappingPatch
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.util.integrations.Constants.GENERAL
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.formats.Instruction31i
@ -56,7 +57,7 @@ class HeaderSwitchPatch : BytecodePatch() {
mutableMethod.addInstructions(
insertIndex, """
invoke-static {v$viewRegister}, Lapp/revanced/integrations/patches/layout/GeneralLayoutPatch;->enablePremiumHeader(I)I
invoke-static {v$viewRegister}, $GENERAL->enablePremiumHeader(I)I
move-result v$viewRegister
"""
)
@ -80,7 +81,7 @@ class HeaderSwitchPatch : BytecodePatch() {
*/
SettingsPatch.addPreference(
arrayOf(
"PREFERENCE: GENERAL_LAYOUT_SETTINGS",
"PREFERENCE: GENERAL_SETTINGS",
"SETTINGS: HEADER_SWITCH"
)
)

View File

@ -32,7 +32,7 @@ class MixPlaylistsPatch : BytecodePatch() {
*/
SettingsPatch.addPreference(
arrayOf(
"PREFERENCE: GENERAL_LAYOUT_SETTINGS",
"PREFERENCE: GENERAL_SETTINGS",
"SETTINGS: HIDE_MIX_PLAYLISTS"
)
)

View File

@ -15,7 +15,7 @@ import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.layout.general.personalinformation.fingerprints.AccountSwitcherAccessibilityLabelFingerprint
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.util.integrations.Constants.GENERAL_LAYOUT
import app.revanced.util.integrations.Constants.GENERAL
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@Patch
@ -38,7 +38,7 @@ class HideEmailAddressPatch : BytecodePatch(
addInstructions(
insertIndex, """
invoke-static {v$register}, $GENERAL_LAYOUT->hideEmailAddress(I)I
invoke-static {v$register}, $GENERAL->hideEmailAddress(I)I
move-result v$register
"""
)
@ -50,7 +50,7 @@ class HideEmailAddressPatch : BytecodePatch(
*/
SettingsPatch.addPreference(
arrayOf(
"PREFERENCE: GENERAL_LAYOUT_SETTINGS",
"PREFERENCE: GENERAL_SETTINGS",
"SETTINGS: HIDE_EMAIL_ADDRESS"
)
)

View File

@ -1,25 +0,0 @@
package app.revanced.patches.youtube.layout.general.pivotbar.createbutton.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
object PivotBarFingerprint : MethodFingerprint(
returnType = "L",
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
opcodes = listOf(
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT,
Opcode.RETURN_OBJECT
),
customFingerprint = { methodDef ->
methodDef.definingClass == "Lcom/google/android/apps/youtube/app/ui/pivotbar/PivotBar;" &&
methodDef.implementation?.instructions?.any {
it.opcode.ordinal == Opcode.CONST.ordinal &&
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.imageWithTextTabId
} == true
}
)

View File

@ -1,100 +0,0 @@
package app.revanced.patches.youtube.layout.general.pivotbar.createbutton.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.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.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.shared.fingerprints.PivotBarCreateButtonViewFingerprint
import app.revanced.patches.youtube.layout.general.pivotbar.createbutton.fingerprints.PivotBarFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.util.integrations.Constants.GENERAL_LAYOUT
import app.revanced.util.pivotbar.InjectionUtils.REGISTER_TEMPLATE_REPLACEMENT
import app.revanced.util.pivotbar.InjectionUtils.injectHook
import org.jf.dexlib2.dexbacked.reference.DexBackedMethodReference
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
@Patch
@Name("hide-create-button")
@Description("Hides the create button in the navigation bar.")
@DependsOn(
[
SettingsPatch::class,
SharedResourceIdPatch::class
]
)
@YouTubeCompatibility
@Version("0.0.1")
class CreateButtonRemoverPatch : BytecodePatch(
listOf(
PivotBarCreateButtonViewFingerprint,
PivotBarFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
/*
* Resolve fingerprints
*/
PivotBarFingerprint.result?.let {
val startIndex = it.scanResult.patternScanResult!!.startIndex
val pivotBarInstructions = it.mutableMethod.implementation!!.instructions
createRef = (pivotBarInstructions.elementAt(startIndex) as ReferenceInstruction).reference as DexBackedMethodReference
} ?: return PivotBarFingerprint.toErrorResult()
PivotBarCreateButtonViewFingerprint.result?.let { result ->
with (result.mutableMethod){
val createButtonInstructions = implementation!!.instructions
createButtonInstructions.filter { instruction ->
val fieldReference = (instruction as? ReferenceInstruction)?.reference as? DexBackedMethodReference
fieldReference?.let { it.definingClass == createRef.definingClass && it.name == createRef.name } == true
}.forEach { instruction ->
if (foundIndex == 0) {
foundIndex++
return@forEach
}
/*
* Inject hooks
*/
injectHook(hook, createButtonInstructions.indexOf(instruction) + 2)
/*
* Add settings
*/
SettingsPatch.addPreference(
arrayOf(
"PREFERENCE: GENERAL_LAYOUT_SETTINGS",
"SETTINGS: HIDE_CREATE_BUTTON"
)
)
SettingsPatch.updatePatchStatus("hide-create-button")
return PatchResultSuccess()
}
return PivotBarCreateButtonViewFingerprint.toErrorResult()
}
} ?: return PivotBarCreateButtonViewFingerprint.toErrorResult()
}
private companion object {
const val hook =
"invoke-static { v$REGISTER_TEMPLATE_REPLACEMENT }, $GENERAL_LAYOUT" +
"->" +
"hideCreateButton(Landroid/view/View;)V"
lateinit var createRef: DexBackedMethodReference
var foundIndex: Int = 0
}
}

View File

@ -1,15 +0,0 @@
package app.revanced.patches.youtube.layout.general.pivotbar.shortsbutton.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.Opcode
object PivotBarEnumFingerprint : MethodFingerprint(
opcodes = listOf(
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT_OBJECT,
Opcode.IF_NEZ, // target reference
Opcode.SGET_OBJECT,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT,
)
)

View File

@ -1,12 +0,0 @@
package app.revanced.patches.youtube.layout.general.pivotbar.shortsbutton.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.Opcode
object PivotBarShortsButtonViewFingerprint : MethodFingerprint(
opcodes = listOf(
Opcode.INVOKE_VIRTUAL_RANGE,
Opcode.MOVE_RESULT_OBJECT, // target reference
Opcode.GOTO,
)
)

View File

@ -1,102 +0,0 @@
package app.revanced.patches.youtube.layout.general.pivotbar.shortsbutton.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.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.patch.annotations.Patch
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.shared.fingerprints.PivotBarCreateButtonViewFingerprint
import app.revanced.patches.youtube.layout.general.pivotbar.shortsbutton.fingerprints.PivotBarEnumFingerprint
import app.revanced.patches.youtube.layout.general.pivotbar.shortsbutton.fingerprints.PivotBarShortsButtonViewFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.util.integrations.Constants.GENERAL_LAYOUT
import app.revanced.util.pivotbar.InjectionUtils.REGISTER_TEMPLATE_REPLACEMENT
import app.revanced.util.pivotbar.InjectionUtils.injectHook
@Patch
@Name("hide-shorts-button")
@Description("Hides the shorts button in the navigation bar.")
@DependsOn(
[
SettingsPatch::class,
SharedResourceIdPatch::class
]
)
@YouTubeCompatibility
@Version("0.0.1")
class ShortsButtonRemoverPatch : BytecodePatch(
listOf(PivotBarCreateButtonViewFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
/*
* Resolve fingerprints
*/
PivotBarCreateButtonViewFingerprint.result?.let { parentResult ->
with (
arrayOf(
PivotBarEnumFingerprint,
PivotBarShortsButtonViewFingerprint
).onEach {
it.resolve(
context,
parentResult.mutableMethod,
parentResult.mutableClass
)
}.map {
it.result?.scanResult?.patternScanResult ?: return it.toErrorResult()
}
) {
val enumScanResult = this[0]
val buttonViewResult = this[1]
val enumHookInsertIndex = enumScanResult.startIndex + 2
val buttonHookInsertIndex = buttonViewResult.endIndex
mapOf(
buttonHook to buttonHookInsertIndex,
enumHook to enumHookInsertIndex
).forEach { (hook, insertIndex) ->
parentResult.mutableMethod.injectHook(hook, insertIndex)
}
}
} ?: return PivotBarCreateButtonViewFingerprint.toErrorResult()
/*
* Add settings
*/
SettingsPatch.addPreference(
arrayOf(
"PREFERENCE: GENERAL_LAYOUT_SETTINGS",
"SETTINGS: SHORTS_COMPONENT.PARENT",
"SETTINGS: SHORTS_COMPONENT_PARENT.A",
"SETTINGS: HIDE_SHORTS_BUTTON"
)
)
SettingsPatch.updatePatchStatus("hide-shorts-button")
return PatchResultSuccess()
}
private companion object {
const val enumHook =
"sput-object v$REGISTER_TEMPLATE_REPLACEMENT, $GENERAL_LAYOUT" +
"->" +
"lastPivotTab:Ljava/lang/Enum;"
const val buttonHook =
"invoke-static { v$REGISTER_TEMPLATE_REPLACEMENT }, $GENERAL_LAYOUT" +
"->" +
"hideShortsButton(Landroid/view/View;)V"
}
}

View File

@ -1,15 +0,0 @@
package app.revanced.patches.youtube.layout.general.pivotbar.shortspivotbar.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.Opcode
object ReelWatchBundleFingerprint : MethodFingerprint(
returnType = "V",
opcodes = listOf(
Opcode.CHECK_CAST,
Opcode.IGET_OBJECT,
Opcode.CONST_STRING,
Opcode.INVOKE_VIRTUAL
),
strings = listOf("r_as")
)

View File

@ -1,8 +0,0 @@
package app.revanced.patches.youtube.layout.general.pivotbar.shortspivotbar.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object ReelWatchEndpointFingerprint : MethodFingerprint(
returnType = "V",
customFingerprint = { it.name == "<init>" }
)

View File

@ -1,8 +0,0 @@
package app.revanced.patches.youtube.layout.general.pivotbar.shortspivotbar.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object ReelWatchEndpointParentFingerprint : MethodFingerprint(
returnType = "V",
strings = listOf("Error parsing bytes for updated ReelWatchEndpoint.", "r_aoc")
)

View File

@ -1,16 +0,0 @@
package app.revanced.patches.youtube.layout.general.pivotbar.shortspivotbar.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
object SetPivotBarFingerprint : MethodFingerprint(
returnType = "V",
access = AccessFlags.PRIVATE or AccessFlags.FINAL,
parameters = listOf("Z"),
opcodes = listOf(
Opcode.CHECK_CAST,
Opcode.IF_EQZ
)
)

View File

@ -1,100 +0,0 @@
package app.revanced.patches.youtube.layout.general.pivotbar.shortspivotbar.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.addInstruction
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.patch.annotations.Patch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.shared.fingerprints.PivotBarCreateButtonViewFingerprint
import app.revanced.patches.youtube.layout.general.pivotbar.shortspivotbar.fingerprints.*
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.util.integrations.Constants.GENERAL_LAYOUT
import org.jf.dexlib2.dexbacked.reference.DexBackedTypeReference
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
@Patch
@Name("hide-shorts-pivot-bar")
@Description("Hides the pivotbar when playing shorts.")
@DependsOn([SettingsPatch::class])
@YouTubeCompatibility
@Version("0.0.1")
class ShortsPivotBarPatch : BytecodePatch(
listOf(
PivotBarCreateButtonViewFingerprint,
ReelWatchBundleFingerprint,
ReelWatchEndpointParentFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
PivotBarCreateButtonViewFingerprint.result?.let { parentResult ->
SetPivotBarFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let {
with (it.mutableMethod) {
val startIndex = it.scanResult.patternScanResult!!.startIndex
val instructions = implementation!!.instructions
val indexReference = ((instructions[startIndex] as ReferenceInstruction).reference as DexBackedTypeReference).toString()
if (indexReference != targetReference) return SetPivotBarFingerprint.toErrorResult()
val register = (instructions[startIndex] as OneRegisterInstruction).registerA
addInstruction(
startIndex + 1,
"sput-object v$register, $GENERAL_LAYOUT->pivotbar:$targetReference"
)
}
} ?: return SetPivotBarFingerprint.toErrorResult()
} ?: return PivotBarCreateButtonViewFingerprint.toErrorResult()
ReelWatchBundleFingerprint.result?.let {
with (context
.toMethodWalker(it.method)
.nextMethod(it.scanResult.patternScanResult!!.endIndex, true)
.getMethod() as MutableMethod
) {
addInstruction(
0,
"invoke-static {}, $GENERAL_LAYOUT->hideShortsPlayerPivotBar()V"
)
}
} ?: return ReelWatchBundleFingerprint.toErrorResult()
ReelWatchEndpointParentFingerprint.result?.let { parentResult ->
ReelWatchEndpointFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.mutableMethod?.addInstruction(
0,
"sput-object p1, $GENERAL_LAYOUT->shortsContext:Landroid/content/Context;"
) ?: return ReelWatchEndpointFingerprint.toErrorResult()
} ?: return ReelWatchEndpointParentFingerprint.toErrorResult()
/*
* Add settings
*/
SettingsPatch.addPreference(
arrayOf(
"PREFERENCE: GENERAL_LAYOUT_SETTINGS",
"SETTINGS: SHORTS_COMPONENT.PARENT",
"SETTINGS: SHORTS_COMPONENT_PARENT.B",
"SETTINGS: HIDE_SHORTS_PLAYER_PIVOT_BAR"
)
)
SettingsPatch.updatePatchStatus("hide-shorts-pivot-bar")
return PatchResultSuccess()
}
private companion object {
const val targetReference =
"Lcom/google/android/apps/youtube/app/ui/pivotbar/PivotBar;"
}
}

View File

@ -1,14 +0,0 @@
package app.revanced.patches.youtube.layout.general.pivotbar.switchbutton.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.Opcode
object AutoMotiveFingerprint : MethodFingerprint(
opcodes = listOf(
Opcode.GOTO,
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT,
Opcode.IF_EQZ
),
strings = listOf("Android Automotive")
)

View File

@ -1,60 +0,0 @@
package app.revanced.patches.youtube.layout.general.pivotbar.switchbutton.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.extensions.addInstructions
import app.revanced.patcher.extensions.instruction
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.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.layout.general.pivotbar.switchbutton.fingerprints.AutoMotiveFingerprint
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.util.integrations.Constants.GENERAL_LAYOUT
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@Patch
@Name("switch-create-notification")
@Description("Switching the create button and notification button.")
@DependsOn([SettingsPatch::class])
@YouTubeCompatibility
@Version("0.0.1")
class SwitchCreateButtonPatch : BytecodePatch(
listOf(AutoMotiveFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
AutoMotiveFingerprint.result?.let {
with (it.mutableMethod) {
val insertIndex = it.scanResult.patternScanResult!!.endIndex
val register = (instruction(insertIndex) as OneRegisterInstruction).registerA
addInstructions(
insertIndex, """
invoke-static {v$register}, $GENERAL_LAYOUT->switchCreateNotification(Z)Z
move-result v$register
"""
)
}
} ?: return AutoMotiveFingerprint.toErrorResult()
/*
* Add settings
*/
SettingsPatch.addPreference(
arrayOf(
"PREFERENCE: GENERAL_LAYOUT_SETTINGS",
"SETTINGS: SWITCH_CREATE_NOTIFICATION"
)
)
SettingsPatch.updatePatchStatus("switch-create-notification")
return PatchResultSuccess()
}
}

View File

@ -24,7 +24,7 @@ import app.revanced.patches.youtube.misc.playertype.patch.PlayerTypeHookPatch
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.util.bytecode.BytecodeHelper.updatePatchStatus
import app.revanced.util.integrations.Constants.GENERAL_LAYOUT
import app.revanced.util.integrations.Constants.GENERAL
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
@ -79,7 +79,7 @@ class ShortsComponentPatch : BytecodePatch(
val mutableMethod = context.proxy(classDef).mutableClass.findMutableMethodOf(method)
val viewRegister = (instructions.elementAt(index + 3) as OneRegisterInstruction).registerA
mutableMethod.implementation!!.injectHideCall(index + 4, viewRegister, "layout/GeneralLayoutPatch", "hideShortsPlayerCommentsButton")
mutableMethod.implementation!!.injectHideCall(index + 4, viewRegister, "layout/GeneralPatch", "hideShortsPlayerCommentsButton")
patchSuccessArray[0] = true
}
@ -92,7 +92,7 @@ class ShortsComponentPatch : BytecodePatch(
val mutableMethod = context.proxy(classDef).mutableClass.findMutableMethodOf(method)
val viewRegister = (invokeInstruction as Instruction21c).registerA
mutableMethod.implementation!!.injectHideCall(index - 1, viewRegister, "layout/GeneralLayoutPatch", "hideShortsPlayerRemixButton")
mutableMethod.implementation!!.injectHideCall(index - 1, viewRegister, "layout/GeneralPatch", "hideShortsPlayerRemixButton")
patchSuccessArray[1] = true
}
@ -105,7 +105,7 @@ class ShortsComponentPatch : BytecodePatch(
val mutableMethod = context.proxy(classDef).mutableClass.findMutableMethodOf(method)
val viewRegister = (invokeInstruction as Instruction21c).registerA
mutableMethod.implementation!!.injectHideCall(insertIndex, viewRegister, "layout/GeneralLayoutPatch", "hideShortsPlayerSubscriptionsButton")
mutableMethod.implementation!!.injectHideCall(insertIndex, viewRegister, "layout/GeneralPatch", "hideShortsPlayerSubscriptionsButton")
patchSuccessArray[2] = true
}
@ -137,7 +137,7 @@ class ShortsComponentPatch : BytecodePatch(
it.addInstructions(
insertIndex,"""
invoke-static {v$register}, $GENERAL_LAYOUT->hideShortsPlayerSubscriptionsButton(I)I
invoke-static {v$register}, $GENERAL->hideShortsPlayerSubscriptionsButton(I)I
move-result v$register
"""
)
@ -156,7 +156,7 @@ class ShortsComponentPatch : BytecodePatch(
*/
SettingsPatch.addPreference(
arrayOf(
"PREFERENCE: GENERAL_LAYOUT_SETTINGS",
"PREFERENCE: GENERAL_SETTINGS",
"SETTINGS: SHORTS_COMPONENT.PARENT",
"SETTINGS: SHORTS_COMPONENT_PARENT.A",
"SETTINGS: SHORTS_COMPONENT_PARENT.B",

View File

@ -16,7 +16,7 @@ import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.layout.general.snackbar.fingerprints.HideSnackbarFingerprint
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.util.integrations.Constants.GENERAL_LAYOUT
import app.revanced.util.integrations.Constants.GENERAL
@Patch
@Name("hide-snackbar")
@ -34,7 +34,7 @@ class HideSnackbarPatch : BytecodePatch(
HideSnackbarFingerprint.result?.mutableMethod?.let {
it.addInstructions(
0, """
invoke-static {}, $GENERAL_LAYOUT->hideSnackbar()Z
invoke-static {}, $GENERAL->hideSnackbar()Z
move-result v0
if-eqz v0, :default
return-void
@ -47,7 +47,7 @@ class HideSnackbarPatch : BytecodePatch(
*/
SettingsPatch.addPreference(
arrayOf(
"PREFERENCE: GENERAL_LAYOUT_SETTINGS",
"PREFERENCE: GENERAL_SETTINGS",
"SETTINGS: HIDE_SNACKBAR"
)
)

View File

@ -16,7 +16,7 @@ import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.layout.general.startupshortsreset.fingerprints.UserWasInShortsFingerprint
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.util.integrations.Constants.GENERAL_LAYOUT
import app.revanced.util.integrations.Constants.GENERAL
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@Patch
@ -39,7 +39,7 @@ class HideShortsOnStartupPatch : BytecodePatch(
val register = (instruction(insertIndex - 1) as OneRegisterInstruction).registerA + 2
addInstructions(
insertIndex, """
invoke-static { }, $GENERAL_LAYOUT->hideStartupShortsPlayer()Z
invoke-static { }, $GENERAL->hideStartupShortsPlayer()Z
move-result v$register
if-eqz v$register, :show_startup_shorts_player
return-void
@ -53,7 +53,7 @@ class HideShortsOnStartupPatch : BytecodePatch(
*/
SettingsPatch.addPreference(
arrayOf(
"PREFERENCE: GENERAL_LAYOUT_SETTINGS",
"PREFERENCE: GENERAL_SETTINGS",
"SETTINGS: SHORTS_COMPONENT.PARENT",
"SETTINGS: SHORTS_COMPONENT_PARENT.B",
"SETTINGS: HIDE_STARTUP_SHORTS_PLAYER"

View File

@ -57,7 +57,7 @@ class HideStoriesPatch : BytecodePatch() {
val mutableMethod = context.proxy(classDef).mutableClass.findMutableMethodOf(method)
val viewRegister = (iPutInstruction as Instruction22c).registerA
mutableMethod.implementation!!.injectHideCall(insertIndex, viewRegister, "layout/GeneralLayoutPatch", "hideStoriesShelf")
mutableMethod.implementation!!.injectHideCall(insertIndex, viewRegister, "layout/GeneralPatch", "hideStoriesShelf")
patchSuccessArray[0] = true
patchSuccessArray[1] = true
@ -79,7 +79,7 @@ class HideStoriesPatch : BytecodePatch() {
*/
SettingsPatch.addPreference(
arrayOf(
"PREFERENCE: GENERAL_LAYOUT_SETTINGS",
"PREFERENCE: GENERAL_SETTINGS",
"SETTINGS: HIDE_STORIES_SHELF"
)
)

View File

@ -19,7 +19,7 @@ import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.layout.general.tabletminiplayer.fingerprints.*
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.util.integrations.Constants.GENERAL_LAYOUT
import app.revanced.util.integrations.Constants.GENERAL
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@ -69,7 +69,7 @@ class TabletMiniPlayerPatch : BytecodePatch(
*/
SettingsPatch.addPreference(
arrayOf(
"PREFERENCE: GENERAL_LAYOUT_SETTINGS",
"PREFERENCE: GENERAL_SETTINGS",
"SETTINGS: ENABLE_TABLET_MINIPLAYER"
)
)
@ -92,7 +92,7 @@ class TabletMiniPlayerPatch : BytecodePatch(
this.addInstructions(
index,
"""
invoke-static {v$overrideRegister}, $GENERAL_LAYOUT->enableTabletMiniPlayer(Z)Z
invoke-static {v$overrideRegister}, $GENERAL->enableTabletMiniPlayer(Z)Z
move-result v$overrideRegister
"""
)

View File

@ -1,4 +1,4 @@
package app.revanced.patches.youtube.layout.general.widesearchbar.fingerprints
package app.revanced.patches.youtube.layout.general.widesearchbar.bytecode.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint

View File

@ -1,4 +1,4 @@
package app.revanced.patches.youtube.layout.general.widesearchbar.fingerprints
package app.revanced.patches.youtube.layout.general.widesearchbar.bytecode.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint

View File

@ -1,4 +1,4 @@
package app.revanced.patches.youtube.layout.general.widesearchbar.fingerprints
package app.revanced.patches.youtube.layout.general.widesearchbar.bytecode.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint

View File

@ -1,4 +1,4 @@
package app.revanced.patches.youtube.layout.general.widesearchbar.fingerprints
package app.revanced.patches.youtube.layout.general.widesearchbar.bytecode.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint

View File

@ -1,4 +1,4 @@
package app.revanced.patches.youtube.layout.general.widesearchbar.patch
package app.revanced.patches.youtube.layout.general.widesearchbar.bytecode.patch
import app.revanced.extensions.toErrorResult
import app.revanced.patcher.annotation.Description
@ -15,14 +15,18 @@ 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.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.layout.general.widesearchbar.fingerprints.*
import app.revanced.patches.youtube.layout.general.widesearchbar.bytecode.fingerprints.*
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.util.integrations.Constants.GENERAL_LAYOUT
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])
@DependsOn(
[
SettingsPatch::class
]
)
@YouTubeCompatibility
@Version("0.0.1")
class WideSearchbarPatch : BytecodePatch(
@ -58,7 +62,7 @@ class WideSearchbarPatch : BytecodePatch(
*/
SettingsPatch.addPreference(
arrayOf(
"PREFERENCE: GENERAL_LAYOUT_SETTINGS",
"PREFERENCE: GENERAL_SETTINGS",
"SETTINGS: ENABLE_WIDE_SEARCHBAR"
)
)
@ -72,7 +76,7 @@ class WideSearchbarPatch : BytecodePatch(
val index = method.implementation!!.instructions.size - 1
method.addInstructions(
index, """
invoke-static {}, $GENERAL_LAYOUT->enableWideSearchbar()Z
invoke-static {}, $GENERAL->enableWideSearchbar()Z
move-result p0
"""
)