2019-04-25 20:47:39 +02:00
|
|
|
package org.schabi.newpipe.util;
|
|
|
|
|
|
|
|
import android.content.Context;
|
2020-03-31 19:20:15 +02:00
|
|
|
|
2019-04-25 20:47:39 +02:00
|
|
|
import androidx.appcompat.app.AlertDialog;
|
2020-12-30 23:40:21 +01:00
|
|
|
import androidx.preference.PreferenceManager;
|
2019-04-25 20:47:39 +02:00
|
|
|
|
|
|
|
import org.schabi.newpipe.R;
|
2020-05-06 20:40:44 +02:00
|
|
|
import org.schabi.newpipe.extractor.ServiceList;
|
2019-04-25 20:47:39 +02:00
|
|
|
|
2020-03-31 19:20:15 +02:00
|
|
|
public final class KoreUtil {
|
2019-04-25 20:47:39 +02:00
|
|
|
private KoreUtil() { }
|
|
|
|
|
2020-05-06 20:40:44 +02:00
|
|
|
public static boolean isServiceSupportedByKore(final int serviceId) {
|
|
|
|
return (serviceId == ServiceList.YouTube.getServiceId()
|
|
|
|
|| serviceId == ServiceList.SoundCloud.getServiceId());
|
|
|
|
}
|
|
|
|
|
2021-01-02 20:24:33 +01:00
|
|
|
public static boolean shouldShowPlayWithKodi(final Context context, final int serviceId) {
|
|
|
|
return isServiceSupportedByKore(serviceId)
|
2020-12-30 23:40:21 +01:00
|
|
|
&& PreferenceManager.getDefaultSharedPreferences(context)
|
|
|
|
.getBoolean(context.getString(R.string.show_play_with_kodi_key), false);
|
|
|
|
}
|
|
|
|
|
2019-04-25 20:47:39 +02:00
|
|
|
public static void showInstallKoreDialog(final Context context) {
|
|
|
|
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
|
|
|
builder.setMessage(R.string.kore_not_found)
|
2020-11-20 00:54:27 +01:00
|
|
|
.setPositiveButton(R.string.install, (dialog, which) ->
|
2020-03-31 19:20:15 +02:00
|
|
|
NavigationHelper.installKore(context))
|
2020-11-20 00:54:27 +01:00
|
|
|
.setNegativeButton(R.string.cancel, (dialog, which) -> {
|
2020-03-31 19:20:15 +02:00
|
|
|
});
|
2019-04-25 20:47:39 +02:00
|
|
|
builder.create().show();
|
|
|
|
}
|
|
|
|
}
|