@@ -28,7 +28,7 @@ import kotlinx.android.synthetic.main.activity_pdf_viewer.*
2828class PDFViewerActivity : SimpleActivity () {
2929 private var realFilePath = " "
3030
31- private var systemUiVisible = true
31+ private var isFullScreen = false
3232 private var pdfViewerHeight = - 1
3333 private var positionOffset = 0f
3434
@@ -45,7 +45,7 @@ class PDFViewerActivity : SimpleActivity() {
4545 }
4646
4747 checkIntent()
48- setupFullScreenView ()
48+ setupNotch ()
4949 }
5050
5151 override fun onCreateOptionsMenu (menu : Menu ): Boolean {
@@ -83,6 +83,7 @@ class PDFViewerActivity : SimpleActivity() {
8383 pdf_viewer.fromUri(uri)
8484 .scrollHandle(DefaultScrollHandle (this , primaryColor.getContrastColor(), primaryColor))
8585 .spacing(15 )
86+ .onTap { toggleFullScreen() }
8687 .load()
8788 }
8889
@@ -94,12 +95,10 @@ class PDFViewerActivity : SimpleActivity() {
9495 }
9596 }
9697
97- private fun setupFullScreenView () {
98- pdf_viewer.setOnClickListener {
99- if (systemUiVisible) enterFullScreen() else exitFullScreen()
100- systemUiVisible = ! systemUiVisible
101- }
102- setupNotch()
98+ private fun toggleFullScreen (): Boolean {
99+ if (isFullScreen) exitFullScreen() else enterFullScreen()
100+ isFullScreen = ! isFullScreen
101+ return true
103102 }
104103
105104 private fun enterFullScreen () {
@@ -116,6 +115,8 @@ class PDFViewerActivity : SimpleActivity() {
116115 }
117116
118117 private fun exitFullScreen () {
118+ positionOffset = pdf_viewer.positionOffset
119+
119120 showSystemUI(true )
120121 pdf_viewer.updateLayoutParams<RelativeLayout .LayoutParams > {
121122 this .height = pdfViewerHeight
0 commit comments