package cn.yyxx.eyuancomm.base.utils

import android.content.Context
import android.text.TextUtils
import cn.yyxx.support.PropertiesUtils

/**
 * @author #Suyghur.
 * Created on 2021/06/17
 */
object ParamsUtils {

    private const val CONFIG_FILE = "yyxx_cfg.properties"
    private const val YYXX_GCP_CODE = "YYXX_GCP_CODE"
    private const val YYXX_GAME_CODE = "YYXX_GAME_CODE"
    private const val YYXX_COMM_GCP_CODE = "YYXX_COMM_GCP_CODE"
    private const val YYXX_COMM_GAME_CODE = "YYXX_COMM_GAME_CODE"
    private const val YYXX_CHANNEL_ID = "YYXX_CHANNEL_ID"
    private const val YYXX_ADJSUT_APP_ID = "YYXX_ADJUST_APP_ID"
    private const val YYXX_GOOGLE_APP_ID = "YYXX_GOOGLE_APP_ID"
    private const val YYXX_GOOGLE_CLIENT_ID = "YYXX_GOOGLE_CLIENT_ID"
    private const val YYXX_DO_MAIN_ENV = "YYXX_DO_MAIN_ENV"

    @JvmStatic
    fun getGcpCode(context: Context): String {
        try {
            val code = PropertiesUtils.getValue4Properties(context, CONFIG_FILE, "yyxx_game", YYXX_GCP_CODE)
            if (!TextUtils.isEmpty(code)) {
                return code
            }
        } catch (e: Exception) {
            e.printStackTrace()
        }
        return ""
    }

    @JvmStatic
    fun getGameCode(context: Context): String {
        try {
            val code = PropertiesUtils.getValue4Properties(context, CONFIG_FILE, "yyxx_game", YYXX_GAME_CODE)
            if (!TextUtils.isEmpty(code)) {
                return code
            }
        } catch (e: Exception) {
            e.printStackTrace()
        }
        return ""
    }

    @JvmStatic
    fun getCommGcpCode(context: Context): String {
        try {
            val code = PropertiesUtils.getValue4Properties(context, CONFIG_FILE, "yyxx_game", YYXX_COMM_GCP_CODE)
            if (!TextUtils.isEmpty(code)) {
                return code
            }
        } catch (e: Exception) {
            e.printStackTrace()
        }
        return ""
    }

    @JvmStatic
    fun getCommGameCode(context: Context): String {
        try {
            val code = PropertiesUtils.getValue4Properties(context, CONFIG_FILE, "yyxx_game", YYXX_COMM_GAME_CODE)
            if (!TextUtils.isEmpty(code)) {
                return code
            }
        } catch (e: Exception) {
            e.printStackTrace()
        }
        return ""
    }

    @JvmStatic
    fun getChannelId(context: Context): String {
        try {
            val channelId = PropertiesUtils.getValue4Properties(context, CONFIG_FILE, "yyxx_game", YYXX_CHANNEL_ID)
            if (!TextUtils.isEmpty(channelId)) {
                return channelId
            }
        } catch (e: Exception) {
            e.printStackTrace()
        }
        return ""
    }

    @JvmStatic
    fun getAdjustAppId(context: Context): String {
        try {
            val appId = PropertiesUtils.getValue4Properties(context, CONFIG_FILE, "yyxx_game", YYXX_ADJSUT_APP_ID)
            if (!TextUtils.isEmpty(appId)) {
                return appId
            }
        } catch (e: Exception) {
            e.printStackTrace()
        }
        return ""
    }

    @JvmStatic
    fun getGoogleAppId(context: Context): String {
        try {
            val appId = PropertiesUtils.getValue4Properties(context, CONFIG_FILE, "yyxx_game", YYXX_GOOGLE_APP_ID)
            if (!TextUtils.isEmpty(appId)) {
                return appId
            }
        } catch (e: Exception) {
            e.printStackTrace()
        }
        return ""
    }

    @JvmStatic
    fun getGoogleClientId(context: Context): String {
        try {
            val clientId = PropertiesUtils.getValue4Properties(context, CONFIG_FILE, "yyxx_game", YYXX_GOOGLE_CLIENT_ID)
            if (!TextUtils.isEmpty(clientId)) {
                return clientId
            }
        } catch (e: Exception) {
            e.printStackTrace()
        }
        return ""
    }

    @JvmStatic
    fun getDoMainEnv(context: Context): Int {
        try {
            val env = PropertiesUtils.getValue4Properties(context, CONFIG_FILE, "yyxx_game", YYXX_DO_MAIN_ENV)
            if (!TextUtils.isEmpty(env)) {
                return env.toInt()
            }
        } catch (e: Exception) {
            e.printStackTrace()
        }
        return 1
    }
}