@file:Suppress("unused")

package xyz.myachin.saveto

import android.app.Application
import android.content.pm.PackageManager
import xyz.myachin.saveto.settings.Settings
import xyz.myachin.saveto.ui.MainActivity

class App : Application() {
    override fun onCreate() {
        super.onCreate()
        Settings.setup(applicationContext)
        Thread {
            showSettingsIfNeed()
        }.start()
    }

    private fun showSettingsIfNeed() {
        if (Settings.hideLauncherIcon) {
            if (Settings.versionSettings != getString(R.string.settings_version)) {
                Settings.hideLauncherIcon = false
                Settings.versionSettings = getString(R.string.settings_version)
                Settings.setComponentState(
                    applicationContext,
                    MainActivity::class.java.name,
                    PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
                )
            }
        }
    }
}