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..42f5cf9b94e 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; @@ -36,6 +37,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 +101,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 +862,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 51abe14fbbf..11e9fa9f9f3 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 e6fb35a1634..f491004f37c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -811,4 +811,10 @@ About Channel tabs What tabs are shown on the channel pages + 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" /> + +