parent
83efc53edc
commit
b18232615d
@ -1,3 +1,6 @@
|
||||
[submodule "app/libgocryptfs"]
|
||||
path = app/libgocryptfs
|
||||
url = https://forge.chapril.org/hardcoresushi/libgocryptfs.git
|
||||
[submodule "libpdfviewer"]
|
||||
path = libpdfviewer
|
||||
url = https://forge.chapril.org/hardcoresushi/libpdfviewer.git
|
||||
|
@ -0,0 +1,51 @@
|
||||
package sushi.hardcore.droidfs.file_viewers
|
||||
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import sushi.hardcore.droidfs.R
|
||||
import sushi.hardcore.droidfs.databinding.ActivityPdfViewerBinding
|
||||
import java.io.ByteArrayInputStream
|
||||
import java.io.File
|
||||
|
||||
class PdfViewer: FileViewerActivity() {
|
||||
private lateinit var binding: ActivityPdfViewerBinding
|
||||
|
||||
override fun hideSystemUi() {
|
||||
//don't hide system ui
|
||||
}
|
||||
|
||||
override fun getFileType(): String {
|
||||
return "pdf"
|
||||
}
|
||||
|
||||
override fun viewFile() {
|
||||
binding = ActivityPdfViewerBinding.inflate(layoutInflater)
|
||||
val toolbar = binding.root.findViewById<Toolbar>(R.id.toolbar)
|
||||
setSupportActionBar(toolbar)
|
||||
title = ""
|
||||
val titleText = toolbar.findViewById<TextView>(R.id.title_text)
|
||||
val fileName = File(filePath).name
|
||||
titleText.text = fileName
|
||||
binding.pdfViewer.activity = this
|
||||
setContentView(binding.root)
|
||||
val fileSize = gocryptfsVolume.getSize(filePath)
|
||||
loadWholeFile(filePath, fileSize)?.let {
|
||||
binding.pdfViewer.loadPdf(ByteArrayInputStream(it), fileName, fileSize)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
||||
binding.pdfViewer.onCreateOptionMenu(menu)
|
||||
return super.onCreateOptionsMenu(menu)
|
||||
}
|
||||
|
||||
override fun onPrepareOptionsMenu(menu: Menu?): Boolean {
|
||||
return binding.pdfViewer.onPrepareOptionsMenu(menu)
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
return binding.pdfViewer.onOptionsItemSelected(item) || super.onOptionsItemSelected(item)
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<include android:id="@+id/toolbar" layout="@layout/toolbar"/>
|
||||
|
||||
<org.grapheneos.pdfviewer.PdfViewer
|
||||
android:id="@+id/pdf_viewer"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="match_parent"/>
|
||||
|
||||
</LinearLayout>
|
@ -0,0 +1 @@
|
||||
Subproject commit 4e4b7c5da4dddbc3841abd450fa250936be70f4e
|
@ -1,2 +1,2 @@
|
||||
include ':app'
|
||||
include ':app', ':libpdfviewer:app'
|
||||
rootProject.name = "DroidFS"
|
Loading…
Reference in new issue