package com.all.pdfreader.pro.app.ui.act

import android.annotation.SuppressLint
import android.content.Intent
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import com.all.pdfreader.pro.app.databinding.ActivitySplashBinding

@SuppressLint("CustomSplashScreen")
class SplashActivity : BaseActivity() {
    
    override val TAG: String = "SplashActivity"

    private lateinit var binding: ActivitySplashBinding

    companion object {
        private const val SPLASH_DELAY = 3000L // 启动页显示时长
    }
    
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivitySplashBinding.inflate(layoutInflater)
        // 设置启动页布局
        setContentView(binding.root)
        
        // 延迟跳转到权限检查
        Handler(Looper.getMainLooper()).postDelayed({
            navigateToNext()
        }, SPLASH_DELAY)
    }
    
    private fun navigateToNext() {
        val intent =  Intent(this, MainActivity::class.java)
//        val intent = if (StoragePermissionHelper.hasBasicStoragePermission(this)) {
//            Intent(this, MainActivity::class.java)
//        } else {
//            Intent(this, PermissionActivity::class.java)
//        }
        startActivity(intent)
        finish()
    }
    
    @Deprecated("Deprecated in Java")
    @SuppressLint("MissingSuperCall")
    override fun onBackPressed() {
        // 启动页禁止返回
    }
}