package com.gingersoft.gsa.cloud.common.utils;

import android.Manifest;

import androidx.fragment.app.Fragment;

import com.permissionx.guolindev.PermissionX;
import com.permissionx.guolindev.callback.RequestCallback;

/**
 * @author 宇航.
 * User: admin
 * Date: 2021/3/18
 * Time: 15:32
 * Use:
 */
public class XPermissionUtils {


    /**
     * 请求摄像头权限
     */
    public static void launchCamera(Fragment fragment, RequestCallback callback) {
        PermissionX.init(fragment)
                .permissions(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA)
                .onExplainRequestReason((scope, deniedList) -> scope.showRequestReasonDialog(deniedList, "這個功能需要申請使用相機", "確定", "取消"))
                .onForwardToSettings((scope, deniedList) -> scope.showForwardToSettingsDialog(deniedList, "您需要去設置當中開啟相機權限", "確定", "取消"))
                .request(callback);
    }

}
