mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-13 13:47:42 +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() {
|
object SharedResourceIdPatch : ResourcePatch() {
|
||||||
var AccountSwitcherAccessibility = -1L
|
var AccountSwitcherAccessibility = -1L
|
||||||
var AudioVideoSwitchToggle = -1L
|
var AudioVideoSwitchToggle = -1L
|
||||||
|
var BottomSheetRecyclerView = -1L
|
||||||
var ButtonContainer = -1L
|
var ButtonContainer = -1L
|
||||||
var ButtonIconPaddingMedium = -1L
|
var ButtonIconPaddingMedium = -1L
|
||||||
var ChipCloud = -1L
|
var ChipCloud = -1L
|
||||||
@ -61,6 +62,7 @@ object SharedResourceIdPatch : ResourcePatch() {
|
|||||||
|
|
||||||
AccountSwitcherAccessibility = getId(STRING, "account_switcher_accessibility_label")
|
AccountSwitcherAccessibility = getId(STRING, "account_switcher_accessibility_label")
|
||||||
AudioVideoSwitchToggle = getId(ID, "audio_video_switch_toggle")
|
AudioVideoSwitchToggle = getId(ID, "audio_video_switch_toggle")
|
||||||
|
BottomSheetRecyclerView = getId(LAYOUT, "bottom_sheet_recycler_view")
|
||||||
ButtonContainer = getId(ID, "button_container")
|
ButtonContainer = getId(ID, "button_container")
|
||||||
ButtonIconPaddingMedium = getId(DIMEN, "button_icon_padding_medium")
|
ButtonIconPaddingMedium = getId(DIMEN, "button_icon_padding_medium")
|
||||||
ChipCloud = getId(LAYOUT, "chip_cloud")
|
ChipCloud = getId(LAYOUT, "chip_cloud")
|
||||||
|
@ -371,6 +371,8 @@ Some features may not work properly in the old player layout."</string>
|
|||||||
|
|
||||||
<string name="revanced_bypass_image_region_restrictions_title">Bypass image region restrictions</string>
|
<string name="revanced_bypass_image_region_restrictions_title">Bypass image region restrictions</string>
|
||||||
<string name="revanced_bypass_image_region_restrictions_summary">Replaces the domain that is blocked in some regions so that playlist thumbnails, channel avatars, etc. can be received.</string>
|
<string name="revanced_bypass_image_region_restrictions_summary">Replaces the domain that is blocked in some regions so that playlist thumbnails, channel avatars, etc. can be received.</string>
|
||||||
|
<string name="revanced_change_share_sheet_title">Change share sheet</string>
|
||||||
|
<string name="revanced_change_share_sheet_summary">Change from in-app share sheet to system share sheet.</string>
|
||||||
<string name="revanced_enable_cairo_splash_animation_title">Enable Cairo splash animation</string>
|
<string name="revanced_enable_cairo_splash_animation_title">Enable Cairo splash animation</string>
|
||||||
<string name="revanced_enable_cairo_splash_animation_summary">Enables Cairo splash animation when the app starts up.</string>
|
<string name="revanced_enable_cairo_splash_animation_summary">Enables Cairo splash animation when the app starts up.</string>
|
||||||
<string name="revanced_enable_debug_logging_title">Enable debug logging</string>
|
<string name="revanced_enable_debug_logging_title">Enable debug logging</string>
|
||||||
|
Reference in New Issue
Block a user