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
3d1596c7
Commit
3d1596c7
authored
Sep 20, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
c30c7593
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
382 additions
and
97 deletions
+382
-97
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+12
-9
DocumentBean.kt
.../java/com/base/pdfviewerscannerwhite/bean/DocumentBean.kt
+4
-2
DocumentAdapter.kt
.../base/pdfviewerscannerwhite/ui/adapter/DocumentAdapter.kt
+33
-13
PdfActivity.kt
...base/pdfviewerscannerwhite/ui/document/pdf/PdfActivity.kt
+81
-39
PdfMergeActivity.kt
...pdfviewerscannerwhite/ui/document/pdf/PdfMergeActivity.kt
+17
-0
PdfSelectActivity.kt
...dfviewerscannerwhite/ui/document/pdf/PdfSelectActivity.kt
+51
-0
DocumentFragment.kt
...om/base/pdfviewerscannerwhite/ui/main/DocumentFragment.kt
+3
-3
DocumentPresenter.kt
...m/base/pdfviewerscannerwhite/ui/main/DocumentPresenter.kt
+6
-5
DocumentView.kt
...va/com/base/pdfviewerscannerwhite/ui/main/DocumentView.kt
+4
-4
ToolFragment.kt
...va/com/base/pdfviewerscannerwhite/ui/main/ToolFragment.kt
+9
-1
KeyBoardUtils.kt
...ava/com/base/pdfviewerscannerwhite/utils/KeyBoardUtils.kt
+25
-0
bg_7fdcee_10.xml
app/src/main/res/drawable/bg_7fdcee_10.xml
+1
-1
bg_selector_btn.xml
app/src/main/res/drawable/bg_selector_btn.xml
+2
-2
activity_pdf.xml
app/src/main/res/layout/activity_pdf.xml
+14
-16
activity_pdf_merge.xml
app/src/main/res/layout/activity_pdf_merge.xml
+10
-0
activity_pdf_select.xml
app/src/main/res/layout/activity_pdf_select.xml
+85
-0
item_docment.xml
app/src/main/res/layout/item_docment.xml
+25
-2
No files found.
app/src/main/AndroidManifest.xml
View file @
3d1596c7
...
...
@@ -45,21 +45,24 @@
android:launchMode=
"singleTop"
android:screenOrientation=
"portrait"
tools:ignore=
"DiscouragedApi,LockedOrientationActivity"
/>
<!-- <activity -->
<!-- android:name="com.artifex.mupdf.viewer.PdfTestActivity" -->
<!-- android:exported="false" -->
<!-- android:launchMode="singleTop" -->
<!-- android:screenOrientation="portrait" -->
<!-- tools:ignore="DiscouragedApi,LockedOrientationActivity" /> -->
<activity
android:name=
".ui.document.pdf.PdfMergeActivity"
android:exported=
"false"
android:launchMode=
"singleTop"
android:screenOrientation=
"portrait"
tools:ignore=
"DiscouragedApi,LockedOrientationActivity"
/>
<activity
android:name=
".ui.document.pdf.PdfSelectActivity"
android:exported=
"false"
android:launchMode=
"singleTop"
android:screenOrientation=
"portrait"
tools:ignore=
"DiscouragedApi,LockedOrientationActivity"
/>
<activity
android:name=
".ui.document.pdf.PdfActivity"
android:exported=
"false"
android:screenOrientation=
"portrait"
android:theme=
"@style/Theme.PDFViewerScannerWhite"
tools:ignore=
"DiscouragedApi,LockedOrientationActivity"
/>
<activity
android:name=
".ui.document.pdf.PdfLoadingActivity"
android:exported=
"false"
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/bean/DocumentBean.kt
View file @
3d1596c7
...
...
@@ -4,12 +4,14 @@ import android.net.Uri
data class
DocumentBean
(
val
path
:
String
=
""
,
var
uri
:
Uri
=
Uri
.
EMPTY
,
var
uri
:
Uri
=
Uri
.
EMPTY
,
val
type
:
String
=
""
,
var
isBookmarked
:
Boolean
=
false
)
{
companion
object
{
var
showSelect
:
Boolean
=
false
var
isSelect
:
Boolean
=
false
companion
object
{
const
val
TYPE_PDF
=
"type_pdf"
}
}
app/src/main/java/com/base/pdfviewerscannerwhite/ui/adapter/DocumentAdapter.kt
View file @
3d1596c7
...
...
@@ -22,6 +22,7 @@ class DocumentAdapter : BaseQuickAdapter<DocumentBean, DocumentAdapter.DocumentV
var
itemClick
:
((
item
:
DocumentBean
)
->
Unit
)?
=
null
var
bookmarkAction
:
((
addRemove
:
Boolean
,
path
:
String
)
->
Unit
)?
=
null
var
moreAction
:
((
item
:
DocumentBean
)
->
Unit
)?
=
null
var
selectAction
:
((
size
:
Int
)
->
Unit
)?
=
null
@SuppressLint
(
"SetTextI18n"
)
override
fun
onBindViewHolder
(
holder
:
DocumentViewHolder
,
position
:
Int
,
item
:
DocumentBean
?)
{
...
...
@@ -33,24 +34,43 @@ 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
()
if
(
item
.
isBookmarked
)
{
binding
.
ivBookmark
.
setImageResource
(
R
.
mipmap
.
h_soucang_s
)
}
else
{
binding
.
ivBookmark
.
setImageResource
(
R
.
mipmap
.
h_soucang_n
)
}
binding
.
flBookmark
.
setOnClickListener
{
if
(
item
.
showSelect
)
{
binding
.
flMore
.
visibility
=
View
.
INVISIBLE
binding
.
flBookmark
.
visibility
=
View
.
INVISIBLE
binding
.
flSelect
.
visibility
=
View
.
VISIBLE
binding
.
ivSelector
.
isSelected
=
item
.
isSelect
binding
.
flSelect
.
setOnClickListener
{
item
.
isSelect
=
!
item
.
isSelect
notifyItemChanged
(
position
,
"aaa"
)
selectAction
?.
invoke
(
items
.
filter
{
it
.
isSelect
}.
size
)
}
}
else
{
binding
.
flSelect
.
visibility
=
View
.
GONE
binding
.
flMore
.
visibility
=
View
.
VISIBLE
binding
.
flBookmark
.
visibility
=
View
.
VISIBLE
if
(
item
.
isBookmarked
)
{
b
ookmarkAction
?.
invoke
(
false
,
item
.
path
)
b
inding
.
ivBookmark
.
setImageResource
(
R
.
mipmap
.
h_soucang_s
)
}
else
{
bookmarkAction
?.
invoke
(
true
,
item
.
path
)
binding
.
ivBookmark
.
setImageResource
(
R
.
mipmap
.
h_soucang_n
)
}
binding
.
flBookmark
.
setOnClickListener
{
if
(
item
.
isBookmarked
)
{
bookmarkAction
?.
invoke
(
false
,
item
.
path
)
}
else
{
bookmarkAction
?.
invoke
(
true
,
item
.
path
)
}
item
.
isBookmarked
=
!
item
.
isBookmarked
notifyItemChanged
(
position
,
"aaaa"
)
}
binding
.
flMore
.
setOnClickListener
{
moreAction
?.
invoke
(
item
)
}
item
.
isBookmarked
=
!
item
.
isBookmarked
notifyItemChanged
(
position
,
"aaaa"
)
}
binding
.
flMore
.
setOnClickListener
{
moreAction
?.
invoke
(
item
)
}
binding
.
root
.
setOnClickListener
{
itemClick
?.
invoke
(
item
)
}
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/ui/document/pdf/PdfActivity.kt
View file @
3d1596c7
...
...
@@ -11,7 +11,6 @@ import android.view.View
import
android.view.animation.Animation
import
android.view.animation.TranslateAnimation
import
android.view.inputmethod.EditorInfo
import
android.view.inputmethod.InputMethodManager
import
androidx.activity.addCallback
import
androidx.core.widget.addTextChangedListener
import
com.artifex.mupdfdemo.Annotation
...
...
@@ -27,6 +26,8 @@ import com.base.pdfviewerscannerwhite.bean.PdfPageBean
import
com.base.pdfviewerscannerwhite.databinding.ActivityPdfBinding
import
com.base.pdfviewerscannerwhite.helper.BaseActivity
import
com.base.pdfviewerscannerwhite.ui.document.pdf.PdfLoadingActivity.Companion.DO_SAVE_PDF
import
com.base.pdfviewerscannerwhite.utils.KeyBoardUtils.hideKeyboard
import
com.base.pdfviewerscannerwhite.utils.KeyBoardUtils.showKeyBoard
import
com.base.pdfviewerscannerwhite.utils.ToastUtils.toast
import
java.io.File
...
...
@@ -71,20 +72,34 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>(), PdfView {
if
(
muPDFCore
==
null
)
{
toast
(
"can't open pdf"
)
}
else
{
pdfPresenter
.
iniPdfPage
(
path
)
createPdfUI
()
binding
.
root
.
postDelayed
({
pdfPresenter
.
iniPdfPage
(
path
)
},
500
)
}
}
override
fun
initListener
()
{
onBackPressedDispatcher
.
addCallback
{
hideKeyboard
(
binding
.
editSearch
)
if
(
uiMode
==
UI_MODE_SEARCH
)
{
changeNormalUI
()
cancelSearch
()
return
@addCallback
}
if
(
uiMode
==
UI_MODE_EDITE_SELECT
)
{
changeNormalUI
()
cancelOperation
()
return
@addCallback
}
if
(
uiMode
==
UI_MODE_EDITE_SAVE
)
{
changeNormalUI
()
resetPdfView
()
return
@addCallback
}
finishToMain
()
}
binding
.
flFanhui
.
setOnClickListener
{
onBackPressedDispatcher
.
onBackPressed
()
...
...
@@ -145,7 +160,7 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>(), PdfView {
binding
.
ivSearch
.
setOnClickListener
{
bianJiScaleXiao
{
changeSearchUI
()
binding
.
editSearch
.
requestFocus
(
)
showKeyBoard
(
binding
.
editSearch
)
}
}
binding
.
editSearch
.
addTextChangedListener
{
...
...
@@ -172,11 +187,31 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>(), PdfView {
}
}
private
fun
resetPdfView
()
{
val
pageView
=
binding
.
mupdfReaderView
.
displayedView
as
MuPDFView
?
binding
.
mupdfReaderView
.
refresh
(
true
)
}
private
fun
cancelOperation
()
{
val
pageView
=
binding
.
mupdfReaderView
.
displayedView
as
MuPDFView
?
if
(
pageView
!=
null
)
{
pageView
.
deselectAnnotation
()
pageView
.
deleteSelectedAnnotation
()
pageView
.
deselectText
()
pageView
.
cancelDraw
()
}
}
private
fun
cancelSearch
()
{
SearchTaskResult
.
set
(
null
)
binding
.
mupdfReaderView
.
resetupChildren
()
}
/**
* 有个问题,一旦pdf某页编辑后加个蒙层,搜索功能就是失效了
*/
private
fun
search
(
direction
:
Int
)
{
this
.
hideKeyboard
()
this
.
hideKeyboard
(
binding
.
editSearch
)
val
displayPage
:
Int
=
binding
.
mupdfReaderView
.
displayedViewIndex
val
r
=
SearchTaskResult
.
get
()
val
searchPage
=
r
?.
pageNumber
?:
-
1
...
...
@@ -192,18 +227,12 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>(), PdfView {
}
@SuppressLint
(
"ServiceCast"
)
private
fun
hideKeyboard
()
{
val
imm
=
this
.
getSystemService
(
INPUT_METHOD_SERVICE
)
as
InputMethodManager
imm
.
hideSoftInputFromWindow
(
binding
.
editSearch
.
windowToken
,
0
)
}
private
var
isShowTopBottomLayout
=
true
private
fun
hideTopBottomLayout
()
{
if
(
isShowTopBottomLayout
)
{
isShowTopBottomLayout
=
false
hideKeyboard
()
hideKeyboard
(
binding
.
editSearch
)
val
topAnim
:
Animation
=
TranslateAnimation
(
0f
,
0f
,
0f
,
-
binding
.
vAnimatorTop
.
height
.
toFloat
())
topAnim
.
setDuration
(
200
)
topAnim
.
setAnimationListener
(
object
:
Animation
.
AnimationListener
{
...
...
@@ -267,34 +296,39 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>(), PdfView {
}
private
fun
bianJiScaleDa
()
{
val
scaleXAnimator
=
ObjectAnimator
.
ofFloat
(
binding
.
ivBianji
,
"scaleX"
,
0f
,
1.0f
)
scaleXAnimator
.
duration
=
200
val
scaleYAnimator
=
ObjectAnimator
.
ofFloat
(
binding
.
ivBianji
,
"scaleY"
,
0f
,
1.0f
)
scaleYAnimator
.
duration
=
200
val
animatorSet
=
AnimatorSet
()
animatorSet
.
playTogether
(
scaleXAnimator
,
scaleYAnimator
)
animatorSet
.
start
()
if
(
binding
.
ivBianji
.
scaleX
==
0f
)
{
val
scaleXAnimator
=
ObjectAnimator
.
ofFloat
(
binding
.
ivBianji
,
"scaleX"
,
0f
,
1.0f
)
scaleXAnimator
.
duration
=
200
val
scaleYAnimator
=
ObjectAnimator
.
ofFloat
(
binding
.
ivBianji
,
"scaleY"
,
0f
,
1.0f
)
scaleYAnimator
.
duration
=
200
val
animatorSet
=
AnimatorSet
()
animatorSet
.
playTogether
(
scaleXAnimator
,
scaleYAnimator
)
animatorSet
.
start
()
}
}
private
fun
bianJiScaleXiao
(
endAction
:
(()
->
Unit
)?
=
null
)
{
val
scaleXAnimator
=
ObjectAnimator
.
ofFloat
(
binding
.
ivBianji
,
"scaleX"
,
1.0f
,
0f
)
scaleXAnimator
.
duration
=
200
val
scaleYAnimator
=
ObjectAnimator
.
ofFloat
(
binding
.
ivBianji
,
"scaleY"
,
1.0f
,
0f
)
scaleYAnimator
.
duration
=
200
val
animatorSet
=
AnimatorSet
()
animatorSet
.
addListener
(
object
:
Animator
.
AnimatorListener
{
override
fun
onAnimationStart
(
animation
:
Animator
)
=
Unit
override
fun
onAnimationEnd
(
animation
:
Animator
)
{
endAction
?.
invoke
()
}
if
(
binding
.
ivBianji
.
scaleX
==
1f
)
{
val
scaleXAnimator
=
ObjectAnimator
.
ofFloat
(
binding
.
ivBianji
,
"scaleX"
,
1.0f
,
0f
)
scaleXAnimator
.
duration
=
200
val
scaleYAnimator
=
ObjectAnimator
.
ofFloat
(
binding
.
ivBianji
,
"scaleY"
,
1.0f
,
0f
)
scaleYAnimator
.
duration
=
200
val
animatorSet
=
AnimatorSet
()
animatorSet
.
addListener
(
object
:
Animator
.
AnimatorListener
{
override
fun
onAnimationStart
(
animation
:
Animator
)
=
Unit
override
fun
onAnimationEnd
(
animation
:
Animator
)
{
endAction
?.
invoke
()
}
override
fun
onAnimationCancel
(
animation
:
Animator
)
=
Unit
override
fun
onAnimationRepeat
(
animation
:
Animator
)
=
Unit
})
animatorSet
.
playTogether
(
scaleXAnimator
,
scaleYAnimator
)
animatorSet
.
start
()
override
fun
onAnimationCancel
(
animation
:
Animator
)
=
Unit
override
fun
onAnimationRepeat
(
animation
:
Animator
)
=
Unit
})
animatorSet
.
playTogether
(
scaleXAnimator
,
scaleYAnimator
)
animatorSet
.
start
()
}
}
/**
...
...
@@ -347,13 +381,18 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>(), PdfView {
*/
private
fun
changeNormalUI
()
{
uiMode
=
UI_MODE_NORMAL
binding
.
ivWancheng
.
visibility
=
View
.
GONE
binding
.
clOperation
.
visibility
=
View
.
GONE
binding
.
tvBtnSave
.
visibility
=
View
.
GONE
binding
.
editSearch
.
visibility
=
View
.
INVISIBLE
binding
.
ivXuanzhuan
.
visibility
=
View
.
VISIBLE
binding
.
ivSearch
.
visibility
=
View
.
VISIBLE
binding
.
ivMore
.
visibility
=
View
.
VISIBLE
binding
.
rvPager
.
visibility
=
View
.
VISIBLE
binding
.
tvPdfName
.
visibility
=
View
.
VISIBLE
bianJiScaleDa
()
}
/**
...
...
@@ -386,6 +425,8 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>(), PdfView {
binding
.
ivWancheng
.
visibility
=
View
.
VISIBLE
if
(
binding
.
llHighlight
==
view
)
{
binding
.
llHighlight
.
setBackgroundColor
(
Color
.
parseColor
(
"#F5F5F5"
))
}
else
{
...
...
@@ -413,6 +454,7 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>(), PdfView {
* 编辑报错UI模式
*/
private
fun
changeEditSaveUI
()
{
uiMode
=
UI_MODE_EDITE_SAVE
binding
.
ivWancheng
.
visibility
=
View
.
INVISIBLE
binding
.
ivMore
.
visibility
=
View
.
INVISIBLE
binding
.
ivXuanzhuan
.
visibility
=
View
.
INVISIBLE
...
...
@@ -437,8 +479,8 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>(), PdfView {
const
val
UI_MODE_NORMAL
=
0
const
val
UI_MODE_SEARCH
=
1
const
val
UI_MODE_EDITE_S
AVE
=
2
const
val
UI_MODE_EDITE_S
ELECT
=
3
const
val
UI_MODE_EDITE_S
ELECT
=
2
const
val
UI_MODE_EDITE_S
AVE
=
3
const
val
SAVE_MODE_HIGHLIGHT
=
"Highlight"
const
val
SAVE_MODE_GLIDE_LINE
=
"Glide Line"
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/ui/document/pdf/PdfMergeActivity.kt
0 → 100644
View file @
3d1596c7
package
com.base.pdfviewerscannerwhite.ui.document.pdf
import
com.base.pdfviewerscannerwhite.databinding.ActivityPdfMergeBinding
import
com.base.pdfviewerscannerwhite.helper.BaseActivity
class
PdfMergeActivity
:
BaseActivity
<
ActivityPdfMergeBinding
>()
{
override
val
binding
:
ActivityPdfMergeBinding
by
lazy
{
ActivityPdfMergeBinding
.
inflate
(
layoutInflater
)
}
override
fun
initView
()
{
}
}
\ No newline at end of file
app/src/main/java/com/base/pdfviewerscannerwhite/ui/document/pdf/PdfSelectActivity.kt
0 → 100644
View file @
3d1596c7
package
com.base.pdfviewerscannerwhite.ui.document.pdf
import
android.annotation.SuppressLint
import
android.view.View
import
androidx.lifecycle.lifecycleScope
import
com.base.pdfviewerscannerwhite.bean.DocumentBean
import
com.base.pdfviewerscannerwhite.databinding.ActivityPdfSelectBinding
import
com.base.pdfviewerscannerwhite.helper.BaseActivity
import
com.base.pdfviewerscannerwhite.ui.adapter.DocumentAdapter
import
com.base.pdfviewerscannerwhite.ui.main.DocumentPresenter
import
com.base.pdfviewerscannerwhite.ui.main.DocumentView
class
PdfSelectActivity
:
BaseActivity
<
ActivityPdfSelectBinding
>(),
DocumentView
{
private
lateinit
var
documentPresenter
:
DocumentPresenter
private
lateinit
var
adapter
:
DocumentAdapter
override
val
binding
:
ActivityPdfSelectBinding
by
lazy
{
ActivityPdfSelectBinding
.
inflate
(
layoutInflater
)
}
override
fun
initView
()
{
documentPresenter
=
DocumentPresenter
(
this
,
this
,
DocumentBean
.
TYPE_PDF
,
lifecycleScope
)
initAdapter
()
documentPresenter
.
initData
()
}
@SuppressLint
(
"SetTextI18n"
)
private
fun
initAdapter
()
{
adapter
=
DocumentAdapter
()
adapter
.
selectAction
=
{
if
(
it
==
0
)
{
binding
.
tvSelectTip
.
visibility
=
View
.
INVISIBLE
binding
.
tvBtnNext
.
isEnabled
=
false
}
else
{
binding
.
tvBtnNext
.
isEnabled
=
true
binding
.
tvSelectTip
.
visibility
=
View
.
VISIBLE
binding
.
tvSelectTip
.
text
=
"$it items has been selected"
}
}
binding
.
rv
.
adapter
=
adapter
}
override
fun
refreshDocumentRv
(
documentList
:
List
<
DocumentBean
>)
{
super
.
refreshDocumentRv
(
documentList
)
documentList
.
map
{
it
.
showSelect
=
true
}
adapter
.
submitList
(
documentList
)
}
}
\ No newline at end of file
app/src/main/java/com/base/pdfviewerscannerwhite/ui/main/DocumentFragment.kt
View file @
3d1596c7
...
...
@@ -32,14 +32,14 @@ class DocumentFragment() : BaseFragment<FragmentDocumentBinding>(), DocumentView
}
override
fun
setView
()
{
documentPresenter
=
DocumentPresenter
(
this
,
type
,
lifecycleScope
)
documentPresenter
=
DocumentPresenter
(
requireContext
(),
this
,
type
,
lifecycleScope
)
initAdapter
()
if
(
documentList
!=
null
)
{
adapter
.
submitList
(
documentList
)
}
else
{
if
(
requireContext
().
checkStorePermission
())
{
documentPresenter
.
initData
(
requireContext
()
)
documentPresenter
.
initData
()
}
}
}
...
...
@@ -99,7 +99,7 @@ class DocumentFragment() : BaseFragment<FragmentDocumentBinding>(), DocumentView
override
fun
dialogRename
(
item
:
DocumentBean
)
{
val
file
=
File
(
item
.
path
)
requireContext
().
showDocumentRenameDialog
(
file
.
name
,
firstDialog
)
{
newName
->
documentPresenter
.
renameDocumentBean
(
requireContext
(),
file
,
newName
)
documentPresenter
.
renameDocumentBean
(
file
,
newName
)
}
}
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/ui/main/DocumentPresenter.kt
View file @
3d1596c7
...
...
@@ -11,12 +11,13 @@ import kotlinx.coroutines.launch
import
java.io.File
class
DocumentPresenter
(
val
context
:
Context
,
val
documentView
:
DocumentView
,
val
type
:
String
,
val
lifecycleScope
:
LifecycleCoroutineScope
)
{
fun
getDocumentBeanList
(
context
:
Context
):
List
<
DocumentBean
>
{
private
fun
getDocumentBeanList
(
):
List
<
DocumentBean
>
{
var
selectionArgs
=
arrayOf
(
ConstObject
.
MIME_TYPE_PDF
)
if
(
type
==
DocumentBean
.
TYPE_PDF
)
{
selectionArgs
=
arrayOf
(
ConstObject
.
MIME_TYPE_PDF
)
...
...
@@ -30,8 +31,8 @@ class DocumentPresenter(
return
documentList
}
fun
initData
(
context
:
Context
)
=
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
val
documentList
=
getDocumentBeanList
(
context
)
fun
initData
()
=
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
val
documentList
=
getDocumentBeanList
()
launch
(
Dispatchers
.
Main
)
{
documentView
.
refreshDocumentRv
(
documentList
)
}
...
...
@@ -45,13 +46,13 @@ class DocumentPresenter(
}
}
fun
renameDocumentBean
(
context
:
Context
,
file
:
File
,
newName
:
String
)
=
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
fun
renameDocumentBean
(
file
:
File
,
newName
:
String
)
=
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
runCatching
{
val
nameFile
=
File
(
file
.
parentFile
,
newName
)
file
.
renameTo
(
nameFile
)
}
val
documentList
=
getDocumentBeanList
(
context
)
val
documentList
=
getDocumentBeanList
()
launch
(
Dispatchers
.
Main
)
{
documentView
.
refreshDocumentRv
(
documentList
)
}
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/ui/main/DocumentView.kt
View file @
3d1596c7
...
...
@@ -4,9 +4,9 @@ import com.base.pdfviewerscannerwhite.bean.DocumentBean
interface
DocumentView
{
fun
dialogRename
(
item
:
DocumentBean
)
fun
refreshDocumentRv
(
documentList
:
List
<
DocumentBean
>)
fun
splitPdf
(
path
:
String
)
fun
dialogRename
(
item
:
DocumentBean
)
=
Unit
fun
refreshDocumentRv
(
documentList
:
List
<
DocumentBean
>)
=
Unit
fun
splitPdf
(
path
:
String
)
=
Unit
fun
deleteDocument
(
item
:
DocumentBean
)
fun
deleteDocument
(
item
:
DocumentBean
)
=
Unit
}
\ No newline at end of file
app/src/main/java/com/base/pdfviewerscannerwhite/ui/main/ToolFragment.kt
View file @
3d1596c7
package
com.base.pdfviewerscannerwhite.ui.main
import
android
x.recyclerview.widget.RecyclerView
import
android
.content.Intent
import
com.base.pdfviewerscannerwhite.databinding.FragmentToolBinding
import
com.base.pdfviewerscannerwhite.helper.BaseFragment
import
com.base.pdfviewerscannerwhite.ui.document.pdf.PdfSelectActivity
class
ToolFragment
:
BaseFragment
<
FragmentToolBinding
>()
{
...
...
@@ -14,4 +15,11 @@ class ToolFragment : BaseFragment<FragmentToolBinding>() {
override
fun
setView
()
{
}
override
fun
setListener
()
{
super
.
setListener
()
binding
.
llMerge
.
setOnClickListener
{
startActivity
(
Intent
(
requireContext
(),
PdfSelectActivity
::
class
.
java
))
}
}
}
\ No newline at end of file
app/src/main/java/com/base/pdfviewerscannerwhite/utils/KeyBoardUtils.kt
0 → 100644
View file @
3d1596c7
package
com.base.pdfviewerscannerwhite.utils
import
android.annotation.SuppressLint
import
android.content.Context
import
android.content.Context.INPUT_METHOD_SERVICE
import
android.view.inputmethod.InputMethodManager
import
android.widget.EditText
object
KeyBoardUtils
{
@SuppressLint
(
"ServiceCast"
)
fun
Context
.
hideKeyboard
(
editText
:
EditText
)
{
editText
.
clearFocus
()
val
imm
=
this
.
getSystemService
(
INPUT_METHOD_SERVICE
)
as
InputMethodManager
imm
.
hideSoftInputFromWindow
(
editText
.
windowToken
,
0
)
}
@SuppressLint
(
"ServiceCast"
)
fun
Context
.
showKeyBoard
(
editText
:
EditText
)
{
editText
.
requestFocus
()
val
imm
=
this
.
getSystemService
(
INPUT_METHOD_SERVICE
)
as
InputMethodManager
?
imm
?.
showSoftInput
(
editText
,
InputMethodManager
.
SHOW_IMPLICIT
)
}
}
\ No newline at end of file
app/src/main/res/drawable/bg_7fdcee_10.xml
View file @
3d1596c7
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<solid
android:color=
"#
00B8D
E"
/>
<solid
android:color=
"#
7FDCE
E"
/>
<corners
android:radius=
"10dp"
/>
</shape>
\ No newline at end of file
app/src/main/res/drawable/bg_selector_btn.xml
View file @
3d1596c7
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<item
android:drawable=
"@drawable/bg_00b8de_10"
android:state_enabled=
"
fals
e"
/>
<item
android:drawable=
"@drawable/bg_7fdcee_10"
android:state_enabled=
"
tru
e"
/>
<item
android:drawable=
"@drawable/bg_00b8de_10"
android:state_enabled=
"
tru
e"
/>
<item
android:drawable=
"@drawable/bg_7fdcee_10"
android:state_enabled=
"
fals
e"
/>
</selector>
\ No newline at end of file
app/src/main/res/layout/activity_pdf.xml
View file @
3d1596c7
...
...
@@ -90,7 +90,7 @@
android:src=
"@mipmap/wancheng"
android:visibility=
"gone"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraint
End
_toStartOf=
"@id/iv_more"
app:layout_constraint
Start
_toStartOf=
"@id/iv_more"
app:layout_constraintTop_toTopOf=
"parent"
tools:ignore=
"ContentDescription"
/>
...
...
@@ -159,6 +159,17 @@
app:layout_constraintTop_toBottomOf=
"@id/v_animator_top"
tools:text=
"1/3"
/>
<ImageView
android:id=
"@+id/iv_bianji"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"15dp"
android:layout_marginBottom=
"108dp"
android:src=
"@mipmap/bianji"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
tools:ignore=
"ContentDescription"
/>
<ViewAnimator
android:id=
"@+id/v_animator_bottom"
android:layout_width=
"match_parent"
...
...
@@ -182,7 +193,6 @@
android:visibility=
"gone"
app:layout_constraintBottom_toTopOf=
"@id/v_animator_bottom"
>
<LinearLayout
android:id=
"@+id/ll_highlight"
...
...
@@ -245,7 +255,6 @@
<LinearLayout
android:id=
"@+id/ll_strikethrough"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:background=
"?android:attr/selectableItemBackground"
...
...
@@ -288,7 +297,7 @@
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:src=
"@mipmap/
strike
"
android:src=
"@mipmap/
painting
"
tools:ignore=
"ContentDescription"
/>
<TextView
...
...
@@ -296,7 +305,7 @@
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:layout_marginTop=
"6dp"
android:text=
"
Strikethroug
h"
android:text=
"
Painting Brus
h"
android:textColor=
"#232323"
android:textSize=
"12sp"
tools:ignore=
"HardcodedText"
/>
...
...
@@ -320,16 +329,5 @@
</ViewAnimator>
<ImageView
android:id=
"@+id/iv_bianji"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"15dp"
android:layout_marginBottom=
"108dp"
android:src=
"@mipmap/bianji"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
tools:ignore=
"ContentDescription"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/layout/activity_pdf_merge.xml
0 → 100644
View file @
3d1596c7
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:id=
"@+id/main"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
tools:context=
".ui.document.pdf.PdfMergeActivity"
>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/layout/activity_pdf_select.xml
0 → 100644
View file @
3d1596c7
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:id=
"@+id/main"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
tools:context=
".ui.document.pdf.PdfSelectActivity"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:id=
"@+id/cl_top"
android:layout_width=
"match_parent"
android:layout_height=
"60dp"
app:layout_constraintTop_toTopOf=
"parent"
>
<FrameLayout
android:id=
"@+id/fl_fanhui"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toStartOf=
"@id/tv_select_tip"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:padding=
"15dp"
android:src=
"@mipmap/fanhui_b"
tools:ignore=
"ContentDescription"
/>
</FrameLayout>
<TextView
android:id=
"@+id/tv_select_tip"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:ellipsize=
"end"
android:singleLine=
"true"
android:textColor=
"@color/black"
android:textSize=
"19sp"
android:textStyle=
"bold"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toEndOf=
"@id/fl_fanhui"
app:layout_constraintTop_toTopOf=
"parent"
tools:ignore=
"HardcodedText"
tools:text=
"1 item has been selected"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
<FrameLayout
android:layout_width=
"match_parent"
android:layout_height=
"0dp"
android:layout_marginBottom=
"8dp"
app:layout_constraintBottom_toTopOf=
"@id/tv_btn_next"
app:layout_constraintTop_toBottomOf=
"@id/cl_top"
>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/rv"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
app:layoutManager=
"androidx.recyclerview.widget.LinearLayoutManager"
tools:listitem=
"@layout/item_docment"
/>
</FrameLayout>
<TextView
android:id=
"@+id/tv_btn_next"
android:layout_width=
"338dp"
android:layout_height=
"48dp"
android:layout_marginBottom=
"24dp"
android:background=
"@drawable/bg_selector_btn"
android:enabled=
"false"
android:gravity=
"center"
android:text=
"Next"
android:textColor=
"@color/white"
android:textSize=
"18sp"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
tools:ignore=
"HardcodedText"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/layout/item_docment.xml
View file @
3d1596c7
...
...
@@ -17,8 +17,8 @@
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
tools:
src=
"@mipmap/h_pdfioc
n"
tools:
ignore=
"ContentDescriptio
n"
/>
tools:
ignore=
"ContentDescriptio
n"
tools:
src=
"@mipmap/h_pdfioc
n"
/>
<FrameLayout
...
...
@@ -42,6 +42,29 @@
tools:ignore=
"ContentDescription"
/>
</FrameLayout>
<FrameLayout
android:id=
"@+id/fl_select"
android:layout_width=
"45dp"
android:layout_height=
"45dp"
android:layout_marginEnd=
"5dp"
android:background=
"?android:attr/selectableItemBackground"
android:clickable=
"true"
android:focusable=
"true"
android:padding=
"15dp"
android:visibility=
"gone"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
>
<ImageView
android:id=
"@+id/iv_selector"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:src=
"@drawable/bg_selector_select"
tools:ignore=
"ContentDescription"
/>
</FrameLayout>
<FrameLayout
android:id=
"@+id/fl_bookmark"
android:layout_width=
"45dp"
...
...
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