diff --git a/app/android/src/androidMain/AndroidManifest.xml b/app/android/src/androidMain/AndroidManifest.xml index 4545857d..90c7efd5 100644 --- a/app/android/src/androidMain/AndroidManifest.xml +++ b/app/android/src/androidMain/AndroidManifest.xml @@ -1,56 +1,55 @@ - - + + + android:name="android.hardware.wifi" + android:required="false" /> + android:name="android.hardware.ethernet" + android:required="false" /> + android:allowBackup="true" + android:icon="@mipmap/ic_launcher" + android:label="@string/app_name" + android:roundIcon="@mipmap/ic_launcher_round" + android:supportsRtl="true" + android:theme="@style/SplashScreenTheme" + android:name=".App" + android:appCategory="video" + android:allowAudioPlaybackCapture="false" + android:enableOnBackInvokedCallback="true" + android:usesCleartextTraffic="true" + android:networkSecurityConfig="@xml/network_security"> + android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME" + android:value="dev.datlag.burningseries.shared.CastOptionsProvider" /> + android:exported="true" + android:visibleToInstantApps="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden|mnc|colorMode|density|fontScale|fontWeightAdjustment|keyboard|layoutDirection|locale|mcc|navigation|smallestScreenSize|touchscreen|uiMode" + android:name=".MainActivity" + android:supportsPictureInPicture="true"> - + - + + android:name="instantapps.clients.allowed" + android:value="true" /> - + android:name="androidx.mediarouter.media.MediaTransferReceiver" + android:exported="true"> \ No newline at end of file diff --git a/app/android/src/androidMain/kotlin/dev/datlag/burningseries/MainActivity.kt b/app/android/src/androidMain/kotlin/dev/datlag/burningseries/MainActivity.kt index 73a886b5..cd74b7e6 100644 --- a/app/android/src/androidMain/kotlin/dev/datlag/burningseries/MainActivity.kt +++ b/app/android/src/androidMain/kotlin/dev/datlag/burningseries/MainActivity.kt @@ -120,7 +120,7 @@ class MainActivity : AppCompatActivity() { } override fun onUserLeaveHint() { - if (PIPEventDispatcher.invoke() == true) { + if (PIPEnabled) { enterPIPMode() } else { super.onUserLeaveHint() @@ -134,6 +134,10 @@ class MainActivity : AppCompatActivity() { } private fun enterPIPMode() { + if (!PIPEnabled) { + return + } + val builder = PictureInPictureParams.Builder() .setAspectRatio(Rational(16, 9)) @@ -148,4 +152,12 @@ class MainActivity : AppCompatActivity() { this.enterPictureInPictureMode(builder.build()) } + + override fun enterPictureInPictureMode(params: PictureInPictureParams): Boolean { + return if (!PIPEnabled) { + false + } else { + super.enterPictureInPictureMode(params) + } + } } \ No newline at end of file diff --git a/app/android/src/androidMain/res/mipmap-anydpi-v26/ic_launcher.xml b/app/android/src/androidMain/res/mipmap-anydpi-v26/ic_launcher.xml index 7353dbd1..7005cb8e 100644 --- a/app/android/src/androidMain/res/mipmap-anydpi-v26/ic_launcher.xml +++ b/app/android/src/androidMain/res/mipmap-anydpi-v26/ic_launcher.xml @@ -2,4 +2,5 @@ + \ No newline at end of file diff --git a/app/android/src/androidMain/res/xml/network_security.xml b/app/android/src/androidMain/res/xml/network_security.xml new file mode 100644 index 00000000..96e5b6ba --- /dev/null +++ b/app/android/src/androidMain/res/xml/network_security.xml @@ -0,0 +1,30 @@ + + + + + + + + + https://wrapapi.com + http://wrapapi.com + wrapapi.com + + https://bs.to + http://bs.to + bs.to + + https://jsonbase.com + http://jsonbase.com + jsonbase.com + + https://googleapis.com + http://googleapis.com + googleapis.com + + + + + + + \ No newline at end of file diff --git a/app/shared/src/androidMain/kotlin/dev/datlag/burningseries/shared/ui/Events.kt b/app/shared/src/androidMain/kotlin/dev/datlag/burningseries/shared/ui/Events.kt index 490087cd..77bf22d6 100644 --- a/app/shared/src/androidMain/kotlin/dev/datlag/burningseries/shared/ui/Events.kt +++ b/app/shared/src/androidMain/kotlin/dev/datlag/burningseries/shared/ui/Events.kt @@ -7,6 +7,6 @@ var SmallIcon: Int = 0 var NotificationPermission: Boolean = false var KeyEventDispatcher: (event: KeyEvent?) -> Boolean? = { null } -var PIPEventDispatcher: () -> Boolean? = { null } +var PIPEnabled: Boolean = false var PIPModeListener: (Boolean) -> Unit = { } var PIPActions: () -> ArrayList? = { null } \ No newline at end of file diff --git a/app/shared/src/androidMain/kotlin/dev/datlag/burningseries/shared/ui/screen/initial/series/SeriesScreen.android.kt b/app/shared/src/androidMain/kotlin/dev/datlag/burningseries/shared/ui/screen/initial/series/SeriesScreen.android.kt index 02a0b095..aa646edd 100644 --- a/app/shared/src/androidMain/kotlin/dev/datlag/burningseries/shared/ui/screen/initial/series/SeriesScreen.android.kt +++ b/app/shared/src/androidMain/kotlin/dev/datlag/burningseries/shared/ui/screen/initial/series/SeriesScreen.android.kt @@ -4,14 +4,14 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.SideEffect import dev.datlag.burningseries.shared.ui.KeyEventDispatcher import dev.datlag.burningseries.shared.ui.PIPActions -import dev.datlag.burningseries.shared.ui.PIPEventDispatcher +import dev.datlag.burningseries.shared.ui.PIPEnabled import dev.datlag.burningseries.shared.ui.PIPModeListener @Composable actual fun EnterSeriesScreen() { SideEffect { KeyEventDispatcher = { null } - PIPEventDispatcher = { null } + PIPEnabled = false PIPModeListener = { } PIPActions = { null } } diff --git a/app/shared/src/androidMain/kotlin/dev/datlag/burningseries/shared/ui/screen/video/VideoScreen.android.kt b/app/shared/src/androidMain/kotlin/dev/datlag/burningseries/shared/ui/screen/video/VideoScreen.android.kt index 003df95d..0b9af95f 100644 --- a/app/shared/src/androidMain/kotlin/dev/datlag/burningseries/shared/ui/screen/video/VideoScreen.android.kt +++ b/app/shared/src/androidMain/kotlin/dev/datlag/burningseries/shared/ui/screen/video/VideoScreen.android.kt @@ -363,7 +363,7 @@ actual fun VideoScreen(component: VideoComponent) { KeyEventDispatcher = { event -> event?.let { playerView.dispatchKeyEvent(it) } } - PIPEventDispatcher = { true } + PIPEnabled = true PIPModeListener = { isInPIP -> if (isInPIP) { controls.visibility = View.GONE @@ -419,7 +419,7 @@ actual fun VideoScreen(component: VideoComponent) { DisposableEffect(Unit) { onDispose { KeyEventDispatcher = { null } - PIPEventDispatcher = { null } + PIPEnabled = false PIPModeListener = { } PIPActions = { null } Kast.unselect(UnselectReason.stopped) diff --git a/extension/content/src/jsMain/kotlin/content.kt b/extension/content/src/jsMain/kotlin/content.kt index 453be159..a5bc49be 100644 --- a/extension/content/src/jsMain/kotlin/content.kt +++ b/extension/content/src/jsMain/kotlin/content.kt @@ -2,34 +2,18 @@ import common.collect import common.forEachNotNull import common.isNullOrEmpty import common.onReady -import dev.datlag.burningseries.color.createTheme -import dev.datlag.burningseries.color.scheme.Scheme -import dev.datlag.burningseries.color.theme.Theme import dev.datlag.burningseries.model.ExtensionMessage import kotlinx.browser.document import kotlinx.browser.window -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import kotlinx.dom.hasClass import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json import org.w3c.dom.* -val themes = mutableMapOf() - @OptIn(ExperimentalStdlibApi::class) fun main() { document.onReady { val href = document.URL.ifBlank { document.location?.href } ?: document.URL - val coverImage = document.getElementsByClassName("serie")[0]?.getElementsByTagName("img")?.get(0) as? HTMLImageElement - if (coverImage != null) { - if (!themes.containsKey(href)) { - GlobalScope.launch(Dispatchers.Default) { - themes[href] = coverImage.createTheme() - } - } - } if (document.getElementsByClassName("episodes").length <= 0) { checkEpisode(href) @@ -178,17 +162,7 @@ private fun getThemeColor(docHref: String, href: String): Pair { } else { 0xFFd2e4ff.toInt() to 0xFF001c37.toInt() } - val scheme = themes[docHref]?.getScheme() ?: themes[href]?.getScheme() - return (scheme?.primaryContainer ?: fallbackBackground) to (scheme?.onPrimaryContainer ?: fallbackContent) -} - -private fun Theme.getScheme(): Scheme { - val isDarkMode = window.matchMedia("(prefers-color-scheme: dark)").matches - return if (isDarkMode) { - this.schemes.dark - } else { - this.schemes.light - } + return fallbackBackground to fallbackContent } @OptIn(ExperimentalStdlibApi::class) diff --git a/network/src/commonMain/kotlin/dev/datlag/burningseries/network/state/SaveStateMachine.kt b/network/src/commonMain/kotlin/dev/datlag/burningseries/network/state/SaveStateMachine.kt index d7d8af5c..6b683590 100644 --- a/network/src/commonMain/kotlin/dev/datlag/burningseries/network/state/SaveStateMachine.kt +++ b/network/src/commonMain/kotlin/dev/datlag/burningseries/network/state/SaveStateMachine.kt @@ -68,7 +68,7 @@ class SaveStateMachine( }.getOrNull() ?: false } - return@coroutineScope jsonBaseSaved.await() || mongoSaved.await() || firebaseSaved.await() + return@coroutineScope mongoSaved.await() || firebaseSaved.await() || jsonBaseSaved.await() } val stream = if (state.snapshot.loadStream) {