package cn.yyxx.eyuangame.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_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"

    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 ""
    }

    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 ""
    }


    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 ""
    }

    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 ""
    }

    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 ""
    }

}