From 5532666ad5459af9eb43fc8f811a0f0c9dbd2907 Mon Sep 17 00:00:00 2001 From: Abanoub Sameh Date: Sun, 6 Jun 2021 00:36:39 +0200 Subject: [PATCH 1/2] Long press on player share button to copy url to clipboard --- app/src/main/java/org/schabi/newpipe/player/Player.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/src/main/java/org/schabi/newpipe/player/Player.java b/app/src/main/java/org/schabi/newpipe/player/Player.java index d51a25789..ccab05a86 100644 --- a/app/src/main/java/org/schabi/newpipe/player/Player.java +++ b/app/src/main/java/org/schabi/newpipe/player/Player.java @@ -532,6 +532,7 @@ public final class Player implements binding.moreOptionsButton.setOnClickListener(this); binding.moreOptionsButton.setOnLongClickListener(this); binding.share.setOnClickListener(this); + binding.share.setOnLongClickListener(this); binding.fullScreenButton.setOnClickListener(this); binding.screenRotationButton.setOnClickListener(this); binding.playWithKodi.setOnClickListener(this); @@ -3629,6 +3630,10 @@ public final class Player implements fragmentListener.onMoreOptionsLongClicked(); hideControls(0, 0); hideSystemUIIfNeeded(); + } else if (v.getId() == binding.share.getId()) { + if (currentMetadata != null) { + ShareUtils.copyToClipboard(context, currentMetadata.getMetadata().getOriginalUrl()); + } } return true; } From bede75850730faaa760866f1d4c3785ff9fe3117 Mon Sep 17 00:00:00 2001 From: Stypox Date: Tue, 8 Jun 2021 14:34:51 +0200 Subject: [PATCH 2/2] Use url at current time for long click on player share button --- .../org/schabi/newpipe/player/Player.java | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/player/Player.java b/app/src/main/java/org/schabi/newpipe/player/Player.java index ccab05a86..0c5dbbb6f 100644 --- a/app/src/main/java/org/schabi/newpipe/player/Player.java +++ b/app/src/main/java/org/schabi/newpipe/player/Player.java @@ -2918,6 +2918,18 @@ public final class Player implements : currentMetadata.getMetadata().getUrl(); } + @NonNull + private String getVideoUrlAtCurrentTime() { + final int timeSeconds = binding.playbackSeekBar.getProgress() / 1000; + String videoUrl = getVideoUrl(); + if (!isLive() && timeSeconds >= 0 && currentMetadata != null + && currentMetadata.getMetadata().getServiceId() == YouTube.getServiceId()) { + // Timestamp doesn't make sense in a live stream so drop it + videoUrl += ("&t=" + timeSeconds); + } + return videoUrl; + } + @NonNull public String getVideoTitle() { return currentMetadata == null @@ -3581,7 +3593,7 @@ public final class Player implements } else if (v.getId() == binding.moreOptionsButton.getId()) { onMoreOptionsClicked(); } else if (v.getId() == binding.share.getId()) { - onShareClicked(); + ShareUtils.shareText(context, getVideoTitle(), getVideoUrlAtCurrentTime()); } else if (v.getId() == binding.playWithKodi.getId()) { onPlayWithKodiClicked(); } else if (v.getId() == binding.openInBrowser.getId()) { @@ -3631,9 +3643,7 @@ public final class Player implements hideControls(0, 0); hideSystemUIIfNeeded(); } else if (v.getId() == binding.share.getId()) { - if (currentMetadata != null) { - ShareUtils.copyToClipboard(context, currentMetadata.getMetadata().getOriginalUrl()); - } + ShareUtils.copyToClipboard(context, getVideoUrlAtCurrentTime()); } return true; } @@ -3705,19 +3715,6 @@ public final class Player implements showControls(DEFAULT_CONTROLS_DURATION); } - private void onShareClicked() { - // share video at the current time (youtube.com/watch?v=ID&t=SECONDS) - // Timestamp doesn't make sense in a live stream so drop it - - final int ts = binding.playbackSeekBar.getProgress() / 1000; - String videoUrl = getVideoUrl(); - if (!isLive() && ts >= 0 && currentMetadata != null - && currentMetadata.getMetadata().getServiceId() == YouTube.getServiceId()) { - videoUrl += ("&t=" + ts); - } - ShareUtils.shareText(context, getVideoTitle(), videoUrl); - } - private void onPlayWithKodiClicked() { if (currentMetadata != null) { pause();