From f15c35ba2706ce85a8055258b2f0fd8648aeb9e4 Mon Sep 17 00:00:00 2001 From: Siddhesh Naik Date: Sun, 17 Sep 2023 15:33:08 +0530 Subject: [PATCH 1/6] 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 | | --- | --- | | | | --- .../newpipe/local/playlist/LocalPlaylistFragment.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 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 0d8f8133440..a4023ce947b 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 @@ -374,16 +374,18 @@ public boolean onOptionsItemSelected(final MenuItem item) { } /** - * 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))); } From b196e808a023e0498e4b1de102197072164eda91 Mon Sep 17 00:00:00 2001 From: Siddhesh Naik Date: Wed, 20 Sep 2023 15:54:27 +0530 Subject: [PATCH 2/6] Add confirmation dialog to the playlist sharing process - Added a confirmation dialog for users to choose between sharing playlist formats. - Users can choose to save their sharing format preference to skip the confirmation dialog. - Added an option in the settings to update the sharing preference. --- .../local/playlist/LocalPlaylistFragment.java | 65 +++++++++++++++++-- .../main/res/layout/dialog_share_playlist.xml | 28 ++++++++ app/src/main/res/values/settings_keys.xml | 2 + app/src/main/res/values/strings.xml | 6 ++ app/src/main/res/xml/video_audio_settings.xml | 8 +++ 5 files changed, 104 insertions(+), 5 deletions(-) create mode 100644 app/src/main/res/layout/dialog_share_playlist.xml 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 a4023ce947b..c1cea305b08 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 @@ -5,6 +5,7 @@ import static org.schabi.newpipe.util.ThemeHelper.shouldUseGridLayout; import android.content.Context; +import android.content.SharedPreferences; import android.os.Bundle; import android.os.Parcelable; import android.text.InputType; @@ -22,6 +23,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AlertDialog; +import androidx.preference.PreferenceManager; import androidx.recyclerview.widget.ItemTouchHelper; import androidx.recyclerview.widget.RecyclerView; import androidx.viewbinding.ViewBinding; @@ -36,6 +38,7 @@ import org.schabi.newpipe.database.playlist.model.PlaylistEntity; import org.schabi.newpipe.database.stream.model.StreamEntity; import org.schabi.newpipe.databinding.DialogEditTextBinding; +import org.schabi.newpipe.databinding.DialogSharePlaylistBinding; import org.schabi.newpipe.databinding.LocalPlaylistHeaderBinding; import org.schabi.newpipe.databinding.PlaylistControlBinding; import org.schabi.newpipe.error.ErrorInfo; @@ -99,6 +102,8 @@ public class LocalPlaylistFragment extends BaseLocalListFragment Single.just(playlist.stream() .map(PlaylistStreamEntry::getStreamEntity) - .map(streamEntity -> String.format("- %s: %s", - streamEntity.getTitle(), streamEntity.getUrl())) + .map(streamEntity -> { + if (shouldSharePlaylistDetails) { + return String.format("- %s: %s", + streamEntity.getTitle(), streamEntity.getUrl()); + } else { + return streamEntity.getUrl(); + } + }) .collect(Collectors.joining("\n")))) .observeOn(AndroidSchedulers.mainThread()) .subscribe(urlsText -> ShareUtils.shareText( - requireContext(), name, String.format("%s\n%s", name, urlsText)), + requireContext(), name, shouldSharePlaylistDetails + ? String.format("%s\n%s", name, urlsText) : urlsText), throwable -> showUiErrorSnackbar(this, "Sharing playlist", throwable))); } @@ -843,5 +863,40 @@ private PlayQueue getPlayQueue(final int index) { } return new SinglePlayQueue(streamInfoItems, index); } + + private void createShareConfirmationDialog() { + if (getContext() == null) { + return; + } + + final DialogSharePlaylistBinding dialogBinding = DialogSharePlaylistBinding + .inflate(getLayoutInflater()); + + new AlertDialog.Builder(getContext()) + .setTitle(R.string.share_playlist) + .setCancelable(true) + .setView(dialogBinding.getRoot()) + .setPositiveButton(R.string.share_playlist_with_details, (dialog, which) -> { + sharedPreferences.edit() + .putBoolean(requireContext().getString( + R.string.share_playlist_with_details_can_show_dialog_key), + !dialogBinding.rememberChoiceCheckBox.isChecked()) + .putBoolean(requireContext().getString( + R.string.share_playlist_with_details_key), true) + .commit(); + sharePlaylist(); + }) + .setNegativeButton(R.string.share_playlist_with_list, (dialog, which) -> { + sharedPreferences.edit() + .putBoolean(requireContext().getString( + R.string.share_playlist_with_details_can_show_dialog_key), + !dialogBinding.rememberChoiceCheckBox.isChecked()) + .putBoolean(requireContext().getString( + R.string.share_playlist_with_details_key), false) + .commit(); + sharePlaylist(); + }) + .show(); + } } diff --git a/app/src/main/res/layout/dialog_share_playlist.xml b/app/src/main/res/layout/dialog_share_playlist.xml new file mode 100644 index 00000000000..571264e57ea --- /dev/null +++ b/app/src/main/res/layout/dialog_share_playlist.xml @@ -0,0 +1,28 @@ + + + + + + + diff --git a/app/src/main/res/values/settings_keys.xml b/app/src/main/res/values/settings_keys.xml index 880fa92da7b..23e3597b27f 100644 --- a/app/src/main/res/values/settings_keys.xml +++ b/app/src/main/res/values/settings_keys.xml @@ -24,6 +24,8 @@ screen_brightness_timestamp_key clear_queue_confirmation_key ignore_hardware_media_buttons_key + share_playlist_with_details_key + share_playlist_with_details_can_show_dialog_key popup_saved_width popup_saved_x diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9dfca829440..8d723bacf13 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 \? + Share Playlist + Share playlist with details such as playlist name and video titles Or a simply share a list of video links + Share with details + Share list + Remember my choice + Share playlist with details such as playlist name and video titles \ No newline at end of file diff --git a/app/src/main/res/xml/video_audio_settings.xml b/app/src/main/res/xml/video_audio_settings.xml index 727ce4df40a..87d89594278 100644 --- a/app/src/main/res/xml/video_audio_settings.xml +++ b/app/src/main/res/xml/video_audio_settings.xml @@ -249,5 +249,13 @@ android:title="@string/ignore_hardware_media_buttons_title" app:singleLineTitle="false" app:iconSpaceReserved="false" /> + + From 118ed48a896ded8d4ef79cd12958695b41daa052 Mon Sep 17 00:00:00 2001 From: Siddhesh Naik Date: Thu, 21 Sep 2023 00:19:23 +0530 Subject: [PATCH 3/6] TobiGr - review comments - Used string resources for the sharing content formats. - Updated shared preference key to `remember_local_playlist_sharing_option_key` - Updated dialog string values. --- .../local/playlist/LocalPlaylistFragment.java | 50 +++++++++++-------- app/src/main/res/values/settings_keys.xml | 2 +- app/src/main/res/values/strings.xml | 8 +-- 3 files changed, 34 insertions(+), 26 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 c1cea305b08..5a4eab6e831 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 @@ -352,8 +352,8 @@ public void onComplete() { @Override public boolean onOptionsItemSelected(final MenuItem item) { if (item.getItemId() == R.id.menu_item_share_playlist) { - if (sharedPreferences.getBoolean(requireContext().getString( - R.string.share_playlist_with_details_can_show_dialog_key), true)) { + if (!sharedPreferences.getBoolean(requireContext().getString( + R.string.remember_local_playlist_sharing_option_key), false)) { createShareConfirmationDialog(); } else { sharePlaylist(); @@ -388,14 +388,19 @@ public boolean onOptionsItemSelected(final MenuItem item) { * Share the playlist as a newline-separated list of stream URLs and video names. */ private void sharePlaylist() { + final Context context = getContext(); + if (context == null) { + return; + } + final boolean shouldSharePlaylistDetails = sharedPreferences.getBoolean( - requireContext().getString(R.string.share_playlist_with_details_key), false); + context.getString(R.string.share_playlist_with_details_key), false); disposables.add(playlistManager.getPlaylistStreams(playlistId) .flatMapSingle(playlist -> Single.just(playlist.stream() .map(PlaylistStreamEntry::getStreamEntity) .map(streamEntity -> { if (shouldSharePlaylistDetails) { - return String.format("- %s: %s", + return context.getString(R.string.video_details_list_item, streamEntity.getTitle(), streamEntity.getUrl()); } else { return streamEntity.getUrl(); @@ -404,8 +409,9 @@ private void sharePlaylist() { .collect(Collectors.joining("\n")))) .observeOn(AndroidSchedulers.mainThread()) .subscribe(urlsText -> ShareUtils.shareText( - requireContext(), name, shouldSharePlaylistDetails - ? String.format("%s\n%s", name, urlsText) : urlsText), + context, name, shouldSharePlaylistDetails + ? context.getString(R.string.share_playlist_content_details, + name, urlsText) : urlsText), throwable -> showUiErrorSnackbar(this, "Sharing playlist", throwable))); } @@ -877,26 +883,26 @@ private void createShareConfirmationDialog() { .setCancelable(true) .setView(dialogBinding.getRoot()) .setPositiveButton(R.string.share_playlist_with_details, (dialog, which) -> { - sharedPreferences.edit() - .putBoolean(requireContext().getString( - R.string.share_playlist_with_details_can_show_dialog_key), - !dialogBinding.rememberChoiceCheckBox.isChecked()) - .putBoolean(requireContext().getString( - R.string.share_playlist_with_details_key), true) - .commit(); - sharePlaylist(); + savePreferencesAndSharePlaylist( + dialogBinding.rememberChoiceCheckBox.isChecked(), true); }) .setNegativeButton(R.string.share_playlist_with_list, (dialog, which) -> { - sharedPreferences.edit() - .putBoolean(requireContext().getString( - R.string.share_playlist_with_details_can_show_dialog_key), - !dialogBinding.rememberChoiceCheckBox.isChecked()) - .putBoolean(requireContext().getString( - R.string.share_playlist_with_details_key), false) - .commit(); - sharePlaylist(); + savePreferencesAndSharePlaylist( + dialogBinding.rememberChoiceCheckBox.isChecked(), false); }) .show(); } + + private void savePreferencesAndSharePlaylist(final boolean rememberPlaylistSharingOption, + final boolean sharePlaylistWithDetails) { + sharedPreferences.edit() + .putBoolean(requireContext().getString( + R.string.remember_local_playlist_sharing_option_key), + rememberPlaylistSharingOption) + .putBoolean(requireContext().getString( + R.string.share_playlist_with_details_key), sharePlaylistWithDetails) + .apply(); + sharePlaylist(); + } } diff --git a/app/src/main/res/values/settings_keys.xml b/app/src/main/res/values/settings_keys.xml index 23e3597b27f..42c2639c226 100644 --- a/app/src/main/res/values/settings_keys.xml +++ b/app/src/main/res/values/settings_keys.xml @@ -25,7 +25,7 @@ clear_queue_confirmation_key ignore_hardware_media_buttons_key share_playlist_with_details_key - share_playlist_with_details_can_show_dialog_key + remember_local_playlist_sharing_option_key popup_saved_width popup_saved_x diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8d723bacf13..317de1a92f3 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -833,9 +833,11 @@ High quality \? Share Playlist - Share playlist with details such as playlist name and video titles Or a simply share a list of video links + Share playlist with details such as playlist name and video titles or as a simple list of video URLs Share with details - Share list + Share URL list Remember my choice Share playlist with details such as playlist name and video titles - \ No newline at end of file + - %s: %s + %s\n%s + From 9b48adbc752e4503b3b550cd8302226e0f4fa00c Mon Sep 17 00:00:00 2001 From: Siddhesh Naik Date: Sat, 23 Sep 2023 18:29:45 +0530 Subject: [PATCH 4/6] Address review comments - Removed the setting item to update the playlist sharing preference. - Removed the option to save user's playlist sharing preference. Video demo: - https://github.com/TeamNewPipe/NewPipe/assets/87667048/5ac5ab6f-163d-4407-bd67-a078a8b55bbb PR Commit Message 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. - 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 Screenshots: | Before | After | | --- | --- | | | | Video demo: - https://github.com/TeamNewPipe/NewPipe/assets/87667048/5ac5ab6f-163d-4407-bd67-a078a8b55bbb --- .../local/playlist/LocalPlaylistFragment.java | 49 +++++-------------- .../main/res/layout/dialog_share_playlist.xml | 28 ----------- app/src/main/res/values/settings_keys.xml | 2 - app/src/main/res/values/strings.xml | 2 - app/src/main/res/xml/video_audio_settings.xml | 8 --- 5 files changed, 12 insertions(+), 77 deletions(-) delete mode 100644 app/src/main/res/layout/dialog_share_playlist.xml 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 5a4eab6e831..560ea46545a 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 @@ -5,7 +5,6 @@ import static org.schabi.newpipe.util.ThemeHelper.shouldUseGridLayout; import android.content.Context; -import android.content.SharedPreferences; import android.os.Bundle; import android.os.Parcelable; import android.text.InputType; @@ -23,7 +22,6 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AlertDialog; -import androidx.preference.PreferenceManager; import androidx.recyclerview.widget.ItemTouchHelper; import androidx.recyclerview.widget.RecyclerView; import androidx.viewbinding.ViewBinding; @@ -38,7 +36,6 @@ import org.schabi.newpipe.database.playlist.model.PlaylistEntity; import org.schabi.newpipe.database.stream.model.StreamEntity; import org.schabi.newpipe.databinding.DialogEditTextBinding; -import org.schabi.newpipe.databinding.DialogSharePlaylistBinding; import org.schabi.newpipe.databinding.LocalPlaylistHeaderBinding; import org.schabi.newpipe.databinding.PlaylistControlBinding; import org.schabi.newpipe.error.ErrorInfo; @@ -54,8 +51,8 @@ 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; @@ -102,8 +99,6 @@ public class LocalPlaylistFragment extends BaseLocalListFragment Single.just(playlist.stream() .map(PlaylistStreamEntry::getStreamEntity) @@ -875,34 +867,17 @@ private void createShareConfirmationDialog() { return; } - final DialogSharePlaylistBinding dialogBinding = DialogSharePlaylistBinding - .inflate(getLayoutInflater()); - new AlertDialog.Builder(getContext()) .setTitle(R.string.share_playlist) + .setMessage(R.string.share_playlist_with_details_message) .setCancelable(true) - .setView(dialogBinding.getRoot()) .setPositiveButton(R.string.share_playlist_with_details, (dialog, which) -> { - savePreferencesAndSharePlaylist( - dialogBinding.rememberChoiceCheckBox.isChecked(), true); + sharePlaylist(/* shouldSharePlaylistDetails= */ true); }) .setNegativeButton(R.string.share_playlist_with_list, (dialog, which) -> { - savePreferencesAndSharePlaylist( - dialogBinding.rememberChoiceCheckBox.isChecked(), false); + sharePlaylist(/* shouldSharePlaylistDetails= */ false); }) .show(); } - - private void savePreferencesAndSharePlaylist(final boolean rememberPlaylistSharingOption, - final boolean sharePlaylistWithDetails) { - sharedPreferences.edit() - .putBoolean(requireContext().getString( - R.string.remember_local_playlist_sharing_option_key), - rememberPlaylistSharingOption) - .putBoolean(requireContext().getString( - R.string.share_playlist_with_details_key), sharePlaylistWithDetails) - .apply(); - sharePlaylist(); - } } diff --git a/app/src/main/res/layout/dialog_share_playlist.xml b/app/src/main/res/layout/dialog_share_playlist.xml deleted file mode 100644 index 571264e57ea..00000000000 --- a/app/src/main/res/layout/dialog_share_playlist.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - diff --git a/app/src/main/res/values/settings_keys.xml b/app/src/main/res/values/settings_keys.xml index 42c2639c226..880fa92da7b 100644 --- a/app/src/main/res/values/settings_keys.xml +++ b/app/src/main/res/values/settings_keys.xml @@ -24,8 +24,6 @@ screen_brightness_timestamp_key clear_queue_confirmation_key ignore_hardware_media_buttons_key - share_playlist_with_details_key - remember_local_playlist_sharing_option_key popup_saved_width popup_saved_x diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 317de1a92f3..d956ba5ba93 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -836,8 +836,6 @@ Share playlist with details such as playlist name and video titles or as a simple list of video URLs Share with details Share URL list - Remember my choice - Share playlist with details such as playlist name and video titles - %s: %s %s\n%s diff --git a/app/src/main/res/xml/video_audio_settings.xml b/app/src/main/res/xml/video_audio_settings.xml index 87d89594278..727ce4df40a 100644 --- a/app/src/main/res/xml/video_audio_settings.xml +++ b/app/src/main/res/xml/video_audio_settings.xml @@ -249,13 +249,5 @@ android:title="@string/ignore_hardware_media_buttons_title" app:singleLineTitle="false" app:iconSpaceReserved="false" /> - - From cde8fb5b08cac19ef8ad6053b0ce58352eee906a Mon Sep 17 00:00:00 2001 From: Siddhesh Naik Date: Sun, 24 Sep 2023 13:36:30 +0530 Subject: [PATCH 5/6] Address review comments - opusforlife2 - Updated string value for the dialog option. Video demo: - https://github.com/TeamNewPipe/NewPipe/assets/87667048/09962034-146a-4fa6-acbc-5bc58cba2d10 PR Commit Message 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. - 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 Screenshots: | Before | After | Confirmation Dialog | | --- | --- | --- | | | | | Video demo: - https://github.com/TeamNewPipe/NewPipe/assets/87667048/09962034-146a-4fa6-acbc-5bc58cba2d10 --- .../schabi/newpipe/local/playlist/LocalPlaylistFragment.java | 4 ++-- app/src/main/res/values/strings.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 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 560ea46545a..79159292bd4 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 @@ -869,9 +869,9 @@ private void createShareConfirmationDialog() { new AlertDialog.Builder(getContext()) .setTitle(R.string.share_playlist) - .setMessage(R.string.share_playlist_with_details_message) + .setMessage(R.string.share_playlist_with_titles_message) .setCancelable(true) - .setPositiveButton(R.string.share_playlist_with_details, (dialog, which) -> { + .setPositiveButton(R.string.share_playlist_with_titles, (dialog, which) -> { sharePlaylist(/* shouldSharePlaylistDetails= */ true); }) .setNegativeButton(R.string.share_playlist_with_list, (dialog, which) -> { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d956ba5ba93..bf618739c16 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -833,8 +833,8 @@ High quality \? Share Playlist - Share playlist with details such as playlist name and video titles or as a simple list of video URLs - Share with details + 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 From 2e198e6be7074c9f83f1bdafc46adac5749c4dee Mon Sep 17 00:00:00 2001 From: TobiGr Date: Tue, 26 Sep 2023 10:37:07 +0200 Subject: [PATCH 6/6] Add documentation and make small improvements --- .../local/playlist/LocalPlaylistFragment.java | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 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 79159292bd4..28711c6fe2b 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 @@ -382,10 +382,7 @@ public boolean onOptionsItemSelected(final MenuItem item) { * shared content. */ private void sharePlaylist(final boolean shouldSharePlaylistDetails) { - final Context context = getContext(); - if (context == null) { - return; - } + final Context context = requireContext(); disposables.add(playlistManager.getPlaylistStreams(playlistId) .flatMapSingle(playlist -> Single.just(playlist.stream() @@ -862,21 +859,22 @@ private PlayQueue getPlayQueue(final int index) { return new SinglePlayQueue(streamInfoItems, index); } + /** + * Creates a dialog to confirm whether the user wants to share the playlist + * with the playlist details or just the list of stream URLs. + * After the user has made a choice, the playlist is shared. + */ private void createShareConfirmationDialog() { - if (getContext() == null) { - return; - } - - new AlertDialog.Builder(getContext()) + new AlertDialog.Builder(requireContext()) .setTitle(R.string.share_playlist) .setMessage(R.string.share_playlist_with_titles_message) .setCancelable(true) - .setPositiveButton(R.string.share_playlist_with_titles, (dialog, which) -> { - sharePlaylist(/* shouldSharePlaylistDetails= */ true); - }) - .setNegativeButton(R.string.share_playlist_with_list, (dialog, which) -> { - sharePlaylist(/* shouldSharePlaylistDetails= */ false); - }) + .setPositiveButton(R.string.share_playlist_with_titles, (dialog, which) -> + sharePlaylist(/* shouldSharePlaylistDetails= */ true) + ) + .setNegativeButton(R.string.share_playlist_with_list, (dialog, which) -> + sharePlaylist(/* shouldSharePlaylistDetails= */ false) + ) .show(); } }