package com.gh.gamecenter.setting.provider

import android.content.Context
import android.content.Intent
import android.net.Uri
import com.alibaba.android.arouter.facade.annotation.Route
import com.gh.gamecenter.common.constant.Constants
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.common.utils.EnvHelper
import com.gh.gamecenter.core.provider.IWebProvider

@Route(path = RouteConsts.provider.webActivity, name = "WebActivity暴露服务")
class WebProviderImpl : IWebProvider {
    override fun getIntent(context: Context, url: String, autoCompletionTitle: Boolean): Intent {
        return Intent(Intent.ACTION_VIEW).apply {
            data = Uri.parse(url)
        }
    }

    override fun getWebIntent(context: Context, title: String, url: String): Intent {
        return Intent(Intent.ACTION_VIEW).apply {
            data = Uri.parse(url)
        }
    }

    override fun getBindWechatIntent(context: Context): Intent {
        val url: String = if (EnvHelper.isDevEnv) {
            Constants.WECHAT_BIND_ADDRESS_DEV
        } else {
            Constants.WECHAT_BIND_ADDRESS
        }
        return Intent(Intent.ACTION_VIEW).apply {
            data = Uri.parse(url)
        }
    }

    override fun getSecurityCertificationIntent(context: Context): Intent? {
        return Intent(Intent.ACTION_VIEW).apply {
            data = Uri.parse(SECURITY_CERTIFICATION_URL)
        }
    }

    override fun init(context: Context?) {
        // Do nothing
    }

    companion object {
        const val SECURITY_CERTIFICATION_URL = "https://credit.cecdc.com/CX20190909718761807395238.html"
    }
}