Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
P
PDF Viewer Scanner White
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wanglei
PDF Viewer Scanner White
Commits
9105d9c3
Commit
9105d9c3
authored
Sep 26, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
1eb1f4cd
Hide whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
225 additions
and
68 deletions
+225
-68
DEMO.docx
app/src/main/assets/DEMO.docx
+0
-0
DEMO.pdf
app/src/main/assets/DEMO.pdf
+0
-0
DEMO.pptx
app/src/main/assets/DEMO.pptx
+0
-0
DEMO.xlsx
app/src/main/assets/DEMO.xlsx
+0
-0
DocumentBean.kt
.../java/com/base/pdfviewerscannerwhite/bean/DocumentBean.kt
+3
-3
DocumentAdapter.kt
.../base/pdfviewerscannerwhite/ui/adapter/DocumentAdapter.kt
+4
-2
ExcelActivity.kt
.../pdfviewerscannerwhite/ui/document/excel/ExcelActivity.kt
+2
-6
PdfActivity.kt
...base/pdfviewerscannerwhite/ui/document/pdf/PdfActivity.kt
+2
-0
PptActivity.kt
...base/pdfviewerscannerwhite/ui/document/ppt/PptActivity.kt
+16
-8
WordActivity.kt
...se/pdfviewerscannerwhite/ui/document/word/WordActivity.kt
+4
-1
DocumentFragment.kt
...om/base/pdfviewerscannerwhite/ui/main/DocumentFragment.kt
+7
-3
DocumentPresenter.kt
...m/base/pdfviewerscannerwhite/ui/main/DocumentPresenter.kt
+19
-2
MainActivity.kt
...va/com/base/pdfviewerscannerwhite/ui/main/MainActivity.kt
+0
-1
DialogView.kt
...java/com/base/pdfviewerscannerwhite/ui/view/DialogView.kt
+41
-2
AssetUtils.kt
...n/java/com/base/pdfviewerscannerwhite/utils/AssetUtils.kt
+109
-0
IntentShareUtils.kt
.../com/base/pdfviewerscannerwhite/utils/IntentShareUtils.kt
+10
-0
activity_ppt.xml
app/src/main/res/layout/activity_ppt.xml
+1
-30
file_paths.xml
app/src/main/res/xml/file_paths.xml
+3
-1
IOffice.java
library/src/main/java/com/cherry/lib/doc/office/IOffice.java
+0
-1
PGControl.java
.../java/com/cherry/lib/doc/office/pg/control/PGControl.java
+1
-1
PGPageListItem.java
.../com/cherry/lib/doc/office/pg/control/PGPageListItem.java
+0
-2
PGPrintMode.java
...ava/com/cherry/lib/doc/office/pg/control/PGPrintMode.java
+1
-2
Presentation.java
...va/com/cherry/lib/doc/office/pg/control/Presentation.java
+1
-1
APageListAdapter.java
...ib/doc/office/system/beans/pagelist/APageListAdapter.java
+0
-1
APageListView.java
...y/lib/doc/office/system/beans/pagelist/APageListView.java
+1
-1
No files found.
app/src/main/assets/DEMO.docx
0 → 100644
View file @
9105d9c3
File added
app/src/main/assets/DEMO.pdf
0 → 100644
View file @
9105d9c3
File added
app/src/main/assets/DEMO.pptx
0 → 100644
View file @
9105d9c3
File added
app/src/main/assets/DEMO.xlsx
0 → 100644
View file @
9105d9c3
File added
app/src/main/java/com/base/pdfviewerscannerwhite/bean/DocumentBean.kt
View file @
9105d9c3
...
...
@@ -3,10 +3,10 @@ package com.base.pdfviewerscannerwhite.bean
import
android.net.Uri
data class
DocumentBean
(
va
l
path
:
String
=
""
,
va
r
path
:
String
=
""
,
var
uri
:
Uri
=
Uri
.
EMPTY
,
va
l
type
:
String
=
""
,
var
isBookmarked
:
Boolean
=
false
va
r
type
:
String
=
""
,
var
isBookmarked
:
Boolean
=
false
,
)
{
var
uiType
:
Int
=
0
//0首页模式 1合并选择模式 2拆分模式 3解锁加锁模式
var
isSelect
:
Boolean
=
false
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/ui/adapter/DocumentAdapter.kt
View file @
9105d9c3
...
...
@@ -74,8 +74,10 @@ class DocumentAdapter : BaseQuickAdapter<DocumentBean, DocumentAdapter.DocumentV
}
val
file
=
File
(
item
.
path
)
binding
.
tvName
.
text
=
file
.
name
binding
.
tvInfo
.
text
=
file
.
lastModified
().
toFormatTime
()
+
" "
+
file
.
length
().
toFormatSize
()
runCatching
{
binding
.
tvName
.
text
=
file
.
name
binding
.
tvInfo
.
text
=
file
.
lastModified
().
toFormatTime
()
+
" "
+
file
.
length
().
toFormatSize
()
}
when
(
item
.
uiType
)
{
0
->
{
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/ui/document/excel/ExcelActivity.kt
View file @
9105d9c3
...
...
@@ -8,19 +8,14 @@ import android.view.View
import
android.view.animation.Animation
import
android.view.animation.TranslateAnimation
import
androidx.activity.addCallback
import
androidx.lifecycle.lifecycleScope
import
com.base.pdfviewerscannerwhite.bean.DocumentBean
import
com.base.pdfviewerscannerwhite.databinding.ActivityExcelBinding
import
com.base.pdfviewerscannerwhite.helper.BaseActivity
import
com.base.pdfviewerscannerwhite.ui.view.DialogView.showDocumentMore
import
com.base.pdfviewerscannerwhite.utils.KeyBoardUtils.hideKeyboard
import
com.base.pdfviewerscannerwhite.utils.LogEx
import
com.base.pdfviewerscannerwhite.utils.ToastUtils.toast
import
com.cherry.lib.doc.bean.DocEngine
import
com.cherry.lib.doc.office.ss.control.SSControl
import
com.cherry.lib.doc.util.Constant
import
kotlinx.coroutines.delay
import
kotlinx.coroutines.launch
import
java.io.File
class
ExcelActivity
:
BaseActivity
<
ActivityExcelBinding
>()
{
...
...
@@ -32,6 +27,7 @@ class ExcelActivity : BaseActivity<ActivityExcelBinding>() {
}
companion
object
{
var
excelDocumentBean
:
DocumentBean
=
DocumentBean
()
fun
launchDocViewer
(
activity
:
Activity
,
docSourceType
:
Int
,
...
...
@@ -70,7 +66,7 @@ class ExcelActivity : BaseActivity<ActivityExcelBinding>() {
switchOrientation
()
}
binding
.
ivMore
.
setOnClickListener
{
showDocumentMore
(
DocumentBean
.
TYPE_EXCEL
)
showDocumentMore
(
excelDocumentBean
)
}
binding
.
mDocView
.
singleTapAction
=
{
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/ui/document/pdf/PdfActivity.kt
View file @
9105d9c3
...
...
@@ -50,6 +50,7 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>(), PdfView {
private
var
saveMode
=
""
private
var
path
:
String
=
""
private
var
uri
:
String
?
=
null
private
var
assets
:
String
?
=
null
private
var
density
=
0f
override
val
binding
:
ActivityPdfBinding
by
lazy
{
...
...
@@ -64,6 +65,7 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>(), PdfView {
path
=
intent
.
extras
?.
getString
(
"path"
)
?:
""
uri
=
intent
.
extras
?.
getString
(
"uri"
)
assets
=
intent
.
extras
?.
getString
(
"assets"
)
?:
""
LogEx
.
logDebug
(
TAG
,
"path=$path"
)
LogEx
.
logDebug
(
TAG
,
"uri=$uri"
)
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/ui/document/ppt/PptActivity.kt
View file @
9105d9c3
...
...
@@ -9,13 +9,14 @@ import android.view.animation.Animation
import
android.view.animation.TranslateAnimation
import
androidx.activity.addCallback
import
androidx.core.view.isVisible
import
com.base.pdfviewerscannerwhite.bean.DocumentBean
.Companion.TYPE_PPT
import
com.base.pdfviewerscannerwhite.bean.DocumentBean
import
com.base.pdfviewerscannerwhite.databinding.ActivityPptBinding
import
com.base.pdfviewerscannerwhite.helper.BaseActivity
import
com.base.pdfviewerscannerwhite.ui.view.DialogView.showDocumentMore
import
com.base.pdfviewerscannerwhite.utils.KeyBoardUtils.hideKeyboard
import
com.base.pdfviewerscannerwhite.utils.LogEx
import
com.cherry.lib.doc.bean.DocEngine
import
com.cherry.lib.doc.office.pg.control.PGControl
import
com.cherry.lib.doc.office.system.beans.pagelist.APageListAdapter
import
com.cherry.lib.doc.util.Constant
class
PptActivity
:
BaseActivity
<
ActivityPptBinding
>()
{
...
...
@@ -27,6 +28,8 @@ class PptActivity : BaseActivity<ActivityPptBinding>() {
}
companion
object
{
var
pptDocumentBean
:
DocumentBean
=
DocumentBean
()
fun
launchDocViewer
(
activity
:
Activity
,
docSourceType
:
Int
,
...
...
@@ -44,6 +47,8 @@ class PptActivity : BaseActivity<ActivityPptBinding>() {
}
private
var
totalPageNumber
=
0
@SuppressLint
(
"SetTextI18n"
)
override
fun
initView
()
{
initSpData
(
intent
)
...
...
@@ -51,6 +56,7 @@ class PptActivity : BaseActivity<ActivityPptBinding>() {
if
(!
binding
.
tvPageCount
.
isVisible
)
{
binding
.
tvPageCount
.
isVisible
=
true
}
totalPageNumber
=
total
binding
.
tvPageCount
.
text
=
"$current/$total"
}
binding
.
mDocView
.
singleTapAction
=
{
...
...
@@ -77,7 +83,10 @@ class PptActivity : BaseActivity<ActivityPptBinding>() {
switchOrientation
()
}
binding
.
ivMore
.
setOnClickListener
{
showDocumentMore
(
TYPE_PPT
)
showDocumentMore
(
pptDocumentBean
,
totalPageNumber
-
1
)
{
pageIndex
->
((
binding
.
mDocView
.
iOffice
?.
control
?.
appControl
as
PGControl
)
.
pgView
.
pgPrintMode
.
listView
.
showPDFPageForIndex
(
pageIndex
))
}
}
}
...
...
@@ -92,15 +101,15 @@ class PptActivity : BaseActivity<ActivityPptBinding>() {
private
var
docSourceType
=
0
private
var
fileType
=
-
1
private
var
engine
:
Int
=
DocEngine
.
INTERNAL
.
value
private
var
docUrl
:
String
?
=
null
// 文件地址
private
var
pathOrUri
:
String
?
=
null
// 文件地址
private
fun
initSpData
(
intent
:
Intent
?)
{
docUrl
=
intent
?.
getStringExtra
(
Constant
.
INTENT_DATA_KEY
)
pathOrUri
=
intent
?.
getStringExtra
(
Constant
.
INTENT_DATA_KEY
)
docSourceType
=
intent
?.
getIntExtra
(
Constant
.
INTENT_SOURCE_KEY
,
0
)
?:
0
fileType
=
intent
?.
getIntExtra
(
Constant
.
INTENT_TYPE_KEY
,
-
1
)
?:
-
1
engine
=
intent
?.
getIntExtra
(
Constant
.
INTENT_ENGINE_KEY
,
DocEngine
.
INTERNAL
.
value
)
?:
DocEngine
.
INTERNAL
.
value
binding
.
mDocView
.
openDoc
(
this
,
docUrl
,
docSourceType
,
fileType
,
false
,
DocEngine
.
values
().
first
{
it
.
value
==
engine
})
LogEx
.
logDebug
(
TAG
,
"initData-docUrl = $
docUrl
"
)
binding
.
mDocView
.
openDoc
(
this
,
pathOrUri
,
docSourceType
,
fileType
,
false
,
DocEngine
.
values
().
first
{
it
.
value
==
engine
})
LogEx
.
logDebug
(
TAG
,
"initData-docUrl = $
pathOrUri
"
)
LogEx
.
logDebug
(
TAG
,
"initData-docSourceType = $docSourceType"
)
LogEx
.
logDebug
(
TAG
,
"initData-fileType = $fileType"
)
LogEx
.
logDebug
(
TAG
,
"initData-engine = $engine"
)
...
...
@@ -130,7 +139,6 @@ class PptActivity : BaseActivity<ActivityPptBinding>() {
if
(
isShowTopLayout
)
{
isShowTopLayout
=
false
hideKeyboard
(
binding
.
editSearch
)
val
topAnim
:
Animation
=
TranslateAnimation
(
0f
,
0f
,
0f
,
-
binding
.
vAnimatorTop
.
height
.
toFloat
())
topAnim
.
setDuration
(
200
)
topAnim
.
setAnimationListener
(
object
:
Animation
.
AnimationListener
{
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/ui/document/word/WordActivity.kt
View file @
9105d9c3
...
...
@@ -40,7 +40,7 @@ class WordActivity : BaseActivity<ActivityWordBinding>() {
switchOrientation
()
}
binding
.
ivMore
.
setOnClickListener
{
showDocumentMore
(
DocumentBean
.
TYPE_WORD
)
showDocumentMore
(
wordDocumentBean
)
}
mPoiViewer
.
singleTapAction
=
{
...
...
@@ -112,5 +112,8 @@ class WordActivity : BaseActivity<ActivityWordBinding>() {
}
}
companion
object
{
var
wordDocumentBean
:
DocumentBean
=
DocumentBean
()
}
}
\ No newline at end of file
app/src/main/java/com/base/pdfviewerscannerwhite/ui/main/DocumentFragment.kt
View file @
9105d9c3
...
...
@@ -78,14 +78,18 @@ class DocumentFragment() : BaseFragment<FragmentDocumentBinding>(), DocumentView
}
}
if
(
type
==
TYPE_WORD
)
{
startActivity
(
Intent
(
requireContext
(),
WordActivity
::
class
.
java
).
apply
{
putExtra
(
"path"
,
item
.
path
)
})
// startActivity(Intent(requireContext(), WordActivity::class.java).apply {
// putExtra("path", item.path)
// })
WordActivity
.
wordDocumentBean
PptActivity
.
launchDocViewer
(
requireActivity
(),
3
,
item
.
path
,
-
1
,
100
)
}
if
(
type
==
TYPE_EXCEL
)
{
ExcelActivity
.
excelDocumentBean
ExcelActivity
.
launchDocViewer
(
requireActivity
(),
3
,
item
.
path
,
-
1
,
100
)
}
if
(
type
==
TYPE_PPT
)
{
PptActivity
.
pptDocumentBean
=
item
PptActivity
.
launchDocViewer
(
requireActivity
(),
3
,
item
.
path
,
-
1
,
100
)
}
}
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/ui/main/DocumentPresenter.kt
View file @
9105d9c3
...
...
@@ -5,6 +5,11 @@ import androidx.lifecycle.LifecycleCoroutineScope
import
com.base.pdfviewerscannerwhite.bean.ConstObject
import
com.base.pdfviewerscannerwhite.bean.DocumentBean
import
com.base.pdfviewerscannerwhite.ui.document.pdf.PdfBoxUtils
import
com.base.pdfviewerscannerwhite.utils.AssetUtils.getDemoDocx
import
com.base.pdfviewerscannerwhite.utils.AssetUtils.getDemoPdf
import
com.base.pdfviewerscannerwhite.utils.AssetUtils.getDemoPptx
import
com.base.pdfviewerscannerwhite.utils.AssetUtils.getDemoXlsx
import
com.base.pdfviewerscannerwhite.utils.AssetUtils.saveAssetsFile
import
com.base.pdfviewerscannerwhite.utils.SpStringUtils
import
com.base.pdfviewerscannerwhite.utils.getMediaFile
import
kotlinx.coroutines.Dispatchers
...
...
@@ -19,27 +24,39 @@ class DocumentPresenter(
)
{
private
fun
getDocumentBeanList
():
List
<
DocumentBean
>
{
context
.
saveAssetsFile
()
var
selectionArgs
=
arrayOf
(
ConstObject
.
MIME_TYPE_PDF
)
val
demoDocumentBean
=
DocumentBean
()
if
(
type
==
DocumentBean
.
TYPE_PDF
)
{
selectionArgs
=
arrayOf
(
ConstObject
.
MIME_TYPE_PDF
)
demoDocumentBean
.
path
=
context
.
getDemoPdf
()
}
if
(
type
==
DocumentBean
.
TYPE_WORD
)
{
selectionArgs
=
arrayOf
(
ConstObject
.
MIME_TYPE_DOC
,
ConstObject
.
MIME_TYPE_DOCX
)
demoDocumentBean
.
path
=
context
.
getDemoDocx
()
}
if
(
type
==
DocumentBean
.
TYPE_EXCEL
)
{
selectionArgs
=
arrayOf
(
ConstObject
.
MIME_TYPE_XLS
,
ConstObject
.
MIME_TYPE_XLSX
)
demoDocumentBean
.
path
=
context
.
getDemoXlsx
()
}
if
(
type
==
DocumentBean
.
TYPE_PPT
)
{
selectionArgs
=
arrayOf
(
ConstObject
.
MIME_TYPE_PPT
,
ConstObject
.
MIME_TYPE_PPTX
)
demoDocumentBean
.
path
=
context
.
getDemoPptx
()
}
demoDocumentBean
.
type
=
type
val
bookmarkList
=
SpStringUtils
.
getSpStringList
(
SpStringUtils
.
BOOKMARK_KEY
)
val
list
=
context
.
getMediaFile
(
selectionArgs
=
selectionArgs
)
val
documentList
=
list
.
map
{
DocumentBean
(
it
.
path
,
uri
=
it
.
uri
,
type
,
bookmarkList
.
contains
(
it
.
path
))
DocumentBean
(
it
.
path
,
uri
=
it
.
uri
,
type
=
type
,
isBookmarked
=
bookmarkList
.
contains
(
it
.
path
))
}
return
documentList
val
new
=
documentList
.
toMutableList
()
new
.
add
(
0
,
demoDocumentBean
)
return
new
}
fun
initData
()
=
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/ui/main/MainActivity.kt
View file @
9105d9c3
...
...
@@ -5,7 +5,6 @@ import android.net.Uri
import
android.view.View
import
androidx.activity.OnBackPressedCallback
import
androidx.core.content.ContextCompat
import
androidx.core.view.isVisible
import
androidx.fragment.app.Fragment
import
androidx.viewpager2.adapter.FragmentStateAdapter
import
androidx.viewpager2.widget.ViewPager2
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/ui/view/DialogView.kt
View file @
9105d9c3
...
...
@@ -31,6 +31,7 @@ import com.base.pdfviewerscannerwhite.ui.view.DialogView.showPdfMoreDialog
import
com.base.pdfviewerscannerwhite.utils.ActivityLauncher
import
com.base.pdfviewerscannerwhite.utils.IntentShareUtils.sharePdfIntent
import
com.base.pdfviewerscannerwhite.utils.IntentShareUtils.sharePdfPrintIntent
import
com.base.pdfviewerscannerwhite.utils.IntentShareUtils.sharePptIntent
import
com.base.pdfviewerscannerwhite.utils.KotlinExt.toFormatSize
import
com.base.pdfviewerscannerwhite.utils.KotlinExt.toFormatTime
import
com.base.pdfviewerscannerwhite.utils.KotlinExt.toFormatTime2
...
...
@@ -231,7 +232,11 @@ object DialogView {
}
fun
Activity
.
showDocumentMore
(
type
:
String
)
{
fun
Activity
.
showDocumentMore
(
documentBean
:
DocumentBean
,
pageNumber
:
Int
=
0
,
jumpAction
:
((
pageIndex
:
Int
)
->
Unit
)?
=
null
)
{
val
dialog
=
BottomSheetDialog
(
this
,
R
.
style
.
BottomSheetDialog
)
val
binding
=
DialogDocumentMoreBinding
.
inflate
(
LayoutInflater
.
from
(
this
))
dialog
.
setContentView
(
binding
.
root
)
...
...
@@ -244,9 +249,43 @@ object DialogView {
//展开
behavior
.
state
=
BottomSheetBehavior
.
STATE_EXPANDED
if
(
type
==
TYPE_EXCEL
)
{
if
(
documentBean
.
type
==
TYPE_EXCEL
)
{
binding
.
llJump
.
visibility
=
View
.
GONE
}
if
(
documentBean
.
isBookmarked
)
{
binding
.
ivBookmark
.
setImageResource
(
R
.
mipmap
.
h_soucang_s
)
}
else
{
binding
.
ivBookmark
.
setImageResource
(
R
.
mipmap
.
h_soucang_n
)
}
binding
.
ivBookmark
.
setOnClickListener
{
binding
.
ivBookmark
.
isSelected
=
!
binding
.
ivBookmark
.
isSelected
if
(
binding
.
ivBookmark
.
isSelected
)
{
binding
.
ivBookmark
.
setImageResource
(
R
.
mipmap
.
h_soucang_s
)
SpStringUtils
.
addSpString
(
SpStringUtils
.
BOOKMARK_KEY
,
documentBean
.
path
)
}
else
{
binding
.
ivBookmark
.
setImageResource
(
R
.
mipmap
.
h_soucang_n
)
SpStringUtils
.
deleteSpString
(
SpStringUtils
.
BOOKMARK_KEY
,
documentBean
.
path
)
}
}
binding
.
llDetail
.
setOnClickListener
{
showDocumentDetail
(
documentBean
.
path
)
}
binding
.
llShare
.
setOnClickListener
{
val
uri
=
FileProvider
.
getUriForFile
(
this
,
this
.
packageName
+
".provider"
,
File
(
documentBean
.
path
)
)
startActivity
(
Intent
.
createChooser
(
sharePptIntent
(
uri
),
"Share PDF"
))
}
binding
.
llJump
.
setOnClickListener
{
showJumpPageNumberDialog
(
pageNumber
)
{
pageIndex
->
dialog
.
dismiss
()
jumpAction
?.
invoke
(
pageIndex
)
}
}
}
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/utils/AssetUtils.kt
0 → 100644
View file @
9105d9c3
package
com.base.pdfviewerscannerwhite.utils
import
android.content.Context
import
android.content.res.AssetManager
import
java.io.BufferedReader
import
java.io.ByteArrayOutputStream
import
java.io.File
import
java.io.FileOutputStream
import
java.io.IOException
import
java.io.InputStream
import
java.io.InputStreamReader
object
AssetUtils
{
fun
Context
.
readByteArrayFromAsset
(
fileName
:
String
):
ByteArray
{
val
assetManager
:
AssetManager
=
this
.
assets
var
ins
:
InputStream
?
=
null
val
byteStream
=
ByteArrayOutputStream
()
try
{
ins
=
assetManager
.
open
(
fileName
)
var
nextValue
:
Int
while
(
ins
.
read
().
also
{
nextValue
=
it
}
!=
-
1
)
{
byteStream
.
write
(
nextValue
)
}
}
catch
(
e
:
IOException
)
{
e
.
printStackTrace
()
}
finally
{
try
{
ins
?.
close
()
byteStream
.
close
()
}
catch
(
e
:
IOException
)
{
e
.
printStackTrace
()
}
}
return
byteStream
.
toByteArray
()
}
fun
Context
.
getDemoPdf
():
String
{
val
demoFile
=
File
(
filesDir
,
"demo"
)
demoFile
.
mkdirs
()
val
file
=
File
(
demoFile
,
"DEMO.pdf"
)
return
file
.
absolutePath
}
fun
Context
.
getDemoDocx
():
String
{
val
demoFile
=
File
(
filesDir
,
"demo"
)
demoFile
.
mkdirs
()
val
file
=
File
(
demoFile
,
"DEMO.docx"
)
return
file
.
absolutePath
}
fun
Context
.
getDemoXlsx
():
String
{
val
demoFile
=
File
(
filesDir
,
"demo"
)
demoFile
.
mkdirs
()
val
file
=
File
(
demoFile
,
"DEMO.xlsx"
)
return
file
.
absolutePath
}
fun
Context
.
getDemoPptx
():
String
{
val
demoFile
=
File
(
filesDir
,
"demo"
)
demoFile
.
mkdirs
()
val
file
=
File
(
demoFile
,
"DEMO.pptx"
)
return
file
.
absolutePath
}
fun
Context
.
saveAssetsFile
()
{
val
demoFile
=
File
(
filesDir
,
"demo"
)
demoFile
.
mkdirs
()
arrayOf
(
"DEMO.pdf,DEMO.docx"
,
"DEMO.xlsx"
,
"DEMO.pptx"
).
forEach
{
val
file
=
File
(
demoFile
,
it
)
if
(
file
.
exists
()
&&
file
.
length
()
!=
0L
)
{
return
}
file
.
createNewFile
()
try
{
FileOutputStream
(
file
).
use
{
fos
->
fos
.
write
(
readByteArrayFromAsset
(
it
))
}
}
catch
(
e
:
IOException
)
{
e
.
printStackTrace
()
}
}
}
fun
Context
.
readJsonFromAsset
(
fileName
:
String
):
String
{
var
json
=
""
try
{
val
assetManager
=
this
.
assets
val
inputStream
=
assetManager
.
open
(
fileName
)
val
reader
=
BufferedReader
(
InputStreamReader
(
inputStream
))
var
line
:
String
?
val
jsonString
=
StringBuilder
()
while
(
reader
.
readLine
().
also
{
line
=
it
}
!=
null
)
{
jsonString
.
append
(
line
)
}
reader
.
close
()
inputStream
.
close
()
json
=
jsonString
.
toString
()
}
catch
(
e
:
IOException
)
{
e
.
printStackTrace
()
}
return
json
}
}
\ No newline at end of file
app/src/main/java/com/base/pdfviewerscannerwhite/utils/IntentShareUtils.kt
View file @
9105d9c3
...
...
@@ -15,6 +15,16 @@ object IntentShareUtils {
return
shareIntent
}
fun
sharePptIntent
(
uri
:
Uri
):
Intent
{
val
shareIntent
=
Intent
().
apply
{
action
=
Intent
.
ACTION_SEND
putExtra
(
Intent
.
EXTRA_STREAM
,
uri
)
type
=
"application/vnd.ms-powerpoint"
addFlags
(
Intent
.
FLAG_GRANT_READ_URI_PERMISSION
)
// 授权临时权限
}
return
shareIntent
}
fun
sharePdfPrintIntent
(
uri
:
Uri
):
Intent
{
// 创建打印的 Intent
val
intent
=
Intent
(
Intent
.
ACTION_SEND
)
...
...
app/src/main/res/layout/activity_ppt.xml
View file @
9105d9c3
...
...
@@ -61,22 +61,10 @@
android:layout_marginEnd=
"16dp"
android:src=
"@mipmap/hengping"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toStartOf=
"@id/iv_search"
app:layout_constraintTop_toTopOf=
"parent"
tools:ignore=
"ContentDescription"
/>
<ImageView
android:id=
"@+id/iv_search"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"16dp"
android:src=
"@mipmap/h_sousuo"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toStartOf=
"@id/iv_more"
app:layout_constraintTop_toTopOf=
"parent"
tools:ignore=
"ContentDescription"
/>
<ImageView
android:id=
"@+id/iv_more"
android:layout_width=
"wrap_content"
...
...
@@ -88,24 +76,7 @@
app:layout_constraintTop_toTopOf=
"parent"
tools:ignore=
"ContentDescription"
/>
<EditText
android:id=
"@+id/edit_search"
android:layout_width=
"0dp"
android:layout_height=
"40dp"
android:layout_marginStart=
"5dp"
android:layout_marginEnd=
"20dp"
android:background=
"@drawable/bg_f8f9fe_10"
android:hint=
"input..."
android:paddingHorizontal=
"18dp"
android:singleLine=
"true"
android:textColor=
"@color/black"
android:textColorHint=
"#B8B9BD"
android:visibility=
"gone"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toStartOf=
"@id/iv_search"
app:layout_constraintStart_toEndOf=
"@id/fl_fanhui"
app:layout_constraintTop_toTopOf=
"parent"
tools:ignore=
"Autofill,HardcodedText,TextFields"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
...
...
app/src/main/res/xml/file_paths.xml
View file @
9105d9c3
...
...
@@ -6,5 +6,7 @@
<external-path
name=
"extern_files"
path=
"."
/>
<files-path
name=
"files"
path=
"."
/>
</paths>
library/src/main/java/com/cherry/lib/doc/office/IOffice.java
View file @
9105d9c3
...
...
@@ -317,7 +317,6 @@ public abstract class IOffice implements IMainFrame {
@Override
public
boolean
isChangePage
()
{
// TODO Auto-generated method stub
return
true
;
}
...
...
library/src/main/java/com/cherry/lib/doc/office/pg/control/PGControl.java
View file @
9105d9c3
...
...
@@ -544,7 +544,7 @@ public class PGControl extends AbstractControl {
//
private
boolean
isDispose
;
//
p
rivate
Presentation
pgView
;
p
ublic
Presentation
pgView
;
//
private
IControl
mainControl
;
//
...
...
library/src/main/java/com/cherry/lib/doc/office/pg/control/PGPageListItem.java
View file @
9105d9c3
...
...
@@ -42,8 +42,6 @@ public class PGPageListItem extends APageListItem
private
static
final
int
BACKGROUND_COLOR
=
0xFFFFFFFF
;
/**
*
* @param content
* @param parentSize
*/
public
PGPageListItem
(
APageListView
listView
,
IControl
control
,
PGEditor
editor
,
int
pageWidth
,
int
pageHeight
)
{
...
...
library/src/main/java/com/cherry/lib/doc/office/pg/control/PGPrintMode.java
View file @
9105d9c3
...
...
@@ -29,7 +29,6 @@ import com.cherry.lib.doc.office.system.SysKit;
import
com.cherry.lib.doc.office.system.beans.pagelist.APageListItem
;
import
com.cherry.lib.doc.office.system.beans.pagelist.APageListView
;
import
com.cherry.lib.doc.office.system.beans.pagelist.IPageListViewListener
;
import
android.content.Context
;
import
android.graphics.Bitmap
;
import
android.graphics.Canvas
;
...
...
@@ -627,7 +626,7 @@ public class PGPrintMode extends FrameLayout implements IPageListViewListener {
//
private
IControl
control
;
//
p
rivate
APageListView
listView
;
p
ublic
APageListView
listView
;
// 绘制器
private
Paint
paint
;
//
...
...
library/src/main/java/com/cherry/lib/doc/office/pg/control/Presentation.java
View file @
9105d9c3
...
...
@@ -1057,6 +1057,6 @@ public class Presentation extends FrameLayout implements IFind, IExportListener
/**
*
*/
p
rivate
PGPrintMode
pgPrintMode
;
p
ublic
PGPrintMode
pgPrintMode
;
private
CalloutView
callouts
;
}
library/src/main/java/com/cherry/lib/doc/office/system/beans/pagelist/APageListAdapter.java
View file @
9105d9c3
...
...
@@ -32,7 +32,6 @@ public class APageListAdapter extends BaseAdapter
/**
* construct
*
* @param pdfListView
*/
public
APageListAdapter
(
APageListView
view
)
{
...
...
library/src/main/java/com/cherry/lib/doc/office/system/beans/pagelist/APageListView.java
View file @
9105d9c3
...
...
@@ -1025,7 +1025,7 @@ public class APageListView extends AdapterView<Adapter> {
//
private
IPageListViewListener
pageListViewListener
;
//
p
rivate
Adapter
pageAdapter
;
p
ublic
Adapter
pageAdapter
;
//
private
APageListEventManage
eventManage
;
//
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment