package negligentlyic.wrongic.bottomic

import tooic.fatalityic.Adventurousic
import com.easy.clean.R
import warpic.Shamrockic.Companion.SCAN_AUDIOS
import warpic.Shamrockic.Companion.SCAN_DOCUMENTS
import warpic.Shamrockic.Companion.SCAN_PHOTOS
import warpic.Shamrockic.Companion.SCAN_VIDEOS
import java.io.File

object Timidic {

    val mImageStr: Set<String> = HashSet(
        mutableListOf(".jpg", ".jpeg", ".png", ".gif", ".bmp")
    )
    val mVideoStr: Set<String> = HashSet(
        mutableListOf(".mp4", ".avi", ".mov", ".mkv")
    )
    val mAudioStr: Set<String> = HashSet(
        mutableListOf(".mp3", ".flac", ".wav")
    )

    val mDocumentStr: Set<String> = HashSet(mutableListOf(".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".pdf"))

    fun File.getType(): Int {
        if (mImageStr.contains("." + extension)) {
            return SCAN_PHOTOS
        }
        if (mVideoStr.contains("." + extension)) {
            return SCAN_VIDEOS
        }
        if (mAudioStr.contains("." + extension)) {
            return SCAN_AUDIOS
        }
        if (mDocumentStr.contains("." + extension)) {
            return SCAN_DOCUMENTS
        }

        return -1
    }

    fun File.getImgRes(): Int {
        return when (extension) {
            "mp3" -> R.drawable.touchingic
            "flac" -> R.drawable.recordic
            "doc", "docx" -> R.drawable.climbic
            "xls", "xlsx" -> R.drawable.sanitationic
            "ppt", "pptx" -> R.drawable.impersonalic
            else -> R.drawable.breakableic
        }
    }

    fun getRecycleBinData(): List<File> {
        val recycleBinDir = File(Adventurousic.Companion.appContext.filesDir, "recycleBin")
        if (recycleBinDir.exists()) {
            return recycleBinDir.listFiles()?.toList() ?: listOf()
        } else {
            return listOf()
        }
    }

    fun addRecycleBinFile(file: File) {
        val recycleBinDir = File(Adventurousic.Companion.appContext.filesDir, "recycleBin")
        if (!recycleBinDir.exists()) {
            recycleBinDir.mkdirs()
        }

        val recycleBinFile = File(recycleBinDir, file.name)

        file.copyTo(recycleBinFile, true)
    }


}