11package dev.dimension.flare.ui.screen.serviceselect
22
3- import android.graphics.Color
4- import android.view.View
53import android.view.ViewGroup.LayoutParams
64import android.webkit.CookieManager
75import android.webkit.WebSettings
6+ import android.webkit.WebStorage
87import android.widget.FrameLayout
98import androidx.compose.foundation.background
109import androidx.compose.foundation.layout.fillMaxSize
@@ -15,6 +14,7 @@ import androidx.compose.runtime.LaunchedEffect
1514import androidx.compose.runtime.getValue
1615import androidx.compose.runtime.remember
1716import androidx.compose.ui.Modifier
17+ import androidx.compose.ui.draw.alpha
1818import com.kevinnzou.web.WebView
1919import com.kevinnzou.web.rememberWebViewState
2020import dev.dimension.flare.ui.component.FlareScaffold
@@ -25,10 +25,19 @@ import kotlinx.coroutines.delay
2525import moe.tlaster.precompose.molecule.producePresenter
2626import kotlin.time.Duration.Companion.seconds
2727
28+ // https://github.com/j-fbriere/squawker/blob/20ab95b1b5cdada080aa8ebd1d5e0f3ad7c719e5/lib/constants.dart#L87-L93
29+ // idk why it works but it works
30+ private val userAgent =
31+ mapOf (
32+ " 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" ,
33+ " Pragma" to " no-cache" ,
34+ " Cache-Control" to " no-cache" ,
35+ )
36+
2837@Composable
2938internal fun XQTLoginScreen (toHome : () -> Unit ) {
3039 val state by producePresenter { xQtLoginPresenter(toHome) }
31- val webViewState = rememberWebViewState(" https://${UiApplication .XQT .host} " )
40+ val webViewState = rememberWebViewState(" https://${UiApplication .XQT .host} /i/flow/login " )
3241 LaunchedEffect (Unit ) {
3342 while (true ) {
3443 if (! state.loading) {
@@ -56,15 +65,16 @@ internal fun XQTLoginScreen(toHome: () -> Unit) {
5665 ),
5766 modifier =
5867 Modifier
68+ .alpha(0.99f )
5969 .background(MaterialTheme .colorScheme.background)
6070 .padding(it)
6171 .fillMaxSize(),
6272 onCreated = {
63- it.setLayerType(View .LAYER_TYPE_SOFTWARE , null )
64- it.setBackgroundColor(Color .TRANSPARENT )
6573 // clea all cookies
74+ WebStorage .getInstance().deleteAllData()
6675 CookieManager .getInstance().removeAllCookies(null )
6776 with (it.settings) {
77+ userAgentString = userAgent.toString()
6878 javaScriptEnabled = true
6979 domStorageEnabled = true
7080 javaScriptCanOpenWindowsAutomatically = false
0 commit comments