Skip to content

Commit

Permalink
finalizing app
Browse files Browse the repository at this point in the history
  • Loading branch information
DatL4g committed Dec 13, 2023
1 parent c732a2e commit 5b0195c
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 66 deletions.
63 changes: 31 additions & 32 deletions app/android/src/androidMain/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,56 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />

<uses-feature
android:name="android.hardware.wifi"
android:required="false"/>
android:name="android.hardware.wifi"
android:required="false" />

<uses-feature
android:name="android.hardware.ethernet"
android:required="false"/>
android:name="android.hardware.ethernet"
android:required="false" />

<application
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: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">

<meta-data
android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME"
android:value="dev.datlag.burningseries.shared.CastOptionsProvider" />
android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME"
android:value="dev.datlag.burningseries.shared.CastOptionsProvider" />

<activity
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: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">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<meta-data
android:name="instantapps.clients.allowed"
android:value="true"/>
android:name="instantapps.clients.allowed"
android:value="true" />

<receiver
android:name="androidx.mediarouter.media.MediaTransferReceiver"
android:exported="true">
</receiver>
android:name="androidx.mediarouter.media.MediaTransferReceiver"
android:exported="true"></receiver>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class MainActivity : AppCompatActivity() {
}

override fun onUserLeaveHint() {
if (PIPEventDispatcher.invoke() == true) {
if (PIPEnabled) {
enterPIPMode()
} else {
super.onUserLeaveHint()
Expand All @@ -134,6 +134,10 @@ class MainActivity : AppCompatActivity() {
}

private fun enterPIPMode() {
if (!PIPEnabled) {
return
}

val builder = PictureInPictureParams.Builder()
.setAspectRatio(Rational(16, 9))

Expand All @@ -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)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
30 changes: 30 additions & 0 deletions app/android/src/androidMain/res/xml/network_security.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates src="system" />
</trust-anchors>
</base-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">https://wrapapi.com</domain>
<domain includeSubdomains="true">http://wrapapi.com</domain>
<domain includeSubdomains="true">wrapapi.com</domain>

<domain includeSubdomains="true">https://bs.to</domain>
<domain includeSubdomains="true">http://bs.to</domain>
<domain includeSubdomains="true">bs.to</domain>

<domain includeSubdomains="true">https://jsonbase.com</domain>
<domain includeSubdomains="true">http://jsonbase.com</domain>
<domain includeSubdomains="true">jsonbase.com</domain>

<domain includeSubdomains="true">https://googleapis.com</domain>
<domain includeSubdomains="true">http://googleapis.com</domain>
<domain includeSubdomains="true">googleapis.com</domain>

<trust-anchors>
<certificates src="system" />
<certificates src="user" />
</trust-anchors>
</domain-config>
</network-security-config>
Original file line number Diff line number Diff line change
Expand Up @@ -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<RemoteAction>? = { null }
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
28 changes: 1 addition & 27 deletions extension/content/src/jsMain/kotlin/content.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Theme?>()

@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)
Expand Down Expand Up @@ -178,17 +162,7 @@ private fun getThemeColor(docHref: String, href: String): Pair<Int, Int> {
} 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 5b0195c

Please sign in to comment.