Commit 8b19238e authored by wanglei's avatar wanglei

...

parent 7cba32e7
......@@ -9,6 +9,7 @@
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/android-pdf-viewer/build
/build
/captures
.externalNativeBuild
......
plugins {
id 'com.android.library'
id 'org.jetbrains.kotlin.android'
}
android {
namespace 'com.github.barteksc.pdfviewer' // 添加 namespace
compileSdkVersion 34 // 更新为最新 SDK 版本
defaultConfig {
minSdkVersion 21 // 提升最低 SDK 版本以符合现代应用标准
targetSdkVersion 34 // 更新为目标 SDK 版本
versionCode 1
versionName "2.8.1"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation 'com.github.barteksc:pdfium-android:1.7.1'
implementation("androidx.core:core-ktx:1.10.1")
implementation ("com.android.support:support-v4:28.0.0")
}
plugins {
id("com.android.library")
id("org.jetbrains.kotlin.android")
}
android {
namespace = "com.github.barteksc.pdfviewer"
compileSdk = 34 // 更新为最新 SDK 版本
defaultConfig {
minSdk = 24 // 提升最低 SDK 版本以符合现代应用标准
//noinspection OldTargetApi
targetSdk = 34 // 更新为目标 SDK 版本
}
}
dependencies {
//noinspection UseTomlInstead
implementation("com.github.barteksc:pdfium-android:1.7.1")
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.activity)
implementation(libs.androidx.appcompat)
}
\ No newline at end of file
......@@ -16,6 +16,7 @@ android {
defaultConfig {
applicationId = "com.tool.advanced.cleaner"
minSdk = 24
//noinspection OldTargetApi
targetSdk = 34
versionCode = 5
versionName = "1.5"
......@@ -76,7 +77,6 @@ dependencies {
implementation(libs.androidx.constraintlayout)
implementation(libs.androidx.navigation.fragment.ktx)
implementation(libs.androidx.navigation.ui.ktx)
implementation(project(":android-pdf-viewer"))
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
......@@ -111,7 +111,7 @@ dependencies {
// https://developers.google.com/ml-kit/vision/doc-scanner/android
implementation("com.google.android.gms:play-services-mlkit-document-scanner:16.0.0-beta1")
// https://github.com/DImuthuUpe/AndroidPdfViewer
implementation("com.github.barteksc:android-pdf-viewer:2.8.1")
implementation(project(":android-pdf-viewer"))
//相机
......
package com.base.scanqrclear.ui.scan
import android.net.Uri
import androidx.activity.addCallback
import androidx.core.view.updatePadding
import com.base.scanqrclear.base.BaseActivity
import com.base.scanqrclear.databinding.ActivityPdfResultBinding
import com.base.scanqrclear.utils.BarUtils
import com.github.barteksc.pdfviewer.scroll.DefaultScrollHandle
import com.gyf.immersionbar.ktx.immersionBar
class PdfResultActivity : BaseActivity<ActivityPdfResultBinding>(ActivityPdfResultBinding::inflate) {
private var uri: String = ""
override fun initView() {
super.initView()
binding.clTop.updatePadding(top = BarUtils.getStatusBarHeight())
uri = intent.extras?.getString("uri") ?: ""
val name = uri.split("/").last()
binding.tvPdfName.text = name
displayFromUri(uri)
}
override fun initListener() {
super.initListener()
onBackPressedDispatcher.addCallback {
finish()
}
binding.flBack.setOnClickListener {
onBackPressedDispatcher.onBackPressed()
}
}
private fun displayFromUri(uri: String) {
binding.pdfView.fromUri(Uri.parse(uri))
.defaultPage(0)
// .onPageChange(this)
.enableAnnotationRendering(true)
// .onLoad(this)
.scrollHandle(DefaultScrollHandle(this))
.spacing(10) // in dp
// .onPageError(this)
.load()
}
override fun configSystemBar() {
immersionBar {
statusBarColor("#FFFFFFFF")
statusBarDarkFont(true)
}
}
}
\ No newline at end of file
package com.base.scanqrclear.ui.scan
import android.content.Intent
import androidx.activity.addCallback
import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.IntentSenderRequest
......@@ -56,8 +57,8 @@ class ScanOtherActivity : BaseActivity<ActivityScanOtherBinding>(ActivityScanOth
when (item.key) {
KEY_DOCUMENT -> {
val options = GmsDocumentScannerOptions.Builder()
.setGalleryImportAllowed(false)
.setPageLimit(2)
.setGalleryImportAllowed(true)
// .setPageLimit(2)
.setResultFormats(RESULT_FORMAT_JPEG, RESULT_FORMAT_PDF)
.setScannerMode(SCANNER_MODE_FULL)
.build()
......@@ -83,18 +84,16 @@ class ScanOtherActivity : BaseActivity<ActivityScanOtherBinding>(ActivityScanOth
val imageUri = page.imageUri
// imageUri=file:///data/user/0/com.tool.advanced.cleaner/cache/mlkit_docscan_ui_client/268059886691727.jpg
LogEx.logDebug(TAG, "imageUri=$imageUri")
if (BuildConfig.DEBUG) {
binding.tvTest.append("imageUri=$imageUri\n")
}
}
val pdfUri = data?.pdf?.uri
val pdfPageCount = data?.pdf?.pageCount
LogEx.logDebug(TAG, "pdfUri=$pdfUri")
// pdfUri=file:///data/user/0/com.tool.advanced.cleaner/cache/mlkit_docscan_ui_client/268059987162265.pdf
binding.tvTest.append("pdfUri=$pdfUri\n")
LogEx.logDebug(TAG, "pdfPageCount=$pdfPageCount")
binding.tvTest.append("pdfPageCount=$pdfPageCount")
startActivity(Intent(this, PdfResultActivity::class.java).apply {
putExtra("uri", pdfUri.toString())
})
}
}
......
......@@ -45,6 +45,12 @@
</androidx.constraintlayout.widget.ConstraintLayout>
<com.github.barteksc.pdfviewer.PDFView
android:id="@+id/pdfView"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@id/clBottom"
app:layout_constraintTop_toBottomOf="@id/clTop" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/clBottom"
......
......@@ -87,13 +87,4 @@
</com.base.scanqrclear.ads.NativeParentView>
<TextView
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:id="@+id/tvTest"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ 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