@file:Suppress("unused")

package xyz.myachin.saveto

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

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

    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.setLauncherIconState(
                    applicationContext,
                    PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
                )
            }
        }
    }
}