From 48a5107296c4f62fa762dafe4e999337f2b23e62 Mon Sep 17 00:00:00 2001 From: khimaros Date: Wed, 30 Dec 2020 14:40:21 -0800 Subject: [PATCH] address pull request feedback --- .../schabi/newpipe/fragments/list/BaseListFragment.java | 7 ++----- .../newpipe/fragments/list/playlist/PlaylistFragment.java | 8 ++------ .../newpipe/local/history/StatisticsPlaylistFragment.java | 8 ++------ .../newpipe/local/playlist/LocalPlaylistFragment.java | 8 ++------ app/src/main/java/org/schabi/newpipe/util/KoreUtil.java | 8 ++++++++ .../java/org/schabi/newpipe/util/StreamDialogEntry.java | 2 +- 6 files changed, 17 insertions(+), 24 deletions(-) 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 ecfaaf80e..10527d189 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 @@ -360,11 +360,8 @@ public abstract class BaseListFragment extends BaseStateFragment StreamDialogEntry.share )); } - final boolean enableKodiEntry = KoreUtil.isServiceSupportedByKore(item.getServiceId()) - && PreferenceManager.getDefaultSharedPreferences(context) - .getBoolean(context.getString(R.string.show_play_with_kodi_key), false); - if (enableKodiEntry) { - entries.add(StreamDialogEntry.play_on_kodi); + if (KoreUtil.shouldShowPlayWithKodi(context, item)) { + entries.add(StreamDialogEntry.play_with_kodi); } StreamDialogEntry.setEnabledEntries(entries); diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java index a4ccd9c78..0eed5f4b0 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java @@ -17,7 +17,6 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.content.res.AppCompatResources; -import androidx.preference.PreferenceManager; import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; @@ -176,11 +175,8 @@ public class PlaylistFragment extends BaseListInfoFragment { StreamDialogEntry.share )); } - final boolean enableKodiEntry = KoreUtil.isServiceSupportedByKore(item.getServiceId()) - && PreferenceManager.getDefaultSharedPreferences(context) - .getBoolean(context.getString(R.string.show_play_with_kodi_key), false); - if (enableKodiEntry) { - entries.add(StreamDialogEntry.play_on_kodi); + if (KoreUtil.shouldShowPlayWithKodi(context, item)) { + entries.add(StreamDialogEntry.play_with_kodi); } StreamDialogEntry.setEnabledEntries(entries); 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 59537f1a8..a6a73e05f 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 @@ -17,7 +17,6 @@ import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AlertDialog; -import androidx.preference.PreferenceManager; import com.google.android.material.snackbar.Snackbar; @@ -415,11 +414,8 @@ public class StatisticsPlaylistFragment StreamDialogEntry.share )); } - final boolean enableKodiEntry = KoreUtil.isServiceSupportedByKore(infoItem.getServiceId()) - && PreferenceManager.getDefaultSharedPreferences(context) - .getBoolean(context.getString(R.string.show_play_with_kodi_key), false); - if (enableKodiEntry) { - entries.add(StreamDialogEntry.play_on_kodi); + if (KoreUtil.shouldShowPlayWithKodi(context, infoItem)) { + entries.add(StreamDialogEntry.play_with_kodi); } StreamDialogEntry.setEnabledEntries(entries); diff --git a/app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java b/app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java index c6314f557..94f76cc75 100644 --- a/app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java +++ b/app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java @@ -20,7 +20,6 @@ import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AlertDialog; -import androidx.preference.PreferenceManager; import androidx.recyclerview.widget.ItemTouchHelper; import androidx.recyclerview.widget.RecyclerView; @@ -783,11 +782,8 @@ public class LocalPlaylistFragment extends BaseLocalListFragment { + play_with_kodi(R.string.play_with_kodi_title, (fragment, item) -> { final Uri videoUrl = Uri.parse(item.getUrl()); try { NavigationHelper.playWithKore(fragment.getContext(), videoUrl);