package com.swago.baseswago.util

import android.os.Build
import android.text.TextUtils
import java.util.*

/**
 *@date 2021/12/18 16:16
 *description:
 */
object SwagoInfo {

    private var versionCode = ""
    private var languageCode = "en"
    private var appClient = "android"
    private var channel = "DDD01"

    fun isGooglePackage():Boolean{
        return false
    }

    fun getLanguageCode(): String {
        val language = Locale.getDefault().language
        languageCode = when (language) {
            "en" -> {
                "en"
            }
            "in" -> {
                "id"
            }
            else -> {
                "en"
            }
        }
        return languageCode
    }


    fun getDeviceInfo():String{
        return Build.BRAND + "--" + Build.MODEL
    }

    fun getVersionCode():String{
        if (TextUtils.isEmpty(versionCode)) {
            versionCode = try {
                val context = AppContext.getContext()
                val packageManager = context.packageManager
                val info = packageManager.getPackageInfo(context.packageName, 0)
                info.versionCode.toString()
            } catch (e: Exception) {
                e.printStackTrace()
                "-1"
            }
        }
        return versionCode
    }

    fun getAppClient():String{
        return appClient
    }

    fun getChannel():String{
        return channel
    }

}