From 9ca6cfd6374159b50ccc4716bf8d3ba15891014d Mon Sep 17 00:00:00 2001 From: Stypox Date: Wed, 6 May 2020 20:40:44 +0200 Subject: [PATCH] Fix Kodi button showing up in unsupported services --- .../newpipe/fragments/detail/VideoDetailFragment.java | 8 ++++---- app/src/main/java/org/schabi/newpipe/util/KoreUtil.java | 6 ++++++ 2 files changed, 10 insertions(+), 4 deletions(-) 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 35352c013..ec1c655a0 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 @@ -632,9 +632,10 @@ public class VideoDetailFragment extends BaseStateFragment } private void updateMenuItemVisibility() { - // show kodi if set in settings + // show kodi button if it supports the current service and it is enabled in settings menu.findItem(R.id.action_play_with_kodi).setVisible( - PreferenceManager.getDefaultSharedPreferences(activity).getBoolean( + KoreUtil.isServiceSupportedByKore(serviceId) + && PreferenceManager.getDefaultSharedPreferences(activity).getBoolean( activity.getString(R.string.show_play_with_kodi_key), false)); } @@ -665,8 +666,7 @@ public class VideoDetailFragment extends BaseStateFragment return true; case R.id.action_play_with_kodi: try { - NavigationHelper.playWithKore(activity, Uri.parse( - url.replace("https", "http"))); + NavigationHelper.playWithKore(activity, Uri.parse(currentInfo.getUrl())); } catch (Exception e) { if (DEBUG) { Log.i(TAG, "Failed to start kore", e); diff --git a/app/src/main/java/org/schabi/newpipe/util/KoreUtil.java b/app/src/main/java/org/schabi/newpipe/util/KoreUtil.java index 85cf82db1..983fe689b 100644 --- a/app/src/main/java/org/schabi/newpipe/util/KoreUtil.java +++ b/app/src/main/java/org/schabi/newpipe/util/KoreUtil.java @@ -7,10 +7,16 @@ import android.content.DialogInterface; import androidx.appcompat.app.AlertDialog; import org.schabi.newpipe.R; +import org.schabi.newpipe.extractor.ServiceList; public final class KoreUtil { private KoreUtil() { } + public static boolean isServiceSupportedByKore(final int serviceId) { + return (serviceId == ServiceList.YouTube.getServiceId() + || serviceId == ServiceList.SoundCloud.getServiceId()); + } + public static void showInstallKoreDialog(final Context context) { final AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setMessage(R.string.kore_not_found)