mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-23 08:30:44 +00:00
Merge pull request #5310 from khimaros/list-play-kodi
add list item to play video on kodi
This commit is contained in:
commit
92a87a5ed2
@ -31,6 +31,7 @@ import org.schabi.newpipe.info_list.InfoItemDialog;
|
|||||||
import org.schabi.newpipe.info_list.InfoListAdapter;
|
import org.schabi.newpipe.info_list.InfoListAdapter;
|
||||||
import org.schabi.newpipe.player.helper.PlayerHolder;
|
import org.schabi.newpipe.player.helper.PlayerHolder;
|
||||||
import org.schabi.newpipe.report.ErrorActivity;
|
import org.schabi.newpipe.report.ErrorActivity;
|
||||||
|
import org.schabi.newpipe.util.KoreUtil;
|
||||||
import org.schabi.newpipe.util.NavigationHelper;
|
import org.schabi.newpipe.util.NavigationHelper;
|
||||||
import org.schabi.newpipe.util.OnClickGesture;
|
import org.schabi.newpipe.util.OnClickGesture;
|
||||||
import org.schabi.newpipe.util.StateSaver;
|
import org.schabi.newpipe.util.StateSaver;
|
||||||
@ -332,7 +333,6 @@ public abstract class BaseListFragment<I, N> extends BaseStateFragment<I>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void showStreamDialog(final StreamInfoItem item) {
|
protected void showStreamDialog(final StreamInfoItem item) {
|
||||||
final Context context = getContext();
|
final Context context = getContext();
|
||||||
final Activity activity = getActivity();
|
final Activity activity = getActivity();
|
||||||
@ -359,6 +359,9 @@ public abstract class BaseListFragment<I, N> extends BaseStateFragment<I>
|
|||||||
StreamDialogEntry.share
|
StreamDialogEntry.share
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
if (KoreUtil.shouldShowPlayWithKodi(context, item.getServiceId())) {
|
||||||
|
entries.add(StreamDialogEntry.play_with_kodi);
|
||||||
|
}
|
||||||
StreamDialogEntry.setEnabledEntries(entries);
|
StreamDialogEntry.setEnabledEntries(entries);
|
||||||
|
|
||||||
new InfoItemDialog(activity, item, StreamDialogEntry.getCommands(context),
|
new InfoItemDialog(activity, item, StreamDialogEntry.getCommands(context),
|
||||||
|
@ -42,6 +42,7 @@ import org.schabi.newpipe.report.ErrorActivity;
|
|||||||
import org.schabi.newpipe.report.UserAction;
|
import org.schabi.newpipe.report.UserAction;
|
||||||
import org.schabi.newpipe.util.ExtractorHelper;
|
import org.schabi.newpipe.util.ExtractorHelper;
|
||||||
import org.schabi.newpipe.util.ImageDisplayConstants;
|
import org.schabi.newpipe.util.ImageDisplayConstants;
|
||||||
|
import org.schabi.newpipe.util.KoreUtil;
|
||||||
import org.schabi.newpipe.util.Localization;
|
import org.schabi.newpipe.util.Localization;
|
||||||
import org.schabi.newpipe.util.NavigationHelper;
|
import org.schabi.newpipe.util.NavigationHelper;
|
||||||
import org.schabi.newpipe.util.ShareUtils;
|
import org.schabi.newpipe.util.ShareUtils;
|
||||||
@ -174,6 +175,9 @@ public class PlaylistFragment extends BaseListInfoFragment<PlaylistInfo> {
|
|||||||
StreamDialogEntry.share
|
StreamDialogEntry.share
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
if (KoreUtil.shouldShowPlayWithKodi(context, item.getServiceId())) {
|
||||||
|
entries.add(StreamDialogEntry.play_with_kodi);
|
||||||
|
}
|
||||||
StreamDialogEntry.setEnabledEntries(entries);
|
StreamDialogEntry.setEnabledEntries(entries);
|
||||||
|
|
||||||
StreamDialogEntry.start_here_on_background.setCustomAction((fragment, infoItem) ->
|
StreamDialogEntry.start_here_on_background.setCustomAction((fragment, infoItem) ->
|
||||||
|
@ -37,6 +37,7 @@ import org.schabi.newpipe.report.ErrorActivity;
|
|||||||
import org.schabi.newpipe.report.ErrorInfo;
|
import org.schabi.newpipe.report.ErrorInfo;
|
||||||
import org.schabi.newpipe.report.UserAction;
|
import org.schabi.newpipe.report.UserAction;
|
||||||
import org.schabi.newpipe.settings.SettingsActivity;
|
import org.schabi.newpipe.settings.SettingsActivity;
|
||||||
|
import org.schabi.newpipe.util.KoreUtil;
|
||||||
import org.schabi.newpipe.util.NavigationHelper;
|
import org.schabi.newpipe.util.NavigationHelper;
|
||||||
import org.schabi.newpipe.util.OnClickGesture;
|
import org.schabi.newpipe.util.OnClickGesture;
|
||||||
import org.schabi.newpipe.util.StreamDialogEntry;
|
import org.schabi.newpipe.util.StreamDialogEntry;
|
||||||
@ -413,6 +414,9 @@ public class StatisticsPlaylistFragment
|
|||||||
StreamDialogEntry.share
|
StreamDialogEntry.share
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
if (KoreUtil.shouldShowPlayWithKodi(context, infoItem.getServiceId())) {
|
||||||
|
entries.add(StreamDialogEntry.play_with_kodi);
|
||||||
|
}
|
||||||
StreamDialogEntry.setEnabledEntries(entries);
|
StreamDialogEntry.setEnabledEntries(entries);
|
||||||
|
|
||||||
StreamDialogEntry.start_here_on_background.setCustomAction((fragment, infoItemDuplicate) ->
|
StreamDialogEntry.start_here_on_background.setCustomAction((fragment, infoItemDuplicate) ->
|
||||||
|
@ -41,6 +41,7 @@ import org.schabi.newpipe.player.helper.PlayerHolder;
|
|||||||
import org.schabi.newpipe.player.playqueue.PlayQueue;
|
import org.schabi.newpipe.player.playqueue.PlayQueue;
|
||||||
import org.schabi.newpipe.player.playqueue.SinglePlayQueue;
|
import org.schabi.newpipe.player.playqueue.SinglePlayQueue;
|
||||||
import org.schabi.newpipe.report.UserAction;
|
import org.schabi.newpipe.report.UserAction;
|
||||||
|
import org.schabi.newpipe.util.KoreUtil;
|
||||||
import org.schabi.newpipe.util.Localization;
|
import org.schabi.newpipe.util.Localization;
|
||||||
import org.schabi.newpipe.util.NavigationHelper;
|
import org.schabi.newpipe.util.NavigationHelper;
|
||||||
import org.schabi.newpipe.util.OnClickGesture;
|
import org.schabi.newpipe.util.OnClickGesture;
|
||||||
@ -781,6 +782,9 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
|
|||||||
StreamDialogEntry.share
|
StreamDialogEntry.share
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
if (KoreUtil.shouldShowPlayWithKodi(context, infoItem.getServiceId())) {
|
||||||
|
entries.add(StreamDialogEntry.play_with_kodi);
|
||||||
|
}
|
||||||
StreamDialogEntry.setEnabledEntries(entries);
|
StreamDialogEntry.setEnabledEntries(entries);
|
||||||
|
|
||||||
StreamDialogEntry.start_here_on_background.setCustomAction((fragment, infoItemDuplicate) ->
|
StreamDialogEntry.start_here_on_background.setCustomAction((fragment, infoItemDuplicate) ->
|
||||||
|
@ -937,9 +937,7 @@ public class VideoPlayerImpl extends VideoPlayer
|
|||||||
service.getString(R.string.show_play_with_kodi_key), false);
|
service.getString(R.string.show_play_with_kodi_key), false);
|
||||||
// show kodi button if it supports the current service and it is enabled in settings
|
// show kodi button if it supports the current service and it is enabled in settings
|
||||||
final boolean showKodiButton = playQueue != null && playQueue.getItem() != null
|
final boolean showKodiButton = playQueue != null && playQueue.getItem() != null
|
||||||
&& KoreUtil.isServiceSupportedByKore(playQueue.getItem().getServiceId())
|
&& KoreUtil.shouldShowPlayWithKodi(context, playQueue.getItem().getServiceId());
|
||||||
&& PreferenceManager.getDefaultSharedPreferences(context)
|
|
||||||
.getBoolean(context.getString(R.string.show_play_with_kodi_key), false);
|
|
||||||
playWithKodi.setVisibility(videoPlayerSelected() && kodiEnabled && showKodiButton
|
playWithKodi.setVisibility(videoPlayerSelected() && kodiEnabled && showKodiButton
|
||||||
? View.VISIBLE : View.GONE);
|
? View.VISIBLE : View.GONE);
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package org.schabi.newpipe.util;
|
package org.schabi.newpipe.util;
|
||||||
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
import androidx.preference.PreferenceManager;
|
||||||
|
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
import org.schabi.newpipe.extractor.ServiceList;
|
import org.schabi.newpipe.extractor.ServiceList;
|
||||||
@ -16,6 +16,12 @@ public final class KoreUtil {
|
|||||||
|| serviceId == ServiceList.SoundCloud.getServiceId());
|
|| serviceId == ServiceList.SoundCloud.getServiceId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean shouldShowPlayWithKodi(final Context context, final int serviceId) {
|
||||||
|
return isServiceSupportedByKore(serviceId)
|
||||||
|
&& PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
|
.getBoolean(context.getString(R.string.show_play_with_kodi_key), false);
|
||||||
|
}
|
||||||
|
|
||||||
public static void showInstallKoreDialog(final Context context) {
|
public static void showInstallKoreDialog(final Context context) {
|
||||||
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||||
builder.setMessage(R.string.kore_not_found)
|
builder.setMessage(R.string.kore_not_found)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package org.schabi.newpipe.util;
|
package org.schabi.newpipe.util;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.net.Uri;
|
||||||
|
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
@ -70,6 +71,15 @@ public enum StreamDialogEntry {
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
play_with_kodi(R.string.play_with_kodi_title, (fragment, item) -> {
|
||||||
|
final Uri videoUrl = Uri.parse(item.getUrl());
|
||||||
|
try {
|
||||||
|
NavigationHelper.playWithKore(fragment.getContext(), videoUrl);
|
||||||
|
} catch (final Exception e) {
|
||||||
|
KoreUtil.showInstallKoreDialog(fragment.getActivity());
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
|
||||||
share(R.string.share, (fragment, item) ->
|
share(R.string.share, (fragment, item) ->
|
||||||
ShareUtils.shareUrl(fragment.getContext(), item.getName(), item.getUrl()));
|
ShareUtils.shareUrl(fragment.getContext(), item.getName(), item.getUrl()));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user