mirror of
https://github.com/revanced/revanced-patches
synced 2024-12-02 23:42:55 +01:00
feat(youtube/copy-video-url): add tap and hold functionality to copy video url buttons (#2174)
This commit is contained in:
parent
89ef0fcd42
commit
95bbf46e77
@ -26,8 +26,7 @@ import app.revanced.patches.youtube.video.information.patch.VideoInformationPatc
|
||||
@Version("0.0.1")
|
||||
class CopyVideoUrlBytecodePatch : BytecodePatch() {
|
||||
private companion object {
|
||||
const val INTEGRATIONS_PACKAGE = "Lapp/revanced/integrations"
|
||||
const val INTEGRATIONS_PLAYER_PACKAGE = "$INTEGRATIONS_PACKAGE/videoplayer"
|
||||
const val INTEGRATIONS_PLAYER_PACKAGE = "Lapp/revanced/integrations/videoplayer"
|
||||
val BUTTONS_DESCRIPTORS = listOf(
|
||||
"$INTEGRATIONS_PLAYER_PACKAGE/CopyVideoUrlButton;",
|
||||
"$INTEGRATIONS_PLAYER_PACKAGE/CopyVideoUrlTimestampButton;"
|
||||
@ -38,10 +37,8 @@ class CopyVideoUrlBytecodePatch : BytecodePatch() {
|
||||
|
||||
// Initialize buttons and inject visibility control
|
||||
BUTTONS_DESCRIPTORS.forEach { descriptor ->
|
||||
val initializeButtonDescriptor = "$descriptor->initializeButton(Ljava/lang/Object;)V"
|
||||
val visibilityDescriptor = "$descriptor->changeVisibility(Z)V"
|
||||
PlayerControlsBytecodePatch.initializeControl(initializeButtonDescriptor)
|
||||
PlayerControlsBytecodePatch.injectVisibilityCheckCall(visibilityDescriptor)
|
||||
PlayerControlsBytecodePatch.initializeControl("$descriptor->initializeButton(Landroid/view/View;)V")
|
||||
PlayerControlsBytecodePatch.injectVisibilityCheckCall("$descriptor->changeVisibility(Z)V")
|
||||
}
|
||||
|
||||
return PatchResultSuccess()
|
||||
|
@ -14,6 +14,7 @@ import app.revanced.patches.youtube.misc.playercontrols.resource.patch.BottomCon
|
||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||
import app.revanced.util.resources.ResourceUtils
|
||||
import app.revanced.util.resources.ResourceUtils.copyResources
|
||||
import app.revanced.util.resources.ResourceUtils.mergeStrings
|
||||
|
||||
@Name("copy-video-url-resource")
|
||||
@DependsOn([BottomControlsResourcePatch::class, SettingsPatch::class])
|
||||
@ -28,13 +29,13 @@ class CopyVideoUrlResourcePatch : ResourcePatch {
|
||||
SwitchPreference(
|
||||
"revanced_copy_video_url",
|
||||
StringResource("revanced_copy_video_url_title", "Show copy video URL button"),
|
||||
StringResource("revanced_copy_video_url_summary_on", "Button is shown, click to copy video URL without timestamp"),
|
||||
StringResource("revanced_copy_video_url_summary_on", "Button is shown. Tap to copy video URL. Tap and hold to copy video URL with timestamp"),
|
||||
StringResource("revanced_copy_video_url_summary_off", "Button is not shown")
|
||||
),
|
||||
SwitchPreference(
|
||||
"revanced_copy_video_url_timestamp",
|
||||
StringResource("revanced_copy_video_url_timestamp_title", "Show copy timestamp URL button"),
|
||||
StringResource("revanced_copy_video_url_timestamp_summary_on", "Button is shown, click to copy video URL with timestamp"),
|
||||
StringResource("revanced_copy_video_url_timestamp_summary_on", "Button is shown. Tap to copy video URL with timestamp. Tap and hold to copy video without timestamp"),
|
||||
StringResource("revanced_copy_video_url_timestamp_summary_off", "Button is not shown")
|
||||
)
|
||||
),
|
||||
@ -48,6 +49,9 @@ class CopyVideoUrlResourcePatch : ResourcePatch {
|
||||
"revanced_yt_copy_timestamp.xml"
|
||||
))
|
||||
|
||||
// merge strings
|
||||
context.mergeStrings("copyvideourl/host/values/strings.xml")
|
||||
|
||||
BottomControlsResourcePatch.addControls("copyvideourl/host/layout/${BottomControlsResourcePatch.TARGET_RESOURCE_NAME}")
|
||||
|
||||
return PatchResultSuccess()
|
||||
|
@ -21,23 +21,24 @@ import app.revanced.patches.youtube.video.information.patch.VideoInformationPatc
|
||||
@DownloadsCompatibility
|
||||
@Version("0.0.1")
|
||||
class DownloadsBytecodePatch : BytecodePatch() {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
val integrationsPackage = "app/revanced/integrations"
|
||||
val classDescriptor = "L$integrationsPackage/videoplayer/DownloadButton;"
|
||||
private companion object {
|
||||
const val BUTTON_DESCRIPTOR = "Lapp/revanced/integrations/videoplayer/DownloadButton;"
|
||||
}
|
||||
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
/*
|
||||
initialize the control
|
||||
*/
|
||||
|
||||
val initializeDownloadsDescriptor = "$classDescriptor->initializeButton(Ljava/lang/Object;)V"
|
||||
PlayerControlsBytecodePatch.initializeControl(initializeDownloadsDescriptor)
|
||||
PlayerControlsBytecodePatch.initializeControl(
|
||||
"$BUTTON_DESCRIPTOR->initializeButton(Landroid/view/View;)V")
|
||||
|
||||
/*
|
||||
add code to change the visibility of the control
|
||||
*/
|
||||
|
||||
val changeVisibilityDescriptor = "$classDescriptor->changeVisibility(Z)V"
|
||||
PlayerControlsBytecodePatch.injectVisibilityCheckCall(changeVisibilityDescriptor)
|
||||
PlayerControlsBytecodePatch.injectVisibilityCheckCall(
|
||||
"$BUTTON_DESCRIPTOR->changeVisibility(Z)V")
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
5
src/main/resources/copyvideourl/host/values/strings.xml
Normal file
5
src/main/resources/copyvideourl/host/values/strings.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="revanced_share_copy_url_success">URL copied to clipboard</string>
|
||||
<string name="revanced_share_copy_url_timestamp_success">URL with timestamp copied</string>
|
||||
</resources>
|
Loading…
Reference in New Issue
Block a user