Commit 46e36737 authored by wanglei's avatar wanglei

...

parent c861e374
...@@ -58,6 +58,7 @@ dependencies { ...@@ -58,6 +58,7 @@ dependencies {
//第三方UI //第三方UI
implementation("io.github.cymchad:BaseRecyclerViewAdapterHelper4:4.1.4") implementation("io.github.cymchad:BaseRecyclerViewAdapterHelper4:4.1.4")
implementation("com.h6ah4i.android.widget.verticalseekbar:verticalseekbar:1.0.0")
//mlkit //mlkit
implementation("com.google.android.gms:play-services-mlkit-document-scanner:16.0.0-beta1") implementation("com.google.android.gms:play-services-mlkit-document-scanner:16.0.0-beta1")
......
...@@ -5,6 +5,7 @@ import android.animation.AnimatorSet ...@@ -5,6 +5,7 @@ import android.animation.AnimatorSet
import android.animation.ObjectAnimator import android.animation.ObjectAnimator
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.content.Intent import android.content.Intent
import android.content.pm.ActivityInfo
import android.graphics.Color import android.graphics.Color
import android.util.DisplayMetrics import android.util.DisplayMetrics
import android.view.View import android.view.View
...@@ -31,6 +32,7 @@ import com.base.pdfviewerscannerwhite.utils.KeyBoardUtils.showKeyBoard ...@@ -31,6 +32,7 @@ import com.base.pdfviewerscannerwhite.utils.KeyBoardUtils.showKeyBoard
import com.base.pdfviewerscannerwhite.utils.ToastUtils.toast import com.base.pdfviewerscannerwhite.utils.ToastUtils.toast
import java.io.File import java.io.File
class PdfActivity : BaseActivity<ActivityPdfBinding>(), PdfView { class PdfActivity : BaseActivity<ActivityPdfBinding>(), PdfView {
...@@ -66,6 +68,7 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>(), PdfView { ...@@ -66,6 +68,7 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>(), PdfView {
changeNormalUI() changeNormalUI()
muPDFCore = pdfPresenter.openFile(path) muPDFCore = pdfPresenter.openFile(path)
muPDFCore?.needsPassword()
// 搜索设为空 // 搜索设为空
SearchTaskResult.set(null) SearchTaskResult.set(null)
...@@ -185,6 +188,9 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>(), PdfView { ...@@ -185,6 +188,9 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>(), PdfView {
putExtra("doWhat", DO_SAVE_PDF) putExtra("doWhat", DO_SAVE_PDF)
}) })
} }
binding.ivXuanzhuan.setOnClickListener {
switchOrientation()
}
} }
/** /**
...@@ -476,6 +482,14 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>(), PdfView { ...@@ -476,6 +482,14 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>(), PdfView {
searchTask?.stop() searchTask?.stop()
} }
fun switchOrientation() {
requestedOrientation = if (requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
} else {
ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
}
}
companion object { companion object {
const val UI_MODE_NORMAL = 0 const val UI_MODE_NORMAL = 0
......
package com.base.pdfviewerscannerwhite.utils 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.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.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.PDPage
import com.tom_roush.pdfbox.pdmodel.PDPageContentStream import com.tom_roush.pdfbox.pdmodel.PDPageContentStream
import com.tom_roush.pdfbox.pdmodel.common.PDRectangle import com.tom_roush.pdfbox.pdmodel.common.PDRectangle
import com.tom_roush.pdfbox.pdmodel.encryption.AccessPermission
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
...@@ -155,4 +158,28 @@ object PdfBoxUtils { ...@@ -155,4 +158,28 @@ object PdfBoxUtils {
document.close() document.close()
} }
fun setPassword(
sourceFilePath: String,
userPassword: String,
ownerPassword: String
) {
try {
PDDocument.load(File(sourceFilePath)).use { document ->
val ap = AccessPermission()
ap.setCanPrint(false)
ap.setCanModify(false)
ap.setCanExtractContent(false)
ap.setCanExtractForAccessibility(false)
ap.setCanFillInForm(false)
val spp = StandardProtectionPolicy(userPassword, ownerPassword, ap)
document.protect(spp)
document.save(File(sourceFilePath))
}
} catch (e: Exception) {
}
}
} }
\ No newline at end of file
...@@ -10,7 +10,6 @@ import com.base.pdfviewerscannerwhite.R ...@@ -10,7 +10,6 @@ import com.base.pdfviewerscannerwhite.R
import com.base.pdfviewerscannerwhite.bean.PdfPageBean import com.base.pdfviewerscannerwhite.bean.PdfPageBean
import com.base.pdfviewerscannerwhite.databinding.ItemPdfPagerBinding import com.base.pdfviewerscannerwhite.databinding.ItemPdfPagerBinding
import com.base.pdfviewerscannerwhite.databinding.ItemPdfPagerSplitBinding import com.base.pdfviewerscannerwhite.databinding.ItemPdfPagerSplitBinding
import com.base.pdfviewerscannerwhite.utils.PdfBoxUtils
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.util.concurrent.LinkedBlockingQueue import java.util.concurrent.LinkedBlockingQueue
...@@ -86,13 +85,13 @@ class PdfPagerAdapter(val pdfPath: String, val itemLayout: Int = R.layout.item_p ...@@ -86,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)
} // }
} // }
} }
} }
......
...@@ -8,7 +8,6 @@ import com.base.pdfviewerscannerwhite.R ...@@ -8,7 +8,6 @@ import com.base.pdfviewerscannerwhite.R
import com.base.pdfviewerscannerwhite.bean.PdfPageBean import com.base.pdfviewerscannerwhite.bean.PdfPageBean
import com.base.pdfviewerscannerwhite.ui.document.pdf.PdfMergeActivity.Companion.mergePdfList import com.base.pdfviewerscannerwhite.ui.document.pdf.PdfMergeActivity.Companion.mergePdfList
import com.base.pdfviewerscannerwhite.utils.LogEx import com.base.pdfviewerscannerwhite.utils.LogEx
import com.base.pdfviewerscannerwhite.utils.PdfBoxUtils
import com.tom_roush.pdfbox.multipdf.PDFMergerUtility import com.tom_roush.pdfbox.multipdf.PDFMergerUtility
import com.tom_roush.pdfbox.pdmodel.PDDocument import com.tom_roush.pdfbox.pdmodel.PDDocument
import java.io.File import java.io.File
...@@ -36,12 +35,12 @@ class PdfPresenter( ...@@ -36,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(
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
android:layout_height="match_parent" /> android:layout_height="match_parent" />
<ViewAnimator <ViewAnimator
android:id="@+id/v_animator_top" android:id="@+id/v_animator_top"
android:layout_width="match_parent" android:layout_width="match_parent"
......
This diff is collapsed.
...@@ -38,4 +38,6 @@ android { ...@@ -38,4 +38,6 @@ android {
dependencies { dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation(libs.androidx.appcompat) implementation(libs.androidx.appcompat)
// api 'com.artifex.mupdf:viewer:1.24.9a'
} }
\ No newline at end of file
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