package com.erwan.revwatch

import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.erwan.revwatch.prefs.AppPrefs

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        val config = AppPrefs.load(this)
        if (!config.setupComplete) {
            startActivity(Intent(this, SetupActivity::class.java))
            finish()
            return
        }

        val isHomePress = intent?.hasCategory(Intent.CATEGORY_HOME) == true
        startActivity(Intent(this, DashboardActivity::class.java).apply {
            if (!isHomePress) putExtra(DashboardActivity.EXTRA_SHOW_INTRO, true)
            addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)
        })
        finish()
    }
}
