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
41888b0d
Commit
41888b0d
authored
Sep 26, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
876ba615
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
84 additions
and
29 deletions
+84
-29
DocumentFragment.kt
...om/base/pdfviewerscannerwhite/ui/main/DocumentFragment.kt
+3
-5
DialogView.kt
...java/com/base/pdfviewerscannerwhite/ui/view/DialogView.kt
+51
-20
IntentShareUtils.kt
.../com/base/pdfviewerscannerwhite/utils/IntentShareUtils.kt
+26
-0
dialog_document_home_more.xml
app/src/main/res/layout/dialog_document_home_more.xml
+4
-4
No files found.
app/src/main/java/com/base/pdfviewerscannerwhite/ui/main/DocumentFragment.kt
View file @
41888b0d
...
...
@@ -17,6 +17,7 @@ import com.base.pdfviewerscannerwhite.ui.document.pdf.PdfActivity
import
com.base.pdfviewerscannerwhite.ui.document.pdf.PdfSplitActivity
import
com.base.pdfviewerscannerwhite.ui.document.ppt.PptActivity
import
com.base.pdfviewerscannerwhite.ui.document.word.WordActivity
import
com.base.pdfviewerscannerwhite.ui.view.DialogView.showDocumentHomeMoreDialog
import
com.base.pdfviewerscannerwhite.ui.view.DialogView.showDocumentRenameDialog
import
com.base.pdfviewerscannerwhite.ui.view.DialogView.showPdfHomeMoreDialog
import
com.base.pdfviewerscannerwhite.ui.view.DialogView.showPdfPwdDialog
...
...
@@ -78,14 +79,11 @@ class DocumentFragment() : BaseFragment<FragmentDocumentBinding>(), DocumentView
}
}
if
(
type
==
TYPE_WORD
)
{
// startActivity(Intent(requireContext(), WordActivity::class.java).apply {
// putExtra("path", item.path)
// })
WordActivity
.
wordDocumentBean
=
item
WordActivity
.
launchDocViewer
(
requireActivity
(),
3
,
item
.
path
,
-
1
,
100
)
}
if
(
type
==
TYPE_EXCEL
)
{
ExcelActivity
.
excelDocumentBean
=
item
ExcelActivity
.
excelDocumentBean
=
item
ExcelActivity
.
launchDocViewer
(
requireActivity
(),
3
,
item
.
path
,
-
1
,
100
)
}
if
(
type
==
TYPE_PPT
)
{
...
...
@@ -98,7 +96,7 @@ class DocumentFragment() : BaseFragment<FragmentDocumentBinding>(), DocumentView
requireContext
().
showPdfHomeMoreDialog
(
this
,
item
,
adapter
,
dismissAction
=
{
firstDialog
=
null
})
}
if
(
item
.
type
==
TYPE_WORD
||
item
.
type
==
TYPE_EXCEL
||
item
.
type
==
TYPE_PPT
)
{
// requireContext().showDocumentDetail(
)
firstDialog
=
requireContext
().
showDocumentHomeMoreDialog
(
item
,
this
)
}
}
binding
.
rv
.
adapter
=
adapter
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/ui/view/DialogView.kt
View file @
41888b0d
...
...
@@ -31,6 +31,7 @@ import com.base.pdfviewerscannerwhite.ui.document.pdf.PdfBoxUtils
import
com.base.pdfviewerscannerwhite.ui.main.DocumentView
import
com.base.pdfviewerscannerwhite.ui.document.pdf.PdfView
import
com.base.pdfviewerscannerwhite.utils.ActivityLauncher
import
com.base.pdfviewerscannerwhite.utils.IntentShareUtils.documentShare
import
com.base.pdfviewerscannerwhite.utils.IntentShareUtils.shareExcelIntent
import
com.base.pdfviewerscannerwhite.utils.IntentShareUtils.sharePdfIntent
import
com.base.pdfviewerscannerwhite.utils.IntentShareUtils.sharePdfPrintIntent
...
...
@@ -40,6 +41,7 @@ import com.base.pdfviewerscannerwhite.utils.KotlinExt.toFormatSize
import
com.base.pdfviewerscannerwhite.utils.KotlinExt.toFormatTime
import
com.base.pdfviewerscannerwhite.utils.KotlinExt.toFormatTime2
import
com.base.pdfviewerscannerwhite.utils.KotlinExt.toFormatTime3
import
com.base.pdfviewerscannerwhite.utils.KotlinExt.toFormatTime4
import
com.base.pdfviewerscannerwhite.utils.LogEx
import
com.base.pdfviewerscannerwhite.utils.PermissionUtils.requestStoragePermission
import
com.base.pdfviewerscannerwhite.utils.SpStringUtils
...
...
@@ -111,7 +113,8 @@ object DialogView {
}
fun
Context
.
showDocumentHomeMoreDialog
()
{
@SuppressLint
(
"SetTextI18n"
)
fun
Context
.
showDocumentHomeMoreDialog
(
item
:
DocumentBean
,
documentView
:
DocumentView
):
BottomSheetDialog
{
val
dialog
=
BottomSheetDialog
(
this
,
R
.
style
.
BottomSheetDialog
)
val
binding
=
DialogDocumentHomeMoreBinding
.
inflate
(
LayoutInflater
.
from
(
this
))
dialog
.
setContentView
(
binding
.
root
)
...
...
@@ -124,6 +127,46 @@ object DialogView {
//展开
behavior
.
state
=
BottomSheetBehavior
.
STATE_EXPANDED
val
file
=
File
(
item
.
path
)
binding
.
tvName
.
text
=
file
.
name
binding
.
tvInfo
.
text
=
file
.
lastModified
().
toFormatTime4
()
+
" "
+
file
.
length
().
toFormatSize
()
if
(
item
.
isBookmarked
)
{
binding
.
ivBookmark
.
setImageResource
(
R
.
mipmap
.
h_soucang_s
)
}
else
{
binding
.
ivBookmark
.
setImageResource
(
R
.
mipmap
.
h_soucang_n
)
}
when
(
item
.
type
)
{
TYPE_WORD
->
{
binding
.
ivDocument
.
setImageResource
(
R
.
mipmap
.
h_wordfiocn
)
}
TYPE_EXCEL
->
{
binding
.
ivDocument
.
setImageResource
(
R
.
mipmap
.
h_exceliocn
)
}
TYPE_PPT
->
{
binding
.
ivDocument
.
setImageResource
(
R
.
mipmap
.
h_pptfiocn
)
}
}
binding
.
llRename
.
setOnClickListener
{
documentView
.
dialogRename
(
item
)
}
binding
.
llDetail
.
setOnClickListener
{
showDocumentDetail
(
item
.
path
)
}
binding
.
llShare
.
setOnClickListener
{
documentShare
(
item
)
}
binding
.
llDelete
.
setOnClickListener
{
dialog
.
dismiss
()
showDeleteDialog
{
runCatching
{
File
(
item
.
path
).
delete
()
}
documentView
.
deleteDocument
(
item
)
}
}
return
dialog
}
...
...
@@ -294,24 +337,7 @@ object DialogView {
showDocumentDetail
(
documentBean
.
path
)
}
binding
.
llShare
.
setOnClickListener
{
val
uri
=
FileProvider
.
getUriForFile
(
this
,
this
.
packageName
+
".provider"
,
File
(
documentBean
.
path
)
)
var
intent
:
Intent
?
=
null
var
desc
=
"Share PDF"
if
(
documentBean
.
type
==
TYPE_PPT
)
{
intent
=
sharePptIntent
(
uri
)
desc
=
"Share PPT"
}
if
(
documentBean
.
type
==
TYPE_WORD
)
{
intent
=
shareWordIntent
(
uri
)
desc
=
"Share Word"
}
if
(
documentBean
.
type
==
TYPE_EXCEL
)
{
intent
=
shareExcelIntent
(
uri
)
desc
=
"Share Excel"
}
intent
?.
let
{
startActivity
(
Intent
.
createChooser
(
it
,
desc
))
}
documentShare
(
documentBean
)
}
binding
.
llJump
.
setOnClickListener
{
showJumpPageNumberDialog
(
pageNumber
)
{
pageIndex
->
...
...
@@ -322,7 +348,6 @@ object DialogView {
}
@SuppressLint
(
"SetTextI18n"
)
fun
Context
.
showPdfPwdDialog
(
state
:
Int
,
...
...
@@ -464,6 +489,12 @@ object DialogView {
val
tempName
=
"Split_"
+
System
.
currentTimeMillis
().
toFormatTime2
()
binding
.
edit
.
setText
(
name
?:
tempName
)
if
(
name
==
null
)
{
binding
.
edit
.
selectAll
()
}
else
{
val
nameS
=
name
.
split
(
"."
)[
0
]
binding
.
edit
.
setSelection
(
0
,
nameS
.
length
)
}
binding
.
edit
.
requestFocus
()
binding
.
tvCancel
.
setOnClickListener
{
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/utils/IntentShareUtils.kt
View file @
41888b0d
package
com.base.pdfviewerscannerwhite.utils
import
android.content.Context
import
android.content.Intent
import
android.net.Uri
import
androidx.core.content.FileProvider
import
com.base.pdfviewerscannerwhite.bean.DocumentBean
import
com.base.pdfviewerscannerwhite.ui.view.DialogView.showDocumentMore
import
java.io.File
object
IntentShareUtils
{
fun
Context
.
documentShare
(
documentBean
:
DocumentBean
)
{
val
uri
=
FileProvider
.
getUriForFile
(
this
,
this
.
packageName
+
".provider"
,
File
(
documentBean
.
path
)
)
var
intent
:
Intent
?
=
null
var
desc
=
"Share PDF"
if
(
documentBean
.
type
==
DocumentBean
.
TYPE_PPT
)
{
intent
=
sharePptIntent
(
uri
)
desc
=
"Share PPT"
}
if
(
documentBean
.
type
==
DocumentBean
.
TYPE_WORD
)
{
intent
=
shareWordIntent
(
uri
)
desc
=
"Share Word"
}
if
(
documentBean
.
type
==
DocumentBean
.
TYPE_EXCEL
)
{
intent
=
shareExcelIntent
(
uri
)
desc
=
"Share Excel"
}
intent
?.
let
{
startActivity
(
Intent
.
createChooser
(
it
,
desc
))
}
}
fun
sharePdfIntent
(
uri
:
Uri
):
Intent
{
val
shareIntent
=
Intent
().
apply
{
action
=
Intent
.
ACTION_SEND
...
...
app/src/main/res/layout/dialog_document_home_more.xml
View file @
41888b0d
...
...
@@ -15,7 +15,7 @@
app:layout_constraintTop_toTopOf=
"parent"
>
<ImageView
android:id=
"@+id/iv_
pdf
"
android:id=
"@+id/iv_
document
"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"16dp"
...
...
@@ -31,10 +31,10 @@
android:layout_height=
"wrap_content"
android:layout_marginHorizontal=
"16dp"
android:orientation=
"vertical"
app:layout_constraintBottom_toBottomOf=
"@id/iv_
pdf
"
app:layout_constraintBottom_toBottomOf=
"@id/iv_
document
"
app:layout_constraintEnd_toStartOf=
"@id/iv_bookmark"
app:layout_constraintStart_toEndOf=
"@id/iv_
pdf
"
app:layout_constraintTop_toTopOf=
"@id/iv_
pdf
"
>
app:layout_constraintStart_toEndOf=
"@id/iv_
document
"
app:layout_constraintTop_toTopOf=
"@id/iv_
document
"
>
<TextView
android:id=
"@+id/tv_name"
...
...
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