package com.all.pdfreader.pdf.reader.ui.fragment

import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.net.toUri
import androidx.fragment.app.Fragment
import com.all.pdfreader.pdf.reader.PRApp
import com.all.pdfreader.pdf.reader.R
import com.all.pdfreader.pdf.reader.databinding.FragmentToolsBinding
import com.all.pdfreader.pdf.reader.model.PdfPickerSource
import com.all.pdfreader.pdf.reader.ui.act.PdfPickerActivity
import com.all.pdfreader.pdf.reader.ui.act.PdfResultActivity
import com.all.pdfreader.pdf.reader.ui.act.PictureSelectorActivity
import com.all.pdfreader.pdf.reader.util.GlideEngine
import com.luck.picture.lib.basic.PictureSelector
import com.luck.picture.lib.config.PictureMimeType
import com.luck.picture.lib.config.SelectMimeType
import com.luck.picture.lib.config.SelectModeConfig
import com.luck.picture.lib.engine.CompressFileEngine
import com.luck.picture.lib.entity.LocalMedia
import com.luck.picture.lib.interfaces.OnKeyValueResultCallbackListener
import com.luck.picture.lib.interfaces.OnMediaEditInterceptListener
import com.luck.picture.lib.interfaces.OnResultCallbackListener
import com.luck.picture.lib.style.PictureSelectorStyle
import com.luck.picture.lib.style.SelectMainStyle
import com.luck.picture.lib.utils.DateUtils
import com.yalantis.ucrop.UCrop
import top.zibin.luban.Luban
import top.zibin.luban.OnNewCompressListener
import java.io.File

class ToolsFrag : BaseFrag() {
    override val TAG: String = "ToolsFrag"
    private lateinit var binding: FragmentToolsBinding

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
    ): View {
        binding = FragmentToolsBinding.inflate(layoutInflater)
        return binding.root
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        initView()
    }

    private fun initView() {
        binding.mergeBtn.setOnClickListener {
            val intent = PdfPickerActivity.createIntent(requireActivity(), PdfPickerSource.MERGE)
            startActivity(intent)
        }
        binding.splitBtn.setOnClickListener {
            val intent = PdfPickerActivity.createIntent(requireActivity(), PdfPickerSource.SPLIT)
            startActivity(intent)
        }
        binding.lockBtn.setOnClickListener {
            val intent = PdfPickerActivity.createIntent(requireActivity(), PdfPickerSource.LOCK)
            startActivity(intent)
        }
        binding.unLockBtn.setOnClickListener {
            val intent = PdfPickerActivity.createIntent(requireActivity(), PdfPickerSource.UNLOCK)
            startActivity(intent)
        }
        binding.imgToPdfBtn.setOnClickListener {
            val intent = Intent(requireActivity(), PictureSelectorActivity::class.java)
            startActivity(intent)
        }
        binding.pdfToImgBtn.setOnClickListener {
            val intent = PdfPickerActivity.createIntent(requireActivity(), PdfPickerSource.PDF_TO_IMAGES)
            startActivity(intent)
        }
        binding.pdfToLongImgBtn.setOnClickListener {
            val intent = PdfPickerActivity.createIntent(requireActivity(), PdfPickerSource.TO_LONG_IMAGE)
            startActivity(intent)
        }
        binding.printBtn.setOnClickListener {
            val intent = PdfPickerActivity.createIntent(requireActivity(), PdfPickerSource.PRINT)
            startActivity(intent)
        }
    }
}