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 c7b61eceb..7f8afdbe8 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 @@ -58,6 +58,7 @@ import org.schabi.newpipe.extractor.stream.StreamInfoItem; import org.schabi.newpipe.extractor.stream.VideoStream; import org.schabi.newpipe.fragments.BackPressable; import org.schabi.newpipe.fragments.BaseStateFragment; +import org.schabi.newpipe.fragments.local.PlaylistAppendDialog; import org.schabi.newpipe.history.HistoryListener; import org.schabi.newpipe.info_list.InfoItemBuilder; import org.schabi.newpipe.info_list.InfoItemDialog; @@ -145,6 +146,7 @@ public class VideoDetailFragment extends BaseStateFragment implement private TextView detailControlsBackground; private TextView detailControlsPopup; + private TextView detailControlsAddToPlaylist; private TextView appendControlsDetail; private LinearLayout videoDescriptionRootLayout; @@ -327,6 +329,11 @@ public class VideoDetailFragment extends BaseStateFragment implement case R.id.detail_controls_popup: openPopupPlayer(false); break; + case R.id.detail_controls_playlist_append: + if (getFragmentManager() != null && currentInfo != null) { + PlaylistAppendDialog.newInstance(currentInfo).show(getFragmentManager(), TAG); + } + break; case R.id.detail_uploader_root_layout: if (TextUtils.isEmpty(currentInfo.getUploaderUrl())) { Log.w(TAG, "Can't open channel because we got no channel URL"); @@ -429,6 +436,7 @@ public class VideoDetailFragment extends BaseStateFragment implement detailControlsBackground = rootView.findViewById(R.id.detail_controls_background); detailControlsPopup = rootView.findViewById(R.id.detail_controls_popup); + detailControlsAddToPlaylist = rootView.findViewById(R.id.detail_controls_playlist_append); appendControlsDetail = rootView.findViewById(R.id.touch_append_detail); videoDescriptionRootLayout = rootView.findViewById(R.id.detail_description_root_layout); @@ -479,6 +487,7 @@ public class VideoDetailFragment extends BaseStateFragment implement thumbnailBackgroundButton.setOnClickListener(this); detailControlsBackground.setOnClickListener(this); detailControlsPopup.setOnClickListener(this); + detailControlsAddToPlaylist.setOnClickListener(this); relatedStreamExpandButton.setOnClickListener(this); detailControlsBackground.setLongClickable(true); diff --git a/app/src/main/java/org/schabi/newpipe/fragments/local/LocalPlaylistFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/local/LocalPlaylistFragment.java index 6709b1bad..44ecfb924 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/local/LocalPlaylistFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/local/LocalPlaylistFragment.java @@ -144,9 +144,8 @@ public class LocalPlaylistFragment extends BaseListFragment, infoListAdapter.setOnStreamSelectedListener(new InfoItemBuilder.OnInfoItemSelectedListener() { @Override public void selected(StreamInfoItem selectedItem) { - if (getParentFragment() == null) return; // Requires the parent fragment to find holder for fragment replacement - NavigationHelper.openVideoDetailFragment(getParentFragment().getFragmentManager(), + NavigationHelper.openVideoDetailFragment(getFragmentManager(), selectedItem.getServiceId(), selectedItem.url, selectedItem.getName()); } diff --git a/app/src/main/java/org/schabi/newpipe/fragments/local/MostPlayedFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/local/MostPlayedFragment.java index 466b1d569..7862cf2f4 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/local/MostPlayedFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/local/MostPlayedFragment.java @@ -9,7 +9,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -public class MostPlayedFragment extends HistoryPlaylistFragment { +public class MostPlayedFragment extends StatisticsPlaylistFragment { @Override protected String getName() { return getString(R.string.title_most_played); diff --git a/app/src/main/java/org/schabi/newpipe/fragments/local/HistoryPlaylistFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/local/StatisticsPlaylistFragment.java similarity index 96% rename from app/src/main/java/org/schabi/newpipe/fragments/local/HistoryPlaylistFragment.java rename to app/src/main/java/org/schabi/newpipe/fragments/local/StatisticsPlaylistFragment.java index 3941df6c0..8db1f8780 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/local/HistoryPlaylistFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/local/StatisticsPlaylistFragment.java @@ -35,7 +35,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers; import static org.schabi.newpipe.util.AnimationUtils.animateView; -public abstract class HistoryPlaylistFragment +public abstract class StatisticsPlaylistFragment extends BaseListFragment, Void> { private View headerRootLayout; @@ -130,9 +130,7 @@ public abstract class HistoryPlaylistFragment infoListAdapter.setOnStreamSelectedListener(new InfoItemBuilder.OnInfoItemSelectedListener() { @Override public void selected(StreamInfoItem selectedItem) { - if (getParentFragment() == null) return; - // Requires the parent fragment to find holder for fragment replacement - NavigationHelper.openVideoDetailFragment(getParentFragment().getFragmentManager(), + NavigationHelper.openVideoDetailFragment(getFragmentManager(), selectedItem.getServiceId(), selectedItem.url, selectedItem.getName()); } @@ -231,7 +229,7 @@ public abstract class HistoryPlaylistFragment @Override public void onError(Throwable exception) { - HistoryPlaylistFragment.this.onError(exception); + StatisticsPlaylistFragment.this.onError(exception); } @Override diff --git a/app/src/main/java/org/schabi/newpipe/fragments/local/WatchHistoryFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/local/WatchHistoryFragment.java index 794872954..2a4b8cfb0 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/local/WatchHistoryFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/local/WatchHistoryFragment.java @@ -11,7 +11,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -public class WatchHistoryFragment extends HistoryPlaylistFragment { +public class WatchHistoryFragment extends StatisticsPlaylistFragment { @Override protected String getName() { return getString(R.string.title_watch_history); diff --git a/app/src/main/res/drawable-hdpi/ic_playlist_add_black_24dp.png b/app/src/main/res/drawable-hdpi/ic_playlist_add_black_24dp.png new file mode 100644 index 000000000..731b42590 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_playlist_add_black_24dp.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_playlist_add_white_24dp.png b/app/src/main/res/drawable-hdpi/ic_playlist_add_white_24dp.png new file mode 100644 index 000000000..4fb76e178 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_playlist_add_white_24dp.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_playlist_add_black_24dp.png b/app/src/main/res/drawable-mdpi/ic_playlist_add_black_24dp.png new file mode 100644 index 000000000..d7a7514a8 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_playlist_add_black_24dp.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_playlist_add_white_24dp.png b/app/src/main/res/drawable-mdpi/ic_playlist_add_white_24dp.png new file mode 100644 index 000000000..73c981285 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_playlist_add_white_24dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_playlist_add_black_24dp.png b/app/src/main/res/drawable-xhdpi/ic_playlist_add_black_24dp.png new file mode 100644 index 000000000..dc4ebe9f3 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_playlist_add_black_24dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_playlist_add_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_playlist_add_white_24dp.png new file mode 100644 index 000000000..52ccba0b2 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_playlist_add_white_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_playlist_add_black_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_playlist_add_black_24dp.png new file mode 100644 index 000000000..af0bae3f0 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_playlist_add_black_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_playlist_add_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_playlist_add_white_24dp.png new file mode 100644 index 000000000..3f652366d Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_playlist_add_white_24dp.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_playlist_add_black_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_playlist_add_black_24dp.png new file mode 100644 index 000000000..46020a7e0 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_playlist_add_black_24dp.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_playlist_add_white_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_playlist_add_white_24dp.png new file mode 100644 index 000000000..70e74e4a2 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_playlist_add_white_24dp.png differ diff --git a/app/src/main/res/layout/fragment_video_detail.xml b/app/src/main/res/layout/fragment_video_detail.xml index 8c445adcd..cf555ffa5 100644 --- a/app/src/main/res/layout/fragment_video_detail.xml +++ b/app/src/main/res/layout/fragment_video_detail.xml @@ -273,7 +273,26 @@ android:paddingBottom="6dp" android:paddingTop="6dp" android:text="@string/controls_background_title" - android:textSize="12sp" /> + android:textSize="12sp"/> + + diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index 61bc5e520..46676e200 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -26,6 +26,7 @@ + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index df5b15c19..361f453c4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -38,6 +38,7 @@ Background Popup + Add To Video download path Path to store downloaded videos in @@ -375,4 +376,5 @@ Create New Playlist Delete Playlist Name + Add To Playlist diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index ee526ca41..1f79bbf3d 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -41,6 +41,7 @@ @drawable/ic_play_arrow_black_24dp @drawable/ic_whatshot_black_24dp @drawable/ic_channel_black_24dp + @drawable/ic_playlist_add_black_24dp @color/light_separator_color @color/light_contrast_background_color @@ -88,6 +89,7 @@ @drawable/ic_play_arrow_white_24dp @drawable/ic_whatshot_white_24dp @drawable/ic_channel_white_24dp + @drawable/ic_playlist_add_white_24dp @color/dark_separator_color @color/dark_contrast_background_color