2021-03-26 13:28:11 +01:00
|
|
|
package org.schabi.newpipe.util.external_communication;
|
2019-04-25 20:47:39 +02:00
|
|
|
|
|
|
|
import android.content.Context;
|
2020-03-31 19:20:15 +02:00
|
|
|
|
2021-05-21 14:52:21 +02:00
|
|
|
import androidx.annotation.NonNull;
|
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;
|
2021-03-26 13:28:11 +01:00
|
|
|
import org.schabi.newpipe.util.NavigationHelper;
|
2019-04-25 20:47:39 +02:00
|
|
|
|
2021-12-26 15:34:36 +01:00
|
|
|
/**
|
|
|
|
* Util class that provides methods which are related to the Kodi Media Center and its Kore app.
|
|
|
|
* @see <a href="https://kodi.tv/">Kodi website</a>
|
|
|
|
*/
|
2021-03-26 13:28:11 +01:00
|
|
|
public final class KoreUtils {
|
|
|
|
private KoreUtils() { }
|
2019-04-25 20:47:39 +02:00
|
|
|
|
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-05-21 14:52:21 +02:00
|
|
|
public static boolean shouldShowPlayWithKodi(@NonNull final Context context,
|
|
|
|
final int serviceId) {
|
2021-01-02 20:24:33 +01:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2021-05-21 14:52:21 +02:00
|
|
|
public static void showInstallKoreDialog(@NonNull final Context context) {
|
2019-04-25 20:47:39 +02:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|