Commit c020fab7 authored by wanglei's avatar wanglei

...提交部分功能...

parent 9964ecd4
......@@ -17,7 +17,8 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.SuperPDFReader"
tools:targetApi="31">
tools:targetApi="33">
<activity
android:name=".activity.PdfConvertedActivity"
android:exported="false"
......@@ -66,6 +67,17 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileProvider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
</application>
</manifest>
\ No newline at end of file
......@@ -4,17 +4,24 @@ import android.animation.Animator
import android.animation.AnimatorListenerAdapter
import android.animation.ValueAnimator
import android.annotation.SuppressLint
import android.content.Intent
import android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
import android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
import android.graphics.Color
import android.net.Uri
import android.util.Log
import android.view.View
import android.widget.Toast
import androidx.activity.addCallback
import androidx.core.animation.addListener
import androidx.core.content.FileProvider
import androidx.lifecycle.lifecycleScope
import com.base.superpdfreader.databinding.ActivityPdfBrowserBinding
import com.base.superpdfreader.helps.BaseActivity
import com.base.superpdfreader.helps.LogEx
import com.base.superpdfreader.utils.BarUtils
import com.base.superpdfreader.view.DialogViews.showEnterDdfPassword
import com.base.superpdfreader.view.DocumentDetailDialog.showDocumentDetailDialog
import com.github.barteksc.pdfviewer.scroll.DefaultScrollHandle
import com.tom_roush.pdfbox.pdmodel.PDDocument
import kotlinx.coroutines.Dispatchers
......@@ -29,7 +36,8 @@ class PdfBrowserActivity : BaseActivity<ActivityPdfBrowserBinding>() {
var pageNumber = 0
private val TAG = "PdfBrowserActivity"
private var orientation = SCREEN_ORIENTATION_PORTRAIT
private var path: String = ""
override val binding: ActivityPdfBrowserBinding by lazy {
ActivityPdfBrowserBinding.inflate(layoutInflater)
......@@ -39,7 +47,7 @@ class PdfBrowserActivity : BaseActivity<ActivityPdfBrowserBinding>() {
BarUtils.setStatusBarLightMode(this, true)
BarUtils.setStatusBarColor(this, Color.TRANSPARENT)
val path = intent.extras?.getString("Path") ?: ""
path = intent.extras?.getString("Path") ?: ""
val file = File(path)
if (file.exists()) {
......@@ -82,6 +90,7 @@ class PdfBrowserActivity : BaseActivity<ActivityPdfBrowserBinding>() {
}.password(password).load()
}
@SuppressLint("QueryPermissionsNeeded")
override fun initListener() {
binding.pdfview.setOnClickListener {
toggleTools()
......@@ -94,6 +103,42 @@ class PdfBrowserActivity : BaseActivity<ActivityPdfBrowserBinding>() {
onBackPressedDispatcher.addCallback {
finishToMain()
}
binding.ivRotate.setOnClickListener {
if (orientation == SCREEN_ORIENTATION_PORTRAIT) {
orientation = SCREEN_ORIENTATION_LANDSCAPE
requestedOrientation = orientation
} else {
orientation = SCREEN_ORIENTATION_PORTRAIT
requestedOrientation = orientation
}
}
binding.ivShare.setOnClickListener {
val shareIntent = Intent(Intent.ACTION_SEND).apply {
setType("application/pdf")
val uri: Uri = FileProvider.getUriForFile(
this@PdfBrowserActivity,
this@PdfBrowserActivity.packageName + ".fileProvider",
File(path)
)
//取的都是gradle.build中的applicationId
LogEx.logDebug(TAG, "applicationId=${this@PdfBrowserActivity.applicationInfo.packageName}")
LogEx.logDebug(TAG, "packageName=${this@PdfBrowserActivity.packageName}")
LogEx.logDebug(TAG, "uri=$uri")
putExtra(Intent.EXTRA_STREAM, uri)
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
}
val chooser: Intent = Intent.createChooser(shareIntent, "share pdf")
// 检查是否有可以处理此Intent的应用
if (shareIntent.resolveActivity(packageManager) != null) {
startActivity(chooser)
} else {
Toast.makeText(this, "No application to share", Toast.LENGTH_SHORT).show()
}
}
}
......
......@@ -4,8 +4,10 @@ import android.annotation.SuppressLint
import android.app.Dialog
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.widget.TextView
import android.widget.Toast
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.view.isVisible
import androidx.core.widget.addTextChangedListener
import com.base.superpdfreader.R
......@@ -17,6 +19,7 @@ import com.base.superpdfreader.bean.PdfParameterBean.Companion.arrayPageSize
import com.base.superpdfreader.databinding.DialogPdfParametersBinding
import com.base.superpdfreader.databinding.DialogPdfSaveBinding
import com.base.superpdfreader.view.XmlEx.inflate
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog
import java.text.SimpleDateFormat
......@@ -72,6 +75,8 @@ object PDFSaveDialog {
binding.flSelector.setOnClickListener {
binding.ivSelector.isSelected = !binding.ivSelector.isSelected
binding.flPassword.isVisible = binding.ivSelector.isSelected
val parentView = binding.root.parent as View
BottomSheetBehavior.from(parentView).state = BottomSheetBehavior.STATE_EXPANDED
}
binding.tvSave.setOnClickListener {
if (binding.flPassword.isVisible) {
......@@ -86,6 +91,8 @@ object PDFSaveDialog {
saveAction.invoke(pdfParameterBean)
dialog.dismiss()
}
val parentView = binding.root.parent as View
BottomSheetBehavior.from(parentView).state = BottomSheetBehavior.STATE_EXPANDED
}
fun Context.showPDFSaveParametersDialog(array: Array<String>, click: (index: Int, s: String) -> Unit) {
......
......@@ -73,6 +73,7 @@
tools:ignore="ContentDescription" />
<ImageView
android:visibility="invisible"
android:id="@+id/iv_print"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
......@@ -81,6 +82,7 @@
tools:ignore="ContentDescription" />
<ImageView
android:visibility="invisible"
android:id="@+id/iv_search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
......@@ -89,6 +91,7 @@
tools:ignore="ContentDescription" />
<ImageView
android:visibility="gone"
android:id="@+id/iv_more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
......
<resources xmlns:tools="http://schemas.android.com/tools"
tools:ignore="MissingDefaultResource">
<paths>
<!-- Environment.getExternalStorageDirectory() + “/path/” -->
<!-- /storage/emulated/0/path/ -->
<external-path
name="sdcard"
path="." />
</paths>
</resources>
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