fix #619, use a different pdf viewer

This commit is contained in:
tibbi 2022-12-09 20:47:18 +01:00
parent 44c07dd253
commit ab47bcadbe
4 changed files with 23 additions and 14 deletions

View File

@ -64,8 +64,8 @@ android {
} }
dependencies { dependencies {
implementation 'com.github.SimpleMobileTools:Simple-Commons:f538687d6e' implementation 'com.github.SimpleMobileTools:Simple-Commons:b452494768'
implementation 'com.github.tibbi:AndroidPdfViewer:da57ff410e' implementation 'com.github.tibbi:PdfViewPager:1bc22f031a'
implementation 'com.github.Stericson:RootTools:df729dcb13' implementation 'com.github.Stericson:RootTools:df729dcb13'
implementation 'com.github.Stericson:RootShell:1.6' implementation 'com.github.Stericson:RootShell:1.6'
implementation 'com.alexvasilkov:gesture-views:2.5.2' implementation 'com.alexvasilkov:gesture-views:2.5.2'

View File

@ -640,7 +640,7 @@ class MainActivity : SimpleActivity() {
private fun launchAbout() { private fun launchAbout() {
closeSearch() closeSearch()
val licenses = LICENSE_GLIDE or LICENSE_PATTERN or LICENSE_REPRINT or LICENSE_GESTURE_VIEWS or LICENSE_PDF_VIEWER or LICENSE_AUTOFITTEXTVIEW val licenses = LICENSE_GLIDE or LICENSE_PATTERN or LICENSE_REPRINT or LICENSE_GESTURE_VIEWS or LICENSE_PDF_VIEW_PAGER or LICENSE_AUTOFITTEXTVIEW
val faqItems = arrayListOf( val faqItems = arrayListOf(
FAQItem(R.string.faq_3_title_commons, R.string.faq_3_text_commons), FAQItem(R.string.faq_3_title_commons, R.string.faq_3_text_commons),

View File

@ -8,7 +8,6 @@ import android.print.PrintAttributes
import android.print.PrintManager import android.print.PrintManager
import android.view.WindowManager import android.view.WindowManager
import android.widget.RelativeLayout import android.widget.RelativeLayout
import com.github.barteksc.pdfviewer.scroll.DefaultScrollHandle
import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.REAL_FILE_PATH import com.simplemobiletools.commons.helpers.REAL_FILE_PATH
import com.simplemobiletools.commons.helpers.isPiePlus import com.simplemobiletools.commons.helpers.isPiePlus
@ -16,11 +15,14 @@ import com.simplemobiletools.filemanager.pro.R
import com.simplemobiletools.filemanager.pro.extensions.hideSystemUI import com.simplemobiletools.filemanager.pro.extensions.hideSystemUI
import com.simplemobiletools.filemanager.pro.extensions.showSystemUI import com.simplemobiletools.filemanager.pro.extensions.showSystemUI
import com.simplemobiletools.filemanager.pro.helpers.PdfDocumentAdapter import com.simplemobiletools.filemanager.pro.helpers.PdfDocumentAdapter
import es.voghdev.pdfviewpager.library.adapter.BasePDFPagerAdapter
import es.voghdev.pdfviewpager.library.adapter.PDFPagerAdapter
import kotlinx.android.synthetic.main.activity_pdf_viewer.* import kotlinx.android.synthetic.main.activity_pdf_viewer.*
class PDFViewerActivity : SimpleActivity() { class PDFViewerActivity : SimpleActivity() {
private var realFilePath = "" private var realFilePath = ""
private var isFullScreen = false private var isFullScreen = false
private var adapter: BasePDFPagerAdapter? = null
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
showTransparentTop = true showTransparentTop = true
@ -54,6 +56,11 @@ class PDFViewerActivity : SimpleActivity() {
window.navigationBarColor = Color.TRANSPARENT window.navigationBarColor = Color.TRANSPARENT
} }
override fun onDestroy() {
super.onDestroy()
adapter?.close()
}
private fun setupMenu() { private fun setupMenu() {
(pdf_viewer_appbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight (pdf_viewer_appbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight
pdf_viewer_toolbar.menu.apply { pdf_viewer_toolbar.menu.apply {
@ -92,17 +99,19 @@ class PDFViewerActivity : SimpleActivity() {
return return
} }
val primaryColor = getProperPrimaryColor()
pdf_viewer.setBackgroundColor(getProperBackgroundColor()) pdf_viewer.setBackgroundColor(getProperBackgroundColor())
pdf_viewer.fromUri(uri)
.scrollHandle(DefaultScrollHandle(this, primaryColor.getContrastColor(), primaryColor)) adapter = PDFPagerAdapter.Builder(this)
.spacing(15) .setPdfPath(uri.toString())
.onTap { toggleFullScreen() } .setOnPageClickListener {
.onError { toggleFullScreen()
showErrorToast(it.localizedMessage?.toString() ?: getString(R.string.unknown_error_occurred))
finish()
} }
.load() .setErrorHandler { throwable ->
showErrorToast(throwable.toString())
}
.create()
pdf_viewer.adapter = adapter
showSystemUI(true) showSystemUI(true)

View File

@ -6,7 +6,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior"> app:layout_behavior="@string/appbar_scrolling_view_behavior">
<com.github.barteksc.pdfviewer.PDFView <es.voghdev.pdfviewpager.library.PDFViewPager
android:id="@+id/pdf_viewer" android:id="@+id/pdf_viewer"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="match_parent" />