From d1c68d55bba1abc81d9c1918e3a58c2a2c8e3f1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ensar=20Saraj=C4=8Di=C4=87?= Date: Tue, 4 Jul 2023 14:24:00 +0200 Subject: [PATCH] Revert "fix #619, use a different pdf viewer" This reverts commit ab47bcadbe2807b3aec7c11ce11bb989c58ba35c. --- app/build.gradle | 2 +- .../pro/activities/MainActivity.kt | 1 + .../pro/activities/PDFViewerActivity.kt | 32 +++++++------------ .../main/res/layout/activity_pdf_viewer.xml | 2 +- 4 files changed, 15 insertions(+), 22 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 20bdeee3..c4ff8f1b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -65,7 +65,7 @@ android { dependencies { 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:RootShell:1.6' implementation 'com.alexvasilkov:gesture-views:2.5.2' diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MainActivity.kt index 590885db..e539583a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MainActivity.kt @@ -632,6 +632,7 @@ class MainActivity : SimpleActivity() { } 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 faqItems = arrayListOf( diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/PDFViewerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/PDFViewerActivity.kt index 31fbbb11..8dc4a942 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/PDFViewerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/PDFViewerActivity.kt @@ -6,11 +6,9 @@ import android.graphics.Color import android.os.Bundle import android.print.PrintAttributes import android.print.PrintManager -import android.view.View import android.view.WindowManager -import androidx.viewpager2.widget.MarginPageTransformer 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.helpers.REAL_FILE_PATH 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.showSystemUI 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.* class PDFViewerActivity : SimpleActivity() { @@ -95,21 +91,17 @@ class PDFViewerActivity : SimpleActivity() { return } - val clickListener = View.OnClickListener { - toggleFullScreen() - } - - val errorHandler = PdfErrorHandler { throwable -> showErrorToast(throwable.toString()) } - - pdf_viewer.setPageTransformer(MarginPageTransformer(resources.getDimension(R.dimen.activity_margin).toInt())) - pdf_viewer.orientation = ViewPager2.ORIENTATION_VERTICAL - try { - pdf_viewer.adapter = PDFPagerAdapter(this, clickListener, errorHandler, uri.toString(), getProperBackgroundColor()) - } catch (e: Exception) { - showErrorToast(e) - finish() - return - } + val primaryColor = getProperPrimaryColor() + pdf_viewer.setBackgroundColor(getProperBackgroundColor()) + pdf_viewer.fromUri(uri) + .scrollHandle(DefaultScrollHandle(this, primaryColor.getContrastColor(), primaryColor)) + .spacing(15) + .onTap { toggleFullScreen() } + .onError { + showErrorToast(it.localizedMessage?.toString() ?: getString(R.string.unknown_error_occurred)) + finish() + } + .load() showSystemUI(true) diff --git a/app/src/main/res/layout/activity_pdf_viewer.xml b/app/src/main/res/layout/activity_pdf_viewer.xml index 93244f33..ba3412c6 100644 --- a/app/src/main/res/layout/activity_pdf_viewer.xml +++ b/app/src/main/res/layout/activity_pdf_viewer.xml @@ -6,7 +6,7 @@ android:layout_height="wrap_content" app:layout_behavior="@string/appbar_scrolling_view_behavior"> -