Commit 172606ed authored by wanglei's avatar wanglei

...

parent 46e36737
...@@ -10,6 +10,7 @@ data class DocumentBean( ...@@ -10,6 +10,7 @@ data class DocumentBean(
) { ) {
var uiType: Int = 0//0首页模式 1合并选择模式 2拆分模式 var uiType: Int = 0//0首页模式 1合并选择模式 2拆分模式
var isSelect: Boolean = false var isSelect: Boolean = false
var state: Int = 0//0正常状态 1 锁定
companion object { companion object {
const val TYPE_PDF = "type_pdf" const val TYPE_PDF = "type_pdf"
......
...@@ -4,18 +4,27 @@ import android.annotation.SuppressLint ...@@ -4,18 +4,27 @@ import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.ImageView
import androidx.recyclerview.widget.RecyclerView.ViewHolder import androidx.recyclerview.widget.RecyclerView.ViewHolder
import com.base.pdfviewerscannerwhite.R import com.base.pdfviewerscannerwhite.R
import com.base.pdfviewerscannerwhite.bean.DocumentBean import com.base.pdfviewerscannerwhite.bean.DocumentBean
import com.base.pdfviewerscannerwhite.bean.DocumentBean.Companion.TYPE_PDF import com.base.pdfviewerscannerwhite.bean.DocumentBean.Companion.TYPE_PDF
import com.base.pdfviewerscannerwhite.databinding.ItemDocumentBinding import com.base.pdfviewerscannerwhite.databinding.ItemDocumentBinding
import com.base.pdfviewerscannerwhite.ui.document.pdf.PdfBoxUtils
import com.base.pdfviewerscannerwhite.utils.KotlinExt.toFormatSize import com.base.pdfviewerscannerwhite.utils.KotlinExt.toFormatSize
import com.base.pdfviewerscannerwhite.utils.KotlinExt.toFormatTime import com.base.pdfviewerscannerwhite.utils.KotlinExt.toFormatTime
import com.base.pdfviewerscannerwhite.utils.LogEx
import com.base.pdfviewerscannerwhite.utils.XmlEx.inflate import com.base.pdfviewerscannerwhite.utils.XmlEx.inflate
import com.chad.library.adapter4.BaseQuickAdapter import com.chad.library.adapter4.BaseQuickAdapter
import java.io.File import java.io.File
import java.util.concurrent.LinkedBlockingQueue
import java.util.concurrent.ThreadPoolExecutor
import java.util.concurrent.TimeUnit
class DocumentAdapter : BaseQuickAdapter<DocumentBean, DocumentAdapter.DocumentViewHolder>() { class DocumentAdapter : BaseQuickAdapter<DocumentBean, DocumentAdapter.DocumentViewHolder>() {
private val TAG = "DocumentAdapter"
inner class DocumentViewHolder(view: View) : ViewHolder(view) inner class DocumentViewHolder(view: View) : ViewHolder(view)
...@@ -24,13 +33,25 @@ class DocumentAdapter : BaseQuickAdapter<DocumentBean, DocumentAdapter.DocumentV ...@@ -24,13 +33,25 @@ class DocumentAdapter : BaseQuickAdapter<DocumentBean, DocumentAdapter.DocumentV
var moreAction: ((item: DocumentBean) -> Unit)? = null var moreAction: ((item: DocumentBean) -> Unit)? = null
var selectAction: ((size: Int) -> Unit)? = null var selectAction: ((size: Int) -> Unit)? = null
var corePoolSize = 4 // 核心线程数
var maximumPoolSize = 10 // 最大线程数
var keepAliveTime: Long = 120 // 非核心线程空闲存活时间
var threadPoolExecutor = ThreadPoolExecutor(
corePoolSize,
maximumPoolSize,
keepAliveTime,
TimeUnit.SECONDS,
LinkedBlockingQueue()
)
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
override fun onBindViewHolder(holder: DocumentViewHolder, position: Int, item: DocumentBean?) { override fun onBindViewHolder(holder: DocumentViewHolder, position: Int, item: DocumentBean?) {
if (item == null) return if (item == null) return
val binding = ItemDocumentBinding.bind(holder.itemView) val binding = ItemDocumentBinding.bind(holder.itemView)
if (item.type == TYPE_PDF) { if (item.type == TYPE_PDF) {
binding.iv.setImageResource(R.mipmap.h_pdfiocn) checkPwd(item, binding.iv)
} }
val file = File(item.path) val file = File(item.path)
binding.tvName.text = file.name binding.tvName.text = file.name
binding.tvInfo.text = file.lastModified().toFormatTime() + " " + file.length().toFormatSize() binding.tvInfo.text = file.lastModified().toFormatTime() + " " + file.length().toFormatSize()
...@@ -40,6 +61,7 @@ class DocumentAdapter : BaseQuickAdapter<DocumentBean, DocumentAdapter.DocumentV ...@@ -40,6 +61,7 @@ class DocumentAdapter : BaseQuickAdapter<DocumentBean, DocumentAdapter.DocumentV
binding.flSelect.visibility = View.GONE binding.flSelect.visibility = View.GONE
binding.flMore.visibility = View.VISIBLE binding.flMore.visibility = View.VISIBLE
binding.flBookmark.visibility = View.VISIBLE binding.flBookmark.visibility = View.VISIBLE
if (item.isBookmarked) { if (item.isBookmarked) {
binding.ivBookmark.setImageResource(R.mipmap.h_soucang_s) binding.ivBookmark.setImageResource(R.mipmap.h_soucang_s)
} else { } else {
...@@ -84,6 +106,22 @@ class DocumentAdapter : BaseQuickAdapter<DocumentBean, DocumentAdapter.DocumentV ...@@ -84,6 +106,22 @@ class DocumentAdapter : BaseQuickAdapter<DocumentBean, DocumentAdapter.DocumentV
} }
} }
private fun checkPwd(item: DocumentBean, iv: ImageView) {
threadPoolExecutor.execute {
item.state = PdfBoxUtils.checkPdfEncryption(item.path)
LogEx.logDebug(TAG, "${item.state}")
var res = R.mipmap.h_pdfiocn
when (item.state) {
0 -> res = R.mipmap.h_pdfiocn
1 -> res = R.mipmap.suoding
}
iv.post {
iv.setImageResource(res)
}
}
}
override fun onCreateViewHolder(context: Context, parent: ViewGroup, viewType: Int): DocumentViewHolder { override fun onCreateViewHolder(context: Context, parent: ViewGroup, viewType: Int): DocumentViewHolder {
return DocumentViewHolder(R.layout.item_document.inflate(parent)) return DocumentViewHolder(R.layout.item_document.inflate(parent))
} }
......
...@@ -2,28 +2,24 @@ package com.base.pdfviewerscannerwhite.ui.document.pdf ...@@ -2,28 +2,24 @@ package com.base.pdfviewerscannerwhite.ui.document.pdf
import android.content.Context import android.content.Context
import android.graphics.Bitmap import android.graphics.Bitmap
import android.graphics.Color
import android.graphics.drawable.BitmapDrawable import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import com.base.pdfviewerscannerwhite.utils.LogEx import com.base.pdfviewerscannerwhite.utils.LogEx
import com.tom_roush.pdfbox.pdmodel.PDDocument import com.tom_roush.pdfbox.pdmodel.PDDocument
import com.tom_roush.pdfbox.pdmodel.PDPage
import com.tom_roush.pdfbox.pdmodel.PDPageContentStream
import com.tom_roush.pdfbox.pdmodel.common.PDRectangle
import com.tom_roush.pdfbox.pdmodel.encryption.AccessPermission import com.tom_roush.pdfbox.pdmodel.encryption.AccessPermission
import com.tom_roush.pdfbox.pdmodel.encryption.StandardProtectionPolicy import com.tom_roush.pdfbox.pdmodel.encryption.StandardProtectionPolicy
import com.tom_roush.pdfbox.rendering.ImageType import com.tom_roush.pdfbox.rendering.ImageType
import com.tom_roush.pdfbox.rendering.PDFRenderer import com.tom_roush.pdfbox.rendering.PDFRenderer
import com.tom_roush.pdfbox.rendering.RenderDestination import com.tom_roush.pdfbox.rendering.RenderDestination
import com.tom_roush.pdfbox.text.PDFTextStripper
import com.tom_roush.pdfbox.text.TextPosition
import java.io.File import java.io.File
import java.io.IOException
object PdfBoxUtils { object PdfBoxUtils {
private val TAG = "PdfUtils" private val TAG = "PdfUtils"
fun getPdfDrawables(context: Context, filePath: String, scale: Float = 1f): List<Drawable> { fun getPdfDrawables(context: Context, filePath: String, scale: Float = 1f): List<Drawable> {
val drawableList = arrayListOf<Drawable>() val drawableList = arrayListOf<Drawable>()
val document = PDDocument.load(File(filePath)) val document = PDDocument.load(File(filePath))
...@@ -68,98 +64,37 @@ object PdfBoxUtils { ...@@ -68,98 +64,37 @@ object PdfBoxUtils {
} }
fun getPdfTextLocation(filePath: String) { fun checkPdfEncryption(filePath: String): Int {
var state = 0
// val document = PDDocument.load(File(filePath)) try {
// val stripper = object : PDFTextStripper() { PDDocument.load(File(filePath)).use { document ->
// override fun writeString(text: String?, textPositions: MutableList<TextPosition>?) { if (document.isEncrypted) {
// super.writeString(text, textPositions) println("The PDF is encrypted.")
// } val ap = document.getCurrentAccessPermission()
// } if (ap.canExtractContent()) {
// stripper.sortByPosition = true println("You are allowed to extract content.")
// stripper.startPage = 0 } else {
// stripper.endPage = document.numberOfPages state = 1
// stripper.writeText(document,) println("You are not allowed to extract content.")
}
// fun pdfBoxBoldText(file: String, pageIndex: Int, boldText: String) {
// val document = PDDocument.load(File(file))
// val page = document.getPage(pageIndex)
// val contentStream = PDPageContentStream(document, page)
// val stripper = object : PDFTextStripper() {
// var textPositions: List<TextPosition>? = null
//
// override fun writeString(text: String?, textPositions: MutableList<TextPosition>?) {
// super.writeString(text, textPositions)
// this.textPositions = textPositions
// }
//
// override fun endText() {
// super.endText()
// if (textPositions != null) {
//
// }
// }
// }
//
// }
fun pdfBoxHighlightTex(
file: String, pageIndex: Int,
highlightTex: String,
highlightTextPosition: List<Int>
) {
val document = PDDocument.load(File(file))
val page: PDPage = document.getPage(pageIndex)
val contentStream = PDPageContentStream(
document, page,
PDPageContentStream.AppendMode.APPEND,
true,
true
)
contentStream.setStrokingColor(Color.YELLOW) // 设置高亮颜色
contentStream.setLineWidth(5f) // 设置高亮边框宽度
val stripper = object : PDFTextStripper() {
override fun writeString(text: String?, textPositions: MutableList<TextPosition>?) {
super.writeString(text, textPositions)
if (text?.equals(highlightTex) == true) {
highlightTextPosition.forEach {
val textPosition = textPositions?.get(it)
if (textPosition != null) {
val rect = PDRectangle(
textPosition.xDirAdj,
textPosition.getYDirAdj() - 12f,
textPosition.widthDirAdj,
textPosition.heightDir
)
contentStream.addRect(rect.lowerLeftX, rect.lowerLeftY, rect.width, rect.height)
contentStream.stroke()
} }
if (ap.canPrint()) {
println("You are allowed to print the document.")
} else {
println("You are not allowed to print the document.")
state = 1
} }
} else {
println("The PDF is not encrypted.")
state = 0
} }
} }
} catch (e: IOException) {
e.printStackTrace()
state = 1
} }
return state
stripper.sortByPosition = true;
stripper.startPage = 0
stripper.endPage = document.numberOfPages
// stripper.writeText(document, FileOutputStream(""))
document.close()
} }
fun setPassword( fun setPassword(
sourceFilePath: String, sourceFilePath: String,
userPassword: String, userPassword: String,
......
...@@ -85,13 +85,13 @@ class PdfPagerAdapter(val pdfPath: String, val itemLayout: Int = R.layout.item_p ...@@ -85,13 +85,13 @@ class PdfPagerAdapter(val pdfPath: String, val itemLayout: Int = R.layout.item_p
) { ) {
threadPoolExecutor.execute { threadPoolExecutor.execute {
runCatching { runCatching {
// val drawable = PdfBoxUtils.getPdfDrawablePage(context, pdfPath, item.pageIndex, scale) val drawable = PdfBoxUtils.getPdfDrawablePage(context, pdfPath, item.pageIndex, scale)
// item.pageDrawable = drawable item.pageDrawable = drawable
// itemView.post { itemView.post {
// item.pageDrawable?.let { item.pageDrawable?.let {
// iv.setImageDrawable(it) iv.setImageDrawable(it)
// } }
// } }
} }
} }
......
...@@ -35,12 +35,12 @@ class PdfPresenter( ...@@ -35,12 +35,12 @@ class PdfPresenter(
fun iniPdfPage(filePath: String) { fun iniPdfPage(filePath: String) {
// val list = arrayListOf<PdfPageBean>() val list = arrayListOf<PdfPageBean>()
// val number = PdfBoxUtils.getNumberOfPages(filePath) val number = PdfBoxUtils.getNumberOfPages(filePath)
// repeat(number) { repeat(number) {
// list.add(PdfPageBean(it)) list.add(PdfPageBean(it))
// } }
// pdfView?.initPdfPageRv(list) pdfView?.initPdfPageRv(list)
} }
fun splitPdf( fun splitPdf(
......
...@@ -73,8 +73,7 @@ class PdfSelectActivity : BaseActivity<ActivityPdfSelectBinding>(), DocumentView ...@@ -73,8 +73,7 @@ class PdfSelectActivity : BaseActivity<ActivityPdfSelectBinding>(), DocumentView
binding.rv.adapter = adapter binding.rv.adapter = adapter
} }
override fun refreshDocumentRv(documentList: List<DocumentBean>) { override fun refreshDocumentRv(documentList: List<DocumentBean>, isRefresh: Boolean) {
super.refreshDocumentRv(documentList)
if (doWhat == DO_MERGE_PDF) { if (doWhat == DO_MERGE_PDF) {
documentList.map { it.uiType = 1 } documentList.map { it.uiType = 1 }
} }
...@@ -84,5 +83,4 @@ class PdfSelectActivity : BaseActivity<ActivityPdfSelectBinding>(), DocumentView ...@@ -84,5 +83,4 @@ class PdfSelectActivity : BaseActivity<ActivityPdfSelectBinding>(), DocumentView
adapter.submitList(documentList) adapter.submitList(documentList)
} }
} }
\ No newline at end of file
...@@ -18,7 +18,7 @@ import java.io.File ...@@ -18,7 +18,7 @@ import java.io.File
class DocumentFragment() : BaseFragment<FragmentDocumentBinding>(), DocumentView { class DocumentFragment() : BaseFragment<FragmentDocumentBinding>(), DocumentView {
private var type = TYPE_PDF private var type = TYPE_PDF
private var documentList: List<DocumentBean>? = null private var documentList: ArrayList<DocumentBean> = arrayListOf()
private lateinit var adapter: DocumentAdapter private lateinit var adapter: DocumentAdapter
private lateinit var documentPresenter: DocumentPresenter private lateinit var documentPresenter: DocumentPresenter
private var firstDialog: Dialog? = null private var firstDialog: Dialog? = null
...@@ -35,14 +35,11 @@ class DocumentFragment() : BaseFragment<FragmentDocumentBinding>(), DocumentView ...@@ -35,14 +35,11 @@ class DocumentFragment() : BaseFragment<FragmentDocumentBinding>(), DocumentView
documentPresenter = DocumentPresenter(requireContext(), this, type, lifecycleScope) documentPresenter = DocumentPresenter(requireContext(), this, type, lifecycleScope)
initAdapter() initAdapter()
if (documentList != null) {
adapter.submitList(documentList)
} else {
if (requireContext().checkStorePermission()) { if (requireContext().checkStorePermission()) {
documentPresenter.initData() documentPresenter.initData()
} }
} }
}
private fun initAdapter() { private fun initAdapter() {
adapter = DocumentAdapter() adapter = DocumentAdapter()
...@@ -62,10 +59,18 @@ class DocumentFragment() : BaseFragment<FragmentDocumentBinding>(), DocumentView ...@@ -62,10 +59,18 @@ class DocumentFragment() : BaseFragment<FragmentDocumentBinding>(), DocumentView
binding.rv.adapter = adapter binding.rv.adapter = adapter
} }
override fun refreshDocumentRv(documentList: List<DocumentBean>) { override fun refreshDocumentRv(documentList: List<DocumentBean>, isRefresh: Boolean) {
this@DocumentFragment.documentList = documentList if (isRefresh) {
this.documentList.clear()
}
this.documentList.addAll(documentList)
if (adapter.items.isEmpty()) {
adapter.submitList(documentList) adapter.submitList(documentList)
} else {
adapter.addAll(documentList)
} }
}
override fun splitPdf(path: String) { override fun splitPdf(path: String) {
startActivity(Intent(requireContext(), PdfSplitActivity::class.java).apply { startActivity(Intent(requireContext(), PdfSplitActivity::class.java).apply {
...@@ -74,14 +79,14 @@ class DocumentFragment() : BaseFragment<FragmentDocumentBinding>(), DocumentView ...@@ -74,14 +79,14 @@ class DocumentFragment() : BaseFragment<FragmentDocumentBinding>(), DocumentView
} }
override fun deleteDocument(item: DocumentBean) { override fun deleteDocument(item: DocumentBean) {
val list = documentList?.toMutableList() val list = documentList.toMutableList()
documentPresenter.deleteDocumentBean(item) documentPresenter.deleteDocumentBean(item)
list?.remove(item) list.remove(item)
adapter.submitList(list) adapter.submitList(list)
} }
fun setRecentList() { fun setRecentList() {
val recentList = documentList?.filter { val recentList = documentList.filter {
(System.currentTimeMillis() - File(it.path).lastModified()) < 300L * 24 * 60 * 60 * 1000 (System.currentTimeMillis() - File(it.path).lastModified()) < 300L * 24 * 60 * 60 * 1000
} }
adapter.submitList(recentList) adapter.submitList(recentList)
...@@ -92,7 +97,7 @@ class DocumentFragment() : BaseFragment<FragmentDocumentBinding>(), DocumentView ...@@ -92,7 +97,7 @@ class DocumentFragment() : BaseFragment<FragmentDocumentBinding>(), DocumentView
} }
fun setBookmarkList() { fun setBookmarkList() {
val bookmarkList = documentList?.filter { it.isBookmarked } val bookmarkList = documentList.filter { it.isBookmarked }
adapter.submitList(bookmarkList) adapter.submitList(bookmarkList)
} }
......
...@@ -4,6 +4,7 @@ import android.content.Context ...@@ -4,6 +4,7 @@ import android.content.Context
import androidx.lifecycle.LifecycleCoroutineScope import androidx.lifecycle.LifecycleCoroutineScope
import com.base.pdfviewerscannerwhite.bean.ConstObject import com.base.pdfviewerscannerwhite.bean.ConstObject
import com.base.pdfviewerscannerwhite.bean.DocumentBean import com.base.pdfviewerscannerwhite.bean.DocumentBean
import com.base.pdfviewerscannerwhite.ui.document.pdf.PdfBoxUtils
import com.base.pdfviewerscannerwhite.utils.SpStringUtils import com.base.pdfviewerscannerwhite.utils.SpStringUtils
import com.base.pdfviewerscannerwhite.utils.getMediaFile import com.base.pdfviewerscannerwhite.utils.getMediaFile
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
...@@ -33,9 +34,11 @@ class DocumentPresenter( ...@@ -33,9 +34,11 @@ class DocumentPresenter(
fun initData() = lifecycleScope.launch(Dispatchers.IO) { fun initData() = lifecycleScope.launch(Dispatchers.IO) {
val documentList = getDocumentBeanList() val documentList = getDocumentBeanList()
launch(Dispatchers.Main) { launch(Dispatchers.Main) {
documentView.refreshDocumentRv(documentList) documentView.refreshDocumentRv(documentList, true)
} }
} }
fun saveBookmarkChange(addRemove: Boolean, path: String) { fun saveBookmarkChange(addRemove: Boolean, path: String) {
...@@ -54,7 +57,7 @@ class DocumentPresenter( ...@@ -54,7 +57,7 @@ class DocumentPresenter(
} }
val documentList = getDocumentBeanList() val documentList = getDocumentBeanList()
launch(Dispatchers.Main) { launch(Dispatchers.Main) {
documentView.refreshDocumentRv(documentList) documentView.refreshDocumentRv(documentList, true)
} }
} }
......
...@@ -5,7 +5,8 @@ import com.base.pdfviewerscannerwhite.bean.DocumentBean ...@@ -5,7 +5,8 @@ import com.base.pdfviewerscannerwhite.bean.DocumentBean
interface DocumentView { interface DocumentView {
fun dialogRename(item: DocumentBean) = Unit fun dialogRename(item: DocumentBean) = Unit
fun refreshDocumentRv(documentList: List<DocumentBean>) = Unit fun refreshDocumentRv(documentList: List<DocumentBean>, isRefresh: Boolean) = Unit
fun splitPdf(path: String) = Unit fun splitPdf(path: String) = Unit
fun deleteDocument(item: DocumentBean) = Unit fun deleteDocument(item: DocumentBean) = Unit
......
...@@ -21,10 +21,9 @@ import com.base.pdfviewerscannerwhite.databinding.DialogPdfDetailBinding ...@@ -21,10 +21,9 @@ import com.base.pdfviewerscannerwhite.databinding.DialogPdfDetailBinding
import com.base.pdfviewerscannerwhite.databinding.DialogPdfMoreBinding import com.base.pdfviewerscannerwhite.databinding.DialogPdfMoreBinding
import com.base.pdfviewerscannerwhite.databinding.DialogPdfPasswordBinding import com.base.pdfviewerscannerwhite.databinding.DialogPdfPasswordBinding
import com.base.pdfviewerscannerwhite.ui.adapter.DocumentAdapter import com.base.pdfviewerscannerwhite.ui.adapter.DocumentAdapter
import com.base.pdfviewerscannerwhite.ui.document.pdf.PdfBoxUtils
import com.base.pdfviewerscannerwhite.ui.main.DocumentView import com.base.pdfviewerscannerwhite.ui.main.DocumentView
import com.base.pdfviewerscannerwhite.ui.document.pdf.PdfView import com.base.pdfviewerscannerwhite.ui.document.pdf.PdfView
import com.base.pdfviewerscannerwhite.ui.view.DialogView.showDeleteDialog
import com.base.pdfviewerscannerwhite.ui.view.DialogView.showDocumentRenameDialog
import com.base.pdfviewerscannerwhite.utils.IntentShareUtils.sharePdfIntent import com.base.pdfviewerscannerwhite.utils.IntentShareUtils.sharePdfIntent
import com.base.pdfviewerscannerwhite.utils.IntentShareUtils.sharePdfPrintIntent import com.base.pdfviewerscannerwhite.utils.IntentShareUtils.sharePdfPrintIntent
import com.base.pdfviewerscannerwhite.utils.KotlinExt.toFormatSize import com.base.pdfviewerscannerwhite.utils.KotlinExt.toFormatSize
...@@ -122,6 +121,9 @@ object DialogView { ...@@ -122,6 +121,9 @@ object DialogView {
documentView.deleteDocument(item) documentView.deleteDocument(item)
} }
} }
binding.llLock.setOnClickListener {
showPdfPwdDialog(dialog, item)
}
dialog.setOnDismissListener { dialog.setOnDismissListener {
dismissAction.invoke() dismissAction.invoke()
} }
...@@ -177,7 +179,7 @@ object DialogView { ...@@ -177,7 +179,7 @@ object DialogView {
} }
fun Context.showPdfPwdDialog() { private fun Context.showPdfPwdDialog(firstDialog: Dialog?, item: DocumentBean) {
val dialog = BottomSheetDialog(this, R.style.BottomSheetDialog) val dialog = BottomSheetDialog(this, R.style.BottomSheetDialog)
val binding = DialogPdfPasswordBinding.inflate(LayoutInflater.from(this)) val binding = DialogPdfPasswordBinding.inflate(LayoutInflater.from(this))
dialog.setContentView(binding.root) dialog.setContentView(binding.root)
...@@ -192,6 +194,21 @@ object DialogView { ...@@ -192,6 +194,21 @@ object DialogView {
val behavior = BottomSheetBehavior.from(parentView) val behavior = BottomSheetBehavior.from(parentView)
//展开 //展开
behavior.state = BottomSheetBehavior.STATE_EXPANDED behavior.state = BottomSheetBehavior.STATE_EXPANDED
binding.edit.requestFocus()
binding.edit.addTextChangedListener {
binding.tvConfirm.isEnabled = it.toString().isNotEmpty()
}
binding.tvCancel.setOnClickListener {
dialog.dismiss()
}
binding.tvConfirm.setOnClickListener {
dialog.dismiss()
firstDialog?.dismiss()
val pwd = binding.edit.text.toString()
PdfBoxUtils.setPassword(item.path, pwd, pwd)
}
} }
private fun Context.showJumpPageNumberDialog(pageNumber: Int, okAction: ((pageIndex: Int) -> Unit)?) { private fun Context.showJumpPageNumberDialog(pageNumber: Int, okAction: ((pageIndex: Int) -> Unit)?) {
......
...@@ -12,6 +12,15 @@ ...@@ -12,6 +12,15 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="match_parent" />
<com.h6ah4i.android.widget.verticalseekbar.VerticalSeekBar
android:layout_width="wrap_content"
android:layout_height="350dp"
android:layout_marginEnd="16dp"
android:splitTrack="false"
app:layout_constraintBottom_toTopOf="@id/v_animator_bottom"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/v_animator_top"
app:seekBarRotation="CW90" />
<ViewAnimator <ViewAnimator
......
...@@ -195,6 +195,7 @@ ...@@ -195,6 +195,7 @@
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/ll_lock"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="60dp" android:layout_height="60dp"
android:background="?android:selectableItemBackground" android:background="?android:selectableItemBackground"
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription" tools:ignore="ContentDescription"
tools:src="@mipmap/h_pdfiocn" /> android:src="@mipmap/h_pdfiocn" />
<FrameLayout <FrameLayout
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment