package com.convenient.android.common.activitycontracts.permission

import android.app.Activity
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.os.Environment
import android.provider.Settings
import androidx.activity.result.ActivityResultCaller
import androidx.activity.result.contract.ActivityResultContract
import com.convenient.android.common.activitycontracts.BaseActivityResultLauncher

/**
 * @classname:
 * @author: LiuXiaoLong
 * @date: 2022/8/4
 * description:
 */
/**
 * 获取APP管理所有文件权限启动器
 */
//class ManageAppAllFilesAccessPermissionLauncher(cells: ActivityResultCaller) : BaseActivityResultLauncher<Unit, Boolean>(cells, ManageAppAllFilesAccessPermissionContracts()) {
//}
//
//
///**
// * 跳转到设置 APP 获取所有文件管理权限跳转协议
// */
//class ManageAppAllFilesAccessPermissionContracts : ActivityResultContract<Unit, Boolean>() {
//
//    override fun createIntent(context: Context, input: Unit?): Intent {
//        return Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION, Uri.parse("package:${context.packageName}"))
//    }
//
//    override fun parseResult(resultCode: Int, intent: Intent?): Boolean {
//        return if (resultCode == Activity.RESULT_OK && Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
//            Environment.isExternalStorageManager()
//        } else {
//            false
//        }
//    }
//
//}