package com.xyzshell.andinfo

import android.content.Context
import com.xyzshell.andinfo.libs.AppInfo
import com.xyzshell.andinfo.libs.BatteryInfo
import com.xyzshell.andinfo.libs.CpuInfo
import com.xyzshell.andinfo.libs.DeviceInfo
import com.xyzshell.andinfo.libs.DisplayInfo
import com.xyzshell.andinfo.libs.SensorInfo
import com.xyzshell.andinfo.libs.BuildInfo
import com.xyzshell.andinfo.libs.GpuInfo
import com.xyzshell.andinfo.libs.InputInfo
import com.xyzshell.andinfo.libs.CameraInfo
import com.xyzshell.andinfo.libs.BluetoothInfo
import com.xyzshell.andinfo.libs.StorageInfo
import com.xyzshell.andinfo.libs.DRMInfo
import com.xyzshell.andinfo.libs.MemInfo
import com.xyzshell.andinfo.libs.NetworkInfo

class AndInfo private constructor(private val applicationContext: Context) {

    companion object {
        private lateinit var INSTANCE: AndInfo

        fun init(context: Context) {
            INSTANCE = AndInfo(context.applicationContext)
        }

        val instance: AndInfo
            get() {
                if (!::INSTANCE.isInitialized) {
                    throw IllegalStateException("AndInfo must be initialized with init(context) before use.")
                }
                return INSTANCE
            }
    }

    private val _cpu: CpuInfo
    private val _device: DeviceInfo
    private val _display: DisplayInfo
    private val _sensor: SensorInfo
    private val _build: BuildInfo
    private val _gpu: GpuInfo
    private val _input: InputInfo
    private val _camera: CameraInfo
    private val _bluetooth: BluetoothInfo
    private val _storage: StorageInfo
    private val _app: AppInfo
    private val _drm: DRMInfo
    private val _batter: BatteryInfo
    private val _memory: MemInfo
    private val _network: NetworkInfo

    init {
        _cpu = CpuInfo()
        _device = DeviceInfo(applicationContext)
        _display = DisplayInfo(applicationContext)
        _sensor = SensorInfo(applicationContext)
        _build = BuildInfo(applicationContext)
        _gpu = GpuInfo(applicationContext)
        _input = InputInfo(applicationContext)
        _camera = CameraInfo(applicationContext)
        _bluetooth = BluetoothInfo(applicationContext)
        _storage = StorageInfo(applicationContext)
        _app = AppInfo(applicationContext)
        _drm = DRMInfo(applicationContext)
        _batter = BatteryInfo(applicationContext)
        _memory = MemInfo(applicationContext)
        _network = NetworkInfo(applicationContext)
    }

    val cpu get() = _cpu
    val device get() = _device
    val display get() = _display
    val sensor get() = _sensor
    val build get() = _build
    val gpu get() = _gpu
    val input get() = _input
    val camera get() = _camera
    val bluetooth get() = _bluetooth
    val storage get() = _storage
    val context get() = applicationContext
    val app get() = _app
    val drm get() = _drm
    val battery get() = _batter
    val memory get() = _memory
    val network get() = _network
}
