package com.za.common.util

import android.content.Context
import android.os.Build
import android.os.Environment
import com.za.base.Const
import java.io.File

object AppFileManager {

    //获取人脸大头照存储地址
    fun getFaceDir(context: Context): File {
        val path = context.cacheDir?.path + File.separator + "faceVerify"
        val file = File(path)
        if (!file.exists()) {
            file.mkdir()
        }
        return file
    }

    /**
     * 师傅签名位置保存
     */
    fun getDriverSignDirPath(context : Context) : String {
        val tempPath = context.cacheDir.toString() + File.separator + "driver_sign"
        val tempFile = File(tempPath)
        if (! tempFile.exists()) {
            tempFile.mkdir()
        }
        return tempFile.absolutePath
    }

    /**
     * 师傅签名位置保存
     */
    fun getDriverSignPath(context : Context) : String {
        return getDriverSignDirPath(context) + File.separator + Const.driverSighName
    }

    //人脸大头照存储地址
    fun getFaceFilePath(context: Context): String {
        return getFaceDir(context).absolutePath + File.separator + "avatar.jpg"
    }

    /**
     * app日志路径
     */
    fun getLogPath(context: Context?): String {
        val path = "${context?.filesDir?.absolutePath}${File.separator}Log"
        if (!File(path).exists()) {
            File(path).mkdir()
        }
        return path
    }


    fun orderWaterMarkerPath(context: Context): String {
        val path = context.cacheDir?.path + File.separator + "water_marker"
        if (!File(path).exists()) {
            File(path).mkdir()
        }
        return path
    }

    /**
     * 拍摄的照片的保存位置
     */
    fun getTakePictureParentPath(): String {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
            return Environment.DIRECTORY_PICTURES
        } else {
            val dstPath =
                Environment.getExternalStorageDirectory().absolutePath + File.separator + Environment.DIRECTORY_PICTURES + File.separator + "中道救援"
            val file = File(dstPath)
            if (!file.exists()) {
                file.mkdir()
            }
            return dstPath
        }
    }

}