package com.base.datarecovery.activity.recovery

import android.annotation.SuppressLint
import android.graphics.Color
import android.os.Bundle
import android.os.Environment
import androidx.activity.addCallback
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.base.datarecovery.R
import com.base.datarecovery.bean.ConstObject.SCAN_DOCUMENTS
import com.base.datarecovery.bean.ConstObject.SCAN_PHOTOS
import com.base.datarecovery.bean.ConstObject.SCAN_VIDEOS
import com.base.datarecovery.databinding.ActivityFileRecoveredBinding
import com.base.datarecovery.help.BaseActivity
import com.base.datarecovery.utils.BarUtils
import java.io.File

class FileRecoveredActivity : BaseActivity<ActivityFileRecoveredBinding>() {

    override val binding: ActivityFileRecoveredBinding by lazy {
        ActivityFileRecoveredBinding.inflate(layoutInflater)
    }


    @SuppressLint("SetTextI18n")
    override fun initView() {

        BarUtils.setStatusBarLightMode(this, true)
        BarUtils.setStatusBarColor(this, Color.TRANSPARENT)

        val number = intent.extras?.getInt("Number") ?: 0
        val scanType = intent.extras?.getInt("ScanType")

        binding.tvNumber.text = number.toString()
        val type = when (scanType) {
            SCAN_PHOTOS -> if (number == 1) "Photo" else "Photos"
            SCAN_VIDEOS -> if (number == 1) "Video" else "Videos"
            SCAN_DOCUMENTS -> if (number == 1) "Document" else "Documents"
            else -> ""
        }
        binding.tvType.text = type

        val appName = this.resources.getString(R.string.app_name)
        val appDir = File(Environment.getExternalStorageDirectory(), appName)
        binding.tvDir.text = "Recovered in $appDir"
    }

    override fun initListener() {

        binding.flFanhui.setOnClickListener {
            onBackPressedDispatcher.onBackPressed()
        }
        onBackPressedDispatcher.addCallback {
            finishToMain()
        }
        binding.tvContinue.setOnClickListener {
            finish()
        }
        binding.tvFinish.setOnClickListener {
            onBackPressedDispatcher.onBackPressed()
        }
    }

}