1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-15 13:21:22 +01:00

Fix Kodi button showing up in unsupported services

This commit is contained in:
Stypox 2020-05-06 20:40:44 +02:00
parent 40b1cd82b1
commit 9ca6cfd637
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23
2 changed files with 10 additions and 4 deletions

View File

@ -632,9 +632,10 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo>
}
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<StreamInfo>
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);

View File

@ -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)