Add playlist name and video name in playlist sharing content

- 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.
- Added Playlist name as the header and corresponding video name for
  each video url in following format.
```
My Playlist
- Music1: https://media-url1
- Music2: https://media-url2
- Music3: https://media-url3
```

Screenshot:
| Before | After |
| --- | --- |
| <img src="https://github.com/TeamNewPipe/NewPipe/assets/87667048/fa7b27b2-91d6-491d-8f93-a8b447263de6" width=320> | <img src="https://github.com/TeamNewPipe/NewPipe/assets/87667048/e7ddde18-1d3a-4ccb-8c35-f5bf14e48bec" width=320> |
This commit is contained in:
Siddhesh Naik 2023-09-17 15:33:08 +05:30 committed by TobiGr
parent 9c86afe40d
commit f15c35ba27
1 changed files with 5 additions and 3 deletions

View File

@ -374,16 +374,18 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
}
/**
* Share the playlist as a newline-separated list of stream URLs.
* Share the playlist as a newline-separated list of stream URLs and video names.
*/
public void sharePlaylist() {
disposables.add(playlistManager.getPlaylistStreams(playlistId)
.flatMapSingle(playlist -> Single.just(playlist.stream()
.map(PlaylistStreamEntry::getStreamEntity)
.map(StreamEntity::getUrl)
.map(streamEntity -> String.format("- %s: %s",
streamEntity.getTitle(), streamEntity.getUrl()))
.collect(Collectors.joining("\n"))))
.observeOn(AndroidSchedulers.mainThread())
.subscribe(urlsText -> ShareUtils.shareText(requireContext(), name, urlsText),
.subscribe(urlsText -> ShareUtils.shareText(
requireContext(), name, String.format("%s\n%s", name, urlsText)),
throwable -> showUiErrorSnackbar(this, "Sharing playlist", throwable)));
}