kopia lustrzana https://github.com/TeamNewPipe/NewPipe
Merge pull request #3545 from Stypox/kore
Fix Kodi button showing up with unsupported servicespull/3556/head
commit
b990f30a09
|
@ -632,9 +632,10 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo>
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateMenuItemVisibility() {
|
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(
|
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));
|
activity.getString(R.string.show_play_with_kodi_key), false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -665,8 +666,7 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo>
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_play_with_kodi:
|
case R.id.action_play_with_kodi:
|
||||||
try {
|
try {
|
||||||
NavigationHelper.playWithKore(activity, Uri.parse(
|
NavigationHelper.playWithKore(activity, Uri.parse(currentInfo.getUrl()));
|
||||||
url.replace("https", "http")));
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.i(TAG, "Failed to start kore", e);
|
Log.i(TAG, "Failed to start kore", e);
|
||||||
|
|
|
@ -593,9 +593,6 @@ public final class MainVideoPlayer extends AppCompatActivity
|
||||||
|
|
||||||
titleTextView.setSelected(true);
|
titleTextView.setSelected(true);
|
||||||
channelTextView.setSelected(true);
|
channelTextView.setSelected(true);
|
||||||
boolean showKodiButton = PreferenceManager.getDefaultSharedPreferences(this.context)
|
|
||||||
.getBoolean(this.context.getString(R.string.show_play_with_kodi_key), false);
|
|
||||||
kodiButton.setVisibility(showKodiButton ? View.VISIBLE : View.GONE);
|
|
||||||
|
|
||||||
getRootView().setKeepScreenOn(true);
|
getRootView().setKeepScreenOn(true);
|
||||||
}
|
}
|
||||||
|
@ -712,6 +709,13 @@ public final class MainVideoPlayer extends AppCompatActivity
|
||||||
protected void onMetadataChanged(@NonNull final MediaSourceTag tag) {
|
protected void onMetadataChanged(@NonNull final MediaSourceTag tag) {
|
||||||
super.onMetadataChanged(tag);
|
super.onMetadataChanged(tag);
|
||||||
|
|
||||||
|
// show kodi button if it supports the current service and it is enabled in settings
|
||||||
|
final boolean showKodiButton =
|
||||||
|
KoreUtil.isServiceSupportedByKore(tag.getMetadata().getServiceId())
|
||||||
|
&& PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
|
.getBoolean(context.getString(R.string.show_play_with_kodi_key), false);
|
||||||
|
kodiButton.setVisibility(showKodiButton ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
titleTextView.setText(tag.getMetadata().getName());
|
titleTextView.setText(tag.getMetadata().getName());
|
||||||
channelTextView.setText(tag.getMetadata().getUploaderName());
|
channelTextView.setText(tag.getMetadata().getUploaderName());
|
||||||
}
|
}
|
||||||
|
@ -725,13 +729,12 @@ public final class MainVideoPlayer extends AppCompatActivity
|
||||||
public void onKodiShare() {
|
public void onKodiShare() {
|
||||||
onPause();
|
onPause();
|
||||||
try {
|
try {
|
||||||
NavigationHelper.playWithKore(this.context,
|
NavigationHelper.playWithKore(context, Uri.parse(playerImpl.getVideoUrl()));
|
||||||
Uri.parse(playerImpl.getVideoUrl().replace("https", "http")));
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.i(TAG, "Failed to start kore", e);
|
Log.i(TAG, "Failed to start kore", e);
|
||||||
}
|
}
|
||||||
KoreUtil.showInstallKoreDialog(this.context);
|
KoreUtil.showInstallKoreDialog(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,16 @@ import android.content.DialogInterface;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
|
import org.schabi.newpipe.extractor.ServiceList;
|
||||||
|
|
||||||
public final class KoreUtil {
|
public final class KoreUtil {
|
||||||
private 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) {
|
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)
|
||||||
|
|
|
@ -325,8 +325,9 @@
|
||||||
android:src="@drawable/ic_cast_white_24dp"
|
android:src="@drawable/ic_cast_white_24dp"
|
||||||
android:background="?attr/selectableItemBackground"
|
android:background="?attr/selectableItemBackground"
|
||||||
android:contentDescription="@string/play_with_kodi_title"
|
android:contentDescription="@string/play_with_kodi_title"
|
||||||
|
android:visibility="gone"
|
||||||
tools:ignore="RtlHardcoded"
|
tools:ignore="RtlHardcoded"
|
||||||
android:visibility="visible"/>
|
tools:visibility="visible"/>
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/share"
|
android:id="@+id/share"
|
||||||
|
|
|
@ -317,8 +317,9 @@
|
||||||
android:src="@drawable/ic_cast_white_24dp"
|
android:src="@drawable/ic_cast_white_24dp"
|
||||||
android:background="?attr/selectableItemBackground"
|
android:background="?attr/selectableItemBackground"
|
||||||
android:contentDescription="@string/play_with_kodi_title"
|
android:contentDescription="@string/play_with_kodi_title"
|
||||||
|
android:visibility="gone"
|
||||||
tools:ignore="RtlHardcoded"
|
tools:ignore="RtlHardcoded"
|
||||||
android:visibility="visible"/>
|
tools:visibility="visible"/>
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/share"
|
android:id="@+id/share"
|
||||||
|
|
Ładowanie…
Reference in New Issue