In player hide kodi button if service unsupported

pull/3545/head
Stypox 2020-05-07 09:08:52 +02:00
rodzic 9ca6cfd637
commit 5c711322d4
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4BDF1B40A49FDD23
3 zmienionych plików z 13 dodań i 8 usunięć

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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