From e80b6b3057ac91aa42b71aa90f0e935fc6161d5c Mon Sep 17 00:00:00 2001 From: Siddhesh Naik <87667048+snaik20@users.noreply.github.com> Date: Tue, 26 Sep 2023 14:41:33 +0530 Subject: [PATCH] Add playlist name and video name to playlist sharing content (#10427) - Currently, only a list of videos separated by newline are added in the share content. - This makes it difficult to identify a specific video in a list of Urls. - Used string resources for the sharing content formats. - Added a confirmation dialog for users to choose between sharing playlist formats. - Added Playlist name as the header and corresponding video name for each video url in following format. Playlist - Music1: https://media-url1 - Music2: https://media-url2 - Music3: https://media-url3 Co-authored-by: TobiGr --- .../local/playlist/LocalPlaylistFragment.java | 48 ++++++++++++++++--- app/src/main/res/values/strings.xml | 8 +++- 2 files changed, 49 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java b/app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java index 0d8f81334..28711c6fe 100644 --- a/app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java +++ b/app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java @@ -51,8 +51,8 @@ import org.schabi.newpipe.player.playqueue.SinglePlayQueue; import org.schabi.newpipe.util.Localization; import org.schabi.newpipe.util.NavigationHelper; import org.schabi.newpipe.util.OnClickGesture; -import org.schabi.newpipe.util.external_communication.ShareUtils; import org.schabi.newpipe.util.PlayButtonHelper; +import org.schabi.newpipe.util.external_communication.ShareUtils; import java.util.ArrayList; import java.util.Collections; @@ -346,7 +346,7 @@ public class LocalPlaylistFragment extends BaseLocalListFragment Single.just(playlist.stream() .map(PlaylistStreamEntry::getStreamEntity) - .map(StreamEntity::getUrl) + .map(streamEntity -> { + if (shouldSharePlaylistDetails) { + return context.getString(R.string.video_details_list_item, + streamEntity.getTitle(), streamEntity.getUrl()); + } else { + return streamEntity.getUrl(); + } + }) .collect(Collectors.joining("\n")))) .observeOn(AndroidSchedulers.mainThread()) - .subscribe(urlsText -> ShareUtils.shareText(requireContext(), name, urlsText), + .subscribe(urlsText -> ShareUtils.shareText( + context, name, shouldSharePlaylistDetails + ? context.getString(R.string.share_playlist_content_details, + name, urlsText) : urlsText), throwable -> showUiErrorSnackbar(this, "Sharing playlist", throwable))); } @@ -841,5 +858,24 @@ public class LocalPlaylistFragment extends BaseLocalListFragment + sharePlaylist(/* shouldSharePlaylistDetails= */ true) + ) + .setNegativeButton(R.string.share_playlist_with_list, (dialog, which) -> + sharePlaylist(/* shouldSharePlaylistDetails= */ false) + ) + .show(); + } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9dfca8294..bf618739c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -832,4 +832,10 @@ Medium quality High quality \? - \ No newline at end of file + Share Playlist + Share playlist with details such as playlist name and video titles or as a simple list of video URLs + Share with Titles + Share URL list + - %s: %s + %s\n%s +