Added menu with tappable list items

This commit is contained in:
Jared Fantaye 2022-12-03 09:52:04 +01:00
parent aad5e26f31
commit 8fc5fa979d
3 changed files with 38 additions and 1 deletions

View File

@ -15,6 +15,7 @@ public class PlaylistEntity {
public static final String PLAYLIST_ID = "uid"; public static final String PLAYLIST_ID = "uid";
public static final String PLAYLIST_NAME = "name"; public static final String PLAYLIST_NAME = "name";
public static final String PLAYLIST_THUMBNAIL_URL = "thumbnail_url"; public static final String PLAYLIST_THUMBNAIL_URL = "thumbnail_url";
//TODO: add field
@PrimaryKey(autoGenerate = true) @PrimaryKey(autoGenerate = true)
@ColumnInfo(name = PLAYLIST_ID) @ColumnInfo(name = PLAYLIST_ID)

View File

@ -1,5 +1,6 @@
package org.schabi.newpipe.local.bookmark; package org.schabi.newpipe.local.bookmark;
import android.content.DialogInterface;
import android.os.Bundle; import android.os.Bundle;
import android.os.Parcelable; import android.os.Parcelable;
import android.text.InputType; import android.text.InputType;
@ -23,6 +24,7 @@ import org.schabi.newpipe.database.playlist.PlaylistLocalItem;
import org.schabi.newpipe.database.playlist.PlaylistMetadataEntry; import org.schabi.newpipe.database.playlist.PlaylistMetadataEntry;
import org.schabi.newpipe.database.playlist.model.PlaylistRemoteEntity; import org.schabi.newpipe.database.playlist.model.PlaylistRemoteEntity;
import org.schabi.newpipe.databinding.DialogEditTextBinding; import org.schabi.newpipe.databinding.DialogEditTextBinding;
import org.schabi.newpipe.databinding.DialogTitleBinding;
import org.schabi.newpipe.error.ErrorInfo; import org.schabi.newpipe.error.ErrorInfo;
import org.schabi.newpipe.error.UserAction; import org.schabi.newpipe.error.UserAction;
import org.schabi.newpipe.local.BaseLocalListFragment; import org.schabi.newpipe.local.BaseLocalListFragment;
@ -256,6 +258,37 @@ public final class BookmarkFragment extends BaseLocalListFragment<List<PlaylistL
} }
private void showLocalDialog(final PlaylistMetadataEntry selectedItem) { private void showLocalDialog(final PlaylistMetadataEntry selectedItem) {
//TODO
final DialogTitleBinding dialogBinding =
DialogTitleBinding.inflate(LayoutInflater.from(requireContext()));
dialogBinding.itemRoot.setVisibility(View.GONE);
dialogBinding.itemTitleView.setVisibility(View.GONE);
dialogBinding.itemAdditionalDetails.setVisibility(View.GONE);
final String[] items = new String[]{"Delete", "Rename", "Thumbnail"};
final DialogInterface.OnClickListener action = (d, index) -> {
switch (index) {
case 0: showRenameDialog(selectedItem);
break;
case 1:
break;
case 2:
break;
}
};
//TODO add rename dialog
final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setItems(items, action)
.create()
.show();
}
private void showRenameDialog(final PlaylistMetadataEntry selectedItem) {
final DialogEditTextBinding dialogBinding = final DialogEditTextBinding dialogBinding =
DialogEditTextBinding.inflate(getLayoutInflater()); DialogEditTextBinding.inflate(getLayoutInflater());
dialogBinding.dialogEditText.setHint(R.string.name); dialogBinding.dialogEditText.setHint(R.string.name);

View File

@ -406,6 +406,7 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
// Remove Watched, Functionality data // Remove Watched, Functionality data
final List<PlaylistStreamEntry> notWatchedItems = new ArrayList<>(); final List<PlaylistStreamEntry> notWatchedItems = new ArrayList<>();
boolean thumbnailVideoRemoved = false; boolean thumbnailVideoRemoved = false;
//TODO: add blocker here
if (removePartiallyWatched) { if (removePartiallyWatched) {
for (final var playlistItem : playlist) { for (final var playlistItem : playlist) {
@ -590,6 +591,8 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
return; return;
} }
//TODO add blocker here
final Toast successToast = Toast.makeText(getActivity(), final Toast successToast = Toast.makeText(getActivity(),
R.string.playlist_thumbnail_change_success, R.string.playlist_thumbnail_change_success,
Toast.LENGTH_SHORT); Toast.LENGTH_SHORT);
@ -610,7 +613,7 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
private void updateThumbnailUrl() { private void updateThumbnailUrl() {
final String newThumbnailUrl; final String newThumbnailUrl;
//TODO: add blocker here
if (!itemListAdapter.getItemsList().isEmpty()) { if (!itemListAdapter.getItemsList().isEmpty()) {
newThumbnailUrl = ((PlaylistStreamEntry) itemListAdapter.getItemsList().get(0)) newThumbnailUrl = ((PlaylistStreamEntry) itemListAdapter.getItemsList().get(0))
.getStreamEntity().getThumbnailUrl(); .getStreamEntity().getThumbnailUrl();