package com.develop.setting.init.ui

import android.annotation.SuppressLint
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.webkit.WebView
import android.webkit.WebViewClient
import com.alibaba.android.arouter.facade.annotation.Route
import com.develop.food.base.router.Screens
import com.develop.food.base.ui.BaseActivity
import com.develop.food.base.utils.CURRENT_LANGUAGE
import com.develop.food.base.utils.MmkvUtils
import com.develop.food.base.utils.getSN
import com.develop.setting.R
import com.develop.food.base.utils.CURRENT_LANGUAGE
import com.develop.food.base.widgets.TopTitleView
import com.develop.setting.databinding.ActivityHelpDocsBinding
import com.develop.setting.databinding.ActivityPrivacePolicyBinding

@Route(path = Screens.Setting. HELP)
class HelpDocsActivity : BaseActivity<ActivityHelpDocsBinding>() {
    override fun createViewBinding(inflater: LayoutInflater): ActivityHelpDocsBinding {
        return   ActivityHelpDocsBinding.inflate(inflater)
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding.topBar.listenBackClick {
            finish()
        }
        binding.topBar.setTopBarTitle(R.string.help)


        binding.helpWebview.getSettings().setJavaScriptEnabled(true);
        binding.helpWebview.webViewClient = object : WebViewClient() {
            override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean {
                // 在WebView中加载链接
                view.loadUrl(url)
                return true
            }
        }
        var language = MmkvUtils.getString(CURRENT_LANGUAGE)
        if (language == null) {
            language = "EN"
        }
        //000A 先全部显示英语帮助
        if (getSN().startsWith("000A")) language = "EN"
        var url = "file:///android_asset/help/${language}/help.html"
        binding.helpWebview.loadUrl(url)

    }
}