package com.tencent.liteav.demo.player

import android.graphics.Color
import android.os.Bundle
import android.webkit.WebResourceRequest
import android.webkit.WebView
import android.webkit.WebViewClient
import android.widget.ImageView
import androidx.appcompat.app.AppCompatActivity

class CastHelpActivity : AppCompatActivity() {
    companion object {
        val helpUrl: String = "https://zaojiao.net/ac/#/screencast"
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        supportActionBar?.hide()
        window.decorView.setBackgroundColor(Color.WHITE)
        window.statusBarColor = Color.WHITE

        setContentView(R.layout.activity_cast_help);

        findViewById<ImageView>(R.id.action_back).apply {
            setOnClickListener {
                finish()
            }
        }

        findViewById<WebView>(R.id.cast_webview).apply {
            loadUrl(helpUrl)

            webViewClient = object : WebViewClient() {
                override fun shouldOverrideUrlLoading(
                    view: WebView?,
                    request: WebResourceRequest?,
                ): Boolean {
                    view?.loadUrl(request?.url.toString());
                    return true
                }
            }

            settings.javaScriptEnabled = true
        }
    }
}