Skip to content

Commit 3997d5d

Browse files
committed
Use checkbox to remove partially watched videos
1 parent 6b6d6ff commit 3997d5d

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import android.view.MenuItem;
2323
import android.view.View;
2424
import android.view.ViewGroup;
25+
import android.widget.LinearLayout;
2526
import android.widget.Toast;
2627

2728
import androidx.annotation.NonNull;
@@ -55,6 +56,7 @@
5556
import org.schabi.newpipe.local.history.HistoryRecordManager;
5657
import org.schabi.newpipe.player.playqueue.PlayQueue;
5758
import org.schabi.newpipe.player.playqueue.SinglePlayQueue;
59+
import org.schabi.newpipe.util.DeviceUtils;
5860
import org.schabi.newpipe.util.Localization;
5961
import org.schabi.newpipe.util.NavigationHelper;
6062
import org.schabi.newpipe.util.OnClickGesture;
@@ -366,16 +368,29 @@ public boolean onOptionsItemSelected(final MenuItem item) {
366368
createRenameDialog();
367369
} else if (item.getItemId() == R.id.menu_item_remove_watched) {
368370
if (!isRewritingPlaylist) {
371+
final android.widget.CheckBox removePartiallyWatchedCheckbox =
372+
new android.widget.CheckBox(requireContext());
373+
removePartiallyWatchedCheckbox.setText(
374+
R.string.remove_watched_popup_yes_and_partially_watched_videos);
375+
376+
// Wrap the checkbox in a container with dialog-like horizontal padding
377+
// so it aligns with the dialog title/message on the start side.
378+
final LinearLayout checkboxContainer = new LinearLayout(requireContext());
379+
checkboxContainer.setOrientation(LinearLayout.VERTICAL);
380+
final int padding = DeviceUtils.dpToPx(20, requireContext());
381+
checkboxContainer.setPadding(padding, padding, padding, 0);
382+
checkboxContainer.addView(removePartiallyWatchedCheckbox,
383+
new android.widget.LinearLayout.LayoutParams(
384+
ViewGroup.LayoutParams.MATCH_PARENT,
385+
ViewGroup.LayoutParams.WRAP_CONTENT));
386+
369387
new AlertDialog.Builder(requireContext())
370388
.setMessage(R.string.remove_watched_popup_warning)
371389
.setTitle(R.string.remove_watched_popup_title)
390+
.setView(checkboxContainer)
372391
.setPositiveButton(R.string.ok, (d, id) ->
373-
removeWatchedStreams(false))
374-
.setNeutralButton(
375-
R.string.remove_watched_popup_yes_and_partially_watched_videos,
376-
(d, id) -> removeWatchedStreams(true))
377-
.setNegativeButton(R.string.cancel,
378-
(d, id) -> d.cancel())
392+
removeWatchedStreams(removePartiallyWatchedCheckbox.isChecked()))
393+
.setNegativeButton(R.string.cancel, (d, id) -> d.cancel())
379394
.show();
380395
}
381396
} else if (item.getItemId() == R.id.menu_item_remove_duplicates) {

0 commit comments

Comments
 (0)