From c470909f190465cae3b00621b6b8811070cf7ee9 Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Mon, 23 Apr 2018 22:02:36 +0200 Subject: [PATCH] add delete options for StatisticPlaylistFragment --- .../newpipe/fragments/MainFragment.java | 2 +- .../fragments/detail/VideoDetailFragment.java | 2 +- .../fragments/list/BaseListFragment.java | 38 +------------------ .../newpipe/local/BaseLocalListFragment.java | 1 - .../newpipe/local/HeaderFooterHolder.java | 2 +- .../newpipe/local/LocalItemBuilder.java | 2 +- .../newpipe/local/LocalItemListAdapter.java | 14 ++++--- .../local/bookmark/BookmarkFragment.java | 2 +- .../local/dialog/PlaylistAppendDialog.java | 4 +- .../local/dialog/PlaylistCreationDialog.java | 2 +- .../newpipe/local/dialog/PlaylistDialog.java | 2 +- .../history/StatisticsPlaylistFragment.java | 18 +++++++++ .../newpipe/local/holder/LocalItemHolder.java | 4 +- .../local/holder/LocalPlaylistItemHolder.java | 4 +- .../holder/LocalPlaylistStreamItemHolder.java | 4 +- .../LocalStatisticStreamItemHolder.java | 4 +- .../local/holder/PlaylistItemHolder.java | 4 +- .../holder/RemotePlaylistItemHolder.java | 4 +- .../newpipe/player/ServicePlayerActivity.java | 2 +- app/src/main/res/values/strings.xml | 1 + 20 files changed, 50 insertions(+), 66 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java index 6167672eb..31092d3e6 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java @@ -29,7 +29,7 @@ import org.schabi.newpipe.extractor.kiosk.KioskList; import org.schabi.newpipe.fragments.list.channel.ChannelFragment; import org.schabi.newpipe.local.feed.FeedFragment; import org.schabi.newpipe.fragments.list.kiosk.KioskFragment; -import org.schabi.newpipe.fragments.local.bookmark.BookmarkFragment; +import org.schabi.newpipe.local.bookmark.BookmarkFragment; import org.schabi.newpipe.local.subscription.SubscriptionFragment; import org.schabi.newpipe.report.ErrorActivity; import org.schabi.newpipe.report.UserAction; diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java index 3bf7fd3b8..68c0a11ff 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java @@ -64,7 +64,7 @@ import org.schabi.newpipe.fragments.BackPressable; import org.schabi.newpipe.fragments.BaseStateFragment; import org.schabi.newpipe.util.StreamItemAdapter; import org.schabi.newpipe.util.StreamItemAdapter.StreamSizeWrapper; -import org.schabi.newpipe.fragments.local.dialog.PlaylistAppendDialog; +import org.schabi.newpipe.local.dialog.PlaylistAppendDialog; import org.schabi.newpipe.info_list.InfoItemBuilder; import org.schabi.newpipe.info_list.InfoItemDialog; import org.schabi.newpipe.player.MainVideoPlayer; diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListFragment.java index 30922192c..14ec50775 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListFragment.java @@ -20,8 +20,7 @@ import org.schabi.newpipe.extractor.playlist.PlaylistInfoItem; import org.schabi.newpipe.extractor.stream.StreamInfoItem; import org.schabi.newpipe.fragments.BaseStateFragment; import org.schabi.newpipe.fragments.OnScrollBelowItemsListener; -import org.schabi.newpipe.fragments.local.dialog.PlaylistAppendDialog; -import org.schabi.newpipe.local.history.HistoryInfoItem; +import org.schabi.newpipe.local.dialog.PlaylistAppendDialog; import org.schabi.newpipe.info_list.InfoItemDialog; import org.schabi.newpipe.info_list.InfoListAdapter; import org.schabi.newpipe.player.playqueue.SinglePlayQueue; @@ -222,41 +221,6 @@ public abstract class BaseListFragment extends BaseStateFragment implem new InfoItemDialog(getActivity(), item, commands, actions).show(); } - protected void showHistoryItemDialog(final HistoryInfoItem item) { - final Context context = getContext(); - final Activity activity = getActivity(); - if (context == null || context.getResources() == null || getActivity() == null) return; - - final String[] commands = new String[]{ - context.getResources().getString(R.string.enqueue_on_background), - context.getResources().getString(R.string.enqueue_on_popup), - context.getResources().getString(R.string.append_playlist), - context.getResources().getString(R.string.delete) - }; - - final DialogInterface.OnClickListener actions = (dialogInterface, i) -> { - switch (i) { - case 0: - NavigationHelper.enqueueOnBackgroundPlayer(context, new SinglePlayQueue(item)); - break; - case 1: - NavigationHelper.enqueueOnPopupPlayer(activity, new SinglePlayQueue(item)); - break; - case 2: - if (getFragmentManager() != null) { - PlaylistAppendDialog.fromStreamInfoItems(Collections.singletonList(item)) - .show(getFragmentManager(), TAG); - } - break; - case 3: - - default: - break; - } - }; - - new InfoItemDialog(getActivity(), item, commands, actions).show(); - } /*////////////////////////////////////////////////////////////////////////// // Menu //////////////////////////////////////////////////////////////////////////*/ diff --git a/app/src/main/java/org/schabi/newpipe/local/BaseLocalListFragment.java b/app/src/main/java/org/schabi/newpipe/local/BaseLocalListFragment.java index f581a3abf..5192aa2ab 100644 --- a/app/src/main/java/org/schabi/newpipe/local/BaseLocalListFragment.java +++ b/app/src/main/java/org/schabi/newpipe/local/BaseLocalListFragment.java @@ -13,7 +13,6 @@ import android.view.View; import org.schabi.newpipe.R; import org.schabi.newpipe.fragments.BaseStateFragment; import org.schabi.newpipe.fragments.list.ListViewContract; -import org.schabi.newpipe.fragments.local.LocalItemListAdapter; import static org.schabi.newpipe.util.AnimationUtils.animateView; diff --git a/app/src/main/java/org/schabi/newpipe/local/HeaderFooterHolder.java b/app/src/main/java/org/schabi/newpipe/local/HeaderFooterHolder.java index 3c0830751..49a552b3e 100644 --- a/app/src/main/java/org/schabi/newpipe/local/HeaderFooterHolder.java +++ b/app/src/main/java/org/schabi/newpipe/local/HeaderFooterHolder.java @@ -1,4 +1,4 @@ -package org.schabi.newpipe.fragments.local; +package org.schabi.newpipe.local; import android.support.v7.widget.RecyclerView; import android.view.View; diff --git a/app/src/main/java/org/schabi/newpipe/local/LocalItemBuilder.java b/app/src/main/java/org/schabi/newpipe/local/LocalItemBuilder.java index 5dc6c17a4..148f93075 100644 --- a/app/src/main/java/org/schabi/newpipe/local/LocalItemBuilder.java +++ b/app/src/main/java/org/schabi/newpipe/local/LocalItemBuilder.java @@ -1,4 +1,4 @@ -package org.schabi.newpipe.fragments.local; +package org.schabi.newpipe.local; import android.content.Context; import android.widget.ImageView; diff --git a/app/src/main/java/org/schabi/newpipe/local/LocalItemListAdapter.java b/app/src/main/java/org/schabi/newpipe/local/LocalItemListAdapter.java index d36f56733..d05ef3488 100644 --- a/app/src/main/java/org/schabi/newpipe/local/LocalItemListAdapter.java +++ b/app/src/main/java/org/schabi/newpipe/local/LocalItemListAdapter.java @@ -1,4 +1,4 @@ -package org.schabi.newpipe.fragments.local; +package org.schabi.newpipe.local; import android.app.Activity; import android.support.v7.widget.RecyclerView; @@ -7,11 +7,13 @@ import android.view.View; import android.view.ViewGroup; import org.schabi.newpipe.database.LocalItem; -import org.schabi.newpipe.fragments.local.holder.LocalItemHolder; -import org.schabi.newpipe.fragments.local.holder.LocalPlaylistItemHolder; -import org.schabi.newpipe.fragments.local.holder.LocalPlaylistStreamItemHolder; -import org.schabi.newpipe.fragments.local.holder.LocalStatisticStreamItemHolder; -import org.schabi.newpipe.fragments.local.holder.RemotePlaylistItemHolder; +import org.schabi.newpipe.local.HeaderFooterHolder; +import org.schabi.newpipe.local.LocalItemBuilder; +import org.schabi.newpipe.local.holder.LocalItemHolder; +import org.schabi.newpipe.local.holder.LocalPlaylistItemHolder; +import org.schabi.newpipe.local.holder.LocalPlaylistStreamItemHolder; +import org.schabi.newpipe.local.holder.LocalStatisticStreamItemHolder; +import org.schabi.newpipe.local.holder.RemotePlaylistItemHolder; import org.schabi.newpipe.util.Localization; import org.schabi.newpipe.util.OnClickGesture; diff --git a/app/src/main/java/org/schabi/newpipe/local/bookmark/BookmarkFragment.java b/app/src/main/java/org/schabi/newpipe/local/bookmark/BookmarkFragment.java index f57ef3354..abaf691a4 100644 --- a/app/src/main/java/org/schabi/newpipe/local/bookmark/BookmarkFragment.java +++ b/app/src/main/java/org/schabi/newpipe/local/bookmark/BookmarkFragment.java @@ -1,4 +1,4 @@ -package org.schabi.newpipe.fragments.local.bookmark; +package org.schabi.newpipe.local.bookmark; import android.app.AlertDialog; import android.os.Bundle; 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 35d0eb11a..e422b332a 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,4 +1,4 @@ -package org.schabi.newpipe.fragments.local.dialog; +package org.schabi.newpipe.local.dialog; import android.annotation.SuppressLint; import android.os.Bundle; @@ -18,7 +18,7 @@ import org.schabi.newpipe.database.playlist.PlaylistMetadataEntry; import org.schabi.newpipe.database.stream.model.StreamEntity; import org.schabi.newpipe.extractor.stream.StreamInfo; import org.schabi.newpipe.extractor.stream.StreamInfoItem; -import org.schabi.newpipe.fragments.local.LocalItemListAdapter; +import org.schabi.newpipe.local.LocalItemListAdapter; import org.schabi.newpipe.local.playlist.LocalPlaylistManager; import org.schabi.newpipe.player.playqueue.PlayQueueItem; import org.schabi.newpipe.util.OnClickGesture; diff --git a/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistCreationDialog.java b/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistCreationDialog.java index c7d413bce..ddbe65399 100644 --- a/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistCreationDialog.java +++ b/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistCreationDialog.java @@ -1,4 +1,4 @@ -package org.schabi.newpipe.fragments.local.dialog; +package org.schabi.newpipe.local.dialog; import android.app.AlertDialog; import android.app.Dialog; diff --git a/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistDialog.java b/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistDialog.java index a632988c4..4b8e391c7 100644 --- a/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistDialog.java +++ b/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistDialog.java @@ -1,4 +1,4 @@ -package org.schabi.newpipe.fragments.local.dialog; +package org.schabi.newpipe.local.dialog; import android.os.Bundle; import android.support.annotation.NonNull; diff --git a/app/src/main/java/org/schabi/newpipe/local/history/StatisticsPlaylistFragment.java b/app/src/main/java/org/schabi/newpipe/local/history/StatisticsPlaylistFragment.java index b08b731ea..4e449b51d 100644 --- a/app/src/main/java/org/schabi/newpipe/local/history/StatisticsPlaylistFragment.java +++ b/app/src/main/java/org/schabi/newpipe/local/history/StatisticsPlaylistFragment.java @@ -7,6 +7,7 @@ import android.os.Bundle; import android.os.Parcelable; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.support.design.widget.Snackbar; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -250,6 +251,7 @@ public abstract class StatisticsPlaylistFragment context.getResources().getString(R.string.start_here_on_main), context.getResources().getString(R.string.start_here_on_background), context.getResources().getString(R.string.start_here_on_popup), + context.getResources().getString(R.string.delete), }; final DialogInterface.OnClickListener actions = (dialogInterface, i) -> { @@ -270,6 +272,9 @@ public abstract class StatisticsPlaylistFragment case 4: NavigationHelper.playOnPopupPlayer(activity, getPlayQueue(index)); break; + case 5: + deleteEntry(index); + break; default: break; } @@ -278,6 +283,19 @@ public abstract class StatisticsPlaylistFragment new InfoItemDialog(getActivity(), infoItem, commands, actions).show(); } + private void deleteEntry(final int index) { + final LocalItem infoItem = itemListAdapter.getItemsList() + .get(index); + if(infoItem instanceof StreamStatisticsEntry) { + final StreamStatisticsEntry entry = (StreamStatisticsEntry) infoItem; + recordManager.deleteStreamHistory(entry.streamId); + + Snackbar.make(getView(), R.string.one_item_deleted, Snackbar.LENGTH_SHORT) + .show(); + startLoading(true); + } + } + private PlayQueue getPlayQueue() { return getPlayQueue(0); } diff --git a/app/src/main/java/org/schabi/newpipe/local/holder/LocalItemHolder.java b/app/src/main/java/org/schabi/newpipe/local/holder/LocalItemHolder.java index 2dffdbfdb..889751afa 100644 --- a/app/src/main/java/org/schabi/newpipe/local/holder/LocalItemHolder.java +++ b/app/src/main/java/org/schabi/newpipe/local/holder/LocalItemHolder.java @@ -1,11 +1,11 @@ -package org.schabi.newpipe.fragments.local.holder; +package org.schabi.newpipe.local.holder; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.ViewGroup; import org.schabi.newpipe.database.LocalItem; -import org.schabi.newpipe.fragments.local.LocalItemBuilder; +import org.schabi.newpipe.local.LocalItemBuilder; import java.text.DateFormat; diff --git a/app/src/main/java/org/schabi/newpipe/local/holder/LocalPlaylistItemHolder.java b/app/src/main/java/org/schabi/newpipe/local/holder/LocalPlaylistItemHolder.java index d9eb7caa5..1a5ec63bf 100644 --- a/app/src/main/java/org/schabi/newpipe/local/holder/LocalPlaylistItemHolder.java +++ b/app/src/main/java/org/schabi/newpipe/local/holder/LocalPlaylistItemHolder.java @@ -1,11 +1,11 @@ -package org.schabi.newpipe.fragments.local.holder; +package org.schabi.newpipe.local.holder; import android.view.View; import android.view.ViewGroup; import org.schabi.newpipe.database.LocalItem; import org.schabi.newpipe.database.playlist.PlaylistMetadataEntry; -import org.schabi.newpipe.fragments.local.LocalItemBuilder; +import org.schabi.newpipe.local.LocalItemBuilder; import org.schabi.newpipe.util.ImageDisplayConstants; import java.text.DateFormat; diff --git a/app/src/main/java/org/schabi/newpipe/local/holder/LocalPlaylistStreamItemHolder.java b/app/src/main/java/org/schabi/newpipe/local/holder/LocalPlaylistStreamItemHolder.java index 5f9555d9f..e591b73e5 100644 --- a/app/src/main/java/org/schabi/newpipe/local/holder/LocalPlaylistStreamItemHolder.java +++ b/app/src/main/java/org/schabi/newpipe/local/holder/LocalPlaylistStreamItemHolder.java @@ -1,4 +1,4 @@ -package org.schabi.newpipe.fragments.local.holder; +package org.schabi.newpipe.local.holder; import android.support.v4.content.ContextCompat; import android.view.MotionEvent; @@ -11,7 +11,7 @@ import org.schabi.newpipe.R; import org.schabi.newpipe.database.LocalItem; import org.schabi.newpipe.database.playlist.PlaylistStreamEntry; import org.schabi.newpipe.extractor.NewPipe; -import org.schabi.newpipe.fragments.local.LocalItemBuilder; +import org.schabi.newpipe.local.LocalItemBuilder; import org.schabi.newpipe.util.ImageDisplayConstants; import org.schabi.newpipe.util.Localization; diff --git a/app/src/main/java/org/schabi/newpipe/local/holder/LocalStatisticStreamItemHolder.java b/app/src/main/java/org/schabi/newpipe/local/holder/LocalStatisticStreamItemHolder.java index 199158672..b2a04ca9c 100644 --- a/app/src/main/java/org/schabi/newpipe/local/holder/LocalStatisticStreamItemHolder.java +++ b/app/src/main/java/org/schabi/newpipe/local/holder/LocalStatisticStreamItemHolder.java @@ -1,4 +1,4 @@ -package org.schabi.newpipe.fragments.local.holder; +package org.schabi.newpipe.local.holder; import android.support.v4.content.ContextCompat; import android.view.View; @@ -10,7 +10,7 @@ import org.schabi.newpipe.R; import org.schabi.newpipe.database.LocalItem; import org.schabi.newpipe.database.stream.StreamStatisticsEntry; import org.schabi.newpipe.extractor.NewPipe; -import org.schabi.newpipe.fragments.local.LocalItemBuilder; +import org.schabi.newpipe.local.LocalItemBuilder; import org.schabi.newpipe.util.ImageDisplayConstants; import org.schabi.newpipe.util.Localization; diff --git a/app/src/main/java/org/schabi/newpipe/local/holder/PlaylistItemHolder.java b/app/src/main/java/org/schabi/newpipe/local/holder/PlaylistItemHolder.java index 57bc2a3cb..5d6f192e1 100644 --- a/app/src/main/java/org/schabi/newpipe/local/holder/PlaylistItemHolder.java +++ b/app/src/main/java/org/schabi/newpipe/local/holder/PlaylistItemHolder.java @@ -1,4 +1,4 @@ -package org.schabi.newpipe.fragments.local.holder; +package org.schabi.newpipe.local.holder; import android.view.ViewGroup; import android.widget.ImageView; @@ -6,7 +6,7 @@ import android.widget.TextView; import org.schabi.newpipe.R; import org.schabi.newpipe.database.LocalItem; -import org.schabi.newpipe.fragments.local.LocalItemBuilder; +import org.schabi.newpipe.local.LocalItemBuilder; import java.text.DateFormat; diff --git a/app/src/main/java/org/schabi/newpipe/local/holder/RemotePlaylistItemHolder.java b/app/src/main/java/org/schabi/newpipe/local/holder/RemotePlaylistItemHolder.java index 871138464..12d3063b0 100644 --- a/app/src/main/java/org/schabi/newpipe/local/holder/RemotePlaylistItemHolder.java +++ b/app/src/main/java/org/schabi/newpipe/local/holder/RemotePlaylistItemHolder.java @@ -1,11 +1,11 @@ -package org.schabi.newpipe.fragments.local.holder; +package org.schabi.newpipe.local.holder; import android.view.ViewGroup; import org.schabi.newpipe.database.LocalItem; import org.schabi.newpipe.database.playlist.model.PlaylistRemoteEntity; import org.schabi.newpipe.extractor.NewPipe; -import org.schabi.newpipe.fragments.local.LocalItemBuilder; +import org.schabi.newpipe.local.LocalItemBuilder; import org.schabi.newpipe.util.ImageDisplayConstants; import org.schabi.newpipe.util.Localization; diff --git a/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java b/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java index 4aa8a1472..8b96b651e 100644 --- a/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java +++ b/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java @@ -29,7 +29,7 @@ import com.google.android.exoplayer2.Player; import org.schabi.newpipe.R; import org.schabi.newpipe.extractor.stream.StreamInfo; import org.schabi.newpipe.fragments.OnScrollBelowItemsListener; -import org.schabi.newpipe.fragments.local.dialog.PlaylistAppendDialog; +import org.schabi.newpipe.local.dialog.PlaylistAppendDialog; import org.schabi.newpipe.player.event.PlayerEventListener; import org.schabi.newpipe.player.helper.PlaybackParameterDialog; import org.schabi.newpipe.player.playqueue.PlayQueueAdapter; diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 939e0df13..8878513c1 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -273,6 +273,7 @@ Copied to clipboard Please select an available download folder This permission is needed to\nopen in popup mode + 1 item deleted. MD5