package com.convenient.android.common.config

import android.app.Application
import android.content.Context
import com.convenient.android.common.extension.spGetBoolean
import com.convenient.android.common.extension.spSave

/**
 *    @author : hubowen
 *    @date   : 2020/9/17  8:01 PM
 *    @description：
 */
object MyPdfBaseModule {

    var myApplication: Application? = null

    var isDebug: Boolean = true

    var versionName: String = ""

    /**
     * 是否有同意隐私政策合规
     */
    var isAgreeServerAgreement: Boolean = false
        set(value) {
            field = value
            this.getAppContext()?.spSave("agree_server_agreement", field)
        }
        get() = this.getAppContext()?.spGetBoolean("agree_server_agreement", false) ?: false

    /**
     * 子模块和主模块需要共享全局上下文，故需要在app module初始化时传入
     */
    fun init(myApplication_: Application, isDebug_: Boolean, versionName_: String) {
        if (myApplication == null) {
            myApplication = myApplication_
            isDebug = isDebug_
            versionName = versionName_
        }
    }

    fun getAppContext(): Context? {
        return myApplication?.applicationContext
    }
}