package xyz.myachin.saveto.ui

import android.content.pm.PackageManager
import android.os.Bundle
import android.widget.Button
import androidx.appcompat.app.AppCompatActivity
import com.google.android.material.snackbar.Snackbar
import xyz.myachin.saveto.R
import xyz.myachin.saveto.settings.Settings

class DisableLaunchIconActivity : AppCompatActivity() {
    private lateinit var btOk: Button

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_disable_launch_icon)

        btOk = findViewById(R.id.btOk)

        btOk.setOnClickListener {
            Thread {
                Settings.hideLauncherIcon = true
                Settings.versionSettings = getString(R.string.settings_version)
                Settings.setLauncherIconState(
                    applicationContext,
                    PackageManager.COMPONENT_ENABLED_STATE_DISABLED
                )
            }.run()
            Snackbar
                .make(
                    findViewById(R.id.btOk),
                    R.string.icon_disabled_now,
                    Snackbar.LENGTH_LONG
                )
                .setAnimationMode(Snackbar.ANIMATION_MODE_SLIDE)
                .show()
        }
    }
}