Skip to content

Commit 0611d65

Browse files
TobiGrStypox
authored andcommitted
Use checkbox to remove partially watched videos
1 parent d1f6337 commit 0611d65

1 file changed

Lines changed: 22 additions & 7 deletions

File tree

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

Lines changed: 22 additions & 7 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;
@@ -54,6 +55,7 @@
5455
import org.schabi.newpipe.local.history.HistoryRecordManager;
5556
import org.schabi.newpipe.player.playqueue.PlayQueue;
5657
import org.schabi.newpipe.player.playqueue.SinglePlayQueue;
58+
import org.schabi.newpipe.util.DeviceUtils;
5759
import org.schabi.newpipe.util.Localization;
5860
import org.schabi.newpipe.util.NavigationHelper;
5961
import org.schabi.newpipe.util.OnClickGesture;
@@ -365,16 +367,29 @@ public boolean onOptionsItemSelected(final MenuItem item) {
365367
createRenameDialog();
366368
} else if (item.getItemId() == R.id.menu_item_remove_watched) {
367369
if (!isRewritingPlaylist) {
370+
final android.widget.CheckBox removePartiallyWatchedCheckbox =
371+
new android.widget.CheckBox(requireContext());
372+
removePartiallyWatchedCheckbox.setText(
373+
R.string.remove_watched_popup_yes_and_partially_watched_videos);
374+
375+
// Wrap the checkbox in a container with dialog-like horizontal padding
376+
// so it aligns with the dialog title/message on the start side.
377+
final LinearLayout checkboxContainer = new LinearLayout(requireContext());
378+
checkboxContainer.setOrientation(LinearLayout.VERTICAL);
379+
final int padding = DeviceUtils.dpToPx(20, requireContext());
380+
checkboxContainer.setPadding(padding, padding, padding, 0);
381+
checkboxContainer.addView(removePartiallyWatchedCheckbox,
382+
new android.widget.LinearLayout.LayoutParams(
383+
ViewGroup.LayoutParams.MATCH_PARENT,
384+
ViewGroup.LayoutParams.WRAP_CONTENT));
385+
368386
new AlertDialog.Builder(requireContext())
369387
.setMessage(R.string.remove_watched_popup_warning)
370388
.setTitle(R.string.remove_watched_popup_title)
371-
.setPositiveButton(R.string.ok, (d, id) ->
372-
removeWatchedStreams(false))
373-
.setNeutralButton(
374-
R.string.remove_watched_popup_yes_and_partially_watched_videos,
375-
(d, id) -> removeWatchedStreams(true))
376-
.setNegativeButton(R.string.cancel,
377-
(d, id) -> d.cancel())
389+
.setView(checkboxContainer)
390+
.setPositiveButton(R.string.yes, (d, id) ->
391+
removeWatchedStreams(removePartiallyWatchedCheckbox.isChecked()))
392+
.setNegativeButton(R.string.cancel, (d, id) -> d.cancel())
378393
.show();
379394
}
380395
} else if (item.getItemId() == R.id.menu_item_remove_duplicates) {

0 commit comments

Comments
 (0)