Skip to content

Commit ab47bca

Browse files
committed
fix #619, use a different pdf viewer
1 parent 44c07dd commit ab47bca

File tree

4 files changed

+23
-14
lines changed

4 files changed

+23
-14
lines changed

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ android {
6464
}
6565

6666
dependencies {
67-
implementation 'com.github.SimpleMobileTools:Simple-Commons:f538687d6e'
68-
implementation 'com.github.tibbi:AndroidPdfViewer:da57ff410e'
67+
implementation 'com.github.SimpleMobileTools:Simple-Commons:b452494768'
68+
implementation 'com.github.tibbi:PdfViewPager:1bc22f031a'
6969
implementation 'com.github.Stericson:RootTools:df729dcb13'
7070
implementation 'com.github.Stericson:RootShell:1.6'
7171
implementation 'com.alexvasilkov:gesture-views:2.5.2'

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MainActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ class MainActivity : SimpleActivity() {
640640

641641
private fun launchAbout() {
642642
closeSearch()
643-
val licenses = LICENSE_GLIDE or LICENSE_PATTERN or LICENSE_REPRINT or LICENSE_GESTURE_VIEWS or LICENSE_PDF_VIEWER or LICENSE_AUTOFITTEXTVIEW
643+
val licenses = LICENSE_GLIDE or LICENSE_PATTERN or LICENSE_REPRINT or LICENSE_GESTURE_VIEWS or LICENSE_PDF_VIEW_PAGER or LICENSE_AUTOFITTEXTVIEW
644644

645645
val faqItems = arrayListOf(
646646
FAQItem(R.string.faq_3_title_commons, R.string.faq_3_text_commons),

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/PDFViewerActivity.kt

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,21 @@ import android.print.PrintAttributes
88
import android.print.PrintManager
99
import android.view.WindowManager
1010
import android.widget.RelativeLayout
11-
import com.github.barteksc.pdfviewer.scroll.DefaultScrollHandle
1211
import com.simplemobiletools.commons.extensions.*
1312
import com.simplemobiletools.commons.helpers.REAL_FILE_PATH
1413
import com.simplemobiletools.commons.helpers.isPiePlus
1514
import com.simplemobiletools.filemanager.pro.R
1615
import com.simplemobiletools.filemanager.pro.extensions.hideSystemUI
1716
import com.simplemobiletools.filemanager.pro.extensions.showSystemUI
1817
import com.simplemobiletools.filemanager.pro.helpers.PdfDocumentAdapter
18+
import es.voghdev.pdfviewpager.library.adapter.BasePDFPagerAdapter
19+
import es.voghdev.pdfviewpager.library.adapter.PDFPagerAdapter
1920
import kotlinx.android.synthetic.main.activity_pdf_viewer.*
2021

2122
class PDFViewerActivity : SimpleActivity() {
2223
private var realFilePath = ""
2324
private var isFullScreen = false
25+
private var adapter: BasePDFPagerAdapter? = null
2426

2527
override fun onCreate(savedInstanceState: Bundle?) {
2628
showTransparentTop = true
@@ -54,6 +56,11 @@ class PDFViewerActivity : SimpleActivity() {
5456
window.navigationBarColor = Color.TRANSPARENT
5557
}
5658

59+
override fun onDestroy() {
60+
super.onDestroy()
61+
adapter?.close()
62+
}
63+
5764
private fun setupMenu() {
5865
(pdf_viewer_appbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight
5966
pdf_viewer_toolbar.menu.apply {
@@ -92,17 +99,19 @@ class PDFViewerActivity : SimpleActivity() {
9299
return
93100
}
94101

95-
val primaryColor = getProperPrimaryColor()
96102
pdf_viewer.setBackgroundColor(getProperBackgroundColor())
97-
pdf_viewer.fromUri(uri)
98-
.scrollHandle(DefaultScrollHandle(this, primaryColor.getContrastColor(), primaryColor))
99-
.spacing(15)
100-
.onTap { toggleFullScreen() }
101-
.onError {
102-
showErrorToast(it.localizedMessage?.toString() ?: getString(R.string.unknown_error_occurred))
103-
finish()
103+
104+
adapter = PDFPagerAdapter.Builder(this)
105+
.setPdfPath(uri.toString())
106+
.setOnPageClickListener {
107+
toggleFullScreen()
104108
}
105-
.load()
109+
.setErrorHandler { throwable ->
110+
showErrorToast(throwable.toString())
111+
}
112+
.create()
113+
114+
pdf_viewer.adapter = adapter
106115

107116
showSystemUI(true)
108117

app/src/main/res/layout/activity_pdf_viewer.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
android:layout_height="wrap_content"
77
app:layout_behavior="@string/appbar_scrolling_view_behavior">
88

9-
<com.github.barteksc.pdfviewer.PDFView
9+
<es.voghdev.pdfviewpager.library.PDFViewPager
1010
android:id="@+id/pdf_viewer"
1111
android:layout_width="match_parent"
1212
android:layout_height="match_parent" />

0 commit comments

Comments
 (0)