mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 21:27:43 +02:00
feat(YouTube Music): add Change share sheet
patch
This commit is contained in:
@ -0,0 +1,62 @@
|
||||
package app.revanced.patches.music.misc.share
|
||||
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patches.music.misc.share.fingerprints.BottomSheetRecyclerViewFingerprint
|
||||
import app.revanced.patches.music.utils.compatibility.Constants.COMPATIBLE_PACKAGE
|
||||
import app.revanced.patches.music.utils.integrations.Constants.COMPONENTS_PATH
|
||||
import app.revanced.patches.music.utils.integrations.Constants.MISC_PATH
|
||||
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch
|
||||
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.BottomSheetRecyclerView
|
||||
import app.revanced.patches.music.utils.settings.CategoryType
|
||||
import app.revanced.patches.music.utils.settings.SettingsPatch
|
||||
import app.revanced.patches.shared.litho.LithoFilterPatch
|
||||
import app.revanced.util.getTargetIndexOrThrow
|
||||
import app.revanced.util.getWideLiteralInstructionIndex
|
||||
import app.revanced.util.patch.BaseBytecodePatch
|
||||
import app.revanced.util.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
@Suppress("unused")
|
||||
object ShareSheetPatch : BaseBytecodePatch(
|
||||
name = "Change share sheet",
|
||||
description = "Add option to change from in-app share sheet to system share sheet.",
|
||||
dependencies = setOf(
|
||||
LithoFilterPatch::class,
|
||||
SettingsPatch::class,
|
||||
SharedResourceIdPatch::class
|
||||
),
|
||||
compatiblePackages = COMPATIBLE_PACKAGE,
|
||||
fingerprints = setOf(BottomSheetRecyclerViewFingerprint)
|
||||
) {
|
||||
private const val INTEGRATIONS_CLASS_DESCRIPTOR =
|
||||
"$MISC_PATH/ShareSheetPatch;"
|
||||
|
||||
private const val FILTER_CLASS_DESCRIPTOR =
|
||||
"$COMPONENTS_PATH/ShareSheetMenuFilter;"
|
||||
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
BottomSheetRecyclerViewFingerprint.resultOrThrow().mutableMethod.apply {
|
||||
val constIndex = getWideLiteralInstructionIndex(BottomSheetRecyclerView)
|
||||
val targetIndex = getTargetIndexOrThrow(constIndex, Opcode.CHECK_CAST)
|
||||
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||
|
||||
addInstruction(
|
||||
targetIndex + 1,
|
||||
"invoke-static {v$targetRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->onShareSheetMenuCreate(Landroid/support/v7/widget/RecyclerView;)V"
|
||||
)
|
||||
}
|
||||
|
||||
LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR)
|
||||
|
||||
SettingsPatch.addSwitchPreference(
|
||||
CategoryType.MISC,
|
||||
"revanced_change_share_sheet",
|
||||
"false"
|
||||
)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package app.revanced.patches.music.misc.share.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.BottomSheetRecyclerView
|
||||
import app.revanced.util.fingerprint.LiteralValueFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
|
||||
internal object BottomSheetRecyclerViewFingerprint : LiteralValueFingerprint(
|
||||
returnType = "Lj${'$'}/util/Optional;",
|
||||
accessFlags = AccessFlags.PROTECTED or AccessFlags.FINAL,
|
||||
parameters = emptyList(),
|
||||
literalSupplier = { BottomSheetRecyclerView }
|
||||
)
|
@ -17,6 +17,7 @@ import app.revanced.patches.shared.mapping.ResourceType.STYLE
|
||||
object SharedResourceIdPatch : ResourcePatch() {
|
||||
var AccountSwitcherAccessibility = -1L
|
||||
var AudioVideoSwitchToggle = -1L
|
||||
var BottomSheetRecyclerView = -1L
|
||||
var ButtonContainer = -1L
|
||||
var ButtonIconPaddingMedium = -1L
|
||||
var ChipCloud = -1L
|
||||
@ -61,6 +62,7 @@ object SharedResourceIdPatch : ResourcePatch() {
|
||||
|
||||
AccountSwitcherAccessibility = getId(STRING, "account_switcher_accessibility_label")
|
||||
AudioVideoSwitchToggle = getId(ID, "audio_video_switch_toggle")
|
||||
BottomSheetRecyclerView = getId(LAYOUT, "bottom_sheet_recycler_view")
|
||||
ButtonContainer = getId(ID, "button_container")
|
||||
ButtonIconPaddingMedium = getId(DIMEN, "button_icon_padding_medium")
|
||||
ChipCloud = getId(LAYOUT, "chip_cloud")
|
||||
|
Reference in New Issue
Block a user