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
3521ff36
Commit
3521ff36
authored
Sep 27, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
8241b53d
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
337 additions
and
99 deletions
+337
-99
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+1
-1
DocumentBean.kt
.../java/com/base/pdfviewerscannerwhite/bean/DocumentBean.kt
+1
-1
DocumentAdapter.kt
.../base/pdfviewerscannerwhite/ui/adapter/DocumentAdapter.kt
+11
-1
DocumentFragment.kt
...om/base/pdfviewerscannerwhite/ui/main/DocumentFragment.kt
+68
-38
MainActivity.kt
...va/com/base/pdfviewerscannerwhite/ui/main/MainActivity.kt
+120
-7
IntentShareUtils.kt
.../com/base/pdfviewerscannerwhite/utils/IntentShareUtils.kt
+31
-0
activity_main.xml
app/src/main/res/layout/activity_main.xml
+105
-51
empty.png
app/src/main/res/mipmap-xxhdpi/empty.png
+0
-0
No files found.
app/src/main/AndroidManifest.xml
View file @
3521ff36
...
@@ -43,7 +43,7 @@
...
@@ -43,7 +43,7 @@
<activity
<activity
android:name=
".ui.main.MainActivity"
android:name=
".ui.main.MainActivity"
android:exported=
"false"
android:exported=
"false"
android:launchMode=
"singleT
op
"
android:launchMode=
"singleT
ask
"
android:screenOrientation=
"portrait"
android:screenOrientation=
"portrait"
tools:ignore=
"DiscouragedApi,LockedOrientationActivity"
/>
tools:ignore=
"DiscouragedApi,LockedOrientationActivity"
/>
<activity
<activity
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/bean/DocumentBean.kt
View file @
3521ff36
...
@@ -8,7 +8,7 @@ data class DocumentBean(
...
@@ -8,7 +8,7 @@ data class DocumentBean(
var
type
:
String
=
""
,
var
type
:
String
=
""
,
var
isBookmarked
:
Boolean
=
false
,
var
isBookmarked
:
Boolean
=
false
,
)
{
)
{
var
uiType
:
Int
=
0
//0首页模式 1合并选择模式 2拆分模式 3解锁加锁模式
var
uiType
:
Int
=
0
//0首页模式 1合并选择模式 2拆分模式 3解锁加锁模式
4搜索模式
var
isSelect
:
Boolean
=
false
var
isSelect
:
Boolean
=
false
var
state
:
Int
=
-
1
//0正常状态 1 锁定
var
state
:
Int
=
-
1
//0正常状态 1 锁定
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/ui/adapter/DocumentAdapter.kt
View file @
3521ff36
...
@@ -141,13 +141,23 @@ class DocumentAdapter : BaseQuickAdapter<DocumentBean, DocumentAdapter.DocumentV
...
@@ -141,13 +141,23 @@ class DocumentAdapter : BaseQuickAdapter<DocumentBean, DocumentAdapter.DocumentV
itemClick
?.
invoke
(
item
)
itemClick
?.
invoke
(
item
)
}
}
}
}
4
->
{
binding
.
flBookmark
.
visibility
=
View
.
GONE
binding
.
flMore
.
setOnClickListener
{
moreAction
?.
invoke
(
item
)
}
binding
.
root
.
setOnClickListener
{
itemClick
?.
invoke
(
item
)
}
}
}
}
}
}
private
fun
checkPwd
(
item
:
DocumentBean
,
iv
:
ImageView
)
{
private
fun
checkPwd
(
item
:
DocumentBean
,
iv
:
ImageView
)
{
threadPoolExecutor
.
execute
{
threadPoolExecutor
.
execute
{
item
.
state
=
PdfBoxUtils
.
checkPdfEncryption
(
item
.
path
)
item
.
state
=
PdfBoxUtils
.
checkPdfEncryption
(
item
.
path
)
LogEx
.
logDebug
(
TAG
,
"${item.state}"
)
LogEx
.
logDebug
(
TAG
,
"
checkPwd
${item.state}"
)
var
res
=
R
.
mipmap
.
h_pdfiocn
var
res
=
R
.
mipmap
.
h_pdfiocn
when
(
item
.
state
)
{
when
(
item
.
state
)
{
0
->
res
=
R
.
mipmap
.
h_pdfiocn
0
->
res
=
R
.
mipmap
.
h_pdfiocn
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/ui/main/DocumentFragment.kt
View file @
3521ff36
package
com.base.pdfviewerscannerwhite.ui.main
package
com.base.pdfviewerscannerwhite.ui.main
import
android.annotation.SuppressLint
import
android.annotation.SuppressLint
import
android.app.Activity
import
android.app.Dialog
import
android.app.Dialog
import
android.content.Context
import
android.content.Intent
import
android.content.Intent
import
androidx.core.content.ContentProviderCompat.requireContext
import
androidx.lifecycle.lifecycleScope
import
androidx.lifecycle.lifecycleScope
import
com.base.pdfviewerscannerwhite.bean.DocumentBean
import
com.base.pdfviewerscannerwhite.bean.DocumentBean
import
com.base.pdfviewerscannerwhite.bean.DocumentBean.Companion.TYPE_EXCEL
import
com.base.pdfviewerscannerwhite.bean.DocumentBean.Companion.TYPE_EXCEL
...
@@ -26,7 +29,7 @@ import java.io.File
...
@@ -26,7 +29,7 @@ import java.io.File
class
DocumentFragment
()
:
BaseFragment
<
FragmentDocumentBinding
>(),
DocumentView
{
class
DocumentFragment
()
:
BaseFragment
<
FragmentDocumentBinding
>(),
DocumentView
{
private
var
type
=
TYPE_PDF
var
type
=
TYPE_PDF
private
var
documentList
:
ArrayList
<
DocumentBean
>
=
arrayListOf
()
private
var
documentList
:
ArrayList
<
DocumentBean
>
=
arrayListOf
()
private
lateinit
var
adapter
:
DocumentAdapter
private
lateinit
var
adapter
:
DocumentAdapter
private
lateinit
var
documentPresenter
:
DocumentPresenter
private
lateinit
var
documentPresenter
:
DocumentPresenter
...
@@ -59,39 +62,15 @@ class DocumentFragment() : BaseFragment<FragmentDocumentBinding>(), DocumentView
...
@@ -59,39 +62,15 @@ class DocumentFragment() : BaseFragment<FragmentDocumentBinding>(), DocumentView
documentPresenter
.
saveBookmarkChange
(
addRemove
,
path
)
documentPresenter
.
saveBookmarkChange
(
addRemove
,
path
)
}
}
adapter
.
itemClick
=
{
item
->
adapter
.
itemClick
=
{
item
->
if
(
type
==
TYPE_PDF
)
{
requireActivity
().
jumpDocument
(
item
)
if
(
item
.
state
==
0
)
{
startActivity
(
Intent
(
requireContext
(),
PdfActivity
::
class
.
java
).
apply
{
putExtra
(
"path"
,
item
.
path
)
})
}
if
(
item
.
state
==
1
)
{
requireContext
().
showPdfPwdDialog
(
state
=
item
.
state
,
path
=
item
.
path
,
isCheckPwd
=
true
,
verificationAction
=
{
pwd
->
startActivity
(
Intent
(
requireContext
(),
PdfActivity
::
class
.
java
).
apply
{
putExtra
(
"path"
,
item
.
path
)
putExtra
(
"pwd"
,
pwd
)
})
})
}
}
if
(
type
==
TYPE_WORD
)
{
WordActivity
.
wordDocumentBean
=
item
WordActivity
.
launchDocViewer
(
requireActivity
(),
3
,
item
.
path
,
-
1
,
100
)
}
}
if
(
type
==
TYPE_EXCEL
)
{
adapter
.
moreAction
=
{
item
->
ExcelActivity
.
excelDocumentBean
=
item
documentMoreAction
.
invoke
(
item
)
ExcelActivity
.
launchDocViewer
(
requireActivity
(),
3
,
item
.
path
,
-
1
,
100
)
}
if
(
type
==
TYPE_PPT
)
{
PptActivity
.
pptDocumentBean
=
item
PptActivity
.
launchDocViewer
(
requireActivity
(),
3
,
item
.
path
,
-
1
,
100
)
}
}
binding
.
rv
.
adapter
=
adapter
}
}
adapter
.
moreAction
=
{
item
->
var
documentMoreAction
:
(
item
:
DocumentBean
)
->
Unit
=
{
item
->
if
(
item
.
type
==
TYPE_PDF
)
{
if
(
item
.
type
==
TYPE_PDF
)
{
requireContext
().
showPdfHomeMoreDialog
(
this
,
item
,
adapter
,
dismissAction
=
{
firstDialog
=
null
})
requireContext
().
showPdfHomeMoreDialog
(
this
,
item
,
adapter
,
dismissAction
=
{
firstDialog
=
null
})
}
}
...
@@ -99,8 +78,6 @@ class DocumentFragment() : BaseFragment<FragmentDocumentBinding>(), DocumentView
...
@@ -99,8 +78,6 @@ class DocumentFragment() : BaseFragment<FragmentDocumentBinding>(), DocumentView
firstDialog
=
requireContext
().
showDocumentHomeMoreDialog
(
item
,
this
)
firstDialog
=
requireContext
().
showDocumentHomeMoreDialog
(
item
,
this
)
}
}
}
}
binding
.
rv
.
adapter
=
adapter
}
override
fun
refreshDocumentRv
(
documentList
:
List
<
DocumentBean
>,
isRefresh
:
Boolean
)
{
override
fun
refreshDocumentRv
(
documentList
:
List
<
DocumentBean
>,
isRefresh
:
Boolean
)
{
if
(
isRefresh
)
{
if
(
isRefresh
)
{
...
@@ -174,6 +151,14 @@ class DocumentFragment() : BaseFragment<FragmentDocumentBinding>(), DocumentView
...
@@ -174,6 +151,14 @@ class DocumentFragment() : BaseFragment<FragmentDocumentBinding>(), DocumentView
}
}
}
}
@SuppressLint
(
"NotifyDataSetChanged"
)
fun
changItemSelect
(
select
:
Boolean
)
{
adapter
.
items
.
forEach
{
it
.
isSelect
=
select
}
adapter
.
notifyDataSetChanged
()
}
fun
getSelectItems
():
List
<
DocumentBean
>
{
fun
getSelectItems
():
List
<
DocumentBean
>
{
return
adapter
.
items
.
filter
{
it
.
isSelect
}
return
adapter
.
items
.
filter
{
it
.
isSelect
}
}
}
...
@@ -184,4 +169,49 @@ class DocumentFragment() : BaseFragment<FragmentDocumentBinding>(), DocumentView
...
@@ -184,4 +169,49 @@ class DocumentFragment() : BaseFragment<FragmentDocumentBinding>(), DocumentView
}
}
}
}
fun
getSearchItems
(
search
:
String
):
List
<
DocumentBean
>
{
if
(
isVisible
)
{
return
adapter
.
items
.
filter
{
File
(
it
.
path
).
name
.
contains
(
search
)
}
}
return
listOf
()
}
companion
object
{
fun
Activity
.
jumpDocument
(
item
:
DocumentBean
)
{
if
(
item
.
type
==
TYPE_PDF
)
{
if
(
item
.
state
==
0
)
{
startActivity
(
Intent
(
this
,
PdfActivity
::
class
.
java
).
apply
{
putExtra
(
"path"
,
item
.
path
)
})
}
if
(
item
.
state
==
1
)
{
showPdfPwdDialog
(
state
=
item
.
state
,
path
=
item
.
path
,
isCheckPwd
=
true
,
verificationAction
=
{
pwd
->
startActivity
(
Intent
(
this
,
PdfActivity
::
class
.
java
).
apply
{
putExtra
(
"path"
,
item
.
path
)
putExtra
(
"pwd"
,
pwd
)
})
})
}
}
if
(
item
.
type
==
TYPE_WORD
)
{
WordActivity
.
wordDocumentBean
=
item
WordActivity
.
launchDocViewer
(
this
,
3
,
item
.
path
,
-
1
,
100
)
}
if
(
item
.
type
==
TYPE_EXCEL
)
{
ExcelActivity
.
excelDocumentBean
=
item
ExcelActivity
.
launchDocViewer
(
this
,
3
,
item
.
path
,
-
1
,
100
)
}
if
(
item
.
type
==
TYPE_PPT
)
{
PptActivity
.
pptDocumentBean
=
item
PptActivity
.
launchDocViewer
(
this
,
3
,
item
.
path
,
-
1
,
100
)
}
}
}
}
}
\ No newline at end of file
app/src/main/java/com/base/pdfviewerscannerwhite/ui/main/MainActivity.kt
View file @
3521ff36
This diff is collapsed.
Click to expand it.
app/src/main/java/com/base/pdfviewerscannerwhite/utils/IntentShareUtils.kt
View file @
3521ff36
...
@@ -3,10 +3,13 @@ package com.base.pdfviewerscannerwhite.utils
...
@@ -3,10 +3,13 @@ package com.base.pdfviewerscannerwhite.utils
import
android.content.Context
import
android.content.Context
import
android.content.Intent
import
android.content.Intent
import
android.net.Uri
import
android.net.Uri
import
androidx.core.content.ContextCompat.startActivity
import
androidx.core.content.FileProvider
import
androidx.core.content.FileProvider
import
com.base.pdfviewerscannerwhite.bean.DocumentBean
import
com.base.pdfviewerscannerwhite.bean.DocumentBean
import
com.base.pdfviewerscannerwhite.bean.DocumentBean.Companion.TYPE_PDF
import
java.io.File
import
java.io.File
object
IntentShareUtils
{
object
IntentShareUtils
{
fun
Context
.
documentShare
(
documentBean
:
DocumentBean
)
{
fun
Context
.
documentShare
(
documentBean
:
DocumentBean
)
{
...
@@ -50,6 +53,7 @@ object IntentShareUtils {
...
@@ -50,6 +53,7 @@ object IntentShareUtils {
return
shareIntent
return
shareIntent
}
}
fun
shareWordIntent
(
uri
:
Uri
):
Intent
{
fun
shareWordIntent
(
uri
:
Uri
):
Intent
{
val
shareIntent
=
Intent
().
apply
{
val
shareIntent
=
Intent
().
apply
{
action
=
Intent
.
ACTION_SEND
action
=
Intent
.
ACTION_SEND
...
@@ -81,4 +85,31 @@ object IntentShareUtils {
...
@@ -81,4 +85,31 @@ object IntentShareUtils {
return
intent
return
intent
}
}
fun
Context
.
shareMutDocuments
(
type
:
String
,
uris
:
ArrayList
<
Uri
>
)
{
var
desc
=
"Share PDF files"
val
intent
=
when
(
type
)
{
TYPE_PDF
->
{
shareMutPdfIntent
(
uris
)
}
else
->
shareMutPdfIntent
(
uris
)
}
val
chooserIntent
=
Intent
.
createChooser
(
intent
,
desc
)
startActivity
(
chooserIntent
)
}
fun
shareMutPdfIntent
(
uris
:
ArrayList
<
Uri
>):
Intent
{
val
shareIntent
=
Intent
().
apply
{
action
=
Intent
.
ACTION_SEND_MULTIPLE
type
=
"application/pdf"
addFlags
(
Intent
.
FLAG_GRANT_READ_URI_PERMISSION
)
// 授权临时权限
putParcelableArrayListExtra
(
Intent
.
EXTRA_STREAM
,
uris
)
}
return
shareIntent
}
}
}
\ No newline at end of file
app/src/main/res/layout/activity_main.xml
View file @
3521ff36
...
@@ -31,6 +31,27 @@
...
@@ -31,6 +31,27 @@
tools:ignore=
"ContentDescription"
/>
tools:ignore=
"ContentDescription"
/>
</FrameLayout>
</FrameLayout>
<EditText
android:imeOptions=
"actionDone"
android:id=
"@+id/edit_search"
android:layout_width=
"0dp"
android:layout_height=
"40dp"
android:layout_marginStart=
"10dp"
android:layout_marginEnd=
"20dp"
android:background=
"@drawable/bg_f8f9fe_10"
android:hint=
"Enter the file name to search for"
android:paddingHorizontal=
"18dp"
android:singleLine=
"true"
android:textColor=
"@color/black"
android:textColorHint=
"#B8B9BD"
android:textSize=
"14sp"
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,RtlSymmetry,TextFields"
/>
<TextView
<TextView
android:id=
"@+id/tv_tittle"
android:id=
"@+id/tv_tittle"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
...
@@ -45,14 +66,6 @@
...
@@ -45,14 +66,6 @@
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
tools:ignore=
"HardcodedText"
/>
tools:ignore=
"HardcodedText"
/>
<androidx.constraintlayout.widget.ConstraintLayout
android:id=
"@+id/cl_action"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
>
<ImageView
<ImageView
android:id=
"@+id/iv_paixu"
android:id=
"@+id/iv_paixu"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
...
@@ -100,10 +113,6 @@
...
@@ -100,10 +113,6 @@
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<LinearLayout
<LinearLayout
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"0dp"
android:layout_height=
"0dp"
...
@@ -219,7 +228,6 @@
...
@@ -219,7 +228,6 @@
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
app:layout_constraintTop_toTopOf=
"parent"
/>
<androidx.constraintlayout.widget.ConstraintLayout
<androidx.constraintlayout.widget.ConstraintLayout
android:id=
"@+id/ll_bottom"
android:id=
"@+id/ll_bottom"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
...
@@ -437,4 +445,50 @@
...
@@ -437,4 +445,50 @@
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<FrameLayout
android:id=
"@+id/fl_search"
android:layout_width=
"match_parent"
android:layout_height=
"0dp"
android:background=
"@color/white"
android:visibility=
"gone"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/cl_top"
>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/rv_search"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
app:layoutManager=
"androidx.recyclerview.widget.LinearLayoutManager"
tools:listitem=
"@layout/item_document"
/>
<LinearLayout
android:id=
"@+id/ll_empty"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:layout_marginBottom=
"60dp"
android:orientation=
"vertical"
android:visibility=
"gone"
tools:ignore=
"UseCompoundDrawables,UselessParent"
>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:src=
"@mipmap/empty"
tools:ignore=
"ContentDescription"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:layout_marginTop=
"20dp"
android:text=
"Empty"
android:textColor=
"#B1B4B9"
android:textSize=
"16sp"
tools:ignore=
"HardcodedText"
/>
</LinearLayout>
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/mipmap-xxhdpi/empty.png
0 → 100644
View file @
3521ff36
8.82 KB
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