Revert "fix #619, use a different pdf viewer"

This reverts commit ab47bcadbe.
This commit is contained in:
Ensar Sarajčić 2023-07-04 14:24:00 +02:00
parent 089f352818
commit d1c68d55bb
4 changed files with 15 additions and 22 deletions

View File

@ -65,7 +65,7 @@ android {
dependencies { dependencies {
implementation 'com.github.SimpleMobileTools:Simple-Commons:30e6321592' implementation 'com.github.SimpleMobileTools:Simple-Commons:30e6321592'
implementation 'com.github.tibbi:PdfViewPager:d2af24208d' implementation 'com.github.esensar:AndroidPdfViewer:1b33733a2b'
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

@ -632,6 +632,7 @@ class MainActivity : SimpleActivity() {
} }
private fun launchAbout() { private fun launchAbout() {
// TODO: Add PDFViewer license
val licenses = LICENSE_GLIDE or LICENSE_PATTERN or LICENSE_REPRINT or LICENSE_GESTURE_VIEWS or LICENSE_PDF_VIEW_PAGER 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(

View File

@ -6,11 +6,9 @@ import android.graphics.Color
import android.os.Bundle import android.os.Bundle
import android.print.PrintAttributes import android.print.PrintAttributes
import android.print.PrintManager import android.print.PrintManager
import android.view.View
import android.view.WindowManager import android.view.WindowManager
import androidx.viewpager2.widget.MarginPageTransformer
import android.widget.RelativeLayout import android.widget.RelativeLayout
import androidx.viewpager2.widget.ViewPager2 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
@ -18,8 +16,6 @@ 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.PDFPagerAdapter
import es.voghdev.pdfviewpager.library.adapter.PdfErrorHandler
import kotlinx.android.synthetic.main.activity_pdf_viewer.* import kotlinx.android.synthetic.main.activity_pdf_viewer.*
class PDFViewerActivity : SimpleActivity() { class PDFViewerActivity : SimpleActivity() {
@ -95,21 +91,17 @@ class PDFViewerActivity : SimpleActivity() {
return return
} }
val clickListener = View.OnClickListener { val primaryColor = getProperPrimaryColor()
toggleFullScreen() pdf_viewer.setBackgroundColor(getProperBackgroundColor())
} pdf_viewer.fromUri(uri)
.scrollHandle(DefaultScrollHandle(this, primaryColor.getContrastColor(), primaryColor))
val errorHandler = PdfErrorHandler { throwable -> showErrorToast(throwable.toString()) } .spacing(15)
.onTap { toggleFullScreen() }
pdf_viewer.setPageTransformer(MarginPageTransformer(resources.getDimension(R.dimen.activity_margin).toInt())) .onError {
pdf_viewer.orientation = ViewPager2.ORIENTATION_VERTICAL showErrorToast(it.localizedMessage?.toString() ?: getString(R.string.unknown_error_occurred))
try {
pdf_viewer.adapter = PDFPagerAdapter(this, clickListener, errorHandler, uri.toString(), getProperBackgroundColor())
} catch (e: Exception) {
showErrorToast(e)
finish() finish()
return
} }
.load()
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">
<androidx.viewpager2.widget.ViewPager2 <com.github.barteksc.pdfviewer.PDFView
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" />