Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package dev.dimension.flare.ui.screen.serviceselect

import android.graphics.Color
import android.view.View
import android.view.ViewGroup.LayoutParams
import android.webkit.CookieManager
import android.widget.FrameLayout
Expand All @@ -14,6 +12,7 @@ import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import com.kevinnzou.web.WebView
import com.kevinnzou.web.rememberWebViewState
import dev.dimension.flare.ui.component.FlareScaffold
Expand Down Expand Up @@ -55,12 +54,11 @@ internal fun VVOLoginScreen(toHome: () -> Unit) {
),
modifier =
Modifier
.alpha(0.99f)
.background(MaterialTheme.colorScheme.background)
.padding(it)
.fillMaxSize(),
onCreated = {
it.setLayerType(View.LAYER_TYPE_SOFTWARE, null)
it.setBackgroundColor(Color.TRANSPARENT)
// clea all cookies
CookieManager.getInstance().removeAllCookies(null)
with(it.settings) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package dev.dimension.flare.ui.screen.serviceselect

import android.graphics.Color
import android.view.View
import android.view.ViewGroup.LayoutParams
import android.webkit.CookieManager
import android.webkit.WebSettings
import android.webkit.WebStorage
import android.widget.FrameLayout
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.fillMaxSize
Expand All @@ -15,6 +14,7 @@ import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import com.kevinnzou.web.WebView
import com.kevinnzou.web.rememberWebViewState
import dev.dimension.flare.ui.component.FlareScaffold
Expand All @@ -25,10 +25,19 @@ import kotlinx.coroutines.delay
import moe.tlaster.precompose.molecule.producePresenter
import kotlin.time.Duration.Companion.seconds

// https://github.com/j-fbriere/squawker/blob/20ab95b1b5cdada080aa8ebd1d5e0f3ad7c719e5/lib/constants.dart#L87-L93
// idk why it works but it works
private val userAgent =
mapOf(
"user-agent" to "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Mobile Safari/537.3",
"Pragma" to "no-cache",
"Cache-Control" to "no-cache",
)

@Composable
internal fun XQTLoginScreen(toHome: () -> Unit) {
val state by producePresenter { xQtLoginPresenter(toHome) }
val webViewState = rememberWebViewState("https://${UiApplication.XQT.host}")
val webViewState = rememberWebViewState("https://${UiApplication.XQT.host}/i/flow/login")
LaunchedEffect(Unit) {
while (true) {
if (!state.loading) {
Expand Down Expand Up @@ -56,15 +65,16 @@ internal fun XQTLoginScreen(toHome: () -> Unit) {
),
modifier =
Modifier
.alpha(0.99f)
.background(MaterialTheme.colorScheme.background)
.padding(it)
.fillMaxSize(),
onCreated = {
it.setLayerType(View.LAYER_TYPE_SOFTWARE, null)
it.setBackgroundColor(Color.TRANSPARENT)
// clea all cookies
WebStorage.getInstance().deleteAllData()
CookieManager.getInstance().removeAllCookies(null)
with(it.settings) {
userAgentString = userAgent.toString()
javaScriptEnabled = true
domStorageEnabled = true
javaScriptCanOpenWindowsAutomatically = false
Expand Down
Loading