From 5fb7b3266b965cd725b0b4f72cb43e3f4427f3d6 Mon Sep 17 00:00:00 2001 From: Jared Fantaye Date: Fri, 16 Dec 2022 00:29:22 +0100 Subject: [PATCH] Removed the duplicate dialog and added another toast option --- .../local/dialog/PlaylistAppendDialog.java | 39 ++++--------------- app/src/main/res/values/strings.xml | 4 +- 2 files changed, 9 insertions(+), 34 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistAppendDialog.java b/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistAppendDialog.java index 5767d6163..3414d95ab 100644 --- a/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistAppendDialog.java +++ b/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistAppendDialog.java @@ -1,6 +1,5 @@ package org.schabi.newpipe.local.dialog; -import android.app.AlertDialog; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; @@ -177,20 +176,15 @@ public final class PlaylistAppendDialog extends PlaylistDialog { @NonNull final PlaylistMetadataEntry playlist, @NonNull final List streams) { - final int numberOfDuplicates = manager.getPlaylistDuplicateCount(playlist.uid, - streams.get(0).getUrl()).blockingFirst(); - if (numberOfDuplicates > 0) { - createDuplicateDialog(numberOfDuplicates, manager, playlist, streams); - } else { - addStreamToPlaylist(manager, playlist, streams); - } - } + final int numOfDuplicates = manager.getPlaylistDuplicateCount(playlist.uid, + streams.get(0).getUrl()).blockingFirst(); + String toastText = getString(R.string.playlist_add_stream_success); - private void addStreamToPlaylist(@NonNull final LocalPlaylistManager manager, - @NonNull final PlaylistMetadataEntry playlist, - @NonNull final List streams) { - final Toast successToast = Toast.makeText(getContext(), - R.string.playlist_add_stream_success, Toast.LENGTH_SHORT); + if (numOfDuplicates > 0) { + toastText = getString(R.string.playlist_add_stream_success_duplicate); + } + + final Toast successToast = Toast.makeText(getContext(), toastText, Toast.LENGTH_SHORT); if (playlist.thumbnailUrl .equals("drawable://" + R.drawable.placeholder_thumbnail_playlist)) { @@ -206,21 +200,4 @@ public final class PlaylistAppendDialog extends PlaylistDialog { requireDialog().dismiss(); } - - private void createDuplicateDialog(final int numberOfDuplicates, - @NonNull final LocalPlaylistManager manager, - @NonNull final PlaylistMetadataEntry playlist, - @NonNull final List streams) { - final AlertDialog.Builder builder = new AlertDialog.Builder(this.getActivity()); - builder.setTitle(R.string.duplicate_stream_in_playlist_title); - builder.setMessage(getString(R.string.duplicate_stream_in_playlist_description, - numberOfDuplicates)); - - builder.setPositiveButton(android.R.string.yes, (dialog, i) -> { - addStreamToPlaylist(manager, playlist, streams); - }); - builder.setNeutralButton(R.string.cancel, null); - - builder.create().show(); - } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 70687b8f4..4067381f4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -446,11 +446,9 @@ Delete this playlist\? Playlist created Playlisted + Playlisted duplicate Playlist thumbnail changed. Auto-generated (no uploader found) - Duplicated Video Found - The playlist contains this stream - already %d time(s).\nDo you want to add it one more time? No Captions Fit