From 13ee8e21d06c34a5f01e476ee133a4acc4b854ea Mon Sep 17 00:00:00 2001 From: Lag <> Date: Fri, 10 Mar 2023 21:33:13 +0100 Subject: [PATCH] Semi-unfucked VLC on A13+ --- .../lagradost/cloudstream3/MainActivity.kt | 31 ++++++++++++------- .../ui/result/ResultViewModel2.kt | 8 ++++- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt b/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt index a7449255..7818e357 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt @@ -5,6 +5,7 @@ import android.content.Context import android.content.Intent import android.content.res.ColorStateList import android.content.res.Configuration +import android.os.Build import android.os.Bundle import android.util.AttributeSet import android.util.Log @@ -34,7 +35,6 @@ import com.google.android.material.bottomsheet.BottomSheetDialog import com.google.android.material.navigationrail.NavigationRailView import com.google.android.material.snackbar.Snackbar import com.jaredrummler.android.colorpicker.ColorPickerDialogListener -import com.lagradost.cloudstream3.app import com.lagradost.cloudstream3.APIHolder.allProviders import com.lagradost.cloudstream3.APIHolder.apis import com.lagradost.cloudstream3.APIHolder.getApiDubstatusSettings @@ -170,7 +170,12 @@ open class ResultResume( val VLC = object : ResultResume( VLC_PACKAGE, - "org.videolan.vlc.player.result", + // Android 13 intent restrictions fucks up specifically launching the VLC player + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) { + "org.videolan.vlc.player.result" + } else { + Intent.ACTION_VIEW + }, "extra_position", "extra_duration", ) { @@ -733,15 +738,16 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener { } else { this.setKey(getString(R.string.jsdelivr_proxy_key), true) val parentView: View = findViewById(android.R.id.content) - Snackbar.make(parentView, R.string.jsdelivr_enabled, Snackbar.LENGTH_LONG).let { snackbar -> - snackbar.setAction(R.string.revert) { - setKey(getString(R.string.jsdelivr_proxy_key), false) + Snackbar.make(parentView, R.string.jsdelivr_enabled, Snackbar.LENGTH_LONG) + .let { snackbar -> + snackbar.setAction(R.string.revert) { + setKey(getString(R.string.jsdelivr_proxy_key), false) + } + snackbar.setBackgroundTint(colorFromAttribute(R.attr.primaryGrayBackground)) + snackbar.setTextColor(colorFromAttribute(R.attr.textColor)) + snackbar.setActionTextColor(colorFromAttribute(R.attr.colorPrimary)) + snackbar.show() } - snackbar.setBackgroundTint(colorFromAttribute(R.attr.primaryGrayBackground)) - snackbar.setTextColor(colorFromAttribute(R.attr.textColor)) - snackbar.setActionTextColor(colorFromAttribute(R.attr.colorPrimary)) - snackbar.show() - } } } @@ -1123,7 +1129,10 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener { suspend fun checkGithubConnectivity(): Boolean { return try { - app.get("https://raw.githubusercontent.com/recloudstream/.github/master/connectivitycheck", timeout = 5).text.trim() == "ok" + app.get( + "https://raw.githubusercontent.com/recloudstream/.github/master/connectivitycheck", + timeout = 5 + ).text.trim() == "ok" } catch (t: Throwable) { false } diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultViewModel2.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultViewModel2.kt index 2983b41d..46a8c9f6 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultViewModel2.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultViewModel2.kt @@ -3,6 +3,7 @@ package com.lagradost.cloudstream3.ui.result import android.app.Activity import android.content.* import android.net.Uri +import android.os.Build import android.os.Bundle import android.util.Log import android.widget.Toast @@ -1125,7 +1126,12 @@ class ResultViewModel2 : ViewModel() { 1L } - component = VLC_COMPONENT + // Component no longer safe to use in A13 for VLC + // https://code.videolan.org/videolan/vlc-android/-/issues/2776 + // This will likely need to be updated once VLC fixes their documentation. + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) { + component = VLC_COMPONENT + } putExtra("from_start", !resume) putExtra("position", position)